- 创建 PerfDept 实体类定义部门基本信息字段 - 实现 IPerfDeptService 接口提供部门增删改查方法 - 开发 PerfDeptController 控制器支持 RESTful API 操作 - 集成 MyBatis Plus 完成数据库映射与分页查询 - 添加部门信息的导入导出 Excel 功能 - 实现部门状态校验与批量删除验证逻辑 - 配置部门 VO 视图对象支持 Excel 数据转换
100 lines
3.0 KiB
Java
100 lines
3.0 KiB
Java
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));
|
|
}
|
|
}
|