package com.ltkj.web.controller.system; import java.util.Arrays; import java.util.List; import javax.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; 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(); List list = tjHarmTypeService.list(); 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("/{aids}") public AjaxResult remove(@PathVariable String[] aids) { return toAjax(tjHarmTypeService.removeByIds(Arrays.asList(aids))); } }