Forráskód Böngészése

后台对接前端组件逻辑优化,优化删除接口

limingming 1 éve
szülő
commit
0fc6440306

+ 4 - 6
rouyi-api/src/main/java/com/info666/infraredRemote/controller/GetDeviceInfoController.java

@@ -1,10 +1,9 @@
 package com.info666.infraredRemote.controller;
 
-import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.system.domain.BaseParam;
 import com.ruoyi.system.domain.BasicLibrary;
-import com.ruoyi.system.domain.ComponentsLibrary;
 import com.ruoyi.system.domain.TemplateLibrary;
 import com.ruoyi.system.domain.vo.GetDeviceInfoVo;
 import com.ruoyi.system.service.BasicLibraryService;
@@ -13,13 +12,12 @@ import com.ruoyi.system.service.TemplateLibraryService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 /**
  * @Author: LiMingMing
@@ -40,10 +38,10 @@ public class GetDeviceInfoController {
 
     @ApiOperation("获取遥控设备信息")
     @PostMapping("/getDeviceInfo")
-    public R<List<GetDeviceInfoVo>> getDeviceInfo() {
+    public R<List<GetDeviceInfoVo>> getDeviceInfo(@RequestBody BaseParam param) {
         List<GetDeviceInfoVo> list = new ArrayList<>();
 
-        List<ComponentsLibrary> componentsLibraries = new ArrayList<>();
+//        List<ComponentsLibrary> componentsLibraries = new ArrayList<>();
 
         List<TemplateLibrary> templaList = templateLibraryService.list(new LambdaQueryWrapper<TemplateLibrary>().eq(TemplateLibrary::getDelFlag, 0));
         for (TemplateLibrary templateLibrary : templaList) {

+ 2 - 5
ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/BasicLibraryController.java

@@ -116,11 +116,8 @@ public class BasicLibraryController extends BaseController {
     @Log(title = "基础库管理", businessType = BusinessType.DELETE)
 	@PostMapping("/delete")
     public R<T> remove(@RequestBody BaseParam param) {
-        BasicLibrary basicLibrary = new BasicLibrary();
-        basicLibrary.setId(param.getId());
-        basicLibrary.setDelFlag("2");
-        boolean sta = basicLibraryService.updateById(basicLibrary);
-        if (!sta){
+        boolean flat = basicLibraryService.removeById(param.getId());
+        if (!flat){
             return R.fail("删除失败");
         }
         return R.ok();

+ 13 - 11
ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/ComponentsLibraryController.java

@@ -11,8 +11,11 @@ import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.system.domain.BaseParam;
 import com.ruoyi.system.domain.ComponentsLibrary;
+import com.ruoyi.system.domain.vo.ComponentsAndBasicVo;
+import com.ruoyi.system.service.BasicLibraryService;
 import com.ruoyi.system.service.ComponentsLibraryService;
 import io.swagger.annotations.ApiOperation;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -33,6 +36,9 @@ public class ComponentsLibraryController extends BaseController {
     @Autowired
     private ComponentsLibraryService componentsLibraryService;
 
+    @Autowired
+    private BasicLibraryService basicLibraryService;
+
     /**
      * 查询组件库列表
      */
@@ -52,14 +58,14 @@ public class ComponentsLibraryController extends BaseController {
 
 
     /**
-     * 查询基础库列表
+     * 查询组件全部信息 包括
      */
     @ApiOperation("查询组件库管理列表")
 //    @PreAuthorize("@ss.hasPermi('platform:base:list')")
     @PostMapping("/allList")
-    public R<List<ComponentsLibrary>> getAllList() {
-        List<ComponentsLibrary> basicLibraryList = componentsLibraryService.list(new LambdaQueryWrapper<ComponentsLibrary>().eq(ComponentsLibrary::getDelFlag,0));
-        return R.ok(basicLibraryList);
+    public R<List<ComponentsAndBasicVo>> getAllList() {
+        List<ComponentsAndBasicVo> list = componentsLibraryService.getAllComponentsInfo();
+        return R.ok(list);
     }
 
 
@@ -69,7 +75,6 @@ public class ComponentsLibraryController extends BaseController {
 //    @PreAuthorize("@ss.hasPermi('platform:components:query')")
     @PostMapping(value = "/getInfo")
     public R<ComponentsLibrary> getInfo(@RequestBody BaseParam param) {
-
         return R.ok(componentsLibraryService.getOne(new LambdaQueryWrapper<ComponentsLibrary>().eq(ComponentsLibrary::getId,param.getId())
                 .eq(ComponentsLibrary::getDelFlag,"0"),false));
     }
@@ -96,12 +101,9 @@ public class ComponentsLibraryController extends BaseController {
 //    @PreAuthorize("@ss.hasPermi('platform:components:remove')")
     @Log(title = "组件库", businessType = BusinessType.DELETE)
 	@PostMapping("/delete")
-    public R remove(@RequestBody BaseParam param) {
-        ComponentsLibrary componentsLibrary = new ComponentsLibrary();
-        componentsLibrary.setId(param.getId());
-        componentsLibrary.setDelFlag("2");
-        boolean sta = componentsLibraryService.updateById(componentsLibrary);
-        if (!sta){
+    public R<T> remove(@RequestBody BaseParam param) {
+        boolean flat = componentsLibraryService.removeById(param.getId());
+        if (!flat){
             return R.fail("删除失败");
         }
         return R.ok();

+ 1 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/QrLibraryController.java

@@ -85,10 +85,7 @@ public class QrLibraryController extends BaseController {
     @Log(title = "红外遥控二维码", businessType = BusinessType.DELETE)
 	@PostMapping("/delete")
     public R<T> remove(@RequestBody BaseParam param) {
-        QrLibrary qrLibrary = new QrLibrary();
-        qrLibrary.setId(param.getId());
-        qrLibrary.setDelFlag("2");
-        boolean sta = qrLibraryService.updateById(qrLibrary);
+        boolean sta = qrLibraryService.removeById(param.getId());
         if (!sta){
             return R.fail("删除失败");
         }

+ 3 - 5
ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/TemplateLibraryController.java

@@ -12,6 +12,7 @@ import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.system.domain.BaseParam;
 import com.ruoyi.system.domain.TemplateLibrary;
 import com.ruoyi.system.service.TemplateLibraryService;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -76,11 +77,8 @@ public class TemplateLibraryController extends BaseController {
 //    @PreAuthorize("@ss.hasPermi('platform:template:remove')")
     @Log(title = "模板库", businessType = BusinessType.DELETE)
 	@PostMapping("/delete")
-    public R<Object> remove(@RequestBody BaseParam param) {
-        TemplateLibrary templateLibrary = new TemplateLibrary();
-        templateLibrary.setId(param.getId());
-        templateLibrary.setDelFlag("2");
-        boolean salt = templateLibraryService.updateById(templateLibrary);
+    public R<T> remove(@RequestBody BaseParam param) {
+        boolean salt = templateLibraryService.removeById(param.getId());
         if (!salt){
             return R.fail("删除失败");
         }

+ 4 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/ComponentsLibrary.java

@@ -28,6 +28,10 @@ public class ComponentsLibrary implements Serializable {
     @Excel(name = "组件名称")
     private String name;
 
+    /** 基础库id */
+    @Excel(name = "基础库id")
+    private Long baseId;
+
     /** 组件样式 */
     @Excel(name = "组件样式")
     private String bntStyle;

+ 8 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ComponentsLibraryService.java

@@ -2,6 +2,9 @@ package com.ruoyi.system.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.system.domain.ComponentsLibrary;
+import com.ruoyi.system.domain.vo.ComponentsAndBasicVo;
+
+import java.util.List;
 
 /**
  * 组件库Service接口
@@ -11,5 +14,10 @@ import com.ruoyi.system.domain.ComponentsLibrary;
  */
 public interface ComponentsLibraryService extends IService<ComponentsLibrary> {
 
+    /**
+     * 获取全部的组件按钮信息
+     * @return
+     */
+    List<ComponentsAndBasicVo> getAllComponentsInfo();
 
 }

+ 39 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ComponentsLibraryServiceImpl.java

@@ -1,11 +1,20 @@
 package com.ruoyi.system.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.system.domain.BasicLibrary;
 import com.ruoyi.system.domain.ComponentsLibrary;
+import com.ruoyi.system.domain.vo.ComponentsAndBasicVo;
 import com.ruoyi.system.mapper.ComponentsLibraryMapper;
+import com.ruoyi.system.service.BasicLibraryService;
 import com.ruoyi.system.service.ComponentsLibraryService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * 组件库Service业务层处理
  * 
@@ -15,5 +24,35 @@ import org.springframework.stereotype.Service;
 @Service
 public class ComponentsLibraryServiceImpl extends ServiceImpl<ComponentsLibraryMapper, ComponentsLibrary> implements ComponentsLibraryService {
 
+    @Autowired
+    private BasicLibraryService basicLibraryService;
 
+    @Override
+    public List<ComponentsAndBasicVo> getAllComponentsInfo() {
+        List<ComponentsAndBasicVo> voList = new ArrayList<>();
+        List<ComponentsLibrary> basicLibraryList = this.list(new LambdaQueryWrapper<ComponentsLibrary>().eq(ComponentsLibrary::getDelFlag,0));
+        for (ComponentsLibrary componentsLibrary : basicLibraryList) {
+            ComponentsAndBasicVo componentsAndBasicVo = new ComponentsAndBasicVo();
+            componentsAndBasicVo.setId(componentsLibrary.getId());
+            componentsAndBasicVo.setName(componentsLibrary.getName());
+            componentsAndBasicVo.setBaseId(componentsLibrary.getBaseId());
+            componentsAndBasicVo.setBntStyle(componentsLibrary.getBntStyle());
+            componentsAndBasicVo.setTypeNum(componentsLibrary.getTypeNum());
+            componentsAndBasicVo.setAddSubMax(componentsLibrary.getAddSubMax());
+            componentsAndBasicVo.setAddSubMin(componentsLibrary.getAddSubMin());
+            componentsAndBasicVo.setDictateParameter(componentsLibrary.getDictateParameter());
+            componentsAndBasicVo.setDefValue(componentsLibrary.getDefValue());
+            componentsAndBasicVo.setRepeatCode(componentsLibrary.getRepeatCode());
+            BeanUtils.copyProperties(basicLibraryList,componentsAndBasicVo);
+            BasicLibrary one = basicLibraryService.getOne(new LambdaQueryWrapper<BasicLibrary>().eq(BasicLibrary::getId, componentsLibrary.getBaseId()), false);
+            componentsAndBasicVo.setBaseName(one.getName());
+            componentsAndBasicVo.setBandValue(one.getBandValue());
+            componentsAndBasicVo.setBootCode(one.getBootCode());
+            componentsAndBasicVo.setBootCodeSend(one.getBootCodeSend());
+            componentsAndBasicVo.setDateCode(one.getDateCode());
+            componentsAndBasicVo.setOverCode(one.getOverCode());
+            voList.add(componentsAndBasicVo);
+        }
+        return voList;
+    }
 }