package com.wzs.server.config; import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * @Description TODO * @Author wuzhaosheng * @Date 2022/1/8 15:26 */ @Configuration public class MybatisPlusConfig { //配置分页插件 @Bean public PaginationInterceptor paginationInterceptor(){ return new PaginationInterceptor(); } }
package com.wzs.server.pojo; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.IdType; import java.time.LocalDate; import com.baomidou.mybatisplus.annotation.TableId; import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; /** * <p> * * </p> * * @author wuzhaosheng * @since 2022-01-08 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @TableName("t_employee") @ApiModel(value="Employee对象", description="") public class Employee implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "员工编号") @TableId(value = "id", type = IdType.AUTO) private Integer id; @ApiModelProperty(value = "员工姓名") private String name; @ApiModelProperty(value = "性别") private String gender; @ApiModelProperty(value = "出生日期") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") private LocalDate birthday; @ApiModelProperty(value = "身份证号") private String idCard; @ApiModelProperty(value = "婚姻状况") private String wedlock; @ApiModelProperty(value = "民族") private Integer nationId; @ApiModelProperty(value = "籍贯") private String nativePlace; @ApiModelProperty(value = "政治面貌") private Integer politicId; @ApiModelProperty(value = "邮箱") private String email; @ApiModelProperty(value = "电话号码") private String phone; @ApiModelProperty(value = "联系地址") private String address; @ApiModelProperty(value = "所属部门") private Integer departmentId; @ApiModelProperty(value = "职称ID") private Integer jobLevelId; @ApiModelProperty(value = "职位ID") private Integer posId; @ApiModelProperty(value = "聘用形式") private String engageForm; @ApiModelProperty(value = "最高学历") private String tiptopDegree; @ApiModelProperty(value = "所属专业") private String specialty; @ApiModelProperty(value = "毕业院校") private String school; @ApiModelProperty(value = "入职日期") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") private LocalDate beginDate; @ApiModelProperty(value = "在职状态") private String workState; @ApiModelProperty(value = "工号") private String workID; @ApiModelProperty(value = "合同期限") private Double contractTerm; @ApiModelProperty(value = "转正日期") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") private LocalDate conversionTime; @ApiModelProperty(value = "离职日期") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") private LocalDate notWorkDate; @ApiModelProperty(value = "合同起始日期") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") private LocalDate beginContract; @ApiModelProperty(value = "合同终止日期") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") private LocalDate endContract; @ApiModelProperty(value = "工龄") private Integer workAge; @ApiModelProperty(value = "工资账套ID") private Integer salaryId; @ApiModelProperty(value = "民族") @TableField(exist = false) private Nation nation; @ApiModelProperty(value = "政治面貌") @TableField(exist = false) private PoliticsStatus politicsStatus; @ApiModelProperty(value = "部门") @TableField(exist = false) private Department department; @ApiModelProperty(value = "职称") @TableField(exist = false) private Joblevel joblevel; @ApiModelProperty(value = "职位") @TableField(exist = false) private Position position; }
package com.wzs.server.controller; import com.wzs.server.pojo.Employee; import com.wzs.server.pojo.RespPageBean; import com.wzs.server.service.IEmployeeService; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.time.LocalDate; import java.time.LocalDateTime; /** * <p> * 前端控制器 * </p> * * @author wuzhaosheng * @since 2022-01-08 */ @RestController @RequestMapping("/employee/basic") public class EmployeeController { @Autowired private IEmployeeService employeeService; @ApiOperation(value = "分页查询员工信息") @GetMapping("/") public RespPageBean getEmployeeByPage(@RequestParam(value = "pc",defaultValue = "1") Integer pc, @RequestParam(value = "ps",defaultValue = "10") Integer ps, Employee employee, LocalDate[] beginDateScope){ return employeeService.getEmployeeByPage(pc,ps,employee,beginDateScope); } }
package com.wzs.server.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.wzs.server.pojo.Employee; import com.wzs.server.mapper.EmployeeMapper; import com.wzs.server.pojo.RespPageBean; import com.wzs.server.service.IEmployeeService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDate; /** * <p> * 服务实现类 * </p> * * @author wuzhaosheng * @since 2022-01-08 */ @Service public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements IEmployeeService { @Autowired private EmployeeMapper employeeMapper; @Override public RespPageBean getEmployeeByPage(Integer pc, Integer ps, Employee employee, LocalDate[] beginDateScope) { //开启分页 Page<Employee> page = new Page<>(pc,ps); IPage<Employee> employeeIPage = employeeMapper.getEmployeeByPage(page,employee,beginDateScope); RespPageBean respPageBean = new RespPageBean(); respPageBean.setTotal(employeeIPage.getTotal()); respPageBean.setData(employeeIPage.getRecords()); return respPageBean; } }
package com.wzs.server.mapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.wzs.server.pojo.Employee; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import java.time.LocalDate; /** * <p> * Mapper 接口 * </p> * * @author wuzhaosheng * @since 2022-01-08 */ public interface EmployeeMapper extends BaseMapper<Employee> { IPage<Employee> getEmployeeByPage(Page<Employee> page, @Param("employee") Employee employee, @Param("beginDateScope") LocalDate[] beginDateScope); }