use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class SpringBootStudentCacheCaffeineApplicationTests 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();
}
}
}
use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class ExprotController method exportExcel.
@GetMapping("/excel")
public void exportExcel(HttpServletResponse response) {
List<Person> list = new ArrayList<>();
list.add(new Person(1L, "姓名1", 28, "地址1"));
list.add(new Person(2L, "姓名2", 29, "地址2"));
String[] headers = new String[] { "ID", "名称", "年龄", "地址" };
List<String[]> contents = new ArrayList<>(list.size());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (Person person : list) {
int i = 0;
String[] row = new String[headers.length];
row[i++] = person.getId() + "";
row[i++] = person.getName();
row[i++] = person.getAge() + "";
row[i++] = person.getAddress();
contents.add(row);
}
ExcelExportUtils.exportExcel("PersonInfo", headers, contents, response);
}
use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class DataController method save.
@RequestMapping("/save")
public Person save() {
Person p = new Person("wyf", 32);
Collection<Location> locations = new LinkedHashSet<Location>();
Location loc1 = new Location("上海", "2009");
Location loc2 = new Location("合肥", "2010");
Location loc3 = new Location("广州", "2011");
Location loc4 = new Location("马鞍山", "2012");
locations.add(loc1);
locations.add(loc2);
locations.add(loc3);
locations.add(loc4);
p.setLocations(locations);
return personRepository.save(p);
}
use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class SpringBootStudentHystrixApplicationTests 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();
}
}
}
use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class PersonServiceImpl method save.
@Override
@CachePut(value = "people", key = "#person.id", depict = "用户信息缓存")
public Person save(Person person) {
Person p = personRepository.save(person);
logger.info("为id、key为:" + p.getId() + "数据做了缓存");
return p;
}
Aggregations