package com.ltkj.web.controller.system; import java.util.Arrays; import java.util.List; import javax.servlet.http.HttpServletResponse; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ltkj.hosp.domain.TjDwGrouping; import com.ltkj.hosp.service.ITjDwGroupingService; import com.ltkj.hosp.service.ITjGroupingProService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.ltkj.common.annotation.Log; import com.ltkj.common.core.controller.BaseController; import com.ltkj.common.core.domain.AjaxResult; import com.ltkj.common.enums.BusinessType; import com.ltkj.hosp.domain.TjDwDept; import com.ltkj.hosp.service.ITjDwDeptService; import com.ltkj.common.utils.poi.ExcelUtil; import com.ltkj.common.core.page.TableDataInfo; /** * 体检单位部门Controller * * @author ltkj_赵佳豪&李格 * @date 2023-08-07 */ @RestController @RequestMapping("/hosp/dwdept") @Api(tags = "PC端--团体--体检单位部门接口集") public class TjDwDeptController extends BaseController { @Autowired private ITjDwDeptService dwDeptService; @Autowired private ITjDwGroupingService dwGroupingService; @Autowired private ITjGroupingProService groupingProService; /** * 查询体检单位部门列表 */ // @PreAuthorize("@ss.hasPermi('hosp:dept:list')") @GetMapping("/list") @ApiOperation(value = "查询单位部门列表") public TableDataInfo list(TjDwDept tjDwDept) { startPage(); List list = dwDeptService.selectTjDwDeptList(tjDwDept); return getDataTable(list); } /** * 导出体检单位部门列表 */ // @PreAuthorize("@ss.hasPermi('hosp:dept:export')") @Log(title = "体检单位部门", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, TjDwDept tjDwDept) { List list = dwDeptService.selectTjDwDeptList(tjDwDept); ExcelUtil util = new ExcelUtil(TjDwDept.class); util.exportExcel(response, list, "体检单位部门数据"); } /** * 获取体检单位部门详细信息 */ // @PreAuthorize("@ss.hasPermi('hosp:dept:query')") @GetMapping(value = "/{id}") @ApiOperation(value = "查询单位部门详情信息") public AjaxResult getInfo(@PathVariable("id") String id) { return success(dwDeptService.selectTjDwDeptById(id)); } @GetMapping(value = "/getDwDeptList") @ApiOperation(value = "查询单位下所有的部门列表信息") public AjaxResult getDwDeptList(@RequestParam String dwId) { return success(dwDeptService.list(new LambdaQueryWrapper().eq(TjDwDept::getDwId,dwId))); } /** * 新增体检单位部门 */ // @PreAuthorize("@ss.hasPermi('hosp:dept:add')") @Log(title = "体检单位部门", businessType = BusinessType.INSERT) @PostMapping @ApiOperation(value = "新增单位部门信息") public AjaxResult add(@RequestBody TjDwDept tjDwDept) { if(null==tjDwDept.getDwDeptName()){ return AjaxResult.error("部门名称不能为空!"); } return toAjax(dwDeptService.save(tjDwDept)); } /** * 修改体检单位部门 */ // @PreAuthorize("@ss.hasPermi('hosp:dept:edit')") // @Log(title = "体检单位部门", businessType = BusinessType.UPDATE) @PutMapping @ApiOperation(value = "修改单位部门信息") public AjaxResult edit(@RequestBody TjDwDept tjDwDept) { if(null==tjDwDept.getDwDeptName()){ return AjaxResult.error("部门名称不能为空!"); } return toAjax(dwDeptService.updateById(tjDwDept)); } /** * 删除体检单位部门 */ // @PreAuthorize("@ss.hasPermi('hosp:dept:remove')") // @Log(title = "体检单位部门", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") @ApiOperation(value = "删除单位部门信息") public AjaxResult remove(@PathVariable String[] ids) { if (!dwGroupingService.list(new LambdaQueryWrapper().in(TjDwGrouping::getDwDeptId,Arrays.asList(ids))).isEmpty()){ return AjaxResult.error("该部门下有分组信息,请先删除分组信息!"); } return toAjax(dwDeptService.removeByIds(Arrays.asList(ids))); } @GetMapping(value = "/getTjDwGroupingsByDwAndDwDept") @ApiOperation(value = "根据单位id和部门ID查询单位分组信息") public AjaxResult getTjDwGroupingsByDwAndDwDept(@RequestParam @ApiParam(value = "单位id") String dwId, @RequestParam @ApiParam(value = "部门id") String deptId) { return success(dwGroupingService.list(new LambdaQueryWrapper().eq(TjDwGrouping::getDwId,dwId).eq(TjDwGrouping::getDwDeptId,deptId))); } }