From 7f1a65f3f78bcb1765e2628ad7efa7cdb74a82ac Mon Sep 17 00:00:00 2001 From: shanao Date: Tue, 3 Sep 2024 17:08:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accident/AccidentRecordsController.java | 57 ++++++++++++++++++- .../accident/AccidentRecordsMapper.java | 39 ++++++++++++- .../accident/AccidentRecordsMapper.xml | 4 +- 3 files changed, 94 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/zcloud/controller/accident/AccidentRecordsController.java b/src/main/java/com/zcloud/controller/accident/AccidentRecordsController.java index 29a8d962..d1a6e97c 100644 --- a/src/main/java/com/zcloud/controller/accident/AccidentRecordsController.java +++ b/src/main/java/com/zcloud/controller/accident/AccidentRecordsController.java @@ -29,6 +29,13 @@ public class AccidentRecordsController extends BaseController { private final AccidentRecordsService accidentRecordsService; + /** + * 分页查询 + * + * @param page 分页参数 + * @param request 请求参数 + * @return 返回结果 + */ @RequestMapping(value = "/page") public Map queryPage(Page page, HttpServletRequest request) { page.setPd(new PageData(request)); @@ -39,6 +46,12 @@ public class AccidentRecordsController extends BaseController { return result; } + /** + * 根据id查询 + * + * @param id id + * @return 返回结果 + */ @RequestMapping("/{id}") public Map getById(@PathVariable("id") Long id) { Map result = new HashMap<>(); @@ -47,6 +60,12 @@ public class AccidentRecordsController extends BaseController { return result; } + /** + * 新增 + * + * @param request 请求参数 + * @return 返回结果 + */ @RequestMapping("/save") public Map save(HttpServletRequest request) { AccidentRecords accidentRecords = BeanUtil.mapToBean(new PageData(request), AccidentRecords.class, true); @@ -57,6 +76,12 @@ public class AccidentRecordsController extends BaseController { return result; } + /** + * 修改 + * + * @param request 请求参数 + * @return 返回结果 + */ @RequestMapping("/update") public Map update(HttpServletRequest request) { AccidentRecords accidentRecords = BeanUtil.mapToBean(new PageData(request), AccidentRecords.class, true); @@ -68,6 +93,12 @@ public class AccidentRecordsController extends BaseController { return result; } + /** + * 删除 + * + * @param values id集合 + * @return 是否成功 + */ @RequestMapping("/delete/{ids}") public Map delete(@PathVariable("ids") String values) { String[] split = Optional.of(values).orElseThrow(() -> new RuntimeException("ids不能为空")).split(","); @@ -78,12 +109,22 @@ public class AccidentRecordsController extends BaseController { return result; } + /** + * 导出excel + * + * @param request 请求 + * @param response 响应 + */ @RequestMapping("/export/excel") public void exportExcel(HttpServletRequest request, HttpServletResponse response) { - PageData pd = new PageData(request); - accidentRecordsService.exportExcel(pd, response); + accidentRecordsService.exportExcel(new PageData(request), response); } + /** + * 导入excel + * + * @param file 文件 + */ @RequestMapping("/import/excel") public void importExcel(@RequestParam("file") MultipartFile file) { if (file == null || file.isEmpty()) { @@ -92,6 +133,12 @@ public class AccidentRecordsController extends BaseController { accidentRecordsService.importExcel(file); } + /** + * 导入图片 + * + * @param file 文件 + * @return 是否成功 + */ @RequestMapping("/import/photos") public Map importPhotos(@RequestParam("file") MultipartFile file) { if (file == null || file.isEmpty()) { @@ -103,6 +150,12 @@ public class AccidentRecordsController extends BaseController { return result; } + /** + * 查看图片 + * + * @param path 路径 + * @param response 响应 + */ @RequestMapping("/view/photos/{path}") public void viewPhotos(@PathVariable("path") String path, HttpServletResponse response) { if (StrUtil.isEmpty(path)) { diff --git a/src/main/java/com/zcloud/mapper/datasource/accident/AccidentRecordsMapper.java b/src/main/java/com/zcloud/mapper/datasource/accident/AccidentRecordsMapper.java index db023cbb..bb753499 100644 --- a/src/main/java/com/zcloud/mapper/datasource/accident/AccidentRecordsMapper.java +++ b/src/main/java/com/zcloud/mapper/datasource/accident/AccidentRecordsMapper.java @@ -8,19 +8,54 @@ import org.apache.ibatis.annotations.Param; import java.util.List; + public interface AccidentRecordsMapper { + /** + * 分页查询 + * + * @param page 条件 + * @return 结果 + */ List listPage(Page page); + /** + * 根据id查询 + * + * @param id id + * @return 结果 + */ PageData getById(Long id); + /** + * 新增 + * + * @param accidentRecords 要保存的实体 + * @return 受影响的行数 + */ int save(AccidentRecords accidentRecords); + /** + * 修改 + * + * @param accidentRecords 要修改的实体 + * @return 受影响的行数 + */ int updateById(AccidentRecords accidentRecords); + /** + * 删除 + * + * @param ids 主键数组 + * @return 受影响的行数 + */ int delete(@Param("ids") Long[] ids); + /** + * 导出excel + * + * @param pd 条件 + * @return 结果 + */ List listExcel(PageData pd); - - void saveExcel(AccidentRecordsExcel records, long id, String username); } \ No newline at end of file diff --git a/src/main/resources/mybatis/datasource/accident/AccidentRecordsMapper.xml b/src/main/resources/mybatis/datasource/accident/AccidentRecordsMapper.xml index 4f5a3154..0a36edb8 100644 --- a/src/main/resources/mybatis/datasource/accident/AccidentRecordsMapper.xml +++ b/src/main/resources/mybatis/datasource/accident/AccidentRecordsMapper.xml @@ -2,7 +2,7 @@ - select id, CORP_NAME as companyName, location, incident_date, incident_name from accident_records as ar left join bus_corp_info as bci on ar.corpinfo_id = bci.CORPINFO_ID @@ -288,7 +288,7 @@ suggestions, measures, ar.creator, - date_format(report_date, '%Y年%m月%d日') as 'reportDate' + date_format(report_date, '%Y年%m月%d日%H时%I分%s秒') as 'reportDate' from accident_records as ar left join bus_corp_info as bci on ar.corpinfo_id = bci.CORPINFO_ID