feat(perf): 添加绩效系统部门管理功能
- 创建 PerfDept 实体类定义部门基本信息字段 - 实现 IPerfDeptService 接口提供部门增删改查方法 - 开发 PerfDeptController 控制器支持 RESTful API 操作 - 集成 MyBatis Plus 完成数据库映射与分页查询 - 添加部门信息的导入导出 Excel 功能 - 实现部门状态校验与批量删除验证逻辑 - 配置部门 VO 视图对象支持 Excel 数据转换
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
package com.klp.perf.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.*;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.klp.common.annotation.RepeatSubmit;
|
||||
import com.klp.common.annotation.Log;
|
||||
import com.klp.common.core.controller.BaseController;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.domain.R;
|
||||
import com.klp.common.core.validate.AddGroup;
|
||||
import com.klp.common.core.validate.EditGroup;
|
||||
import com.klp.common.enums.BusinessType;
|
||||
import com.klp.common.utils.poi.ExcelUtil;
|
||||
import com.klp.perf.domain.vo.PerfDeptVo;
|
||||
import com.klp.perf.domain.bo.PerfDeptBo;
|
||||
import com.klp.perf.service.IPerfDeptService;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 绩效系统部门
|
||||
*
|
||||
* @author klp
|
||||
* @date 2026-07-07
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/perf/dept")
|
||||
public class PerfDeptController extends BaseController {
|
||||
|
||||
private final IPerfDeptService iPerfDeptService;
|
||||
|
||||
/**
|
||||
* 查询绩效系统部门列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<PerfDeptVo> list(PerfDeptBo bo, PageQuery pageQuery) {
|
||||
return iPerfDeptService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出绩效系统部门列表
|
||||
*/
|
||||
@Log(title = "绩效系统部门", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(PerfDeptBo bo, HttpServletResponse response) {
|
||||
List<PerfDeptVo> list = iPerfDeptService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "绩效系统部门", PerfDeptVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取绩效系统部门详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R<PerfDeptVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable String id) {
|
||||
return R.ok(iPerfDeptService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增绩效系统部门
|
||||
*/
|
||||
@Log(title = "绩效系统部门", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody PerfDeptBo bo) {
|
||||
return toAjax(iPerfDeptService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改绩效系统部门
|
||||
*/
|
||||
@Log(title = "绩效系统部门", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody PerfDeptBo bo) {
|
||||
return toAjax(iPerfDeptService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除绩效系统部门
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@Log(title = "绩效系统部门", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable String[] ids) {
|
||||
return toAjax(iPerfDeptService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
}
|
||||
53
klp-perf/src/main/java/com/klp/perf/domain/PerfDept.java
Normal file
53
klp-perf/src/main/java/com/klp/perf/domain/PerfDept.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package com.klp.perf.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.klp.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
/**
|
||||
* 绩效系统部门对象 perf_dept
|
||||
*
|
||||
* @author klp
|
||||
* @date 2026-07-07
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("perf_dept")
|
||||
public class PerfDept extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 主键(UUID)
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private String id;
|
||||
/**
|
||||
* 部门/车间名称 如:酸轧车间/技术部
|
||||
*/
|
||||
private String deptName;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Long orderNum;
|
||||
/**
|
||||
* 是否有保底薪资模式 0=否 1=是
|
||||
*/
|
||||
private Integer hasBaoSalary;
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 删除标志(0=正常 1=已删除)
|
||||
*/
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.klp.perf.domain.bo;
|
||||
|
||||
import com.klp.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
|
||||
/**
|
||||
* 绩效系统部门业务对象 perf_dept
|
||||
*
|
||||
* @author klp
|
||||
* @date 2026-07-07
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PerfDeptBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键(UUID)
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 部门/车间名称 如:酸轧车间/技术部
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Long orderNum;
|
||||
|
||||
/**
|
||||
* 是否有保底薪资模式 0=否 1=是
|
||||
*/
|
||||
private Integer hasBaoSalary;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.klp.perf.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.klp.common.annotation.ExcelDictFormat;
|
||||
import com.klp.common.convert.ExcelDictConvert;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 绩效系统部门视图对象 perf_dept
|
||||
*
|
||||
* @author klp
|
||||
* @date 2026-07-07
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class PerfDeptVo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键(UUID)
|
||||
*/
|
||||
@ExcelProperty(value = "主键(UUID)")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 部门/车间名称 如:酸轧车间/技术部
|
||||
*/
|
||||
@ExcelProperty(value = "部门/车间名称 如:酸轧车间/技术部")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@ExcelProperty(value = "排序")
|
||||
private Long orderNum;
|
||||
|
||||
/**
|
||||
* 是否有保底薪资模式 0=否 1=是
|
||||
*/
|
||||
@ExcelProperty(value = "是否有保底薪资模式 0=否 1=是")
|
||||
private Integer hasBaoSalary;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.klp.perf.mapper;
|
||||
|
||||
import com.klp.perf.domain.PerfDept;
|
||||
import com.klp.perf.domain.vo.PerfDeptVo;
|
||||
import com.klp.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 绩效系统部门Mapper接口
|
||||
*
|
||||
* @author klp
|
||||
* @date 2026-07-07
|
||||
*/
|
||||
public interface PerfDeptMapper extends BaseMapperPlus<PerfDeptMapper, PerfDept, PerfDeptVo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.klp.perf.service;
|
||||
|
||||
import com.klp.perf.domain.PerfDept;
|
||||
import com.klp.perf.domain.vo.PerfDeptVo;
|
||||
import com.klp.perf.domain.bo.PerfDeptBo;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 绩效系统部门Service接口
|
||||
*
|
||||
* @author klp
|
||||
* @date 2026-07-07
|
||||
*/
|
||||
public interface IPerfDeptService {
|
||||
|
||||
/**
|
||||
* 查询绩效系统部门
|
||||
*/
|
||||
PerfDeptVo queryById(String id);
|
||||
|
||||
/**
|
||||
* 查询绩效系统部门列表
|
||||
*/
|
||||
TableDataInfo<PerfDeptVo> queryPageList(PerfDeptBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询绩效系统部门列表
|
||||
*/
|
||||
List<PerfDeptVo> queryList(PerfDeptBo bo);
|
||||
|
||||
/**
|
||||
* 新增绩效系统部门
|
||||
*/
|
||||
Boolean insertByBo(PerfDeptBo bo);
|
||||
|
||||
/**
|
||||
* 修改绩效系统部门
|
||||
*/
|
||||
Boolean updateByBo(PerfDeptBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除绩效系统部门信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.klp.perf.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.klp.common.utils.StringUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.klp.perf.domain.bo.PerfDeptBo;
|
||||
import com.klp.perf.domain.vo.PerfDeptVo;
|
||||
import com.klp.perf.domain.PerfDept;
|
||||
import com.klp.perf.mapper.PerfDeptMapper;
|
||||
import com.klp.perf.service.IPerfDeptService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 绩效系统部门Service业务层处理
|
||||
*
|
||||
* @author klp
|
||||
* @date 2026-07-07
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class PerfDeptServiceImpl implements IPerfDeptService {
|
||||
|
||||
private final PerfDeptMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询绩效系统部门
|
||||
*/
|
||||
@Override
|
||||
public PerfDeptVo queryById(String id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询绩效系统部门列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<PerfDeptVo> queryPageList(PerfDeptBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<PerfDept> lqw = buildQueryWrapper(bo);
|
||||
Page<PerfDeptVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询绩效系统部门列表
|
||||
*/
|
||||
@Override
|
||||
public List<PerfDeptVo> queryList(PerfDeptBo bo) {
|
||||
LambdaQueryWrapper<PerfDept> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<PerfDept> buildQueryWrapper(PerfDeptBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<PerfDept> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getDeptName()), PerfDept::getDeptName, bo.getDeptName());
|
||||
lqw.eq(bo.getOrderNum() != null, PerfDept::getOrderNum, bo.getOrderNum());
|
||||
lqw.eq(bo.getHasBaoSalary() != null, PerfDept::getHasBaoSalary, bo.getHasBaoSalary());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), PerfDept::getStatus, bo.getStatus());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增绩效系统部门
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(PerfDeptBo bo) {
|
||||
PerfDept add = BeanUtil.toBean(bo, PerfDept.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改绩效系统部门
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(PerfDeptBo bo) {
|
||||
PerfDept update = BeanUtil.toBean(bo, PerfDept.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(PerfDept entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除绩效系统部门
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
22
klp-perf/src/main/resources/mapper/perf/PerfDeptMapper.xml
Normal file
22
klp-perf/src/main/resources/mapper/perf/PerfDeptMapper.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.klp.perf.mapper.PerfDeptMapper">
|
||||
|
||||
<resultMap type="com.klp.perf.domain.PerfDept" id="PerfDeptResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="deptName" column="dept_name"/>
|
||||
<result property="orderNum" column="order_num"/>
|
||||
<result property="hasBaoSalary" column="has_bao_salary"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user