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 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.TjHarmType; import com.ltkj.hosp.service.ITjHarmTypeService; import com.ltkj.common.utils.poi.ExcelUtil; import com.ltkj.common.core.page.TableDataInfo; /** * 职业病Controller * * @author ltkj_赵佳豪&李格 * @date 2023-12-06 */ @RestController @RequestMapping("/hosp/harmType") public class TjHarmTypeController extends BaseController { @Autowired private ITjHarmTypeService tjHarmTypeService; /** * 查询职业病列表 */ @GetMapping("/list") public TableDataInfo list(TjHarmType tjHarmType) { startPage(); LambdaQueryWrapper wq=new LambdaQueryWrapper<>(); if (tjHarmType.getHarmCode()!=null){ wq.like(TjHarmType::getHarmCode,tjHarmType.getHarmCode()); } if (tjHarmType.getHarmType()!=null){ wq.like(TjHarmType::getHarmType,tjHarmType.getHarmType()); } if (tjHarmType.getHarmPinYin()!=null){ wq.like(TjHarmType::getHarmPinYin,tjHarmType.getHarmPinYin()); } List list = tjHarmTypeService.list(wq); return getDataTable(list); } /** * 导出职业病列表 */ @Log(title = "职业病", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, TjHarmType tjHarmType) { List list = tjHarmTypeService.selectTjHarmTypeList(tjHarmType); ExcelUtil util = new ExcelUtil(TjHarmType.class); util.exportExcel(response, list, "职业病数据"); } /** * 获取职业病详细信息 */ @GetMapping(value = "/{aid}") public AjaxResult getInfo(@PathVariable("aid") String aid) { return success(tjHarmTypeService.getById(aid)); } /** * 新增职业病 */ @Log(title = "职业病", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody TjHarmType tjHarmType) { return toAjax(tjHarmTypeService.save(tjHarmType)); } /** * 修改职业病 */ @Log(title = "职业病", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody TjHarmType tjHarmType) { return toAjax(tjHarmTypeService.updateById(tjHarmType)); } /** * 删除职业病 */ @Log(title = "职业病", businessType = BusinessType.DELETE) @DeleteMapping("/remove") public AjaxResult remove(@RequestBody String[] aids) { return toAjax(tjHarmTypeService.removeByIds(Arrays.asList(aids))); } }