http--员工案例-完善
This commit is contained in:
@@ -14,12 +14,28 @@ public class EmpController {
|
||||
@RequestMapping("/listEmp")
|
||||
public Result listEmp(){
|
||||
//1.加载并解析emp.xml
|
||||
String file = "D:\\workspace_idea\\inmind_web_project250915\\springboot-web-req-resp\\src\\main\\resources\\emp.xml";
|
||||
// String file = "D:\\workspace_idea\\inmind_web_project250915\\springboot-web-req-resp\\src\\main\\resources\\emp.xml";
|
||||
//使用类加载器,获取本项目资源路径
|
||||
String file = this.getClass().getClassLoader().getResource("emp.xml").getFile();
|
||||
List<Emp> empList = XmlParserUtils.parse(file, Emp.class);
|
||||
//2.对数据进行转换
|
||||
/* empList.stream().forEach(emp->{
|
||||
//处理性别 gender:
|
||||
});*/
|
||||
empList.stream().forEach(emp->{
|
||||
//处理性别 gender: 1就是男 2就是女
|
||||
if (emp.getGender().equals("1")) {
|
||||
emp.setGender("男");
|
||||
} else {
|
||||
emp.setGender("女");
|
||||
}
|
||||
//处理职位 job : 1 - 讲师 2-班主任 3-辅导员
|
||||
String job = emp.getJob();
|
||||
if ("1".equals( job)) {
|
||||
emp.setJob("讲师");
|
||||
} else if ("2".equals(job)) {
|
||||
emp.setJob("班主任");
|
||||
} else {
|
||||
emp.setJob("辅导员");
|
||||
}
|
||||
});
|
||||
//3.响应数据
|
||||
|
||||
return Result.success(empList);
|
||||
|
Reference in New Issue
Block a user