Browse Source

完成项目和设备组配置

yangxiaokun 3 years ago
parent
commit
f2fb59eacf

+ 2 - 2
src/main/java/com/zy/bms/controller/GroupController.java

@@ -49,7 +49,7 @@ public class GroupController {
      * 禁用项目组
      */
     @GetMapping("forbidden.do")
-    public ServerResponse forbidden(String id) {
+    public ServerResponse forbidden(Integer id) {
         groupService.update(new UpdateWrapper<Group>().set("status", 0).eq("id", id));
         return ServerResponse.success();
     }
@@ -58,7 +58,7 @@ public class GroupController {
      * 启用项目组
      */
     @GetMapping("permit.do")
-    public ServerResponse permit(String id) {
+    public ServerResponse permit(Integer id) {
         groupService.update(new UpdateWrapper<Group>().set("status", 1).eq("id", id));
         return ServerResponse.success();
     }

+ 8 - 0
src/main/java/com/zy/bms/controller/ItemController.java

@@ -24,6 +24,14 @@ public class ItemController {
     @Resource
     private IItemService itemService;
 
+    /**
+     * 查询所有项目
+     */
+    @GetMapping("listAll.do")
+    public ServerResponse listAll() {
+        return ServerResponse.success(itemService.list());
+    }
+
     /**
      * 分页查询所有项目
      */

+ 23 - 1
src/main/java/com/zy/bms/controller/UserController.java

@@ -1,10 +1,14 @@
 package com.zy.bms.controller;
 
 
+import com.zy.bms.common.ServerResponse;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+
 /**
  * <p>
  * 用户表 前端控制器
@@ -14,7 +18,25 @@ import org.springframework.web.bind.annotation.RestController;
  * @since 2021-06-03
  */
 @RestController
-@RequestMapping("/builder/user")
+@RequestMapping("/bms/api/ubiapp")
 public class UserController {
+//    @Resource
+
 
+//    /**
+//     * 微信登录
+//     *
+//     * @param code 微信登录凭证
+//     * @return 用户openId
+//     */
+//    @PostMapping("login.do")
+//    public ServerResponse login(String code) {
+//        String openId = userService.getWxAppId(code);
+//        if (openId == null) return ServerResponse.createByError();
+//        //保存新用户
+//        if (userService.getByOpenId(openId) == null) {
+//            userService.save(new User(openId));
+//        }
+//        return ServerResponse.createBySuccess(AesUtils.encrypt(openId));
+//    }
 }

+ 9 - 6
src/main/java/com/zy/bms/entity/Group.java

@@ -9,9 +9,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
 /**
- * <p>
- * 项目组
- * </p>
+ * 设备组
  *
  * @author yangxiaokun
  * @since 2021-06-03
@@ -23,13 +21,18 @@ public class Group implements Serializable {
     private static final long serialVersionUID = 1L;
 
     /**
-     * 项目组编号
+     * 主键
      */
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     private String id;
 
     /**
-     * 项目组名称
+     * 设备组编号
+     */
+    private String code;
+
+    /**
+     * 设备组名称
      */
     private String name;
 

+ 12 - 2
src/main/java/com/zy/bms/pojo/vo/GroupListVo.java

@@ -5,7 +5,7 @@ import lombok.Data;
 import java.time.LocalDateTime;
 
 /**
- * 项目组列表视图
+ * 设备组列表视图
  *
  * @author yang xiao kun
  * create on 2021/5/19
@@ -13,10 +13,15 @@ import java.time.LocalDateTime;
 @Data
 public class GroupListVo {
 
+    /**
+     * 设备组主键ID
+     */
+    private Integer id;
+
     /**
      * 项目组编号
      */
-    private String id;
+    private String code;
 
     /**
      * 项目组名称
@@ -28,6 +33,11 @@ public class GroupListVo {
      */
     private String item;
 
+    /**
+     * 项目ID
+     */
+    private String itemId;
+
     /**
      * 备注
      */

+ 1 - 1
src/main/java/com/zy/bms/service/impl/UserPrivilegeServiceImpl.java

@@ -38,7 +38,7 @@ public class UserPrivilegeServiceImpl extends ServiceImpl<UserPrivilegeMapper, U
     public Map<String, List<GroupListVo>> getGroupByUserId(Integer userId) {
         List<GroupListVo> allGroup = groupService.getAllList();
         HashSet<String> ownGroup = new HashSet<>(baseMapper.ownGroupIds(userId));
-        return allGroup.stream().filter(item -> !ownGroup.contains(item.getId()))
+        return allGroup.stream().filter(item -> !ownGroup.contains(item.getCode()))
                 .collect(Collectors.groupingBy(GroupListVo::getItem));
     }
 

+ 9 - 4
src/main/resources/mapper/GroupMapper.xml

@@ -5,20 +5,25 @@
     <select id="listPage" resultType="com.zy.bms.pojo.vo.GroupListVo">
         SELECT
             t1.id,
+            t1.code,
             t1.name,
             t1.remark,
             t1.status,
             t1.create_time,
-            t2.name             AS item
+            t2.name             AS item,
+            t2.id               AS itemId
         FROM item_group t1
         LEFT JOIN item t2 ON t1.item_id = t2.id
         <where>
             <if test="io.name != null and io.name != ''">
-                AND ( t1.id LIKE CONCAT("%",#{io.name},"%")
+                AND ( t1.code LIKE CONCAT("%",#{io.name},"%")
                 OR t1.name LIKE CONCAT("%",#{io.name},"%") )
             </if>
+            <if test="io.itemId != null and io.itemId != ''">
+                AND t1.item_id = #{io.itemId}
+            </if>
             <if test="io.status != null and io.status > -1">
-                AND (t1.status = #{io.status}
+                AND t1.status = #{io.status}
             </if>
         </where>
         ORDER BY t1.create_time DESC
@@ -26,7 +31,7 @@
 
     <select id="getAllList" resultType="com.zy.bms.pojo.vo.GroupListVo">
         SELECT
-            t1.id,
+            t1.code,
             t1.name,
             t2.name AS item
         FROM item_group t1