FengChaoYu 4 tygodni temu
rodzic
commit
553f653724

+ 5 - 23
pom.xml

@@ -92,11 +92,11 @@
             <version>1.18.8</version>
             <scope>provided</scope>
         </dependency>
-        <dependency>
-            <groupId>org.mybatis.spring.boot</groupId>
-            <artifactId>mybatis-spring-boot-autoconfigure</artifactId>
-            <version>2.1.0</version>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>org.mybatis.spring.boot</groupId>-->
+<!--            <artifactId>mybatis-spring-boot-autoconfigure</artifactId>-->
+<!--            <version>2.1.0</version>-->
+<!--        </dependency>-->
 
 
         <dependency>
@@ -379,12 +379,6 @@
             <version>0.0.3</version>
         </dependency>
 
-        <!--企业微信api-->
-        <dependency>
-            <groupId>com.github.binarywang</groupId>
-            <artifactId>weixin-java-cp</artifactId>
-            <version>4.1.0</version>
-        </dependency>
         <!-- 微信支付 -->
         <dependency>
             <groupId>com.github.binarywang</groupId>
@@ -410,18 +404,6 @@
             <version>1.5.19</version>
         </dependency>
 
-        <!--企业微信会话存档-->
-        <dependency>
-            <groupId>org.bouncycastle</groupId>
-            <artifactId>bcpg-jdk16</artifactId>
-            <version>1.46</version>
-        </dependency>
-        <dependency>
-            <groupId>org.bouncycastle</groupId>
-            <artifactId>bcpkix-jdk15on</artifactId>
-            <version>1.64</version>
-        </dependency>
-
         <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>easyexcel</artifactId>

+ 0 - 4
src/main/java/com/gree/mall/manager/config/wx/WxConfiguration.java

@@ -11,7 +11,6 @@ import com.google.common.collect.Maps;
 import com.gree.mall.manager.plus.entity.AdminCompanyWechat;
 import com.gree.mall.manager.plus.service.AdminCompanyWechatService;
 import com.gree.mall.manager.utils.RedisUtil;
-import me.chanjar.weixin.cp.api.WxCpService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Configuration;
@@ -23,8 +22,6 @@ import java.util.Map;
 @Configuration
 public class WxConfiguration {
 
-    //企业微信  key=agentId
-    public static Map<String, Map<Integer, WxCpService>> cpServices = Maps.newConcurrentMap();
     //微信小程序API key = companyWechatId
     public static Map<String, WxMaService> wxMaService = Maps.newConcurrentMap();
     //微信支付服务 key = companyWechatId
@@ -51,7 +48,6 @@ public class WxConfiguration {
 
     public static void reloadWxConfig(List<AdminCompanyWechat> list, RedisUtil redisUtil, String keyPath, String notifyUrl) {
 
-        cpServices.clear();
         wxMaService.clear();
         wxPayServices.clear();
 

+ 0 - 61
src/main/java/com/gree/mall/manager/config/wx/WxCpLettuceRedisConfig.java

@@ -1,61 +0,0 @@
-package com.gree.mall.manager.config.wx;
-
-
-import com.gree.mall.manager.constant.Constant;
-import com.gree.mall.manager.utils.RedisUtil;
-import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
-import org.apache.commons.lang3.ObjectUtils;
-
-
-public class WxCpLettuceRedisConfig extends WxCpDefaultConfigImpl {
-    private RedisUtil redisUtil;
-    private String accessTokenKey;
-
-    public WxCpLettuceRedisConfig(RedisUtil redisUtil){
-        this.redisUtil = redisUtil;
-    }
-
-
-    @Override
-    public void setAgentId(Integer agentId){
-        super.setAgentId(agentId);
-        this.accessTokenKey = Constant.RedisPrefix.WORK_MINI_ACCESS_TOKEN+":"+agentId;
-    }
-
-    @Override
-    public String getAccessToken() {
-        return redisUtil.get(accessTokenKey).toString();
-    }
-
-    @Override
-    public boolean isAccessTokenExpired() {
-        Long expireTime = redisUtil.getExpire(accessTokenKey);
-        if (ObjectUtils.isEmpty(expireTime)) {
-            return true;
-        }
-        // 到期时间小于100秒就算作过期了,就重新调用接口获取
-        return expireTime < 100;
-    }
-
-    @Override
-    public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) {
-        redisUtil.set(accessTokenKey, accessToken, expiresInSeconds - 200);
-    }
-
-    @Override
-    public void expireAccessToken() {
-        redisUtil.expire(accessTokenKey, 0);
-    }
-
-
-    @Override
-    public long getExpiresTime() {
-        Long expire = redisUtil.getExpire(accessTokenKey);
-        return expire == null ? 0 : expire;
-    }
-
-    @Override
-    public void setExpiresTime(long expiresTime) {
-        redisUtil.expire(accessTokenKey, expiresTime);
-    }
-}

+ 0 - 1
src/main/java/com/gree/mall/manager/config/wx/WxMaLettuceRedisConfig.java

@@ -4,7 +4,6 @@ package com.gree.mall.manager.config.wx;
 import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
 import com.gree.mall.manager.constant.Constant;
 import com.gree.mall.manager.utils.RedisUtil;
-import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
 import org.apache.commons.lang3.ObjectUtils;
 
 /**

+ 1 - 1
src/main/java/com/gree/mall/manager/enums/StatusEnum.java

@@ -15,8 +15,8 @@ public enum StatusEnum implements BaseEnum, IEnum<Boolean> {
     TWO("false", "禁用"),
     ;
 
-    @EnumValue
     @JsonValue
+    @EnumValue
     private final String key;
     private final String remark;
 

+ 45 - 11
src/main/java/com/gree/mall/manager/logic/admin/AdminUserLogic.java

@@ -6,11 +6,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-
 import com.google.code.kaptcha.impl.DefaultKaptcha;
 import com.gree.mall.manager.bean.ExcelData;
 import com.gree.mall.manager.bean.SVerification;
-import com.gree.mall.manager.bean.admin.*;
+import com.gree.mall.manager.bean.admin.AdminModuleTree;
+import com.gree.mall.manager.bean.admin.AdminUserCom;
+import com.gree.mall.manager.bean.admin.AdminWebsitGrantBean;
+import com.gree.mall.manager.bean.admin.ExternalMapBean;
 import com.gree.mall.manager.bean.admin.reqDto.AdminUserAddReqBean;
 import com.gree.mall.manager.bean.admin.reqDto.AdminUserPermissions;
 import com.gree.mall.manager.commonmapper.AdminMapper;
@@ -176,7 +178,10 @@ public class AdminUserLogic {
             isAdd = false;
         }
 
-        AdminUserCom admin = commonLogic.getAdminUser(request);
+        AdminUserCom curLoginAmin = commonLogic.getAdminUser(request);
+
+        // 检查账号参数
+        this.checkCreateAdminUserParams(adminUser, curLoginAmin, isAdd);
 
         if (StringUtils.isEmpty(adminUser.getUserName())
                 || (isAdd && StringUtils.isEmpty(adminUser.getPassword()))) {
@@ -195,14 +200,6 @@ public class AdminUserLogic {
             adminUser.setAdminUserId(IdWorker.getIdStr());
         }
 
-        // 需要用户roleId
-        AdminRole addUserRole;
-        if (StringUtils.isEmpty(adminUser.getRoleId()) ||
-                (addUserRole = adminRoleService.getById(adminUser.getRoleId())) == null) {
-            throw new RemoteServiceException("请为用户选择角色");
-        }
-        adminUser.setRoleName(addUserRole.getName());
-
         // 数据权限
         this.dataPermissionsHandle(adminUser, adminUser.getPermissions());
 
@@ -213,6 +210,43 @@ public class AdminUserLogic {
         adminUserService.saveOrUpdate(adminUser);
     }
 
+    private void checkCreateAdminUserParams(AdminUserAddReqBean adminUser, AdminUserCom curLoginAmin, boolean isAdd) {
+        // 检查账号类型
+        if (curLoginAmin.getType() == 2 || curLoginAmin.getType() == 4) {
+            // 如果创建人账号是商家, 所建账号为“商家类型”
+            if (isAdd) {
+                // 新增账号设值4=商家
+                adminUser.setType(4);
+            }
+        } else if (curLoginAmin.getType() == 1 || curLoginAmin.getType() == 3) {
+            // 如果创建人账号是商户, 所建账号为“商户类型”或“商家类型”
+            if (adminUser.getType() == 0) {
+                // 创建人账号不能选择平台
+                throw new RemoteServiceException("创建者不能选择账号类型为“平台账号”");
+            }
+        }
+        // 检查角色
+        AdminRole addUserRole;
+        if (StringUtils.isEmpty(adminUser.getRoleId()) ||
+                (addUserRole = adminRoleService.getById(adminUser.getRoleId())) == null) {
+            throw new RemoteServiceException("请为用户选择角色");
+        }
+        int requireSelectRoleType;
+        if (adminUser.getType() == 2 || adminUser.getType() == 4) {
+            requireSelectRoleType = 2;
+        } else if (adminUser.getType() == 1 || adminUser.getType() == 3) {
+            requireSelectRoleType = 1;
+        } else {
+            requireSelectRoleType = 0;
+        }
+
+        if (requireSelectRoleType != addUserRole.getType()) {
+            throw new RemoteServiceException("账号类型与角色类型不匹配");
+        }
+
+        adminUser.setRoleName(addUserRole.getName());
+    }
+
     private void dataPermissionsHandle(AdminUserAddReqBean adminUser, List<AdminUserPermissions> permissions) {
         if (CollectionUtil.isEmpty(permissions)) {
             throw new RemoteServiceException("请选择至少1个数据权限");

+ 0 - 4
src/main/resources/bootstrap-dev.properties

@@ -69,10 +69,6 @@ server.undertow.max-http-post-size=10240000
 #swagger-login-account
 #spring.security.user.name=admin
 #spring.security.user.password=gree2021
-#mybatis-plus配置
-mybatis-plus.mapper-locations=classpath*:/mapper/**Mapper.xml
-#主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
-mybatis-plus.global-config.db-config.id-type=id_worker_str
 #jackson组件时区
 spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
 spring.jackson.time-zone=GMT+8

+ 0 - 4
src/main/resources/bootstrap-prd.properties

@@ -67,10 +67,6 @@ server.undertow.max-http-post-size=10240000
 #swagger-login-account
 #spring.security.user.name=admin
 #spring.security.user.password=gree2021
-#mybatis-plus配置
-mybatis-plus.mapper-locations=classpath*:/mapper/**Mapper.xml
-#主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
-mybatis-plus.global-config.db-config.id-type=id_worker_str
 #jackson组件时区
 spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
 spring.jackson.time-zone=GMT+8

+ 0 - 4
src/main/resources/bootstrap-test.properties

@@ -69,10 +69,6 @@ server.undertow.max-http-post-size=10240000
 #swagger-login-account
 #spring.security.user.name=admin
 #spring.security.user.password=gree2021
-#mybatis-plus配置
-mybatis-plus.mapper-locations=classpath*:/mapper/**Mapper.xml
-#主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
-mybatis-plus.global-config.db-config.id-type=id_worker_str
 #jackson组件时区
 spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
 spring.jackson.time-zone=GMT+8

+ 8 - 0
src/main/resources/bootstrap.properties

@@ -10,3 +10,11 @@ goods.share.limit.percent=0.4
 server.servlet.context-path=/mallApi
 
 machine.generator.short.id=0
+
+
+
+#mybatis-plus配置
+mybatis-plus.typeEnumsPackage=com.gree.mall.manager.enums
+mybatis-plus.mapper-locations=classpath*:/mapper/**Mapper.xml
+#主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
+mybatis-plus.global-config.db-config.id-type=id_worker_str