From 3b6ced8185a19c9377aa2a059142f15e3b23cd88 Mon Sep 17 00:00:00 2001 From: bleachtred <bleachtred@163.com> Date: 星期一, 27 三月 2023 16:35:12 +0800 Subject: [PATCH] update 优化BaseMapperPlus接口 去除 @param <M> Mapper 泛型 --- ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestDemoController.java | 27 +++++++++++++-------------- 1 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestDemoController.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestDemoController.java index d16fe9d..2f6bc11 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestDemoController.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestDemoController.java @@ -1,8 +1,8 @@ package com.ruoyi.demo.controller; import cn.dev33.satoken.annotation.SaCheckPermission; -import cn.hutool.core.bean.BeanUtil; import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.utils.MapstructUtils; import com.ruoyi.common.core.utils.ValidatorUtils; import com.ruoyi.common.core.validate.AddGroup; import com.ruoyi.common.core.validate.EditGroup; @@ -29,8 +29,8 @@ import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; -import java.util.Arrays; -import java.util.List; + +import java.util.*; import java.util.concurrent.TimeUnit; /** @@ -45,7 +45,7 @@ @RequestMapping("/demo/demo") public class TestDemoController extends BaseController { - private final ITestDemoService iTestDemoService; + private final ITestDemoService testDemoService; /** * 鏌ヨ娴嬭瘯鍗曡〃鍒楄〃 @@ -53,7 +53,7 @@ @SaCheckPermission("demo:demo:list") @GetMapping("/list") public TableDataInfo<TestDemoVo> list(@Validated(QueryGroup.class) TestDemoBo bo, PageQuery pageQuery) { - return iTestDemoService.queryPageList(bo, pageQuery); + return testDemoService.queryPageList(bo, pageQuery); } /** @@ -62,7 +62,7 @@ @SaCheckPermission("demo:demo:list") @GetMapping("/page") public TableDataInfo<TestDemoVo> page(@Validated(QueryGroup.class) TestDemoBo bo, PageQuery pageQuery) { - return iTestDemoService.customPageList(bo, pageQuery); + return testDemoService.customPageList(bo, pageQuery); } /** @@ -75,9 +75,8 @@ @PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public R<Void> importData(@RequestPart("file") MultipartFile file) throws Exception { ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true); - List<TestDemoImportVo> volist = excelResult.getList(); - List<TestDemo> list = BeanUtil.copyToList(volist, TestDemo.class); - iTestDemoService.saveBatch(list); + List<TestDemo> list = MapstructUtils.convert(excelResult.getList(), TestDemo.class); + testDemoService.saveBatch(list); return R.ok(excelResult.getAnalysis()); } @@ -88,7 +87,7 @@ @Log(title = "娴嬭瘯鍗曡〃", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(@Validated TestDemoBo bo, HttpServletResponse response) { - List<TestDemoVo> list = iTestDemoService.queryList(bo); + List<TestDemoVo> list = testDemoService.queryList(bo); // 娴嬭瘯闆姳id瀵煎嚭 // for (TestDemoVo vo : list) { // vo.setId(1234567891234567893L); @@ -105,7 +104,7 @@ @GetMapping("/{id}") public R<TestDemoVo> getInfo(@NotNull(message = "涓婚敭涓嶈兘涓虹┖") @PathVariable("id") Long id) { - return R.ok(iTestDemoService.queryById(id)); + return R.ok(testDemoService.queryById(id)); } /** @@ -119,7 +118,7 @@ // 浣跨敤鏍¢獙宸ュ叿瀵规爣 @Validated(AddGroup.class) 娉ㄨВ // 鐢ㄤ簬鍦ㄩ潪 Controller 鐨勫湴鏂规牎楠屽璞� ValidatorUtils.validate(bo, AddGroup.class); - return toAjax(iTestDemoService.insertByBo(bo)); + return toAjax(testDemoService.insertByBo(bo)); } /** @@ -130,7 +129,7 @@ @RepeatSubmit @PutMapping() public R<Void> edit(@Validated(EditGroup.class) @RequestBody TestDemoBo bo) { - return toAjax(iTestDemoService.updateByBo(bo)); + return toAjax(testDemoService.updateByBo(bo)); } /** @@ -143,6 +142,6 @@ @DeleteMapping("/{ids}") public R<Void> remove(@NotEmpty(message = "涓婚敭涓嶈兘涓虹┖") @PathVariable Long[] ids) { - return toAjax(iTestDemoService.deleteWithValidByIds(Arrays.asList(ids), true)); + return toAjax(testDemoService.deleteWithValidByIds(Arrays.asList(ids), true)); } } -- Gitblit v1.9.3