use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class PersonServiceImpl method findOne1.
@Override
@Cacheable(value = "people1", key = "#person.id", depict = "用户信息缓存1", enableFirstCache = false, firstCache = @FirstCache(expireTime = 4, timeUnit = TimeUnit.MINUTES, expireMode = ExpireMode.ACCESS), secondaryCache = @SecondaryCache(expireTime = 15, preloadTime = 8, forceRefresh = true))
public Person findOne1(Person person) {
Person p = personRepository.findOne(Example.of(person));
logger.info("为id、key为:" + p.getId() + "数据做了缓存");
return p;
}
use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class PersonServiceImpl method findOne.
@Override
@Cacheable(value = "'people' + ':' + #person.id", key = "#person.id", depict = "用户信息缓存", enableFirstCache = false, firstCache = @FirstCache(expireTime = 4, timeUnit = TimeUnit.MINUTES), secondaryCache = @SecondaryCache(expireTime = 15, preloadTime = 8, forceRefresh = true, timeUnit = TimeUnit.HOURS))
public Person findOne(Person person) {
Person p = personRepository.findOne(Example.of(person));
logger.info("为id、key为:" + p.getId() + "数据做了缓存");
return p;
}
use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class ExprotController method exportCsv.
@GetMapping("/csv")
public void exportCsv(HttpServletResponse response) throws IOException {
String fileName = "PersonInfo";
List<String> titles = Arrays.asList("ID", "名称", "年龄", "地址");
List<Person> list = new ArrayList<>();
list.add(new Person(1L, "姓名1", 28, "地址1"));
list.add(new Person(2L, "姓名2", 29, "地址2"));
List<List<Object>> dataList = list.stream().map(person -> {
List<Object> data = new ArrayList<>();
data.add(person.getId());
data.add(person.getName());
data.add(person.getAge());
data.add(person.getAddress());
return data;
}).collect(Collectors.toList());
OutputStream os = response.getOutputStream();
CsvExportUtil.responseSetProperties(fileName, response);
CsvExportUtil.doExportByList(dataList, titles, os);
CsvExportUtil.doExportByList(dataList, null, os);
}
use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class PersonServiceImpl method semaphore.
@Override
@SentinelResource(entryType = EntryType.IN)
public Result semaphore(String arg) {
Person person = new Person();
person.setAge(18);
person.setId(2L);
person.setName("名称semaphore");
person.setAddress("地址semaphore");
logger.info(JSON.toJSONString(person));
return Result.success(person);
}
use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class SpringBootStudentSentinelApplicationTests method testParse.
@Test
public void testParse() {
Person p = new Person();
p.setId(11L);
p.setAge(32);
// 表达式解析
ExpressionParser expressionParser = new SpelExpressionParser();
Expression expression = expressionParser.parseExpression("#person.age+\":\"+#person.id");
StandardEvaluationContext context = new StandardEvaluationContext();
context.setRootObject(p);
logger.info("[SpELTest - testParse ] {} ", expression.getValue(context));
Field[] fields = p.getClass().getDeclaredFields();
for (Field field : fields) {
try {
System.out.println("name:" + field.getName());
field.setAccessible(true);
System.out.println("value:" + field.get(p));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
Aggregations