From 918326632c8a617b06d5f903799f2b09d81edc8e Mon Sep 17 00:00:00 2001 From: Parker Date: Sun, 7 Feb 2021 19:34:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/cache/pushsub/enums/MsgArgsType.java | 5 +++ .../core/cache/pushsub/enums/PushSubType.java | 3 ++ .../pushsub/msgs/CacheDataMsgFactory.java | 2 +- .../cache/pushsub/msgs/MenuMsgFactory.java | 4 +- .../cache/pushsub/msgs/OrgMsgFactory.java | 2 +- .../java/org/opsli/core/utils/MenuUtil.java | 8 ++-- .../tpl/backend/model/TemplateModel.html | 1 - .../org/opsli/modulars/system/SystemMsg.java | 6 +++ .../system/area/mapper/SysAreaMapper.java | 7 +--- .../system/area/mapper/xml/SysAreaMapper.xml | 9 ----- .../area/service/impl/SysAreaServiceImpl.java | 32 +++++++++------ .../system/menu/mapper/MenuMapper.java | 7 ---- .../system/menu/mapper/xml/MenuMapper.xml | 40 ------------------- .../menu/service/impl/MenuServiceImpl.java | 34 +++++++++++++--- .../system/org/mapper/SysOrgMapper.java | 5 --- .../system/org/mapper/xml/SysOrgMapper.xml | 10 ----- .../org/service/impl/SysOrgServiceImpl.java | 27 ++++++------- .../system/role/mapper/RoleMapper.java | 6 --- .../system/role/mapper/xml/RoleMapper.xml | 28 ------------- .../role/service/impl/RoleServiceImpl.java | 29 +++++++------- .../system/tenant/mapper/TenantMapper.java | 6 --- .../system/tenant/mapper/xml/TenantMapper.xml | 14 ------- .../service/impl/TenantServiceImpl.java | 37 +++++++++++++++-- 23 files changed, 131 insertions(+), 191 deletions(-) diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/enums/MsgArgsType.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/enums/MsgArgsType.java index d71e50b..b4d7f38 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/enums/MsgArgsType.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/enums/MsgArgsType.java @@ -57,6 +57,11 @@ public enum MsgArgsType { /** 租户数据 */ TENANT_DATA, + /** 参数编号 */ + OPTION_CODE, + /** 参数数据*/ + OPTION_MODEL_DATA, + /** 缓存数据Key */ CACHE_DATA_KEY, /** 缓存数据Value */ diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/enums/PushSubType.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/enums/PushSubType.java index 208ce9b..a586734 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/enums/PushSubType.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/enums/PushSubType.java @@ -39,6 +39,9 @@ public enum PushSubType { /** 租户 */ TENANT, + /** 系统数据 */ + OPTION, + /** 热点数据 */ HOT_DATA, diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/msgs/CacheDataMsgFactory.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/msgs/CacheDataMsgFactory.java index 8ea86a6..1a9a206 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/msgs/CacheDataMsgFactory.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/msgs/CacheDataMsgFactory.java @@ -30,7 +30,7 @@ import org.opsli.plugins.redis.pushsub.entity.BaseSubMessage; * @BelongsPackage: org.opsli.core.cache.pushsub.msgs * @Author: Parker * @CreateTime: 2020-09-15 16:50 - * @Description: 字典消息 + * @Description: 热数据消息 */ @Data diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/msgs/MenuMsgFactory.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/msgs/MenuMsgFactory.java index 2503757..848a0f5 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/msgs/MenuMsgFactory.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/msgs/MenuMsgFactory.java @@ -29,7 +29,7 @@ import org.opsli.plugins.redis.pushsub.entity.BaseSubMessage; * @BelongsPackage: org.opsli.core.cache.pushsub.msgs * @Author: Parker * @CreateTime: 2020-09-15 16:50 - * @Description: 用户消息 + * @Description: 菜单消息 */ @Data @@ -51,7 +51,7 @@ public final class MenuMsgFactory extends BaseSubMessage{ jsonObj.put(MsgArgsType.MENU_CODE.toString(), menuModel.getMenuCode()); jsonObj.put(MsgArgsType.MENU_MODEL_DATA.toString(), menuModel); - // 用户 + // 菜单 baseSubMessage.build(CHANNEL,PushSubType.MENU.toString(),jsonObj); return baseSubMessage; } diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/msgs/OrgMsgFactory.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/msgs/OrgMsgFactory.java index a087312..54b7446 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/msgs/OrgMsgFactory.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/msgs/OrgMsgFactory.java @@ -52,7 +52,7 @@ public final class OrgMsgFactory extends BaseSubMessage{ jsonObj.put(MsgArgsType.ORG_USER_ID.toString(), orgRefModel.getUserId()); jsonObj.put(MsgArgsType.ORG_USER_DATA.toString(), orgRefModel); - // 用户 + // 组织 baseSubMessage.build(CHANNEL,PushSubType.ORG.toString(),jsonObj); return baseSubMessage; } diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/utils/MenuUtil.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/utils/MenuUtil.java index b7a90d5..f29604a 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/utils/MenuUtil.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/utils/MenuUtil.java @@ -56,7 +56,7 @@ public class MenuUtil { /** - * 根据 userName 获得用户 + * 根据 menuCode 获得菜单 * @param menuCode * @return */ @@ -118,7 +118,7 @@ public class MenuUtil { // ============== 刷新缓存 ============== /** - * 刷新用户 - 删就完了 + * 刷新菜单 - 删就完了 * @param menu * @return */ @@ -130,7 +130,7 @@ public class MenuUtil { // 计数器 int count = 0; - MenuModel menuModel = CacheUtil.getTimed(MenuModel.class, PREFIX_CODE + menu.getMenuCode()); + MenuModel model = CacheUtil.getTimed(MenuModel.class, PREFIX_CODE + menu.getMenuCode()); boolean hasNilFlag = CacheUtil.hasNilFlag(PREFIX_CODE + menu.getMenuCode()); // 只要不为空 则执行刷新 @@ -143,7 +143,7 @@ public class MenuUtil { } } - if(menuModel != null){ + if(model != null){ count++; // 先删除 boolean tmp = CacheUtil.del(PREFIX_CODE + menu.getMenuCode()); diff --git a/opsli-modulars/opsli-modulars-creater/src/main/resources/tpl/backend/model/TemplateModel.html b/opsli-modulars/opsli-modulars-creater/src/main/resources/tpl/backend/model/TemplateModel.html index b991515..e0e5914 100644 --- a/opsli-modulars/opsli-modulars-creater/src/main/resources/tpl/backend/model/TemplateModel.html +++ b/opsli-modulars/opsli-modulars-creater/src/main/resources/tpl/backend/model/TemplateModel.html @@ -58,7 +58,6 @@ public class #(data.model.tableName)Model extends ApiWrapper { #else @ExcelInfo #end - // 验证器 #if(column.validateType != null && column.validateType != "") @ValidationArgs({#(column.validateType)}) #end diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/SystemMsg.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/SystemMsg.java index bf4849b..d06b348 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/SystemMsg.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/SystemMsg.java @@ -46,6 +46,7 @@ public enum SystemMsg implements BaseMsg { EXCEPTION_ROLE_PERMS_ERROR(20202,"角色权限设置失败"), + /** * 用户 */ @@ -80,6 +81,11 @@ public enum SystemMsg implements BaseMsg { */ EXCEPTION_AREA_UNIQUE(20600,"地域编号重复,已存在"), + /** + * 系统参数 + */ + EXCEPTION_OPTIONS_UNIQUE(20700,"参数编号重复,该角色已存在"), + ; private final int code; diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/mapper/SysAreaMapper.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/mapper/SysAreaMapper.java index ffdc947..f42f9df 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/mapper/SysAreaMapper.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/mapper/SysAreaMapper.java @@ -34,15 +34,10 @@ import java.util.List; @Mapper public interface SysAreaMapper extends BaseMapper { - /** - * 唯一验证 - * @return - */ - Integer uniqueVerificationByCode(@Param("ew") Wrapper wrapper); /** * 是否有下级 - * @return + * @return List */ List hasChildren(@Param("ew") Wrapper wrapper); diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/mapper/xml/SysAreaMapper.xml b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/mapper/xml/SysAreaMapper.xml index 2c924d6..1c0e191 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/mapper/xml/SysAreaMapper.xml +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/mapper/xml/SysAreaMapper.xml @@ -2,15 +2,6 @@ - - select - count(0) - from - sys_menu a - where - a.menu_code = #{menuCode} - and a.deleted = 0 - - AND a.id != #{id} - - - diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/service/impl/MenuServiceImpl.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/service/impl/MenuServiceImpl.java index d963065..65a3cec 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/service/impl/MenuServiceImpl.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/service/impl/MenuServiceImpl.java @@ -19,6 +19,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.commons.lang3.StringUtils; +import org.opsli.api.wrapper.system.area.SysAreaModel; import org.opsli.api.wrapper.system.menu.MenuModel; import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.exception.ServiceException; @@ -30,6 +31,7 @@ import org.opsli.core.persistence.querybuilder.QueryBuilder; import org.opsli.core.utils.MenuUtil; import org.opsli.core.utils.UserUtil; import org.opsli.modulars.system.SystemMsg; +import org.opsli.modulars.system.area.entity.SysArea; import org.opsli.modulars.system.menu.entity.SysMenu; import org.opsli.modulars.system.menu.mapper.MenuMapper; import org.opsli.modulars.system.menu.service.IMenuService; @@ -75,9 +77,8 @@ public class MenuServiceImpl extends CrudServiceImpl 0){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_ROLE_UNIQUE); @@ -98,9 +99,8 @@ public class MenuServiceImpl extends CrudServiceImpl 0){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_ROLE_UNIQUE); @@ -123,7 +123,6 @@ public class MenuServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); + + // code 唯一 + wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, "0") + .eq("menu_code", model.getMenuCode()); + + // 重复校验排除自身 + if(StringUtils.isNotEmpty(model.getId())){ + wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId()); + } + + return super.count(wrapper); + } + /** * 逐级删除子数据 diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/org/mapper/SysOrgMapper.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/org/mapper/SysOrgMapper.java index bf80635..d1f39c7 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/org/mapper/SysOrgMapper.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/org/mapper/SysOrgMapper.java @@ -34,11 +34,6 @@ import java.util.List; @Mapper public interface SysOrgMapper extends BaseMapper { - /** - * 唯一验证 - * @return - */ - Integer uniqueVerificationByCode(@Param("ew") Wrapper wrapper); /** * 是否有下级 diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/org/mapper/xml/SysOrgMapper.xml b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/org/mapper/xml/SysOrgMapper.xml index 93f07d7..1eea036 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/org/mapper/xml/SysOrgMapper.xml +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/org/mapper/xml/SysOrgMapper.xml @@ -2,16 +2,6 @@ - - - select - count(0) - from - sys_role - - ${ew.sqlSegment} - - diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/role/service/impl/RoleServiceImpl.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/role/service/impl/RoleServiceImpl.java index bf6cfa0..6d9802d 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/role/service/impl/RoleServiceImpl.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/role/service/impl/RoleServiceImpl.java @@ -51,9 +51,8 @@ public class RoleServiceImpl extends CrudServiceImpl 0){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_ROLE_UNIQUE); @@ -69,9 +68,8 @@ public class RoleServiceImpl extends CrudServiceImpl 0){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_ROLE_UNIQUE); @@ -80,31 +78,34 @@ public class RoleServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); // code 唯一 - wrapper.eq("role_code", entity.getRoleCode()) - .eq(MyBatisConstants.FIELD_DELETE_LOGIC, "0"); + wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, "0") + .eq("role_code", model.getRoleCode()); - // 如果为修改 则跳过当前数据 - if(StringUtils.isNotBlank(entity.getId())){ - wrapper.notIn(MyBatisConstants.FIELD_ID, entity.getId()); + // 重复校验排除自身 + if(StringUtils.isNotEmpty(model.getId())){ + wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId()); } // 租户检测 wrapper = new TenantHandler().handler(super.entityClazz, wrapper); - return mapper.uniqueVerificationByCode(wrapper); + return super.count(wrapper); } + } diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/mapper/TenantMapper.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/mapper/TenantMapper.java index ee8076b..4e41fb4 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/mapper/TenantMapper.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/mapper/TenantMapper.java @@ -31,11 +31,5 @@ import org.opsli.modulars.system.tenant.entity.SysTenant; @Mapper public interface TenantMapper extends BaseMapper { - /** - * 唯一验证 - * @param entity - * @return - */ - Integer uniqueVerificationByName(SysTenant entity); } diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/mapper/xml/TenantMapper.xml b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/mapper/xml/TenantMapper.xml index 88048ce..472b281 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/mapper/xml/TenantMapper.xml +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/mapper/xml/TenantMapper.xml @@ -3,18 +3,4 @@ - - diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/service/impl/TenantServiceImpl.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/service/impl/TenantServiceImpl.java index c0e8c32..a80fe15 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/service/impl/TenantServiceImpl.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/service/impl/TenantServiceImpl.java @@ -17,13 +17,18 @@ package org.opsli.modulars.system.tenant.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.google.common.collect.Lists; +import org.apache.commons.lang3.StringUtils; +import org.opsli.api.wrapper.system.menu.MenuModel; import org.opsli.api.wrapper.system.tenant.TenantModel; +import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.exception.ServiceException; import org.opsli.core.base.service.impl.CrudServiceImpl; import org.opsli.core.msg.CoreMsg; import org.opsli.core.utils.TenantUtil; import org.opsli.modulars.system.SystemMsg; +import org.opsli.modulars.system.menu.entity.SysMenu; import org.opsli.modulars.system.tenant.entity.SysTenant; import org.opsli.modulars.system.tenant.mapper.TenantMapper; import org.opsli.modulars.system.tenant.service.ITenantService; @@ -56,9 +61,8 @@ public class TenantServiceImpl extends CrudServiceImpl 0){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_TENANT_UNIQUE); @@ -74,9 +78,8 @@ public class TenantServiceImpl extends CrudServiceImpl 0){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_TENANT_UNIQUE); @@ -177,8 +180,34 @@ public class TenantServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); + + // name 唯一 + wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, "0") + .eq("tenant_name", model.getTenantName()); + + // 重复校验排除自身 + if(StringUtils.isNotEmpty(model.getId())){ + wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId()); + } + + return super.count(wrapper); + } + // ============ + /** * 清除缓存 * @param tenantIds