当前位置: 首页> 游戏> 游戏 > 东莞设计制作网站制作_服装设计有哪些网站_关键词推广哪家好_关键词优化排名详细步骤

东莞设计制作网站制作_服装设计有哪些网站_关键词推广哪家好_关键词优化排名详细步骤

时间:2025/7/13 1:58:57来源:https://blog.csdn.net/Aishangyuwen/article/details/142407836 浏览次数:0次
东莞设计制作网站制作_服装设计有哪些网站_关键词推广哪家好_关键词优化排名详细步骤

        Controller层

package com.wzb.springbootmybatis20240920.ThreeLevelsExercise20240920.controller;import com.wzb.springbootmybatis20240920.Pojo.Emp;
import com.wzb.springbootmybatis20240920.Pojo.Result;import com.wzb.springbootmybatis20240920.ThreeLevelsExercise20240920.service.Service;
import com.wzb.springbootmybatis20240920.ThreeLevelsExercise20240920.service.ServiceInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.List;// 注解
@RestController
public class Controller {@AutowiredServiceInterface service;@RequestMapping("/emp")public Result listEmp() {List<Emp> empList = service.getList();return Result.success(empList);}
}

        Dao层

package com.wzb.springbootmybatis20240920.ThreeLevelsExercise20240920.dao;import com.wzb.springbootmybatis20240920.Pojo.Emp;
import com.wzb.springbootmybatis20240920.ThreeLevelsExercise20240920.utils.XmlParserUtils;
import org.springframework.stereotype.Component;import java.util.List;@Component
public class Dao implements DaoInterface{@Overridepublic List<Emp> getList() {// 加载.xml文件String filePath = this.getClass().getClassLoader().getResource("emp.xml").getFile();// 利用dom4j解析.xml文件// parse方法需要两个参数,需要解析文件的路径和要解析成的对象List<Emp> empList = XmlParserUtils.parse(filePath, Emp.class);return empList;}
}

        Service层

package com.wzb.springbootmybatis20240920.ThreeLevelsExercise20240920.service;import com.wzb.springbootmybatis20240920.Pojo.Emp;
import com.wzb.springbootmybatis20240920.ThreeLevelsExercise20240920.dao.Dao;
import com.wzb.springbootmybatis20240920.ThreeLevelsExercise20240920.dao.DaoInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;import java.util.List;
import java.util.function.Consumer;@Component
public class Service implements ServiceInterface{@Autowiredprivate DaoInterface dao;@Overridepublic List<Emp> getList() {List<Emp> empList = dao.getList();// 按照业务逻辑处理userList中的数据empList.forEach(new Consumer<Emp>() {@Overridepublic void accept(Emp emp) {String gender = emp.getGender();if (gender.equals("1")) {emp.setGender("男");} else if (gender.equals("2")) {emp.setGender("女");} else {emp.setGender("Error");}String job = emp.getJob();switch (job) {case "1" -> emp.setJob("讲师");case "2" -> emp.setJob("班主任");case "3" -> emp.setJob("就业指导");default -> emp.setJob("Other");}}});return empList;}
}

 

 

关键字:东莞设计制作网站制作_服装设计有哪些网站_关键词推广哪家好_关键词优化排名详细步骤

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: