员工管理案例--完善功能
This commit is contained in:
@@ -1,19 +1,42 @@
|
|||||||
package com.inmind.controller;
|
package com.inmind.controller;
|
||||||
|
|
||||||
|
import com.inmind.pojo.Emp;
|
||||||
import com.inmind.pojo.Result;
|
import com.inmind.pojo.Result;
|
||||||
|
import com.inmind.utils.XmlParserUtils;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class EmpController {
|
public class EmpController {
|
||||||
|
|
||||||
@RequestMapping("/listEmp")
|
@RequestMapping("/listEmp")
|
||||||
public Result listEmp(){
|
public Result listEmp(){
|
||||||
//1.加载并解析emp.xml
|
//1.加载并解析emp.xml
|
||||||
|
//绝对据路径
|
||||||
|
// String file = "D:\\workspace_idea\\inmind_web_project250913\\springboot-web-req-resp\\src\\main\\resources\\emp.xml";
|
||||||
|
String file = this.getClass().getClassLoader().getResource("emp.xml").getFile();
|
||||||
|
List<Emp> emps = XmlParserUtils.parse(file, Emp.class);
|
||||||
|
|
||||||
//2.对数据进行转换处理
|
//2.对数据进行转换处理
|
||||||
|
emps.stream().forEach(emp->{
|
||||||
|
//处理性别
|
||||||
|
if (emp.getGender().equals("1")) {
|
||||||
|
emp.setGender("男");
|
||||||
|
}else{
|
||||||
|
emp.setGender("女");
|
||||||
|
}
|
||||||
|
//处理职务
|
||||||
|
if (emp.getJob().equals("1")) {
|
||||||
|
emp.setJob("班主任");
|
||||||
|
} else if ("2".equals(emp.getJob())) {
|
||||||
|
emp.setJob("讲师");
|
||||||
|
} else {
|
||||||
|
emp.setJob("辅导员");
|
||||||
|
}
|
||||||
|
});
|
||||||
//3.响应员工数据集合
|
//3.响应员工数据集合
|
||||||
return Result.success();
|
return Result.success(emps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user