Browse Source

Merge remote-tracking branch 'origin/test' into test

Ritchie 1 year ago
parent
commit
6f54adaad9

+ 19 - 2
src/main/java/com/szwl/controller/TEquipmentController.java

@@ -30,6 +30,7 @@ import com.szwl.model.param.PasswordParam;
 import com.szwl.model.query.StatisticsParam;
 import com.szwl.model.utils.DateUtils;
 import com.szwl.model.utils.PushUtils;
+import com.szwl.model.vo.EquipmentVO;
 import com.szwl.service.*;
 import com.szwl.util.DownloadUtils;
 import io.swagger.annotations.Api;
@@ -428,7 +429,15 @@ public class TEquipmentController {
         }
 //        query.eq(TEquipment::getAdminId,adminId);
         List<TEquipment> list = tEquipmentService.list(query);
-        return R.ok(list);
+        List<EquipmentVO> equipmentVOS = new ArrayList<>();
+        for (TEquipment equipment : list) {
+            EquipmentVO equipmentVO = new EquipmentVO();
+            equipmentVO.setId(equipment.getId());
+            equipmentVO.setName(equipment.getName());
+            equipmentVO.setClientId(equipment.getClientId());
+            equipmentVOS.add(equipmentVO);
+        }
+        return R.ok(equipmentVOS);
     }
 
     @ApiOperation(value = "查找设备")
@@ -473,7 +482,15 @@ public class TEquipmentController {
         if (StringUtils.isNotEmpty(equipment.getSn())) {
             oldEquipment.setSn(equipment.getSn());
         }
-        if (StringUtils.isNotEmpty(equipment.getName())) {
+        String name = equipment.getName();
+        if (StringUtils.isNotEmpty(name) && !name.equals(oldEquipment.getName())) {
+            LambdaQueryWrapper<TEquipment> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(TEquipment::getAdminId, oldEquipment.getAdminId());
+            queryWrapper.eq(TEquipment::getName, name);
+            TEquipment tEquipment = tEquipmentService.getOne(queryWrapper);
+            if (tEquipment != null) {
+                return R.fail(A0001);
+            }
             oldEquipment.setName(equipment.getName());
         }
         if (StringUtils.isNotEmpty(equipment.getSelfName())) {

+ 12 - 29
src/main/java/com/szwl/controller/TLogoController.java

@@ -19,11 +19,7 @@ import com.szwl.service.TEquipmentService;
 import com.szwl.service.TLogoService;
 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 org.springframework.web.bind.annotation.*;
 
 import javax.jws.Oneway;
 import java.io.IOException;
@@ -55,30 +51,17 @@ public class TLogoController {
     @Autowired
     TLogoService tLogoService;
 
-//    @ApiOperation(value = "定制logo")
-//    @PostMapping("/customLogo")
-//    public ResponseModel<?> customLogo(@RequestBody TEquipment equipment) {
-//
-//        // 根据id找到当前设备
-//        TEquipment tEquipment = tEquipmentService.getById(equipment.getId());
-//        if (tEquipment == null) {
-//            return R.fail("设备为空");
-//        }
-//        // 当前设备的用户id
-//        Long adminId = tEquipment.getAdminId();
-//        // 根据用户id查看用户类型
-//        Integer userType = tAdminService.getById(adminId).getType();
-//        // 仅管理员可修改logo
-//        if (userType != null && (userType == 0 || userType == 1)) {
-//            // 获取当前logo信息
-//            TLogo tLogo = tLogoService.getById(adminId);
-//            System.out.println(tLogo);
-//            // 修改logo
-//            tLogoService.updateById(tLogo);
-//            return R.ok(null,"logo已修改");
-//        }
-//        return R.fail(P0001,"仅管理员可修改logo");
-//    }
+    @ApiOperation(value = "定制logo")
+    @GetMapping("/newCustomLogo")
+    public ResponseModel<?> customLogo(Long id, String logoNumber) {
+        // 根据id找到当前设备
+        TEquipment equipment = tEquipmentService.getById(id);
+        if (equipment == null) {
+            return R.fail("设备为空");
+        }
+        tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("customLogo", logoNumber).toString());
+        return R.ok();
+    }
 
 
     @ApiOperation(value = "定制logo")

+ 18 - 0
src/main/java/com/szwl/model/vo/EquipmentVO.java

@@ -0,0 +1,18 @@
+package com.szwl.model.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class EquipmentVO {
+
+    @ApiModelProperty(value = "设备唯一ID")
+    private Long id;
+
+    @ApiModelProperty(value = "设备编号")
+    private String clientId;
+
+    @ApiModelProperty(value = "机器名称")
+    private String name;
+
+}

+ 5 - 7
src/main/java/com/szwl/service/impl/SysRoleServiceImpl.java

@@ -59,9 +59,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
         return menuList_final;
     }
 
-    public void checkRoleName(String roleName){
+    public void checkRoleName(String roleName, Long adminId){
         LambdaQueryWrapper<SysRole> query = Wrappers.lambdaQuery();
         query.eq(SysRole::getRoleName, roleName);
+        query.eq(SysRole::getAdminId, adminId);
         int count = this.count(query);
         if(count>0){
             throw new BizException(ResponseCodesEnum.B0002,"角色名称已存在");
@@ -69,9 +70,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
     }
 
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public void addSysRole(AddSysRoleParam param){
-        this.checkRoleName(param.getRoleName());
+        this.checkRoleName(param.getRoleName(), param.getAdminId());
         SysRole sysRole = new SysRole()
                 .setRoleName(param.getRoleName())
                 .setAdminId(param.getAdminId())
@@ -80,13 +81,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
         save(sysRole);
     }
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public void updateSysRole(UpdateSysRoleParam param){
         SysRole sysRole = Optional.ofNullable(this.getById(param.getRoleId()))
                 .orElseThrow(() ->new BizException(ResponseCodesEnum.B0005,"无法根据id:"+param.getRoleId()+" 找到角色配置"));
-//        if(StrUtil.equals(param.getRoleName(),sysRole.getRoleName())){
-//            this.checkRoleName(param.getRoleName());
-//        }
         BeanUtil.copyProperties(param,sysRole);
         sysRole.setMenuCodesJson(JSON.toJSONString(param.getMenuCodeList()));
         updateById(sysRole);