From f61dc2d33639010a7b9505fad0cfbe9d36e1f83b Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期二, 24 九月 2024 11:19:44 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java |   81 +++++++++++++++++++++++-----------------
 1 files changed, 46 insertions(+), 35 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java
index 1c46986..bf58c85 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java
@@ -1,20 +1,26 @@
 package com.iailab.module.model.mcs.pre.controller.admin;
 
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.iailab.framework.common.pojo.CommonResult;
 import com.iailab.framework.common.pojo.PageResult;
+import com.iailab.framework.common.util.object.BeanUtils;
 import com.iailab.module.model.mcs.pre.dto.MmPredictItemDTO;
+import com.iailab.module.model.mcs.pre.entity.MmPredictItemEntity;
 import com.iailab.module.model.mcs.pre.service.MmPredictItemService;
 import com.iailab.module.model.mcs.pre.vo.CountItemtypeVO;
+import com.iailab.module.model.mcs.pre.vo.MmPredictItemPageReqVO;
 import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 
-import static com.iailab.framework.common.pojo.CommonResult.error;
 import static com.iailab.framework.common.pojo.CommonResult.success;
 
 /**
@@ -22,7 +28,7 @@
  * @date 2021年04月26日 14:42
  */
 @RestController
-@RequestMapping("/pre/predict-item")
+@RequestMapping("/model/pre/predict-item")
 public class MmPredictItemController {
 
     @Autowired
@@ -32,55 +38,60 @@
      * 预测项列表
      */
     @GetMapping("/page")
-    public CommonResult<PageResult<MmPredictItemRespVO>> page(@RequestParam Map<String, Object> params) {
-        PageResult<MmPredictItemRespVO> page = mmPredictItemService.getPageList(params);
-        return success(page);
+    @PreAuthorize("@ss.hasPermission('model:pre-predict:query')")
+    public CommonResult<PageResult<MmPredictItemRespVO>> page(@Validated MmPredictItemPageReqVO reqVO) {
+        PageResult<MmPredictItemEntity> page = mmPredictItemService.queryPage(reqVO);
+        return success(BeanUtils.toBean(page, MmPredictItemRespVO.class));
+    }
+
+    @GetMapping("/list")
+    @PreAuthorize("@ss.hasPermission('model:pre-predict:query')")
+    public CommonResult<List<MmPredictItemEntity>> list(@RequestParam Map<String, Object> params) {
+        List<MmPredictItemEntity> list = mmPredictItemService.list(params);
+
+        return success(list);
     }
 
     /**
      * 预测项信息
      */
-    @GetMapping("/info/{id}")
-    public CommonResult<MmPredictItemDTO> info(@PathVariable("id") String id, @RequestParam Map<String, Object> params){
-        MmPredictItemDTO predictItem = mmPredictItemService.getDetailById(id, params);
+    @GetMapping("/get/{id}")
+    @PreAuthorize("@ss.hasPermission('model:pre-predict:query')")
+    public CommonResult<MmPredictItemDTO> info(@PathVariable("id") String id){
+        MmPredictItemDTO predictItem = mmPredictItemService.info(id);
         return success(predictItem);
     }
 
     /**
      * 保存预测项
      */
-    @PostMapping
+    @PostMapping("/create")
+    @PreAuthorize("@ss.hasPermission('model:pre-predict:create')")
+    @DSTransactional(rollbackFor= Exception.class)
     public CommonResult<Boolean> save(@RequestBody MmPredictItemDTO mmPredictItemDto){
-        int count = mmPredictItemService.check(mmPredictItemDto.getMmPredictItem());
-        if (count > 0) {
-            return error(999, "名称或编号重复");
-        }
-        mmPredictItemService.savePredictItem(mmPredictItemDto);
+        mmPredictItemService.add(mmPredictItemDto);
         return success(true);
     }
 
     /**
      * 修改预测项
      */
-    @PutMapping
-    public CommonResult<Boolean> update(@RequestBody MmPredictItemDTO mmPredictItemDto){
-        int count = mmPredictItemService.check(mmPredictItemDto.getMmPredictItem());
-        if (count > 0) {
-            return error(999, "名称或编号重复");
-        }
-        mmPredictItemService.update(mmPredictItemDto);
+    @PutMapping("/update")
+    @PreAuthorize("@ss.hasPermission('model:pre-predict:update')")
+    @DSTransactional(rollbackFor= Exception.class)
+    public CommonResult<Boolean> update(@RequestBody MmPredictItemDTO mmPredictItemDTO){
+        mmPredictItemService.update(mmPredictItemDTO);
         return success(true);
     }
 
     /**
      * 删除预测项
      */
-    @DeleteMapping("{id}")
-    public CommonResult<Boolean> delete(@RequestBody String[] itemIds){
-        if (itemIds == null || itemIds.length == 0) {
-            return error(999, "参数不能为空");
-        }
-        mmPredictItemService.deleteBatch(itemIds);
+    @DeleteMapping("/delete")
+    @PreAuthorize("@ss.hasPermission('model:pre-predict:delete')")
+    @DSTransactional(rollbackFor= Exception.class)
+    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
+        mmPredictItemService.deleteBatch(new String[]{id});
         return success(true);
     }
 
@@ -93,14 +104,14 @@
         return success(list);
     }
 
-    /**
-     * 数量
-     */
-    @GetMapping("/count")
-    public CommonResult<Long> count() {
-        Long count = mmPredictItemService.count();
-        return success(count);
-    }
+//    /**
+//     * 数量
+//     */
+//    @GetMapping("/count")
+//    public CommonResult<Long> count() {
+//        Long count = mmPredictItemService.count();
+//        return success(count);
+//    }
 
     /**
      * 上传模型

--
Gitblit v1.9.3