浏览代码

Merge remote-tracking branch 'origin/V1.0.11' into V1.0.11

humingshi-7@163.com 11 月之前
父节点
当前提交
209d1711da

+ 1 - 1
soc-modules/soc-modules-iot/src/main/resources/mapper/DvrDiskMapper.xml

@@ -106,7 +106,7 @@
         iot_device_info d
         inner  join sys_org o on d.org_id =o.id and o.deleted=0 and o.is_lock='0'
         left join iot_device_info_extend ie on d.id =ie.device_id
-        WHERE d.device_type=1 and d.deleted=0
+        WHERE d.device_type=1 and d.deleted=0 and d.enable=0
 
         <if test="pageDto.checkSub==true">
             and d.org_path like concat(#{orgPath},"%")

+ 10 - 2
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysMultiLayerDictionaryController.java

@@ -83,6 +83,10 @@ public class SysMultiLayerDictionaryController {
             dict.setLevel(1);
             dict.setPath(id + "-");
         }
+        final boolean repeat = sysMultiLayerDictionaryService.checkRepeat(dict.getName(), dict.getType(), null);
+        if (!repeat) {
+            return AjaxResult.error("字典名称重复");
+        }
         return AjaxResult.success(sysMultiLayerDictionaryService.save(dict));
     }
 
@@ -95,6 +99,10 @@ public class SysMultiLayerDictionaryController {
     public AjaxResult edit(@Validated @RequestBody SysMultiLayerDictionary dict) {
         dict.setModifiedName(SecurityUtils.getUsername());
         dict.setUpdateTime(LocalDateTime.now());
+        final boolean repeat = sysMultiLayerDictionaryService.checkRepeat(dict.getName(), dict.getType(), dict.getId());
+        if (!repeat) {
+            return AjaxResult.error("字典名称重复");
+        }
         return AjaxResult.success(sysMultiLayerDictionaryService.updateById(dict));
     }
 
@@ -105,7 +113,7 @@ public class SysMultiLayerDictionaryController {
 //    @Log(title = "字典类型", businessType = BusinessType.DELETE)
     @GetMapping("/{id}")
     public AjaxResult getById(@PathVariable Long id) {
-        return AjaxResult.success( sysMultiLayerDictionaryService.getById(id));
+        return AjaxResult.success(sysMultiLayerDictionaryService.getById(id));
     }
 
     /**
@@ -143,7 +151,7 @@ public class SysMultiLayerDictionaryController {
     @ApiOperation("根据type获取字典")
     @GetMapping("/list/{type}")
     private AjaxResult getDictTableList(@PathVariable("type") String type) {
-         return AjaxResult.success(sysMultiLayerDictionaryService.selectListByType(type));
+        return AjaxResult.success(sysMultiLayerDictionaryService.selectListByType(type));
     }
 }
 

+ 2 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysMultiLayerDictionaryService.java

@@ -29,4 +29,6 @@ public interface ISysMultiLayerDictionaryService extends IService<SysMultiLayerD
     TableDataInfo<SysMultiLayerDictionary> selectTableList(SysMultiLayerDictionaryDto para);
 
     List<Pair<Long,String>> selectListByType(String type);
+
+    boolean checkRepeat(String name,String type,Long id);
 }

+ 19 - 12
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysMultiLayerDictionaryServiceImpl.java

@@ -1,6 +1,7 @@
 package com.xunmei.system.service.impl;
 
 import cn.hutool.core.lang.Pair;
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -72,31 +73,26 @@ public class SysMultiLayerDictionaryServiceImpl extends ServiceImpl<SysMultiLaye
     public TableDataInfo<SysMultiLayerDictionary> selectTableList(SysMultiLayerDictionaryDto para) {
         LambdaQueryWrapper<SysMultiLayerDictionary> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(SysMultiLayerDictionary::getDeleted, 0);
-        if(para.getParentId()==-1 && StringUtils.isNotEmpty(para.getType()))
-        {
+        if (para.getParentId() == -1 && StringUtils.isNotEmpty(para.getType())) {
             wrapper.eq(SysMultiLayerDictionary::getType, para.getType());
         }
-        if(StringUtils.isNotEmpty(para.getPath()))
-        {
+        if (StringUtils.isNotEmpty(para.getPath())) {
             wrapper.likeRight(SysMultiLayerDictionary::getPath, para.getPath());
         }
-        if(StringUtils.isEmpty(para.getPath()) && StringUtils.isEmpty(para.getType()) && para.getParentId()!=-1 )
-        {
+        if (StringUtils.isEmpty(para.getPath()) && StringUtils.isEmpty(para.getType()) && para.getParentId() != -1) {
             wrapper.eq(SysMultiLayerDictionary::getParentId, para.getParentId());
         }
 
-        if(StringUtils.isNotEmpty(para.getName()))
-        {
+        if (StringUtils.isNotEmpty(para.getName())) {
             wrapper.like(SysMultiLayerDictionary::getName, para.getName());
         }
-        if(StringUtils.isNotEmpty(para.getStatus()))
-        {
+        if (StringUtils.isNotEmpty(para.getStatus())) {
             wrapper.eq(SysMultiLayerDictionary::getStatus, para.getStatus());
         }
         Page<SysMultiLayerDictionary> page;
-        if (para.getPageNum() != null &&para.getPageSize() != null){
+        if (para.getPageNum() != null && para.getPageSize() != null) {
             page = new Page<>(para.getPageNum(), para.getPageSize());
-        }else{
+        } else {
             page = new Page<>();
         }
 
@@ -113,4 +109,15 @@ public class SysMultiLayerDictionaryServiceImpl extends ServiceImpl<SysMultiLaye
         final List<SysMultiLayerDictionary> dictionaryList = baseMapper.selectList(wrapper);
         return dictionaryList.stream().map(item -> Pair.of(item.getId(), item.getName())).collect(Collectors.toList());
     }
+
+    @Override
+    public boolean checkRepeat(String name, String type, Long id) {
+        final LambdaQueryWrapper<SysMultiLayerDictionary> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(SysMultiLayerDictionary::getDeleted, 0);
+        wrapper.eq(SysMultiLayerDictionary::getName, name);
+        wrapper.eq(SysMultiLayerDictionary::getType, type);
+        wrapper.ne(ObjectUtil.isNotNull(id), SysMultiLayerDictionary::getId, id);
+        final Long count = baseMapper.selectCount(wrapper);
+        return count != null && count < 1;
+    }
 }