Parcourir la source

修改物理删除代码

syh il y a 5 ans
Parent
commit
d4857ac9c0

+ 3 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/DramaItemInfoController.java

@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
 import java.util.Date;
+import java.util.Map;
 
 /**
  * 剧本内容信息
@@ -114,14 +115,8 @@ public class DramaItemInfoController {
     @AutoLog(value = "剧本内容信息-通过id删除")
     @ApiOperation(value = "剧本内容信息-通过id删除", notes = "剧本内容信息-通过id删除")
     @PostMapping(value = "/delete")
-    public Result<Object> delete(@RequestBody DramaItemInfo dramaItemInfo) {
-        try {
-            dramaItemInfoService.removeById(dramaItemInfo.getId());
-        } catch (Exception e) {
-            log.error("删除失败", e.getMessage());
-            return Result.error("删除失败!");
-        }
-        return Result.ok("删除成功!");
+    public Map<String, Object> delete(@RequestBody DramaItemInfo dramaItemInfo) {
+        return dramaItemInfoService.delete(dramaItemInfo.getId());
     }
 
     /**

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IDramaItemInfoService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.ctop.entity.DramaItemInfo;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 剧本内容信息
@@ -17,4 +18,6 @@ public interface IDramaItemInfoService extends IService<DramaItemInfo> {
     List<DramaItemInfo> getByDramaId(Long dramaId);
 
     int getMaxRankByDramaId(Long dramaId);
+
+    Map<String, Object> delete(Long id);
 }

+ 18 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/DramaItemInfoServiceImpl.java

@@ -1,5 +1,7 @@
 package org.jeecg.modules.ctop.service.impl;
 
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.modules.ctop.entity.DramaItemInfo;
@@ -11,7 +13,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 剧本内容信息
@@ -56,4 +60,18 @@ public class DramaItemInfoServiceImpl extends ServiceImpl<DramaItemInfoMapper, D
             return itemInfo.getRank() + 1;
         }
     }
+
+    @Override
+    public Map<String, Object> delete(Long id) {
+        Map<String, Object> result = new HashMap<>();
+        DramaItemInfo info = this.getById(id);
+        if (null == info) {
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_DATA_NOT_EXIST);
+            return result;
+        }
+        info.setEnabled(0);
+        this.updateById(info);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+    }
 }

+ 1 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/StatusCode.java

@@ -20,6 +20,7 @@ public enum StatusCode {
      */
     COMMON_SUCCESS("success", 0, true),
     COMMON_PARAM_ERROR("参数异常", -1, false),
+    COMMON_DATA_NOT_EXIST("数据不存在或者已经被删除", -101, false),
     BYTEDANCE_VIDEO_UPLOAD_FAIL("今日头条视频文件上传失败", -201, false),
     MATERIAL_UPLOAD_FAIL("素材文件上传失败", -201, false),
     IMAGE_NUMBER_SHORTAGE("今日头条图片文件上传失败", -202, false),