Files
ccdi/ruoyi-dpc/src/main/java/com/ruoyi/dpc/controller/DpcEmployeeController.java

135 lines
4.9 KiB
Java
Raw Normal View History

package com.ruoyi.dpc.controller;
2026-01-28 15:45:55 +08:00
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
2026-01-28 15:45:55 +08:00
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableDataInfo;
2026-01-28 15:45:55 +08:00
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dpc.domain.dto.DpcEmployeeAddDTO;
import com.ruoyi.dpc.domain.dto.DpcEmployeeEditDTO;
import com.ruoyi.dpc.domain.dto.DpcEmployeeQueryDTO;
2026-01-29 09:07:50 +08:00
import com.ruoyi.dpc.domain.excel.DpcEmployeeExcel;
import com.ruoyi.dpc.domain.vo.DpcEmployeeVO;
import com.ruoyi.dpc.service.IDpcEmployeeService;
2026-01-29 09:07:50 +08:00
import com.ruoyi.dpc.utils.EasyExcelUtil;
2026-01-28 15:45:55 +08:00
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* 员工信息Controller
*
* @author ruoyi
* @date 2026-01-28
*/
2026-01-28 15:45:55 +08:00
@Tag(name = "员工信息管理")
@RestController
@RequestMapping("/dpc/employee")
public class DpcEmployeeController extends BaseController {
@Resource
private IDpcEmployeeService employeeService;
/**
* 查询员工列表
*/
2026-01-28 15:45:55 +08:00
@Operation(summary = "查询员工列表")
@PreAuthorize("@ss.hasPermi('dpc:employee:list')")
@GetMapping("/list")
public TableDataInfo list(DpcEmployeeQueryDTO queryDTO) {
2026-01-28 15:45:55 +08:00
// 使用MyBatis Plus分页
PageDomain pageDomain = TableSupport.buildPageRequest();
2026-01-29 09:07:50 +08:00
Page<DpcEmployeeVO> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
2026-01-28 15:45:55 +08:00
Page<DpcEmployeeVO> result = employeeService.selectEmployeePage(page, queryDTO);
return getDataTable(result.getRecords(), result.getTotal());
}
/**
* 导出员工列表
*/
2026-01-28 15:45:55 +08:00
@Operation(summary = "导出员工列表")
@PreAuthorize("@ss.hasPermi('dpc:employee:export')")
@Log(title = "员工信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DpcEmployeeQueryDTO queryDTO) {
2026-01-29 09:07:50 +08:00
List<DpcEmployeeExcel> list = employeeService.selectEmployeeListForExport(queryDTO);
EasyExcelUtil.exportExcel(response, list, DpcEmployeeExcel.class, "员工信息");
}
/**
* 获取员工详细信息
*/
2026-01-28 15:45:55 +08:00
@Operation(summary = "获取员工详细信息")
@PreAuthorize("@ss.hasPermi('dpc:employee:query')")
@GetMapping(value = "/{employeeId}")
public AjaxResult getInfo(@PathVariable Long employeeId) {
return success(employeeService.selectEmployeeById(employeeId));
}
/**
* 新增员工
*/
2026-01-28 15:45:55 +08:00
@Operation(summary = "新增员工")
@PreAuthorize("@ss.hasPermi('dpc:employee:add')")
@Log(title = "员工信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody DpcEmployeeAddDTO addDTO) {
return toAjax(employeeService.insertEmployee(addDTO));
}
/**
* 修改员工
*/
2026-01-28 15:45:55 +08:00
@Operation(summary = "修改员工")
@PreAuthorize("@ss.hasPermi('dpc:employee:edit')")
@Log(title = "员工信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody DpcEmployeeEditDTO editDTO) {
return toAjax(employeeService.updateEmployee(editDTO));
}
/**
* 删除员工
*/
2026-01-28 15:45:55 +08:00
@Operation(summary = "删除员工")
@PreAuthorize("@ss.hasPermi('dpc:employee:remove')")
@Log(title = "员工信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{employeeIds}")
public AjaxResult remove(@PathVariable Long[] employeeIds) {
return toAjax(employeeService.deleteEmployeeByIds(employeeIds));
}
/**
2026-01-29 13:39:47 +08:00
* 下载带字典下拉框的导入模板
* 使用@DictDropdown注解自动添加下拉框
*/
2026-01-28 15:45:55 +08:00
@Operation(summary = "下载导入模板")
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) {
2026-01-29 13:39:47 +08:00
EasyExcelUtil.importTemplateWithDictDropdown(response, DpcEmployeeExcel.class, "员工信息");
}
/**
* 导入员工信息
*/
2026-01-28 15:45:55 +08:00
@Operation(summary = "导入员工信息")
@PreAuthorize("@ss.hasPermi('dpc:employee:import')")
@Log(title = "员工信息", businessType = BusinessType.IMPORT)
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
2026-01-29 09:07:50 +08:00
List<DpcEmployeeExcel> list = EasyExcelUtil.importExcel(file.getInputStream(), DpcEmployeeExcel.class);
String message = employeeService.importEmployee(list, updateSupport);
return success(message);
}
}