Explorar el Código

Merge branch 'cpq-dev' of wangfan/adweb3-server into master

chenpeiqing hace 1 mes
padre
commit
e99c1956e7
Se han modificado 34 ficheros con 3485 adiciones y 2466 borrados
  1. 482 606
      jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java
  2. 58 58
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/constant/AdwebConstant.java
  3. 29 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/dto/CommonDto.java
  4. 8 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/mapper/CommonMapper.java
  5. 13 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/mapper/xml/CommonMapper.xml
  6. 48 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/util/MD5Util.java
  7. 75 68
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/AdwebEnquiryMapper.java
  8. 17 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/xml/AdwebEnquiryMapper.xml
  9. 9 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/IAdwebEnquiryService.java
  10. 37 26
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/impl/AdwebEnquiryServiceImpl.java
  11. 38 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/controller/EnterpriseRoleManageController.java
  12. 645 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/controller/EnterpriseUserManageController.java
  13. 34 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/dto/CreateUserParam.java
  14. 11 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/dto/EditPermissionParam.java
  15. 43 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/entity/AdwebSysUserPermission.java
  16. 6 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/mapper/AdwebSysUserPermissionMapper.java
  17. 24 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/service/SysUserPermissionService.java
  18. 96 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/service/impl/SysUserPermissionServiceImpl.java
  19. 35 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/vo/User.java
  20. 6 9
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/ISiteUserPermissionService.java
  21. 232 231
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/impl/AdwebSiteServiceImpl.java
  22. 153 146
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/impl/SiteUserPermissionServiceImpl.java
  23. 459 470
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/userCountry/controller/AdwebUserCountryController.java
  24. 39 37
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/userCountry/entity/AdwebCountry.java
  25. 2 7
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/userCountry/mapper/AdwebCountryMapper.java
  26. 40 42
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/userCountry/mapper/xml/AdwebUserCountryMapper.xml
  27. 2 7
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/userCountry/service/IAdwebCountryService.java
  28. 2 5
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/userCountry/service/impl/AdwebCountryServiceImpl.java
  29. 7 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysUserMapper.java
  30. 297 274
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml
  31. 56 52
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysRoleService.java
  32. 457 413
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysUserService.java
  33. 17 4
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysRoleServiceImpl.java
  34. 8 4
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java

+ 482 - 606
jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java

@@ -2,619 +2,495 @@ package org.jeecg.common.constant;
 
 /**
  * @Description: 通用常量
+ *
  * @author: jeecg-boot
  */
 public interface CommonConstant {
 
-	/**
-	 * 正常状态
-	 */
-	Integer STATUS_NORMAL = 0;
-
-	/**
-	 * 禁用状态
-	 */
-	Integer STATUS_DISABLE = -1;
-
-	/**
-	 * 删除标志
-	 */
-	Integer DEL_FLAG_1 = 1;
-
-	/**
-	 * 未删除
-	 */
-	Integer DEL_FLAG_0 = 0;
-
-	/**
-	 * 系统日志类型: 登录
-	 */
-	int LOG_TYPE_1 = 1;
-	
-	/**
-	 * 系统日志类型: 操作
-	 */
-	int LOG_TYPE_2 = 2;
-
-    /**
-     * 系统日志类型: 租户操作日志
-     */
-    int LOG_TYPE_3 = 3;
-
-    /**
-     * 系统日志类型: 异常
-     */
-    int LOG_TYPE_4 = 4;
-
-	/**
-	 * 操作日志类型: 查询
-	 */
-	int OPERATE_TYPE_1 = 1;
-	
-	/**
-	 * 操作日志类型: 添加
-	 */
-	int OPERATE_TYPE_2 = 2;
-	
-	/**
-	 * 操作日志类型: 更新
-	 */
-	int OPERATE_TYPE_3 = 3;
-	
-	/**
-	 * 操作日志类型: 删除
-	 */
-	int OPERATE_TYPE_4 = 4;
-	
-	/**
-	 * 操作日志类型: 倒入
-	 */
-	int OPERATE_TYPE_5 = 5;
-	
-	/**
-	 * 操作日志类型: 导出
-	 */
-	int OPERATE_TYPE_6 = 6;
-	
-	
-	/** {@code 500 Server Error} (HTTP/1.0 - RFC 1945) */
-    Integer SC_INTERNAL_SERVER_ERROR_500 = 500;
-    /** {@code 404 Not Found} (HTTP/1.0 - RFC 1945) */
-    Integer SC_INTERNAL_NOT_FOUND_404 = 404;
-    /** {@code 200 OK} (HTTP/1.0 - RFC 1945) */
-    Integer SC_OK_200 = 200;
-    
-    /**访问权限认证未通过 510*/
-    Integer SC_JEECG_NO_AUTHZ=510;
-
-    /** 登录用户Shiro权限缓存KEY前缀 */
-    public static String PREFIX_USER_SHIRO_CACHE  = "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:";
-    /** 登录用户Token令牌缓存KEY前缀 */
-    String PREFIX_USER_TOKEN  = "token::jeecg-client::";
-//    /** Token缓存时间:3600秒即一小时 */
-//    int  TOKEN_EXPIRE_TIME  = 3600;
-
-    /** 登录二维码 */
-    String  LOGIN_QRCODE_PRE  = "QRCODELOGIN:";
-    String  LOGIN_QRCODE  = "LQ:";
-    /** 登录二维码token */
-    String  LOGIN_QRCODE_TOKEN  = "LQT:";
-
-
-    /**
-     *  0:一级菜单
-     */
-    Integer MENU_TYPE_0  = 0;
-   /**
-    *  1:子菜单 
-    */
-    Integer MENU_TYPE_1  = 1;
-    /**
-     *  2:按钮权限
-     */
-    Integer MENU_TYPE_2  = 2;
-
-    /**通告对象类型(USER:指定用户,ALL:全体用户)*/
-    String MSG_TYPE_UESR  = "USER";
-    String MSG_TYPE_ALL  = "ALL";
-    
-    /**发布状态(0未发布,1已发布,2已撤销)*/
-    String NO_SEND  = "0";
-    String HAS_SEND  = "1";
-    String HAS_CANCLE  = "2";
-    
-    /**阅读状态(0未读,1已读)*/
-    Integer HAS_READ_FLAG  = 1;
-    Integer NO_READ_FLAG  = 0;
-    
-    /**优先级(L低,M中,H高)*/
-    String PRIORITY_L  = "L";
-    String PRIORITY_M  = "M";
-    String PRIORITY_H  = "H";
-    
-    /**
-     * 短信模板方式  0 .登录模板、1.注册模板、2.忘记密码模板
-     */
-    String SMS_TPL_TYPE_0  = "0";
-    String SMS_TPL_TYPE_1  = "1";
-    String SMS_TPL_TYPE_2  = "2";
-    
-    /**
-     * 状态(0无效1有效)
-     */
-    String STATUS_0 = "0";
-    String STATUS_1 = "1";
-    
-    /**
-     * 同步工作流引擎1同步0不同步
-     */
-    Integer ACT_SYNC_1 = 1;
-    Integer ACT_SYNC_0 = 0;
-
-    /**
-     * 消息类型1:通知公告2:系统消息
-     */
-    String MSG_CATEGORY_1 = "1";
-    String MSG_CATEGORY_2 = "2";
-    
-    /**
-     * 是否配置菜单的数据权限 1是0否
-     */
-    Integer RULE_FLAG_0 = 0;
-    Integer RULE_FLAG_1 = 1;
-
-    /**
-     * 是否用户已被冻结 1正常(解冻) 2冻结 3离职
-     */
-    Integer USER_UNFREEZE = 1;
-    Integer USER_FREEZE = 2;
-    Integer USER_QUIT = 3;
-    
-    /**字典翻译文本后缀*/
-    String DICT_TEXT_SUFFIX = "_dictText";
-    /**字典翻译颜色后缀*/
-    String DICT_COLOR_SUFFIX = "_dictColor";
-
-    /**
-     * 表单设计器主表类型
-     */
-    Integer DESIGN_FORM_TYPE_MAIN = 1;
-
-    /**
-     * 表单设计器子表表类型
-     */
-    Integer DESIGN_FORM_TYPE_SUB = 2;
-
-    /**
-     * 表单设计器URL授权通过
-     */
-    Integer DESIGN_FORM_URL_STATUS_PASSED = 1;
-
-    /**
-     * 表单设计器URL授权未通过
-     */
-    Integer DESIGN_FORM_URL_STATUS_NOT_PASSED = 2;
-
-    /**
-     * 表单设计器新增 Flag
-     */
-    String DESIGN_FORM_URL_TYPE_ADD = "add";
-    /**
-     * 表单设计器修改 Flag
-     */
-    String DESIGN_FORM_URL_TYPE_EDIT = "edit";
-    /**
-     * 表单设计器详情 Flag
-     */
-    String DESIGN_FORM_URL_TYPE_DETAIL = "detail";
-    /**
-     * 表单设计器复用数据 Flag
-     */
-    String DESIGN_FORM_URL_TYPE_REUSE = "reuse";
-    /**
-     * 表单设计器编辑 Flag (已弃用)
-     */
-    String DESIGN_FORM_URL_TYPE_VIEW = "view";
-
-    /**
-     * online参数值设置(是:Y, 否:N)
-     */
-    String ONLINE_PARAM_VAL_IS_TURE = "Y";
-    String ONLINE_PARAM_VAL_IS_FALSE = "N";
-
-    /**
-     * 文件上传类型(本地:local,Minio:minio,阿里云:alioss)
-     */
-    String UPLOAD_TYPE_LOCAL = "local";
-    String UPLOAD_TYPE_MINIO = "minio";
-    String UPLOAD_TYPE_OSS = "alioss";
-
-    /**
-     * 文档上传自定义桶名称
-     */
-    String UPLOAD_CUSTOM_BUCKET = "eoafile";
-    /**
-     * 文档上传自定义路径
-     */
-    String UPLOAD_CUSTOM_PATH = "eoafile";
-    /**
-     * 文件外链接有效天数
-     */
-    Integer UPLOAD_EFFECTIVE_DAYS = 1;
-
-    /**
-     * 员工身份 (1:普通员工  2:上级)
-     */
-    Integer USER_IDENTITY_1 = 1;
-    Integer USER_IDENTITY_2 = 2;
-
-    /** sys_user 表 username 唯一键索引 */
-    String SQL_INDEX_UNIQ_SYS_USER_USERNAME = "uniq_sys_user_username";
-    /** sys_user 表 work_no 唯一键索引 */
-    String SQL_INDEX_UNIQ_SYS_USER_WORK_NO = "uniq_sys_user_work_no";
-    /** sys_user 表 phone 唯一键索引 */
-    String SQL_INDEX_UNIQ_SYS_USER_PHONE = "uniq_sys_user_phone";
-    /** 达梦数据库升提示。违反表[SYS_USER]唯一性约束 */
-    String SQL_INDEX_UNIQ_SYS_USER = "唯一性约束";
-
-    /** sys_user 表 email 唯一键索引 */
-    String SQL_INDEX_UNIQ_SYS_USER_EMAIL = "uniq_sys_user_email";
-    /** sys_quartz_job 表 job_class_name 唯一键索引 */
-    String SQL_INDEX_UNIQ_JOB_CLASS_NAME = "uniq_job_class_name";
-    /** sys_position 表 code 唯一键索引 */
-    String SQL_INDEX_UNIQ_CODE = "uniq_code";
-    /** sys_role 表 code 唯一键索引 */
-    String SQL_INDEX_UNIQ_SYS_ROLE_CODE = "uniq_sys_role_role_code";
-    /** sys_depart 表 code 唯一键索引 */
-    String SQL_INDEX_UNIQ_DEPART_ORG_CODE = "uniq_depart_org_code";
-    /** sys_category 表 code 唯一键索引 */
-    String SQL_INDEX_UNIQ_CATEGORY_CODE = "idx_sc_code";
-    /**
-     * 在线聊天 是否为默认分组
-     */
-    String IM_DEFAULT_GROUP = "1";
-    /**
-     * 在线聊天 图片文件保存路径
-     */
-    String IM_UPLOAD_CUSTOM_PATH = "biz/user_imgs";
-    /**
-     * 在线聊天 用户状态
-     */
-    String IM_STATUS_ONLINE = "online";
-
-    /**
-     * 在线聊天 SOCKET消息类型
-     */
-    String IM_SOCKET_TYPE = "chatMessage";
-
-    /**
-     * 在线聊天 是否开启默认添加好友 1是 0否
-     */
-    String IM_DEFAULT_ADD_FRIEND = "1";
-
-    /**
-     * 在线聊天 用户好友缓存前缀
-     */
-    String IM_PREFIX_USER_FRIEND_CACHE = "sys:cache:im:im_prefix_user_friend_";
-    /**
-     * 缓存用户id与用户名关系
-     */
-    String SYS_USER_ID_MAPPING_CACHE = "sys:cache:user:id_mapping";
-
-    /**
-     * 考勤补卡业务状态 (1:同意  2:不同意)
-     */
-    String SIGN_PATCH_BIZ_STATUS_1 = "1";
-    String SIGN_PATCH_BIZ_STATUS_2 = "2";
-
-    /**
-     * 公文文档上传自定义路径
-     */
-    String UPLOAD_CUSTOM_PATH_OFFICIAL = "officialdoc";
-     /**
-     * 公文文档下载自定义路径
-     */
-    String DOWNLOAD_CUSTOM_PATH_OFFICIAL = "officaldown";
-
-    /**
-     * WPS存储值类别(1 code文号 2 text(WPS模板还是公文发文模板))
-     */
-    String WPS_TYPE_1="1";
-    String WPS_TYPE_2="2";
-
-
-    /**===============================================================================================*/
-    /**
-     * ::非常重要::
-     * 注意:这四个常量值如果修改,需要与 jeecg-boot-starter/jeecg-boot-common/org.jeecg.config.FeignConfig 类中的值保持一致。
-     */
-    String X_ACCESS_TOKEN = "X-Access-Token";
-    String X_SIGN = "X-Sign";
-    String X_TIMESTAMP = "X-TIMESTAMP";
-    /** 租户请求头 更名为:X-Tenant-Id */
-    String TENANT_ID = "X-Tenant-Id";
-    /** 简流接口请求头,用于排除不支持的控件字段  */
-    String X_MiniFlowExclusionFieldMode = "X-Miniflowexclusionfieldmode";
-    /**===============================================================================================*/
-
-    String TOKEN_IS_INVALID_MSG = "Token失效,请重新登录!";
-    String X_FORWARDED_SCHEME = "X-Forwarded-Scheme";
-
-
-    /**
-     * 微服务读取配置文件属性 服务地址
-     */
-    String CLOUD_SERVER_KEY = "spring.cloud.nacos.discovery.server-addr";
-
-    /**
-     * 第三方登录 验证密码/创建用户 都需要设置一个操作码 防止被恶意调用
-     */
-    String THIRD_LOGIN_CODE = "third_login_code";
-
-    /**
-     * 第三方APP同步方向:本地 --> 第三方APP
-     */
-    String THIRD_SYNC_TO_APP = "SYNC_TO_APP";
-    /**
-     * 第三方APP同步方向:第三方APP --> 本地
-     */
-    String THIRD_SYNC_TO_LOCAL = "SYNC_TO_LOCAL";
-
-    /** 系统通告消息状态:0=未发布 */
-    String ANNOUNCEMENT_SEND_STATUS_0 = "0";
-    /** 系统通告消息状态:1=已发布 */
-    String ANNOUNCEMENT_SEND_STATUS_1 = "1";
-    /** 系统通告消息状态:2=已撤销 */
-    String ANNOUNCEMENT_SEND_STATUS_2 = "2";
-
-    /**ONLINE 报表权限用 从request中获取地址栏后的参数*/
-    String ONL_REP_URL_PARAM_STR="onlRepUrlParamStr";
-
-    /**POST请求*/
-    String HTTP_POST = "POST";
-
-    /**PUT请求*/
-    String HTTP_PUT = "PUT";
-
-    /**PATCH请求*/
-    String HTTP_PATCH = "PATCH";
-
-    /**未知的*/
-    String UNKNOWN = "unknown";
-
-    /**字符串http*/
-    String STR_HTTP = "http";
-
-    /**String 类型的空值*/
-    String STRING_NULL = "null";
-
-    /**前端vue3版本Header参数名*/
-    String VERSION="X-Version";
-
-    String VERSION_V3 = "v3";
-
-    /**存储在线程变量里的动态表名*/
-    String DYNAMIC_TABLE_NAME="DYNAMIC_TABLE_NAME";
-    /**
-     * http:// http协议
-     */
-    String HTTP_PROTOCOL = "http://";
-
-    /**
-     * https:// https协议
-     */
-    String HTTPS_PROTOCOL = "https://";
-    
-    /** 部门表唯一key,id */
-    String DEPART_KEY_ID = "id";
-    /** 部门表唯一key,orgCode */
-    String DEPART_KEY_ORG_CODE = "orgCode";
-
-    /**======【消息推送相关】==============================================================================*/
-    /**
-     * 发消息 会传递一些信息到map
-     */
-    String NOTICE_MSG_SUMMARY = "NOTICE_MSG_SUMMARY";
-
-    /**
-     * 发消息 会传递一个业务ID到map
-     */
-    String NOTICE_MSG_BUS_ID = "NOTICE_MSG_BUS_ID";
-
-   /**
-    * 发消息 消息业务类型
-    */
-   String NOTICE_MSG_BUS_TYPE = "NOTICE_MSG_BUS_TYPE";
-
-    /**
-     * 邮箱消息中地址登录时地址后携带的token,需要替换成真实的token值
-     */
-    String LOGIN_TOKEN = "{LOGIN_TOKEN}";
-
-    /**
-     * 模板消息中 跳转地址的对应的key
-     */
-    String MSG_HREF_URL = "url";
-
-    /**
-     * sys_data_log表的类型 用于区别评论区域的日志数据
-     */
-    String DATA_LOG_TYPE_COMMENT = "comment";
-
-    /**
-     * sys_data_log表的类型 老的数据比较 类型都设置为json
-     */
-    String DATA_LOG_TYPE_JSON = "json";
-
-    /** 消息模板:markdown */
-    String MSG_TEMPLATE_TYPE_MD = "5";
-    /**========【消息推送相关】==========================================================================*/
-
-    /**
-     * 短信验证码redis-key的前缀
-     */
-    String PHONE_REDIS_KEY_PRE = "phone_msg";
-
-    /**
-     * 是文件夹
-     */
-    String IT_IS_FOLDER = "1";
-
-    /**
-     * 文件拥有者
-     */
-    String FILE_OWNER = "owner";
-
-    /**
-     * 文件管理员
-     */
-    String FILE_ADMIN = "admin";
-
-    /**
-     * 只允许编辑
-     */
-    String FILE_EDITABLE = "editable";
-
-    /**
-     * 登录失败,用于记录失败次数的key
-     */
-    String LOGIN_FAIL = "LOGIN_FAIL_";
-
-    /**
-     * 入职事件
-     */
-    Integer BPM_USER_EVENT_ADD = 1;
-
-   /**
-    * 离职事件
-    */
-    Integer BPM_USER_EVENT_LEVEL = 2;
-
-   /**
-    * 用户租户状态(正常/已通过审核的)
-    */
-   String USER_TENANT_NORMAL = "1";
-
-   /**
-    * 用户租户状态(离职)
-    */
-   String USER_TENANT_QUIT = "2";
-
-   /**
-    * 用户租户状态(审核中)
-    */
-   String USER_TENANT_UNDER_REVIEW = "3";
-   
-   /**
-    * 用户租户状态(拒绝)
-    */
-   String USER_TENANT_REFUSE = "4";
-
-   /**
-    * 用户租户状态(邀请)
-    */
-   String USER_TENANT_INVITE = "5";
-   
-   /**
-    * 不是叶子节点
-    */
-   Integer NOT_LEAF = 0;
-
-   /**
-    * 是叶子节点
-    */
-   Integer IS_LEAF = 1;
-
-   /**
-    * 钉钉
-    */
-   String DINGTALK = "DINGTALK";
-
-   /**
-    * 企业微信
-    */
-   String WECHAT_ENTERPRISE = "WECHAT_ENTERPRISE";
+  /** 正常状态 */
+  Integer STATUS_NORMAL = 0;
+
+  /** 禁用状态 */
+  Integer STATUS_DISABLE = -1;
+
+  /** 删除标志 */
+  Integer DEL_FLAG_1 = 1;
+
+  /** 未删除 */
+  Integer DEL_FLAG_0 = 0;
+
+  /** 系统日志类型: 登录 */
+  int LOG_TYPE_1 = 1;
+
+  /** 系统日志类型: 操作 */
+  int LOG_TYPE_2 = 2;
+
+  /** 系统日志类型: 租户操作日志 */
+  int LOG_TYPE_3 = 3;
+
+  /** 系统日志类型: 异常 */
+  int LOG_TYPE_4 = 4;
+
+  /** 操作日志类型: 查询 */
+  int OPERATE_TYPE_1 = 1;
+
+  /** 操作日志类型: 添加 */
+  int OPERATE_TYPE_2 = 2;
+
+  /** 操作日志类型: 更新 */
+  int OPERATE_TYPE_3 = 3;
+
+  /** 操作日志类型: 删除 */
+  int OPERATE_TYPE_4 = 4;
+
+  /** 操作日志类型: 倒入 */
+  int OPERATE_TYPE_5 = 5;
+
+  /** 操作日志类型: 导出 */
+  int OPERATE_TYPE_6 = 6;
+
+  /** {@code 500 Server Error} (HTTP/1.0 - RFC 1945) */
+  Integer SC_INTERNAL_SERVER_ERROR_500 = 500;
+
+  /** {@code 404 Not Found} (HTTP/1.0 - RFC 1945) */
+  Integer SC_INTERNAL_NOT_FOUND_404 = 404;
+
+  /** {@code 200 OK} (HTTP/1.0 - RFC 1945) */
+  Integer SC_OK_200 = 200;
+
+  /** 访问权限认证未通过 510 */
+  Integer SC_JEECG_NO_AUTHZ = 510;
+
+  /** 登录用户Shiro权限缓存KEY前缀 */
+  public static String PREFIX_USER_SHIRO_CACHE =
+      "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:";
+
+  /** 登录用户Token令牌缓存KEY前缀 */
+  String PREFIX_USER_TOKEN = "token::jeecg-client::";
+
+  //    /** Token缓存时间:3600秒即一小时 */
+  //    int  TOKEN_EXPIRE_TIME  = 3600;
+
+  /** 登录二维码 */
+  String LOGIN_QRCODE_PRE = "QRCODELOGIN:";
+
+  String LOGIN_QRCODE = "LQ:";
+
+  /** 登录二维码token */
+  String LOGIN_QRCODE_TOKEN = "LQT:";
+
+  /** 0:一级菜单 */
+  Integer MENU_TYPE_0 = 0;
+
+  /** 1:子菜单 */
+  Integer MENU_TYPE_1 = 1;
+
+  /** 2:按钮权限 */
+  Integer MENU_TYPE_2 = 2;
+
+  /** 通告对象类型(USER:指定用户,ALL:全体用户) */
+  String MSG_TYPE_UESR = "USER";
+
+  String MSG_TYPE_ALL = "ALL";
+
+  /** 发布状态(0未发布,1已发布,2已撤销) */
+  String NO_SEND = "0";
+
+  String HAS_SEND = "1";
+  String HAS_CANCLE = "2";
+
+  /** 阅读状态(0未读,1已读) */
+  Integer HAS_READ_FLAG = 1;
+
+  Integer NO_READ_FLAG = 0;
+
+  /** 优先级(L低,M中,H高) */
+  String PRIORITY_L = "L";
+
+  String PRIORITY_M = "M";
+  String PRIORITY_H = "H";
+
+  /** 短信模板方式 0 .登录模板、1.注册模板、2.忘记密码模板 */
+  String SMS_TPL_TYPE_0 = "0";
+
+  String SMS_TPL_TYPE_1 = "1";
+  String SMS_TPL_TYPE_2 = "2";
+
+  /** 状态(0无效1有效) */
+  String STATUS_0 = "0";
+
+  String STATUS_1 = "1";
+
+  /** 同步工作流引擎1同步0不同步 */
+  Integer ACT_SYNC_1 = 1;
+
+  Integer ACT_SYNC_0 = 0;
+
+  /** 消息类型1:通知公告2:系统消息 */
+  String MSG_CATEGORY_1 = "1";
+
+  String MSG_CATEGORY_2 = "2";
+
+  /** 是否配置菜单的数据权限 1是0否 */
+  Integer RULE_FLAG_0 = 0;
+
+  Integer RULE_FLAG_1 = 1;
+
+  /** 是否用户已被冻结 1正常(解冻) 2冻结 3离职 */
+  Integer USER_UNFREEZE = 1;
+
+  Integer USER_FREEZE = 2;
+  Integer USER_QUIT = 3;
+
+  /** 字典翻译文本后缀 */
+  String DICT_TEXT_SUFFIX = "_dictText";
+
+  /** 字典翻译颜色后缀 */
+  String DICT_COLOR_SUFFIX = "_dictColor";
+
+  /** 表单设计器主表类型 */
+  Integer DESIGN_FORM_TYPE_MAIN = 1;
+
+  /** 表单设计器子表表类型 */
+  Integer DESIGN_FORM_TYPE_SUB = 2;
+
+  /** 表单设计器URL授权通过 */
+  Integer DESIGN_FORM_URL_STATUS_PASSED = 1;
+
+  /** 表单设计器URL授权未通过 */
+  Integer DESIGN_FORM_URL_STATUS_NOT_PASSED = 2;
+
+  /** 表单设计器新增 Flag */
+  String DESIGN_FORM_URL_TYPE_ADD = "add";
+
+  /** 表单设计器修改 Flag */
+  String DESIGN_FORM_URL_TYPE_EDIT = "edit";
+
+  /** 表单设计器详情 Flag */
+  String DESIGN_FORM_URL_TYPE_DETAIL = "detail";
+
+  /** 表单设计器复用数据 Flag */
+  String DESIGN_FORM_URL_TYPE_REUSE = "reuse";
+
+  /** 表单设计器编辑 Flag (已弃用) */
+  String DESIGN_FORM_URL_TYPE_VIEW = "view";
+
+  /** online参数值设置(是:Y, 否:N) */
+  String ONLINE_PARAM_VAL_IS_TURE = "Y";
+
+  String ONLINE_PARAM_VAL_IS_FALSE = "N";
+
+  /** 文件上传类型(本地:local,Minio:minio,阿里云:alioss) */
+  String UPLOAD_TYPE_LOCAL = "local";
+
+  String UPLOAD_TYPE_MINIO = "minio";
+  String UPLOAD_TYPE_OSS = "alioss";
+
+  /** 文档上传自定义桶名称 */
+  String UPLOAD_CUSTOM_BUCKET = "eoafile";
+
+  /** 文档上传自定义路径 */
+  String UPLOAD_CUSTOM_PATH = "eoafile";
+
+  /** 文件外链接有效天数 */
+  Integer UPLOAD_EFFECTIVE_DAYS = 1;
+
+  /** 员工身份 (1:普通员工 2:上级) */
+  Integer USER_IDENTITY_1 = 1;
+
+  Integer USER_IDENTITY_2 = 2;
+
+  /** sys_user 表 username 唯一键索引 */
+  String SQL_INDEX_UNIQ_SYS_USER_USERNAME = "uniq_sys_user_username";
+
+  /** sys_user 表 work_no 唯一键索引 */
+  String SQL_INDEX_UNIQ_SYS_USER_WORK_NO = "uniq_sys_user_work_no";
+
+  /** sys_user 表 phone 唯一键索引 */
+  String SQL_INDEX_UNIQ_SYS_USER_PHONE = "uniq_sys_user_phone";
+
+  /** 达梦数据库升提示。违反表[SYS_USER]唯一性约束 */
+  String SQL_INDEX_UNIQ_SYS_USER = "唯一性约束";
+
+  /** sys_user 表 email 唯一键索引 */
+  String SQL_INDEX_UNIQ_SYS_USER_EMAIL = "uniq_sys_user_email";
+
+  /** sys_quartz_job 表 job_class_name 唯一键索引 */
+  String SQL_INDEX_UNIQ_JOB_CLASS_NAME = "uniq_job_class_name";
+
+  /** sys_position 表 code 唯一键索引 */
+  String SQL_INDEX_UNIQ_CODE = "uniq_code";
+
+  /** sys_role 表 code 唯一键索引 */
+  String SQL_INDEX_UNIQ_SYS_ROLE_CODE = "uniq_sys_role_role_code";
+
+  /** sys_depart 表 code 唯一键索引 */
+  String SQL_INDEX_UNIQ_DEPART_ORG_CODE = "uniq_depart_org_code";
+
+  /** sys_category 表 code 唯一键索引 */
+  String SQL_INDEX_UNIQ_CATEGORY_CODE = "idx_sc_code";
+
+  /** 在线聊天 是否为默认分组 */
+  String IM_DEFAULT_GROUP = "1";
+
+  /** 在线聊天 图片文件保存路径 */
+  String IM_UPLOAD_CUSTOM_PATH = "biz/user_imgs";
+
+  /** 在线聊天 用户状态 */
+  String IM_STATUS_ONLINE = "online";
+
+  /** 在线聊天 SOCKET消息类型 */
+  String IM_SOCKET_TYPE = "chatMessage";
+
+  /** 在线聊天 是否开启默认添加好友 1是 0否 */
+  String IM_DEFAULT_ADD_FRIEND = "1";
+
+  /** 在线聊天 用户好友缓存前缀 */
+  String IM_PREFIX_USER_FRIEND_CACHE = "sys:cache:im:im_prefix_user_friend_";
+
+  /** 缓存用户id与用户名关系 */
+  String SYS_USER_ID_MAPPING_CACHE = "sys:cache:user:id_mapping";
+
+  /** 考勤补卡业务状态 (1:同意 2:不同意) */
+  String SIGN_PATCH_BIZ_STATUS_1 = "1";
+
+  String SIGN_PATCH_BIZ_STATUS_2 = "2";
+
+  /** 公文文档上传自定义路径 */
+  String UPLOAD_CUSTOM_PATH_OFFICIAL = "officialdoc";
+
+  /** 公文文档下载自定义路径 */
+  String DOWNLOAD_CUSTOM_PATH_OFFICIAL = "officaldown";
+
+  /** WPS存储值类别(1 code文号 2 text(WPS模板还是公文发文模板)) */
+  String WPS_TYPE_1 = "1";
+
+  String WPS_TYPE_2 = "2";
+
+  /**
+   * ===============================================================================================
+   */
+  /**
+   * ::非常重要:: 注意:这四个常量值如果修改,需要与 jeecg-boot-starter/jeecg-boot-common/org.jeecg.config.FeignConfig
+   * 类中的值保持一致。
+   */
+  String X_ACCESS_TOKEN = "X-Access-Token";
+
+  String X_SIGN = "X-Sign";
+  String X_TIMESTAMP = "X-TIMESTAMP";
+
+  /** 租户请求头 更名为:X-Tenant-Id */
+  String TENANT_ID = "X-Tenant-Id";
+
+  /** 简流接口请求头,用于排除不支持的控件字段 */
+  String X_MiniFlowExclusionFieldMode = "X-Miniflowexclusionfieldmode";
+
+  /**
+   * ===============================================================================================
+   */
+  String TOKEN_IS_INVALID_MSG = "Token失效,请重新登录!";
+
+  String X_FORWARDED_SCHEME = "X-Forwarded-Scheme";
+
+  /** 微服务读取配置文件属性 服务地址 */
+  String CLOUD_SERVER_KEY = "spring.cloud.nacos.discovery.server-addr";
+
+  /** 第三方登录 验证密码/创建用户 都需要设置一个操作码 防止被恶意调用 */
+  String THIRD_LOGIN_CODE = "third_login_code";
+
+  /** 第三方APP同步方向:本地 --> 第三方APP */
+  String THIRD_SYNC_TO_APP = "SYNC_TO_APP";
+
+  /** 第三方APP同步方向:第三方APP --> 本地 */
+  String THIRD_SYNC_TO_LOCAL = "SYNC_TO_LOCAL";
+
+  /** 系统通告消息状态:0=未发布 */
+  String ANNOUNCEMENT_SEND_STATUS_0 = "0";
+
+  /** 系统通告消息状态:1=已发布 */
+  String ANNOUNCEMENT_SEND_STATUS_1 = "1";
+
+  /** 系统通告消息状态:2=已撤销 */
+  String ANNOUNCEMENT_SEND_STATUS_2 = "2";
+
+  /** ONLINE 报表权限用 从request中获取地址栏后的参数 */
+  String ONL_REP_URL_PARAM_STR = "onlRepUrlParamStr";
+
+  /** POST请求 */
+  String HTTP_POST = "POST";
+
+  /** PUT请求 */
+  String HTTP_PUT = "PUT";
+
+  /** PATCH请求 */
+  String HTTP_PATCH = "PATCH";
+
+  /** 未知的 */
+  String UNKNOWN = "unknown";
+
+  /** 字符串http */
+  String STR_HTTP = "http";
+
+  /** String 类型的空值 */
+  String STRING_NULL = "null";
+
+  /** 前端vue3版本Header参数名 */
+  String VERSION = "X-Version";
+
+  String VERSION_V3 = "v3";
+
+  /** 存储在线程变量里的动态表名 */
+  String DYNAMIC_TABLE_NAME = "DYNAMIC_TABLE_NAME";
+
+  /** http:// http协议 */
+  String HTTP_PROTOCOL = "http://";
+
+  /** https:// https协议 */
+  String HTTPS_PROTOCOL = "https://";
+
+  /** 部门表唯一key,id */
+  String DEPART_KEY_ID = "id";
+
+  /** 部门表唯一key,orgCode */
+  String DEPART_KEY_ORG_CODE = "orgCode";
 
   /**
-   * 系统默认租户id 0
+   * ======【消息推送相关】==============================================================================
    */
+  /** 发消息 会传递一些信息到map */
+  String NOTICE_MSG_SUMMARY = "NOTICE_MSG_SUMMARY";
+
+  /** 发消息 会传递一个业务ID到map */
+  String NOTICE_MSG_BUS_ID = "NOTICE_MSG_BUS_ID";
+
+  /** 发消息 消息业务类型 */
+  String NOTICE_MSG_BUS_TYPE = "NOTICE_MSG_BUS_TYPE";
+
+  /** 邮箱消息中地址登录时地址后携带的token,需要替换成真实的token值 */
+  String LOGIN_TOKEN = "{LOGIN_TOKEN}";
+
+  /** 模板消息中 跳转地址的对应的key */
+  String MSG_HREF_URL = "url";
+
+  /** sys_data_log表的类型 用于区别评论区域的日志数据 */
+  String DATA_LOG_TYPE_COMMENT = "comment";
+
+  /** sys_data_log表的类型 老的数据比较 类型都设置为json */
+  String DATA_LOG_TYPE_JSON = "json";
+
+  /** 消息模板:markdown */
+  String MSG_TEMPLATE_TYPE_MD = "5";
+
+  /** ========【消息推送相关】========================================================================== */
+
+  /** 短信验证码redis-key的前缀 */
+  String PHONE_REDIS_KEY_PRE = "phone_msg";
+
+  /** 是文件夹 */
+  String IT_IS_FOLDER = "1";
+
+  /** 文件拥有者 */
+  String FILE_OWNER = "owner";
+
+  /** 文件管理员 */
+  String FILE_ADMIN = "admin";
+
+  /** 只允许编辑 */
+  String FILE_EDITABLE = "editable";
+
+  /** 登录失败,用于记录失败次数的key */
+  String LOGIN_FAIL = "LOGIN_FAIL_";
+
+  /** 入职事件 */
+  Integer BPM_USER_EVENT_ADD = 1;
+
+  /** 离职事件 */
+  Integer BPM_USER_EVENT_LEVEL = 2;
+
+  /** 用户租户状态(正常/已通过审核的) */
+  String USER_TENANT_NORMAL = "1";
+
+  /** 用户租户状态(离职) */
+  String USER_TENANT_QUIT = "2";
+
+  /** 用户租户状态(审核中) */
+  String USER_TENANT_UNDER_REVIEW = "3";
+
+  /** 用户租户状态(拒绝) */
+  String USER_TENANT_REFUSE = "4";
+
+  /** 用户租户状态(邀请) */
+  String USER_TENANT_INVITE = "5";
+
+  /** 不是叶子节点 */
+  Integer NOT_LEAF = 0;
+
+  /** 是叶子节点 */
+  Integer IS_LEAF = 1;
+
+  /** 钉钉 */
+  String DINGTALK = "DINGTALK";
+
+  /** 企业微信 */
+  String WECHAT_ENTERPRISE = "WECHAT_ENTERPRISE";
+
+  /** 系统默认租户id 0 */
   Integer TENANT_ID_DEFAULT_VALUE = 0;
 
- /**
-  * 【low-app用】 应用级别的复制
-  */
- String COPY_LEVEL_APP = "app";
-
- /**
-  * 【low-app用】 菜单级别的复制
-  */
- String COPY_LEVEL_MENU = "menu";
-
-
- /**
-  * 【low-app用】 应用备份
-  */
- String COPY_LEVEL_BAK = "backup";
-
- /**
-  * 【low-app用】 从备份还原
-  */
- String COPY_LEVEL_COVER = "cover";
-
- /** 【QQYUN-6034】关联字段变更历史值,缓存半个小时 */
- String CACHE_REL_FIELD_OLD_VAL = "sys:cache:desform:relFieldOldVal:";
-
-    /**
-     * 排序类型:升序
-     */
-    String ORDER_TYPE_ASC = "ASC";
-    /**
-     * 排序类型:降序
-     */
-    String ORDER_TYPE_DESC = "DESC";
-
-
-   //update-begin---author:scott ---date:2023-09-10  for:积木报表常量----
-   /**
-    * 报表允许设计开发的角色
-    */
-   public static String[] allowDevRoles = new String[]{"lowdeveloper", "admin"};
-   /**
-    * 【对应积木报表的常量】
-    * 数据隔离模式: 按照创建人隔离
-    */
-   public static final String SAAS_MODE_CREATED = "created";
-   /**
-    * 【对应积木报表的常量】
-    * 数据隔离模式: 按照租户隔离
-    */
-   public static final String SAAS_MODE_TENANT = "tenant";
-   //update-end---author:scott ---date::2023-09-10  for:积木报表常量----
- 
-   //update-begin---author:wangshuai---date:2024-04-07---for:修改手机号常量---
-   /**
-    * 修改手机号短信验证码redis-key的前缀
-    */
-   String CHANGE_PHONE_REDIS_KEY_PRE = "sys:cache:phone:change_phone_msg:";
-
-    /**
-     * 缓存用户最后一次收到消息通知的时间 KEY
-     */
-   String CACHE_KEY_USER_LAST_ANNOUNT_TIME_1HOUR = "sys:cache:userinfo:user_last_annount_time::%s";
-   
-   /**
-    * 验证原手机号
-    */
-   String VERIFY_ORIGINAL_PHONE = "verifyOriginalPhone";
-
-   /**
-    * 修改手机号
-    */
-   String UPDATE_PHONE = "updatePhone";
-   //update-end---author:wangshuai---date:2024-04-07---for:修改手机号常量---
-    
-   /**
-    * 修改手机号验证码请求次数超出
-    */
-   Integer PHONE_SMS_FAIL_CODE = 40002;
+  /** 【low-app用】 应用级别的复制 */
+  String COPY_LEVEL_APP = "app";
+
+  /** 【low-app用】 菜单级别的复制 */
+  String COPY_LEVEL_MENU = "menu";
+
+  /** 【low-app用】 应用备份 */
+  String COPY_LEVEL_BAK = "backup";
+
+  /** 【low-app用】 从备份还原 */
+  String COPY_LEVEL_COVER = "cover";
+
+  /** 【QQYUN-6034】关联字段变更历史值,缓存半个小时 */
+  String CACHE_REL_FIELD_OLD_VAL = "sys:cache:desform:relFieldOldVal:";
+
+  /** 排序类型:升序 */
+  String ORDER_TYPE_ASC = "ASC";
+
+  /** 排序类型:降序 */
+  String ORDER_TYPE_DESC = "DESC";
+
+  // update-begin---author:scott ---date:2023-09-10  for:积木报表常量----
+  /** 报表允许设计开发的角色 */
+  public static String[] allowDevRoles = new String[] {"lowdeveloper", "admin"};
+
+  /** 【对应积木报表的常量】 数据隔离模式: 按照创建人隔离 */
+  public static final String SAAS_MODE_CREATED = "created";
+
+  /** 【对应积木报表的常量】 数据隔离模式: 按照租户隔离 */
+  public static final String SAAS_MODE_TENANT = "tenant";
+
+  // update-end---author:scott ---date::2023-09-10  for:积木报表常量----
+
+  // update-begin---author:wangshuai---date:2024-04-07---for:修改手机号常量---
+  /** 修改手机号短信验证码redis-key的前缀 */
+  String CHANGE_PHONE_REDIS_KEY_PRE = "sys:cache:phone:change_phone_msg:";
+
+  /** 缓存用户最后一次收到消息通知的时间 KEY */
+  String CACHE_KEY_USER_LAST_ANNOUNT_TIME_1HOUR = "sys:cache:userinfo:user_last_annount_time::%s";
+
+  /** 验证原手机号 */
+  String VERIFY_ORIGINAL_PHONE = "verifyOriginalPhone";
+
+  /** 修改手机号 */
+  String UPDATE_PHONE = "updatePhone";
+
+  // update-end---author:wangshuai---date:2024-04-07---for:修改手机号常量---
+
+  /** 修改手机号验证码请求次数超出 */
+  Integer PHONE_SMS_FAIL_CODE = 40002;
+
+  /** 有主账户 */
+  Integer HAS_MASTER_ACCOUNT = 1;
+
+  /** 没有主账户 */
+  Integer HAS_NOT_MASTER_ACCOUNT = 0;
 }

+ 58 - 58
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/constant/AdwebConstant.java

@@ -2,62 +2,62 @@ package org.jeecg.modules.adweb.common.constant;
 
 public interface AdwebConstant {
 
-    /** 网站状态 当前状态:0:已删除;1:正常; 2:未发布 */
-    Integer SITE_DEL = 0;
-
-    /** 产品状态0删除1可用 */
-    Integer STATUS = 1;
-
-    /** 组件编码 */
-    String PRODUCT = "product";
-
-    /** 内容 */
-    String NEWS = "news";
-
-    /** 平台标识 */
-    String APPKEY = "adweb";
-
-    /** 内容分类 */
-    String NEWSCATALOG = "newsCatalog";
-
-    String PRODUCTCTALOG = "productCatalog";
-
-    /** 缓存前缀 */
-    String CACHE_PREFIX = "AdWeb3::";
-
-    // 询盘阶段,字典条目
-    String ENQUIRY_PHASE = "enquiry_phase";
-    // 询盘跟进状态,字典条目
-    String ENQUIRY_TRACK_STATUS = "enquiry_track_status";
-    // 询盘用户有效性,字典条目
-    String ENQUIRY_EFFECTIVE = "enquiry_effective";
-    // 询盘回复状态,字典条目
-    String ENQUIRY_REPLAY_STATUS = "enquiry_replay_status";
-    // ADMP dictService
-    String CUSTOMER_ORDER_CURRENCY = "customer_order_currency";
-
-    String ENQUIRY_PARAM_NAME = "enquiry_param_name";
-    String ENQUIRY_PARAM_EMAIL = "enquiry_param_email";
-    String ENQUIRY_PARAM_PHONE = "enquiry_param_phone";
-    String ENQUIRY_PARAM_MESSAGE = "enquiry_param_message";
-    String ENQUIRY_PARAM_COMPANY = "enquiry_param_company";
-    String ENQUIRY_PARAM_FROM_PAGE = "enquiry_param_from_page";
-
-    /** 页面code */
-    String HOME_PAGE_CODE = "home";
-
-    String ABOUT_US_PAGE_CODE = "aboutUs";
-    String PRODUCTS_PAGE_CODE = "products";
-    String PRODUCT_DETAIL_PAGE_CODE = "productDetail";
-    String NEWS_PAGE_CODE = "news";
-    String NEWS_DETAIL_PAGE_CODE = "newsDetail";
-    String CONTACT_US_PAGE_CODE = "contactUs";
-    String FAQ_PAGE_CODE = "faq";
-
-    /** 模板标签 */
-    String TEMPLATE_TAGS = "template_tags";
-
-    /*SEO关键字类型 1 - 指定词 2 - 长尾词 */
-    int KEYWORD_TYPE_APPOINT = 1;
-    int KEYWORD_TYPE_LONG_TAIL = 2;
+  /** 网站状态 当前状态:0:已删除;1:正常; 2:未发布 */
+  Integer SITE_DEL = 0;
+
+  /** 产品状态0删除1可用 */
+  Integer STATUS = 1;
+
+  /** 组件编码 */
+  String PRODUCT = "product";
+
+  /** 内容 */
+  String NEWS = "news";
+
+  /** 平台标识 */
+  String APPKEY = "adweb";
+
+  /** 内容分类 */
+  String NEWSCATALOG = "newsCatalog";
+
+  String PRODUCTCTALOG = "productCatalog";
+
+  /** 缓存前缀 */
+  String CACHE_PREFIX = "AdWeb3::";
+
+  // 询盘阶段,字典条目
+  String ENQUIRY_PHASE = "enquiry_phase";
+  // 询盘跟进状态,字典条目
+  String ENQUIRY_TRACK_STATUS = "enquiry_track_status";
+  // 询盘用户有效性,字典条目
+  String ENQUIRY_EFFECTIVE = "enquiry_effective";
+  // 询盘回复状态,字典条目
+  String ENQUIRY_REPLAY_STATUS = "enquiry_replay_status";
+  // ADMP dictService
+  String CUSTOMER_ORDER_CURRENCY = "customer_order_currency";
+
+  String ENQUIRY_PARAM_NAME = "enquiry_param_name";
+  String ENQUIRY_PARAM_EMAIL = "enquiry_param_email";
+  String ENQUIRY_PARAM_PHONE = "enquiry_param_phone";
+  String ENQUIRY_PARAM_MESSAGE = "enquiry_param_message";
+  String ENQUIRY_PARAM_COMPANY = "enquiry_param_company";
+  String ENQUIRY_PARAM_FROM_PAGE = "enquiry_param_from_page";
+
+  /** 页面code */
+  String HOME_PAGE_CODE = "home";
+
+  String ABOUT_US_PAGE_CODE = "aboutUs";
+  String PRODUCTS_PAGE_CODE = "products";
+  String PRODUCT_DETAIL_PAGE_CODE = "productDetail";
+  String NEWS_PAGE_CODE = "news";
+  String NEWS_DETAIL_PAGE_CODE = "newsDetail";
+  String CONTACT_US_PAGE_CODE = "contactUs";
+  String FAQ_PAGE_CODE = "faq";
+
+  /** 模板标签 */
+  String TEMPLATE_TAGS = "template_tags";
+
+  /*SEO关键字类型 1 - 指定词 2 - 长尾词 */
+  int KEYWORD_TYPE_APPOINT = 1;
+  int KEYWORD_TYPE_LONG_TAIL = 2;
 }

+ 29 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/dto/CommonDto.java

@@ -0,0 +1,29 @@
+package org.jeecg.modules.adweb.common.dto;
+
+import java.util.List;
+import lombok.Data;
+
+@Data
+public class CommonDto {
+  private String type;
+  private String username;
+  private String msg;
+  private Integer code;
+  private String siteName;
+  private String siteCode;
+  private String historyId;
+  private String planName;
+
+  /** 产品明细 */
+  private List<String> name;
+
+  private List<String> category_name;
+  private List<String> tag_name;
+
+  /** 搜索趋势,top10 */
+  private String country;
+
+  private List<String> searchName;
+  private List<Integer> searchValue;
+  private List<Integer> proportionList;
+}

+ 8 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/mapper/CommonMapper.java

@@ -1,10 +1,10 @@
 package org.jeecg.modules.adweb.common.mapper;
 
-import org.apache.ibatis.annotations.Select;
-import org.jeecg.modules.system.entity.SysUser;
-
 import java.util.Date;
 import java.util.List;
+import org.apache.ibatis.annotations.Select;
+import org.jeecg.modules.system.entity.SysPermission;
+import org.jeecg.modules.system.entity.SysUser;
 
 /**
  * 通用MyBatis mapper工具
@@ -30,4 +30,9 @@ public interface CommonMapper {
             "ON t3.id = t2.role_id\n" +
             "WHERE t3.role_code = 'adweb_vip' AND t1.del_flag = 0 AND t1.username != ''")
     List<SysUser> getAdwebVip();
+
+    /**
+     * 获取 adweb_vip 角色的权限
+     */
+    List<SysPermission> getAdwebVipPermission();
 }

+ 13 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/mapper/xml/CommonMapper.xml

@@ -14,4 +14,17 @@
         </where>
     </select>
 
+    <select id="getAdwebVipPermission" resultType="org.jeecg.modules.system.entity.SysPermission">
+        SELECT t3.*
+        FROM sys_role t1,
+             sys_role_permission t2,
+             sys_permission t3
+        WHERE t1.role_code = 'adweb_vip'
+          AND t1.id = t2.role_id
+          AND t2.permission_id = t3.id
+          AND t3.del_flag = 0
+          AND t3.url NOT IN ('/enterprise', '/enterprise/enterpriseUser', '/inquery/rules', '/account', '/tools')
+        ORDER BY t3.sort_no
+    </select>
+
 </mapper>

+ 48 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/util/MD5Util.java

@@ -0,0 +1,48 @@
+package org.jeecg.modules.adweb.common.util;
+
+import java.security.MessageDigest;
+
+public class MD5Util {
+
+  protected static char hexDigits[] = {
+    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
+  };
+
+  /**
+   * 将byte类型的数组转化为md5
+   *
+   * @param source
+   * @return
+   */
+  public static String byte2Md5(byte[] source) {
+    String md5String = "";
+    try {
+      MessageDigest messagedigest = MessageDigest.getInstance("MD5");
+      messagedigest.update(source);
+      md5String = bufferToHex(messagedigest.digest());
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+    return md5String;
+  }
+
+  private static String bufferToHex(byte bytes[]) {
+    return bufferToHex(bytes, 0, bytes.length);
+  }
+
+  private static String bufferToHex(byte bytes[], int m, int n) {
+    StringBuffer stringbuffer = new StringBuffer(2 * n);
+    int k = m + n;
+    for (int l = m; l < k; l++) {
+      appendHexPair(bytes[l], stringbuffer);
+    }
+    return stringbuffer.toString();
+  }
+
+  private static void appendHexPair(byte bt, StringBuffer stringbuffer) {
+    char c0 = hexDigits[(bt & 0xf0) >> 4];
+    char c1 = hexDigits[bt & 0xf];
+    stringbuffer.append(c0);
+    stringbuffer.append(c1);
+  }
+}

+ 75 - 68
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/AdwebEnquiryMapper.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.adweb.enquiry.mapper;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
@@ -16,82 +17,88 @@ import java.util.Date;
 import java.util.List;
 
 /**
- * @Description: 询盘信息存储表单
- * @Author: jeecg-boot
- * @Date: 2024-10-12
- * @Version: V1.0
+ * @Description: 询盘信息存储表单 @Author: jeecg-boot @Date: 2024-10-12 @Version: V1.0
  */
 public interface AdwebEnquiryMapper extends BaseMapper<AdwebEnquiry> {
 
-    /**
-     * @param page
-     * @param userEffective
-     * @param searchText
-     * @param ctimeBegin
-     * @param ctimeEnd
-     * @return
-     */
-    IPage<EnquiryListDto> selectEnquiryList(IPage<EnquirySearchDto> page,
-                                            @Param("codeList") List<String> codeList,
-                                            @Param("userEffective") String userEffective,
-                                            @Param("wasteEnquiryType") String wasteEnquiryType,
-                                            @Param("searchText") String searchText,
-                                            @Param("searchContent") String searchContent,
-                                            @Param("ctimeBegin") Date ctimeBegin,
-                                            @Param("ctimeEnd") Date ctimeEnd,
-                                            @Param("whatsApp") String whatsApp,
-                                            @Param("readStatus") Integer readStatus,
-                                            @Param("principalUid") String principalUid,
-                                            @Param("selfPrincipalUid") String selfPrincipalUid);
+  /**
+   * @param page
+   * @param userEffective
+   * @param searchText
+   * @param ctimeBegin
+   * @param ctimeEnd
+   * @return
+   */
+  IPage<EnquiryListDto> selectEnquiryList(
+      IPage<EnquirySearchDto> page,
+      @Param("codeList") List<String> codeList,
+      @Param("userEffective") String userEffective,
+      @Param("wasteEnquiryType") String wasteEnquiryType,
+      @Param("searchText") String searchText,
+      @Param("searchContent") String searchContent,
+      @Param("ctimeBegin") Date ctimeBegin,
+      @Param("ctimeEnd") Date ctimeEnd,
+      @Param("whatsApp") String whatsApp,
+      @Param("readStatus") Integer readStatus,
+      @Param("principalUid") String principalUid,
+      @Param("selfPrincipalUid") String selfPrincipalUid);
 
-    /**
-     * 根据地区更新询盘跟进人
-     */
-    void updatePrincipalUidByRegion(Integer siteId, List<Integer> siteIds);
+  /** 根据地区更新询盘跟进人 */
+  void updatePrincipalUidByRegion(Integer siteId, List<Integer> siteIds);
 
-    /**
-     * @param page
-     * @param siteId
-     * @param userEffective
-     * @param searchText
-     * @param ctimeBegin
-     * @param ctimeEnd
-     * @return
-     */
-    IPage<EnquiryListDto> queryWasteEnquiryList(IPage<EnquirySearchDto> page,
-                                                @Param("codeList") List<String> codeList,
-                                                @Param("siteId") String siteId,
-                                                @Param("userEffective") String userEffective,
-                                                @Param("searchText") String searchText,
-                                                @Param("ctimeBegin") String ctimeBegin,
-                                                @Param("ctimeEnd") String ctimeEnd,
-                                                @Param("whatsApp") String whatsApp,
-                                                @Param("principalUid") String principalUid);
+  /**
+   * @param page
+   * @param siteId
+   * @param userEffective
+   * @param searchText
+   * @param ctimeBegin
+   * @param ctimeEnd
+   * @return
+   */
+  IPage<EnquiryListDto> queryWasteEnquiryList(
+      IPage<EnquirySearchDto> page,
+      @Param("codeList") List<String> codeList,
+      @Param("siteId") String siteId,
+      @Param("userEffective") String userEffective,
+      @Param("searchText") String searchText,
+      @Param("ctimeBegin") String ctimeBegin,
+      @Param("ctimeEnd") String ctimeEnd,
+      @Param("whatsApp") String whatsApp,
+      @Param("principalUid") String principalUid);
 
-    List<EnquiryListDto> getWastedEnquiry(String wasteEnquiryType, String ip, String email, String keyword, String searchText, String type, Integer siteId);
+  List<EnquiryListDto> getWastedEnquiry(
+      String wasteEnquiryType,
+      String ip,
+      String email,
+      String keyword,
+      String searchText,
+      String type,
+      Integer siteId);
 
-    /**
-     * 获取每日询盘数量及未读询盘数量
-     *
-     * @param siteCode
-     * @param start
-     * @param end
-     * @return List<ImmutableTriple < String, Long, Long>> -- MyBatis COUNT()方法默认类型为Long
-     */
-    List<ImmutableTriple<String, Long, Long>> getEnquiryDailyCounts(String siteCode, Date start, Date end);
+  /**
+   * 获取每日询盘数量及未读询盘数量
+   *
+   * @param siteCode
+   * @param start
+   * @param end
+   * @return List<ImmutableTriple < String, Long, Long>> -- MyBatis COUNT()方法默认类型为Long
+   */
+  List<ImmutableTriple<String, Long, Long>> getEnquiryDailyCounts(
+      String siteCode, Date start, Date end);
 
-    /**
-     * 获取分时间段的询盘数量 - 今天,昨天,本周,上周,本月,上月,全部
-     *
-     * @param siteCode
-     * @return List<Pair < String, Long>> -- MyBatis COUNT()方法默认类型为Long
-     */
-    List<ImmutablePair<String, Long>> getEnquiryPeriodicCounts(String siteCode);
+  /**
+   * 获取分时间段的询盘数量 - 今天,昨天,本周,上周,本月,上月,全部
+   *
+   * @param siteCode
+   * @return List<Pair < String, Long>> -- MyBatis COUNT()方法默认类型为Long
+   */
+  List<ImmutablePair<String, Long>> getEnquiryPeriodicCounts(String siteCode);
 
-    /**
-     * 获取按国家分布的询盘数量
-     */
-    List<EnquiryCountryStatsVO> getEnquiryCountryStats(String siteCode, Date start, Date end);
+  /** 获取按国家分布的询盘数量 */
+  List<EnquiryCountryStatsVO> getEnquiryCountryStats(String siteCode, Date start, Date end);
 
-    List<EnquiryDTO> getEnquiryList(String siteCode, String startTime, String endTime);
+  List<EnquiryDTO> getEnquiryList(String siteCode, String startTime, String endTime);
+
+  /** 统计管理的询盘数量 */
+  List<JSONObject> getEnquiryCount(List<String> uids);
 }

+ 17 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/xml/AdwebEnquiryMapper.xml

@@ -289,7 +289,7 @@
     <update id="updatePrincipalUidByRegion">
         update
         adweb_enquiry t1,
-        admp_country t2,
+        adweb_country t2,
         adweb_user_country t3
         set
         t1.principal_uid = t3.uid
@@ -410,4 +410,20 @@
         </if>
     </select>
 
+    <select id="getEnquiryCount" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        principal_uid uid,
+        count(1) enquiryCount
+        FROM
+        adweb_enquiry
+        WHERE
+        `status` = 1
+        AND principal_uid IN
+        <foreach collection="uids" item="uid" open="(" close=")" separator=",">
+            #{uid}
+        </foreach>
+        GROUP BY
+        principal_uid
+    </select>
+
 </mapper>

+ 9 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/IAdwebEnquiryService.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.adweb.enquiry.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import java.util.List;
+import java.util.Map;
 import org.jeecg.modules.adweb.enquiry.dto.EnquiryDTO;
 import org.jeecg.modules.adweb.enquiry.dto.param.EffectiveEnquiryParamDto;
 import org.jeecg.modules.adweb.enquiry.entity.AdwebEnquiry;
@@ -12,6 +13,14 @@ import org.jeecg.modules.adweb.site.entity.AdwebSite;
  */
 public interface IAdwebEnquiryService extends IService<AdwebEnquiry> {
 
+  /** 统计管理的询盘数量 */
+  Map<String, Integer> getEnquiryCount(List<String> uids);
+
+  /**
+   * 统计管理的询盘数量
+   */
+  int getEnquiryCount(String uid);
+  
   void addEnquiry(EnquiryDTO enquiryDTO, String plugin, AdwebSite adwebSite);
 
   /** 返回用户名称 */

+ 37 - 26
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/impl/AdwebEnquiryServiceImpl.java

@@ -40,6 +40,7 @@ import org.jeecg.modules.adweb.enquiry.mapper.AdwebEnquiryMapper;
 import org.jeecg.modules.adweb.enquiry.service.*;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
 import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
+import org.jeecg.modules.adweb.site.service.ISiteUserPermissionService;
 import org.jeecg.modules.adweb.system.entity.SysException;
 import org.jeecg.modules.adweb.system.service.IMasterSubAccountRelationService;
 import org.jeecg.modules.adweb.system.service.ISysExceptionService;
@@ -97,6 +98,8 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
 
   @Resource private IAdwebSiteEnquiryRuleService adwebSiteEnquiryRuleService;
 
+  @Resource private ISiteUserPermissionService siteUserPermissionService;
+
   @Resource private IEnquiryEmailMessageService enquiryEmailMessageService;
 
   @Resource private IAdwebSiteService adwebSiteService;
@@ -223,6 +226,28 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
     return blackWordList;
   }
 
+  /** 统计管理的询盘数量 */
+  @Override
+  public Map<String, Integer> getEnquiryCount(List<String> uids) {
+    Map<String, Integer> map = new HashMap<>();
+    List<JSONObject> list = adwebEnquiryMapper.getEnquiryCount(uids);
+    if (CollectionUtils.isNotEmpty(list))
+      for (JSONObject object : list) {
+        map.put(object.getString("uid"), object.getInteger("enquiryCount"));
+      }
+    return map;
+  }
+
+  /** 统计管理的询盘数量 */
+  @Override
+  public int getEnquiryCount(String uid) {
+    List<String> codeList = siteUserPermissionService.getSiteCodeList(uid);
+    QueryWrapper<AdwebEnquiry> queryWrapper = new QueryWrapper<>();
+    queryWrapper.eq("status", 1);
+    queryWrapper.in("site_code", codeList);
+    return (int) this.count(queryWrapper);
+  }
+
   /**
    * 添加询盘
    *
@@ -2068,14 +2093,9 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
     adwebRedisUtil.set(TenMinKey, tenMin, 10 * 60);
 
     if (tenMin > emailTenMinNum) {
-      adwebEnquiry.setWasteEnquiry(1);
-      adwebEnquiry.setUserEffective(0);
-      adwebEnquiry.setWasteEnquiryType("email");
-      adwebEnquiry.setEffectiveReason("系统操作-通过十分钟内重复邮箱检测到垃圾询盘-" + adwebEnquiry.getEmail());
-      log.info(
-          "询盘id是:{}, 站点code是:{}, 通过——十分钟内—重复邮箱—检测到垃圾询盘",
-          adwebEnquiry.getId(),
-          adwebEnquiry.getSiteCode());
+      String reason = String.format("系统操作-通过十分钟内重复邮箱检测到垃圾询盘-" + adwebEnquiry.getEmail());
+      markAsWasteEnquiry(adwebEnquiry, reason, "email");
+      logInfo(adwebEnquiry, reason);
       if (enquirySiteBlackEmailService.count(
               new LambdaQueryWrapper<AdwebSiteBlackEmail>()
                   .eq(AdwebSiteBlackEmail::getEmail, adwebEnquiry.getEmail())
@@ -2085,11 +2105,8 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
           == 0) {
         siteBlackEmailList.add(adwebEnquiry.getEmail());
         blackEmailList.add(adwebEnquiry.getEmail());
-        log.info(
-            "询盘id是:{}, 站点code是:{}, 检测十分钟内重复,已标记邮箱, 邮箱是:{}",
-            adwebEnquiry.getId(),
-            adwebEnquiry.getSiteCode(),
-            adwebEnquiry.getEmail());
+
+        logInfo(adwebEnquiry, "检测十分钟内重复,已标记邮箱, 邮箱是:" + adwebEnquiry.getEmail());
       }
       // 存储到数据库中
       EffectiveEnquiryParamDto effectiveEnquiryParamDto = new EffectiveEnquiryParamDto();
@@ -2113,18 +2130,15 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
     adwebRedisUtil.set(oneDayKey, oneDay, 24 * 60 * 60);
 
     if (oneDay > emailOneDayNum) {
-      adwebEnquiry.setWasteEnquiry(1);
-      adwebEnquiry.setUserEffective(0);
-      adwebEnquiry.setWasteEnquiryType("email");
-      adwebEnquiry.setEffectiveReason("系统操作-通过一天内重复邮箱检测到垃圾询盘-" + adwebEnquiry.getEmail());
-      log.info(
-          "询盘id是:{}, 站点code是:{}, 通过——一天内—重复邮箱—检测到垃圾询盘",
-          adwebEnquiry.getId(),
-          adwebEnquiry.getSiteCode());
+      String reason = String.format("系统操作-通过一天内重复邮箱检测到垃圾询盘-" + adwebEnquiry.getEmail());
+      markAsWasteEnquiry(adwebEnquiry, reason, "email");
+      logInfo(adwebEnquiry, reason);
+
       log.info(
           "'--------dealShortSameEmail -----'===>adwebEnquiry.getEmail():{}",
           adwebEnquiry.getEmail());
       log.info("'--------dealShortSameEmail -----'===>adwebSite.getId():{}", adwebSite.getId());
+
       if (enquirySiteBlackEmailService.count(
               new LambdaQueryWrapper<AdwebSiteBlackEmail>()
                   .eq(AdwebSiteBlackEmail::getEmail, adwebEnquiry.getEmail())
@@ -2134,11 +2148,8 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
           == 0) {
         siteBlackEmailList.add(adwebEnquiry.getEmail());
         blackEmailList.add(adwebEnquiry.getEmail());
-        log.info(
-            "询盘id是:{}, 站点code是:{}, 检测十分钟内重复,已标记邮箱, 邮箱是:{}",
-            adwebEnquiry.getId(),
-            adwebEnquiry.getSiteCode(),
-            adwebEnquiry.getEmail());
+
+        logInfo(adwebEnquiry, "检测一天内内重复,已标记邮箱, 邮箱是:" + adwebEnquiry.getEmail());
       }
       // 存储到数据库中
       EffectiveEnquiryParamDto effectiveEnquiryParamDto = new EffectiveEnquiryParamDto();

+ 38 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/controller/EnterpriseRoleManageController.java

@@ -0,0 +1,38 @@
+package org.jeecg.modules.adweb.enterprise.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import java.util.*;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.system.entity.SysRole;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.service.ISysRoleService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @Description: 企业角色管理 @Author: jeecg-boot @Date: 2022-06-13 @Version: V1.0
+ */
+@Tag(name = "企业角色管理")
+@RestController
+@RequestMapping("/enterprise/role")
+@Slf4j
+public class EnterpriseRoleManageController {
+  @Autowired private ISysRoleService sysRoleService;
+
+  @RequestMapping(value = "/queryall", method = RequestMethod.GET)
+  public Result<List<SysRole>> queryall(SysUser user) {
+    Result<List<SysRole>> result = new Result<>();
+    QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
+    queryWrapper.eq("role_code", "adweb_sub_vip").or().eq("create_by", user.getUsername());
+    List<SysRole> list = sysRoleService.list(queryWrapper);
+    if (list == null || list.size() <= 0) {
+      result.error500("未找到角色信息");
+    } else {
+      result.setResult(list);
+      result.setSuccess(true);
+    }
+    return result;
+  }
+}

+ 645 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/controller/EnterpriseUserManageController.java

@@ -0,0 +1,645 @@
+package org.jeecg.modules.adweb.enterprise.controller;
+
+import static org.jeecg.modules.adweb.site.service.impl.AdwebSiteServiceImpl.generateRandomEmail;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletRequest;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.util.*;
+import java.util.stream.Collectors;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.DictPropertyModel;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.FastJsonUtil;
+import org.jeecg.common.util.PasswordUtil;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.config.RestTemplateConfig;
+import org.jeecg.modules.adweb.common.constant.AdwebConstant;
+import org.jeecg.modules.adweb.common.constant.NumConstant;
+import org.jeecg.modules.adweb.common.dto.CommonDto;
+import org.jeecg.modules.adweb.common.mapper.CommonMapper;
+import org.jeecg.modules.adweb.common.service.FeishuService;
+import org.jeecg.modules.adweb.common.util.MD5Util;
+import org.jeecg.modules.adweb.enquiry.entity.AdwebEnquiry;
+import org.jeecg.modules.adweb.enquiry.service.IAdwebEnquiryService;
+import org.jeecg.modules.adweb.enquiry.service.ISubUserEmailService;
+import org.jeecg.modules.adweb.enterprise.dto.CreateUserParam;
+import org.jeecg.modules.adweb.enterprise.dto.EditPermissionParam;
+import org.jeecg.modules.adweb.enterprise.service.SysUserPermissionService;
+import org.jeecg.modules.adweb.enterprise.vo.User;
+import org.jeecg.modules.adweb.site.entity.AdwebSite;
+import org.jeecg.modules.adweb.site.entity.AdwebSiteUserPermission;
+import org.jeecg.modules.adweb.site.entity.AdwebUserWpsite;
+import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
+import org.jeecg.modules.adweb.site.service.IAdwebUserWpsiteService;
+import org.jeecg.modules.adweb.site.service.ISiteUserPermissionService;
+import org.jeecg.modules.adweb.system.entity.MasterSubAccountRelation;
+import org.jeecg.modules.adweb.system.service.IMasterSubAccountRelationService;
+import org.jeecg.modules.adweb.system.service.SysAdwebApi;
+import org.jeecg.modules.system.entity.SysPermission;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.service.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * @Description: 企业用户管理 @Author: jeecg-boot @Date: 2022-06-10 @Version: V1.0
+ */
+@Tag(name = "企业用户管理")
+@RestController
+@RequestMapping("/enterprise/user")
+@Slf4j
+public class EnterpriseUserManageController {
+  @Autowired private ISysUserService sysUserService;
+
+  @Autowired private IMasterSubAccountRelationService masterSubAccountRelationService;
+
+  @Autowired private ISysRoleService sysRoleService;
+
+  @Autowired private ISysUserRoleService sysUserRoleService;
+
+  @Autowired private ISiteUserPermissionService siteUserPermissionService;
+
+  @Autowired private IAdwebSiteService adwebSiteService;
+
+  @Resource private SysUserPermissionService sysUserPermissionService;
+
+  @Resource private CommonMapper adwebCommonMapper;
+
+  @Resource private IAdwebEnquiryService adwebEnquiryService;
+
+  @Resource private SysAdwebApi sysAdwebApi;
+
+  @Autowired private IAdwebUserWpsiteService adwebUserWpsiteService;
+
+  @Autowired private ISubUserEmailService subUserEmailService;
+
+  @Resource private FeishuService openFeishuMsgService;
+
+  @AutoLog(value = "企业用户管理-分页列表查询")
+  @Operation(summary = "企业用户管理-分页列表查询")
+  @GetMapping(value = "/list")
+  public Result<IPage<User>> queryPageList(
+      SysUser user,
+      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+      HttpServletRequest req) {
+    Map<String, String[]> map = new HashMap(req.getParameterMap());
+    map.put("order", new String[] {"asc"});
+
+    LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    List<String> idList =
+        masterSubAccountRelationService.getSubAccountIdByMaster(loginUser.getId());
+    idList.add(loginUser.getId());
+
+    if (CollectionUtils.isEmpty(idList)) {
+      return Result.OK();
+    }
+
+    QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, map);
+    queryWrapper.ne("username", "_reserve_user_external");
+    queryWrapper.in("id", idList);
+    queryWrapper.eq("status", 1);
+    String queryCondition = req.getParameter("queryCondition");
+    if (StringUtils.isNotBlank(queryCondition)) {
+      queryWrapper.and(
+          wrapper ->
+              wrapper
+                  .like("username", queryCondition)
+                  .or()
+                  .like("realname", queryCondition)
+                  .or()
+                  .like("phone", queryCondition));
+    }
+    Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
+    IPage<SysUser> pageList = sysUserService.page(page, queryWrapper);
+    // 类型转换
+    IPage<User> pageList2 = converseType(pageList);
+    // 序号
+    this.addSeqNumber(pageList2.getRecords(), pageNo, pageSize);
+    // 统计管理的询盘和产品数量
+    Map<String, Integer> map1 = adwebEnquiryService.getEnquiryCount(idList);
+    //    Map<String, Integer> map2 = adwebMaterialProductService.getProductCount(idList);
+    for (User user1 : pageList2.getRecords()) {
+      if (map1.get(user1.getId()) != null) {
+        user1.setEnquiryNum(map1.get(user1.getId()));
+      }
+      //      if (map2.get(user1.getId()) != null) {
+      //        user1.setProductNum(map2.get(user1.getId()));
+      //      }
+    }
+    // 主账户产品和询盘数量统计规则不同
+    if (pageNo == 1) {
+      User user1 = pageList2.getRecords().get(0);
+      user1.setPrimaryAccount(true);
+      user1.setEnquiryNum(adwebEnquiryService.getEnquiryCount(user1.getId()));
+      //      user1.setProductNum(adwebMaterialProductService.getProductCount(user1.getId()));
+    }
+    return Result.OK(pageList2);
+  }
+
+  /**
+   * 添加
+   *
+   * @param param 用户的相关信息
+   */
+  @AutoLog(value = "企业用户管理-添加")
+  @Operation(summary = "企业用户管理-添加")
+  @PostMapping(value = "/add")
+  public Result<SysUser> add(@RequestBody CreateUserParam param) {
+    Result<SysUser> result = new Result<SysUser>();
+
+    List<DictPropertyModel> siteRes = sysAdwebApi.queryDictInfoByDictCode("turn_inquiry_site_code");
+    // 判断特殊站点
+    if (CollectionUtils.isNotEmpty(siteRes)
+        && StringUtils.isNotBlank(param.getSiteCode())
+        && siteRes.get(0).getValue().equals(param.getSiteCode())) {
+      if (StringUtils.isEmpty(param.getEmail())) {
+        return result.error500("邮箱不可为空!");
+      }
+      // 获取主账号
+      if (StringUtils.isNotEmpty(param.getMasterId())) {
+        SysUser sysUser = sysUserService.getById(param.getMasterId());
+        // 通过主账号id获取子账号id集合
+        List<String> idList =
+            masterSubAccountRelationService.getSubAccountIdByMaster(sysUser.getId());
+        idList.add(sysUser.getId());
+        if (CollectionUtils.isNotEmpty(idList)) {
+          List<String> emailList = sysUserService.getEmailBySubIdList(idList);
+          // 判断 sysUser 的电子邮件是否存在于 emailList 中
+          boolean emailExists = emailList.contains(param.getEmail());
+          if (emailExists) {
+            return result.error500("邮箱不可重复!");
+          }
+        }
+      }
+    }
+    param.setUsername(param.getUsername().trim());
+    param.setRealname(param.getRealname().trim());
+
+    LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    String masterId = sysUser.getId();
+    String masterName = sysUser.getUsername();
+    String masterEmail = sysUser.getEmail();
+    List<Integer> siteIds = adwebSiteService.getAllSiteIdByUid(masterId);
+
+    if (StringUtils.isNotEmpty(param.getEmail())) {
+      if (param.getEmail().equals(masterEmail)) {
+        return result.error500("子账户邮箱不可以与主账户邮箱一致。");
+      }
+      QueryWrapper<AdwebSite> queryWrapper = new QueryWrapper<>();
+      List<String> codeList = siteUserPermissionService.getSiteCodeList(param.getMasterId());
+      queryWrapper.in("code", codeList);
+      queryWrapper.ne("status", AdwebConstant.SITE_DEL).isNull("parent_group_code");
+      List<AdwebSite> siteList = adwebSiteService.list(queryWrapper);
+      if (CollectionUtils.isNotEmpty(siteList)) {
+        for (AdwebSite adwebSite : siteList) {
+          String emailStr = adwebSite.getEnquiryEmailList();
+          if (StringUtils.isNotEmpty(emailStr)) {
+            List<String> emailList = FastJsonUtil.parseList(emailStr, String.class);
+            for (String email : emailList) {
+              if (email.equals(param.getEmail())) {
+                return result.error500("子账户邮箱不可以与站点询盘配置邮箱一致。");
+              }
+            }
+          }
+        }
+      }
+    }
+
+    try {
+      // 创建子账户
+      SysUser user = new SysUser();
+      user.setUsername(param.getUsername());
+      user.setRealname(param.getRealname());
+      user.setPhone(param.getPhone());
+      String randomEmail = generateRandomEmail();
+      if (param.getSex() != null) {
+        user.setSex(param.getSex());
+      }
+      if (StringUtils.isNotEmpty(param.getEmail())) {
+        user.setEmail(param.getEmail());
+      } else {
+        user.setEmail(randomEmail);
+      }
+
+      user.setAvatar(param.getAvatar());
+      user.setCreateTime(new Date());
+      user.setUpdateTime(new Date());
+      String salt = oConvertUtils.randomGen(8);
+      user.setSalt(salt);
+      String passwordEncode = PasswordUtil.encrypt(param.getUsername(), param.getPassword(), salt);
+      user.setPassword(passwordEncode);
+      user.setStatus(1);
+      user.setDelFlag(CommonConstant.DEL_FLAG_0);
+      user.setHasMasterAccount(CommonConstant.HAS_MASTER_ACCOUNT);
+      String roleId = sysRoleService.getRoleIdByRoleCode("adweb_sub_vip");
+      String relTenantIds = param.getRelTenantIds();
+      sysUserService.saveUser(user, roleId, "", relTenantIds);
+
+      // 创建父子关系
+      MasterSubAccountRelation relation = new MasterSubAccountRelation();
+      relation.setMasterId(masterId);
+      relation.setSubId(user.getId());
+      relation.setMasterName(masterName);
+      relation.setSubName(user.getUsername());
+      relation.setStatus(1);
+      masterSubAccountRelationService.insertAccountRelation(relation);
+
+      // 创建子账户和站点的关系
+      List<AdwebSiteUserPermission> subPermissionList = new ArrayList<>();
+      List<AdwebSiteUserPermission> masterPermissionList =
+          siteUserPermissionService.getPermissionCode(sysUser.getId());
+      for (AdwebSiteUserPermission masterPermission : masterPermissionList) {
+        AdwebSiteUserPermission subPermission = new AdwebSiteUserPermission();
+        subPermission.setUid(user.getId());
+        subPermission.setPermissionCode(masterPermission.getPermissionCode());
+        subPermission.setStatus(masterPermission.getStatus());
+        subPermission.setCreateTime(new Date());
+        subPermissionList.add(subPermission);
+      }
+      siteUserPermissionService.saveBatch(subPermissionList);
+
+      // 给子账户创建权限
+      List<SysPermission> list = adwebCommonMapper.getAdwebVipPermission();
+      List<String> ids = list.stream().map(SysPermission::getId).collect(Collectors.toList());
+      String permissionIds = String.join(",", ids);
+      EditPermissionParam editPermissionParam = new EditPermissionParam();
+      editPermissionParam.setUserId(user.getId());
+      editPermissionParam.setPermissionIds(permissionIds);
+      this.saveRolePermission(editPermissionParam);
+
+      List<CommonDto> errorResults = new ArrayList<>();
+      for (Integer siteId : siteIds) {
+        AdwebSite adwebSite = adwebSiteService.getById(siteId);
+        int userAccount = 2;
+        if (StringUtils.isNotEmpty(adwebSite.getWordpressSetting())) {
+          JsonObject asJsonObject =
+              JsonParser.parseString(adwebSite.getWordpressSetting()).getAsJsonObject();
+          if (adwebSite.getWordpressSetting().contains("userAccount")) {
+            userAccount = asJsonObject.get("userAccount").getAsInt();
+          }
+        }
+
+        if (userAccount == 1 && adwebSite.getCreateType().equals("wp")) {
+          log.info("检查环境配置");
+          String checkUserRoleUrl =
+              adwebSite.getDomain() + "/wp-json/check_user_role_plugin_active/v2";
+          log.info(checkUserRoleUrl);
+
+          MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
+          HttpHeaders headers = new HttpHeaders();
+          headers.add("Content-Type", "application/json");
+          headers.add(
+              "user-agent",
+              "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36");
+          HttpEntity<MultiValueMap> httpEntity = new HttpEntity<>(paramMap, headers);
+
+          RestTemplate restTemplate = null;
+          try {
+            restTemplate = new RestTemplate(RestTemplateConfig.generateHttpRequestFactory());
+          } catch (NoSuchAlgorithmException e) {
+            log.info("忽略SSL证书异常:{}", e.getMessage());
+          } catch (KeyManagementException | KeyStoreException e) {
+            log.info("忽略SSL证书异常:{}", e.getMessage());
+          }
+          ResponseEntity<String> checkPluginResponseEntity = null;
+          try {
+            // 获取响应结果
+            if (restTemplate != null) {
+              checkPluginResponseEntity =
+                  restTemplate.exchange(checkUserRoleUrl, HttpMethod.GET, httpEntity, String.class);
+            }
+
+            String checkPluginResponse = checkPluginResponseEntity.getBody();
+            // 获取响应结果
+            JsonObject checkJsonObject = null;
+            if (checkPluginResponse != null) {
+              checkJsonObject = JsonParser.parseString(checkPluginResponse).getAsJsonObject();
+            }
+            String checkCode = checkJsonObject.get("code").getAsString();
+            String checkMsg = checkJsonObject.get("msg").getAsString();
+            if (!checkCode.equals("200")) {
+              CommonDto commonDto = new CommonDto();
+              commonDto.setType("检测插件状态");
+              commonDto.setSiteName(adwebSite.getName());
+              commonDto.setSiteCode(adwebSite.getCode());
+              commonDto.setMsg(checkMsg);
+              commonDto.setCode(Integer.parseInt(checkCode));
+              errorResults.add(commonDto);
+              log.info(checkCode + ":" + checkMsg);
+              continue;
+            } else {
+              log.info("wordpress新增子账户");
+              String url = adwebSite.getDomain() + "/wp-json/add_user/v2/";
+              log.info(url);
+              String username = param.getUsername();
+              String md5Username = MD5Util.byte2Md5(username.getBytes(StandardCharsets.UTF_8));
+              Map<String, String> map = new HashMap<>();
+              map.put("username", md5Username);
+              map.put("password", "IFQam6zx^A3DfyHqDlhWuxT1");
+              map.put("email", user.getEmail());
+              map.put("nickname", param.getRealname());
+              map.put("type", "adweb_user_sub");
+
+              AdwebUserWpsite adwebUserWpsite = new AdwebUserWpsite();
+              adwebUserWpsite.setSiteId(siteId);
+              adwebUserWpsite.setUid(user.getId());
+              adwebUserWpsite.setUsername(username);
+              adwebUserWpsite.setWpUsername(md5Username);
+              adwebUserWpsite.setStatus(NumConstant.ONE);
+              adwebUserWpsite.setUpdateTime(new Date());
+              adwebUserWpsite.setWpUserpwd("IFQam6zx^A3DfyHqDlhWuxT1");
+              adwebUserWpsite.setWpUserrole("adweb_user_sub");
+
+              // 将Map转换为URL编码的请求体
+              Gson gson = new Gson();
+              String json = gson.toJson(map);
+              log.info(json);
+              HttpEntity<String> httpEntityAdd = new HttpEntity<>(json, headers);
+              ResponseEntity<String> response = null;
+              try {
+                response = restTemplate.exchange(url, HttpMethod.POST, httpEntityAdd, String.class);
+                String responseBody = response.getBody();
+                if (StringUtils.isNoneEmpty(responseBody)) {
+                  JsonObject jsonObject = JsonParser.parseString(responseBody).getAsJsonObject();
+                  String code = jsonObject.get("code").getAsString();
+                  String msg = jsonObject.get("msg").getAsString();
+                  CommonDto commonDto = new CommonDto();
+                  commonDto.setType("新增wordpress用户信息");
+                  commonDto.setSiteName(adwebSite.getName());
+                  commonDto.setSiteCode(adwebSite.getCode());
+                  commonDto.setMsg(msg);
+                  commonDto.setCode(Integer.parseInt(code));
+                  errorResults.add(commonDto);
+                  if (!code.equals("200")) {
+                    log.info(code + ":" + msg);
+                    continue;
+                  } else {
+                    adwebUserWpsiteService.save(adwebUserWpsite);
+                    log.info("wordpress新增子账户成功");
+                  }
+                } else {
+                  CommonDto commonDto = new CommonDto();
+                  commonDto.setType("wordpress新增子账户失败");
+                  commonDto.setSiteName(adwebSite.getName());
+                  commonDto.setSiteCode(adwebSite.getCode());
+                  commonDto.setMsg("wordpress新增子账户失败:");
+                  errorResults.add(commonDto);
+                  log.info("wordpress新增子账户失败");
+                }
+              } catch (Exception e) {
+                CommonDto commonDto = new CommonDto();
+                commonDto.setType("请求新增wordpress用户接口失败");
+                commonDto.setSiteName(adwebSite.getName());
+                commonDto.setSiteCode(adwebSite.getCode());
+                commonDto.setMsg("请求新增wordpress用户接口失败:" + e.getMessage().replaceAll("\"", ""));
+                errorResults.add(commonDto);
+                log.info("请求新增wordpress用户接口失败:{}", e.getMessage());
+              }
+            }
+          } catch (Exception e) {
+            CommonDto commonDto = new CommonDto();
+            commonDto.setType("请求wordpress检测环境接口失败");
+            commonDto.setSiteName(adwebSite.getName());
+            commonDto.setSiteCode(adwebSite.getCode());
+            commonDto.setMsg("请求wordpress检测环境接口失败" + e.getMessage().replaceAll("\"", ""));
+            errorResults.add(commonDto);
+            log.info("请求wordpress检测环境接口失败{}", e.getMessage());
+          }
+        }
+      }
+
+      if (CollectionUtils.isNotEmpty(errorResults)) {
+        String title = "WordPress网站主账户新增子账户:" + param.getRealname();
+        String message = "";
+        for (CommonDto item : errorResults) {
+          message += "**站点名称:**" + item.getSiteName() + "\n";
+          if (item.getSiteCode() != null) {
+            message += "**站点code:**" + item.getSiteCode() + "\n";
+          }
+          message += "**类型:**" + item.getType() + "\n";
+          message += "**信息:**" + item.getMsg() + "\n";
+          if (item.getCode() != null) {
+            message += "**code:**" + item.getCode() + "\n";
+          }
+          message += "\n";
+        }
+        try {
+          openFeishuMsgService.sendAdWebV3FeiShuMsg(title, message);
+        } catch (NoSuchAlgorithmException | InvalidKeyException e) {
+          throw new RuntimeException(e);
+        }
+      }
+      subUserEmailService.removeAll();
+      result.success("添加成功!");
+    } catch (Exception e) {
+      log.error(e.getMessage(), e);
+      result.error500("操作失败");
+    }
+    return result;
+  }
+
+  /**
+   * 子账户分页列表查询
+   *
+   * @param user
+   * @param pageNo
+   * @param pageSize
+   * @param req
+   * @return
+   */
+  @AutoLog(value = "企业用户管理-子账户分页列表查询")
+  @Operation(summary = "企业用户管理-子账户分页列表查询")
+  @GetMapping(value = "/sub/list")
+  public Result<IPage<User>> querySubPageList(
+      SysUser user,
+      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+      @RequestParam String siteCode,
+      HttpServletRequest req) {
+    Map<String, String[]> map = new HashMap(req.getParameterMap());
+    map.put("order", new String[] {"asc"});
+
+    LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    List<String> idList =
+        masterSubAccountRelationService.getSubAccountIdByMaster(loginUser.getId());
+    // 获取当前站点主账号
+    QueryWrapper<AdwebSite> adwebSiteQueryWrapper = new QueryWrapper<>();
+    adwebSiteQueryWrapper.eq("code", siteCode);
+    AdwebSite adwebSite = adwebSiteService.getOne(adwebSiteQueryWrapper);
+    if (adwebSite != null) {
+      idList.add(adwebSite.getUid());
+    }
+    //        idList.add(loginUser.getId());
+    if (CollectionUtils.isEmpty(idList)) {
+      return Result.OK();
+    }
+    QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, map);
+    queryWrapper.ne("username", "_reserve_user_external");
+    queryWrapper.in("id", idList);
+    queryWrapper.eq("status", 1);
+    String queryCondition = req.getParameter("queryCondition");
+    if (StringUtils.isNotEmpty(queryCondition)) {
+      queryWrapper.and(
+          wrapper ->
+              wrapper
+                  .like("username", queryCondition)
+                  .or()
+                  .like("realname", queryCondition)
+                  .or()
+                  .like("phone", queryCondition));
+    }
+    Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
+    IPage<SysUser> pageList = sysUserService.page(page, queryWrapper);
+    // 类型转换
+    IPage<User> pageList2 = converseType(pageList);
+    // 序号
+    this.addSeqNumber(pageList2.getRecords(), pageNo, pageSize);
+    // 统计管理的询盘和产品数量
+    /*Map<String, Integer> map1 = adwebEnquiryService.getEnquiryCount(idList);
+    Map<String, Integer> map2 = adwebMaterialProductService.getProductCount(idList);
+    for (User user1 : pageList2.getRecords()) {
+        if (map1.get(user1.getId()) != null) {
+            user1.setEnquiryNum(map1.get(user1.getId()));
+        }
+        if (map2.get(user1.getId()) != null) {
+            user1.setProductNum(map2.get(user1.getId()));
+        }
+    }*/
+    // 主账户产品和询盘数量统计规则不同
+    if (pageNo == 1 && CollectionUtils.isNotEmpty(pageList2.getRecords())) {
+      User user1 = pageList2.getRecords().get(0);
+      if (user1.getId().equals(adwebSite.getUid())) {
+        user1.setPrimaryAccount(true);
+        user1.setIsInquiry(2);
+      }
+    }
+    return Result.OK(pageList2);
+  }
+
+  /** 保存角色授权 */
+  @RequestMapping(value = "/saveRolePermission", method = RequestMethod.POST)
+  public Result saveRolePermission(@RequestBody EditPermissionParam param) {
+    String userId = param.getUserId();
+    String permissionIds = param.getPermissionIds();
+    try {
+      sysUserPermissionService.editUserPermission(userId, permissionIds);
+      return Result.OK("保存成功!");
+    } catch (Exception e) {
+      log.error(e.getMessage(), e);
+      return Result.error("授权失败!");
+    }
+  }
+
+  /** 冻结&解冻用户 */
+  @RequestMapping(value = "/frozen", method = RequestMethod.PUT)
+  public Result<SysUser> frozenBatch(@RequestBody JSONObject jsonObject) {
+    Result<SysUser> result = new Result<SysUser>();
+    try {
+      String ids = jsonObject.getString("ids");
+      String status = jsonObject.getString("status");
+      String[] arr = ids.split(",");
+      for (String id : arr) {
+        if (oConvertUtils.isNotEmpty(id)) {
+          this.sysUserService.update(
+              new SysUser().setStatus(Integer.parseInt(status)),
+              new UpdateWrapper<SysUser>().lambda().eq(SysUser::getId, id));
+          // 获取该子账户的主账户
+          QueryWrapper<MasterSubAccountRelation> queryWrapper1 = new QueryWrapper<>();
+          queryWrapper1.eq("sub_id", id);
+          List<MasterSubAccountRelation> masterSubAccountRelationList =
+              masterSubAccountRelationService.list(queryWrapper1);
+          String masterUid = null;
+          if (CollectionUtils.isNotEmpty(masterSubAccountRelationList)) {
+            masterUid = masterSubAccountRelationList.get(0).getMasterId();
+            // 把原本跟进人改成主账户
+            this.adwebEnquiryService.update(
+                new AdwebEnquiry().setPrincipalUid(masterUid),
+                new UpdateWrapper<AdwebEnquiry>().lambda().eq(AdwebEnquiry::getPrincipalUid, id));
+          }
+        }
+      }
+    } catch (Exception e) {
+      log.error(e.getMessage(), e);
+      result.error500("操作失败" + e.getMessage());
+    }
+    subUserEmailService.removeAll();
+    result.success("操作成功!");
+    return result;
+  }
+
+  private IPage<User> converseType(IPage<SysUser> pageList) {
+    IPage<User> pageList2 = new Page<>();
+    pageList2.setPages(pageList.getPages());
+    pageList2.setCurrent(pageList.getCurrent());
+    pageList2.setSize(pageList.getSize());
+    pageList2.setTotal(pageList.getTotal());
+    if (CollectionUtils.isEmpty(pageList.getRecords())) {
+      pageList2.setRecords(new ArrayList<>());
+      return pageList2;
+    }
+    List<User> users = new ArrayList<>();
+    for (SysUser sysUser : pageList.getRecords()) {
+      User user = new User();
+      user.setId(sysUser.getId());
+      user.setUsername(sysUser.getUsername());
+      user.setRealname(sysUser.getRealname());
+      user.setAvatar(sysUser.getAvatar());
+      user.setPhone(sysUser.getPhone());
+      user.setEmail(sysUser.getEmail());
+      user.setUpdateTime(sysUser.getUpdateTime());
+      user.setCreateTime(sysUser.getCreateTime());
+      //      user.setIsInquiry(sysUser.getIsInquiry());
+      user.setSex(sysUser.getSex());
+      users.add(user);
+    }
+    pageList2.setRecords(users);
+    return pageList2;
+  }
+
+  /**
+   * 增加序号
+   *
+   * @param productList 结果集合
+   * @param pageNum 页号
+   * @param pageSize 页长
+   */
+  public void addSeqNumber(List<User> productList, int pageNum, int pageSize) {
+    if (CollectionUtils.isEmpty(productList)) {
+      return;
+    }
+    int index = (pageNum - 1) * pageSize + 1;
+    for (User user : productList) {
+      user.setSeqNumber(index++);
+    }
+  }
+}

+ 34 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/dto/CreateUserParam.java

@@ -0,0 +1,34 @@
+package org.jeecg.modules.adweb.enterprise.dto;
+
+import lombok.Data;
+
+/** 请求创建用户的参数 */
+@Data
+public class CreateUserParam {
+
+  private String id;
+
+  private String username;
+
+  private String realname;
+
+  private String password;
+
+  private String phone;
+
+  private String email;
+
+  private String avatar;
+
+  private String masterId;
+
+  private String masterName;
+
+  private String masterEmail;
+
+  private String siteCode;
+
+  private Integer sex;
+
+  private String relTenantIds;
+}

+ 11 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/dto/EditPermissionParam.java

@@ -0,0 +1,11 @@
+package org.jeecg.modules.adweb.enterprise.dto;
+
+import lombok.Data;
+
+@Data
+public class EditPermissionParam {
+
+  private String userId;
+
+  private String permissionIds;
+}

+ 43 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/entity/AdwebSysUserPermission.java

@@ -0,0 +1,43 @@
+package org.jeecg.modules.adweb.enterprise.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+/** 子用户权限表 */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class AdwebSysUserPermission implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  /** id */
+  @TableId(type = IdType.AUTO)
+  private Integer id;
+
+  /** 用户id */
+  private String userId;
+
+  /** 权限id */
+  private String permissionId;
+
+  /** 操作时间 */
+  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+  private Date createTime;
+
+  public AdwebSysUserPermission() {}
+
+  public AdwebSysUserPermission(String userId, String permissionId) {
+    this.userId = userId;
+    this.permissionId = permissionId;
+    this.createTime = new Date();
+  }
+}

+ 6 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/mapper/AdwebSysUserPermissionMapper.java

@@ -0,0 +1,6 @@
+package org.jeecg.modules.adweb.enterprise.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.adweb.enterprise.entity.AdwebSysUserPermission;
+
+public interface AdwebSysUserPermissionMapper extends BaseMapper<AdwebSysUserPermission> {}

+ 24 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/service/SysUserPermissionService.java

@@ -0,0 +1,24 @@
+package org.jeecg.modules.adweb.enterprise.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import java.util.List;
+import org.jeecg.modules.adweb.enterprise.entity.AdwebSysUserPermission;
+import org.jeecg.modules.system.entity.SysPermission;
+
+public interface SysUserPermissionService extends IService<AdwebSysUserPermission> {
+
+  /**
+   * 删除原有权限,赋予新的权限
+   *
+   * @param userId 用户id
+   * @param permissionIds 给用户分配的权限
+   */
+  void editUserPermission(String userId, String permissionIds);
+
+  /**
+   * 获取用户菜单权限
+   *
+   * @param userId 用户id
+   */
+  List<SysPermission> getPermissionsByUserId(String userId);
+}

+ 96 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/service/impl/SysUserPermissionServiceImpl.java

@@ -0,0 +1,96 @@
+package org.jeecg.modules.adweb.enterprise.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import jakarta.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.jeecg.modules.adweb.enterprise.entity.AdwebSysUserPermission;
+import org.jeecg.modules.adweb.enterprise.mapper.AdwebSysUserPermissionMapper;
+import org.jeecg.modules.adweb.enterprise.service.SysUserPermissionService;
+import org.jeecg.modules.system.entity.SysPermission;
+import org.jeecg.modules.system.service.ISysPermissionService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+public class SysUserPermissionServiceImpl
+    extends ServiceImpl<AdwebSysUserPermissionMapper, AdwebSysUserPermission>
+    implements SysUserPermissionService {
+
+  @Resource private ISysPermissionService sysPermissionService;
+
+  /**
+   * 删除原有权限,赋予新的权限
+   *
+   * @param userId 用户id
+   * @param permissionIds 给用户分配的权限
+   */
+  @Override
+  @Transactional
+  public void editUserPermission(String userId, String permissionIds) {
+    QueryWrapper<AdwebSysUserPermission> queryWrapper = new QueryWrapper<>();
+    queryWrapper.eq("user_id", userId);
+    this.remove(queryWrapper);
+
+    List<AdwebSysUserPermission> permissions = new ArrayList<>();
+    String[] permissionIdArr = permissionIds.split(",");
+    for (String permissionId : permissionIdArr) {
+      permissions.add(new AdwebSysUserPermission(userId, permissionId));
+    }
+    // 如果没有首页权限,要增加首页权限
+    SysPermission indexMenu =
+        sysPermissionService
+            .list(new LambdaQueryWrapper<SysPermission>().eq(SysPermission::getName, "首页"))
+            .get(0);
+    if (!permissionIds.contains(indexMenu.getId())) {
+      permissions.add(new AdwebSysUserPermission(userId, indexMenu.getId()));
+    }
+    // 以下两个菜单为默认拥有的权限
+    //    List<SysPermission> fatherPermission =
+    //        sysPermissionService.list(
+    //            new LambdaQueryWrapper<SysPermission>()
+    //                .in(SysPermission::getUrl, Arrays.asList("/account", "/tools")));
+    //
+    //    List<String> fatherPermissionIds =
+    //        fatherPermission.stream().map(SysPermission::getId).collect(Collectors.toList());
+    //
+    //    List<SysPermission> subPermission =
+    //        sysPermissionService.list(
+    //            new LambdaQueryWrapper<SysPermission>()
+    //                .in(SysPermission::getParentId, fatherPermissionIds));
+
+    //    for (SysPermission permission : fatherPermission) {
+    //      permissions.add(new AdwebSysUserPermission(userId, permission.getId()));
+    //    }
+    //    for (SysPermission permission : subPermission) {
+    //      permissions.add(new AdwebSysUserPermission(userId, permission.getId()));
+    //    }
+    this.saveBatch(permissions);
+  }
+
+  /**
+   * 获取用户菜单权限
+   *
+   * @param userId 用户id
+   */
+  @Override
+  public List<SysPermission> getPermissionsByUserId(String userId) {
+    QueryWrapper<AdwebSysUserPermission> queryWrapper = new QueryWrapper<>();
+    queryWrapper.eq("user_id", userId);
+    List<AdwebSysUserPermission> permissions = this.list(queryWrapper);
+
+    List<String> ids =
+        permissions.stream()
+            .map(AdwebSysUserPermission::getPermissionId)
+            .collect(Collectors.toList());
+    QueryWrapper<SysPermission> permissionQueryWrapper = new QueryWrapper<>();
+    permissionQueryWrapper.in("id", ids);
+    permissionQueryWrapper.eq("del_flag", 0);
+    permissionQueryWrapper.orderByAsc("sort_no");
+    return sysPermissionService.list(permissionQueryWrapper);
+  }
+}

+ 35 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enterprise/vo/User.java

@@ -0,0 +1,35 @@
+package org.jeecg.modules.adweb.enterprise.vo;
+
+import java.util.Date;
+import lombok.Data;
+
+@Data
+public class User {
+
+  private String id;
+
+  private String username;
+
+  private String realname;
+
+  private String avatar;
+
+  private String phone;
+
+  private String email;
+
+  private Date updateTime;
+
+  private Date createTime;
+
+  private boolean isPrimaryAccount;
+
+  private int productNum;
+
+  private int EnquiryNum;
+
+  private int seqNumber;
+
+  private Integer isInquiry;
+  private Integer sex;
+}

+ 6 - 9
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/ISiteUserPermissionService.java

@@ -1,22 +1,19 @@
 package org.jeecg.modules.adweb.site.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import org.jeecg.modules.adweb.site.entity.AdwebSiteUserPermission;
-
 import java.util.List;
+import org.jeecg.modules.adweb.site.entity.AdwebSiteUserPermission;
 
 /**
- * @Description: 站点权限表
- * @Author: liang
- * @Date: 2022-08-09
- * @Version: V1.0
+ * @Description: 站点权限表 @Author: liang @Date: 2022-08-09 @Version: V1.0
  */
 public interface ISiteUserPermissionService extends IService<AdwebSiteUserPermission> {
 
-    List<String> getSiteCodeList(String uid);
+  List<String> getSiteCodeList(String uid);
 
-    List<String> getSiteCodeListByUids(List<String> list);
+  List<String> getSiteCodeListByUids(List<String> list);
 
-    void insertSiteUserPermission(String uid, String siteCode, String siteName);
+  void insertSiteUserPermission(String uid, String siteCode, String siteName);
 
+  List<AdwebSiteUserPermission> getPermissionCode(String uid);
 }

+ 232 - 231
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/impl/AdwebSiteServiceImpl.java

@@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xkcoding.http.util.StringUtil;
-
 import jakarta.annotation.Resource;
-
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.shiro.SecurityUtils;
@@ -31,270 +33,269 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
 /**
- * @Description: adweb站点配置表单
- * @Author: jeecg-boot
- * @Date: 2024-09-29
- * @Version: V1.0
+ * @Description: adweb站点配置表单 @Author: jeecg-boot @Date: 2024-09-29 @Version: V1.0
  */
 @Service
 public class AdwebSiteServiceImpl extends ServiceImpl<AdwebSiteMapper, AdwebSite>
-        implements IAdwebSiteService {
+    implements IAdwebSiteService {
 
-    @Resource private SysUserRoleMapper sysUserRoleMapper;
+  @Resource private SysUserRoleMapper sysUserRoleMapper;
 
-    @Autowired private IAdwebUserWpsiteService adwebUserWpsiteService;
+  @Autowired private IAdwebUserWpsiteService adwebUserWpsiteService;
 
-    @Autowired private ISiteUserPermissionService siteUserPermissionService;
+  @Autowired private ISiteUserPermissionService siteUserPermissionService;
 
-    @Lazy @Resource private IMasterSubAccountRelationService masterSubAccountRelationService;
+  @Lazy @Resource private IMasterSubAccountRelationService masterSubAccountRelationService;
 
-    @Resource private ISysBaseAPI sysBaseAPI;
+  @Resource private ISysBaseAPI sysBaseAPI;
 
-    private final RedisUtil redisUtil;
+  private final RedisUtil redisUtil;
 
-    public AdwebSiteServiceImpl(RedisUtil redisUtil) {
-        this.redisUtil = redisUtil;
-    }
+  public AdwebSiteServiceImpl(RedisUtil redisUtil) {
+    this.redisUtil = redisUtil;
+  }
 
-    /**
-     * 查询wordpress站点配置
-     *
-     * @param siteCode
-     */
-    @Override
-    public WordPressConfig queryWordPressConfig(String siteCode) {
-        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        WordPressConfig config = new WordPressConfig();
-        if (StringUtils.isBlank(siteCode)) {
-            return config;
+  /**
+   * 查询wordpress站点配置
+   *
+   * @param siteCode
+   */
+  @Override
+  public WordPressConfig queryWordPressConfig(String siteCode) {
+    LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    WordPressConfig config = new WordPressConfig();
+    if (StringUtils.isBlank(siteCode)) {
+      return config;
+    }
+    try {
+      List<AdwebSite> list =
+          this.list(new LambdaQueryWrapper<AdwebSite>().eq(AdwebSite::getCode, siteCode));
+      if (!list.isEmpty()) {
+        AdwebSite adwebSite = list.get(0);
+        BeanUtils.copyProperties(adwebSite, config);
+        // 开启WP&未上线站点
+        if (adwebSite.getStatus() == NumConstant.TWO.intValue()) {
+          String domainDev = adwebSite.getDomainDev();
+          domainDev = domainDev.replaceAll("https://", "").replaceAll("http://", "");
+          domainDev = "https://" + domainDev;
+          config.setDomain(domainDev);
+        }
+        config.setSiteCode(adwebSite.getCode());
+        String ssoResKeyName = WordPressConstants.SSO_RES_KEY_NAME + siteCode;
+        if (redisUtil.hasKey(ssoResKeyName)) {
+          String ssoResKey = String.valueOf(redisUtil.get(ssoResKeyName));
+          config.setSsoResKey(ssoResKey);
         }
-        try {
-            List<AdwebSite> list =
-                    this.list(new LambdaQueryWrapper<AdwebSite>().eq(AdwebSite::getCode, siteCode));
-            if (!list.isEmpty()) {
-                AdwebSite adwebSite = list.get(0);
-                BeanUtils.copyProperties(adwebSite, config);
-                // 开启WP&未上线站点
-                if (adwebSite.getStatus() == NumConstant.TWO.intValue()) {
-                    String domainDev = adwebSite.getDomainDev();
-                    domainDev = domainDev.replaceAll("https://", "").replaceAll("http://", "");
-                    domainDev = "https://" + domainDev;
-                    config.setDomain(domainDev);
-                }
-                config.setSiteCode(adwebSite.getCode());
-                String ssoResKeyName = WordPressConstants.SSO_RES_KEY_NAME + siteCode;
-                if (redisUtil.hasKey(ssoResKeyName)) {
-                    String ssoResKey = String.valueOf(redisUtil.get(ssoResKeyName));
-                    config.setSsoResKey(ssoResKey);
-                }
-
-                config.setWordpressName("adweb-user");
-                // 处理WordPress配置数据
-                if (StringUtils.isNotBlank(adwebSite.getWordpressSetting())) {
-                    Map<String, Object> wordpressSettingMap =
-                            FastJsonUtil.parseObject(adwebSite.getWordpressSetting(), Map.class);
-                    int userAccount = 2;
 
-                    if (wordpressSettingMap.get("userAccount") != null) {
-                        userAccount =
-                                Integer.parseInt(wordpressSettingMap.get("userAccount").toString());
-                        if (userAccount == 1) {
-                            if (loginUser != null) {
-                                List<String> role =
-                                        sysUserRoleMapper.getRoleByUserName(
-                                                loginUser.getUsername());
-                                if (role.toString().contains("adweb_sub_vip")
-                                        || role.toString().contains("adweb_vip")) {
-                                    List<AdwebUserWpsite> adwebUserWpsites =
-                                            adwebUserWpsiteService.getSitesByUid(loginUser.getId());
-                                    config.setWordpressName(
-                                            adwebUserWpsites.get(0).getWpUsername());
-                                } else if (role.toString().contains("admin")
-                                        || role.toString().contains("adweb_seo_manager")
-                                        || role.toString().contains("adweb_site_manager")
-                                        || role.toString().contains("adweb_oem")) {
-                                    List<AdwebUserWpsite> sites =
-                                            adwebUserWpsiteService.getSitesByUid(
-                                                    adwebSite.getUid());
-                                    config.setWordpressName(sites.get(0).getWpUsername());
-                                }
-                            }
-                        }
-                    }
+        config.setWordpressName("adweb-user");
+        // 处理WordPress配置数据
+        if (StringUtils.isNotBlank(adwebSite.getWordpressSetting())) {
+          Map<String, Object> wordpressSettingMap =
+              FastJsonUtil.parseObject(adwebSite.getWordpressSetting(), Map.class);
+          int userAccount = 2;
 
-                    if (wordpressSettingMap.size() == 1) {
-                        config.setProductType(wordpressSettingMap.get("productType").toString());
-                    } else {
-                        config.setWordpressSetting(wordpressSettingMap.get("setting").toString());
-                        List<String> open =
-                                FastJsonUtil.parseList(
-                                        wordpressSettingMap.get("open").toString(), String.class);
-                        if (CollectionUtils.isNotEmpty(open)) {
-                            config.setOpenSetting(open);
-                        }
-                        if (wordpressSettingMap.size() > 2) {
-                            config.setProductType(
-                                    wordpressSettingMap.get("productType").toString());
-                        }
-                    }
+          if (wordpressSettingMap.get("userAccount") != null) {
+            userAccount = Integer.parseInt(wordpressSettingMap.get("userAccount").toString());
+            if (userAccount == 1) {
+              if (loginUser != null) {
+                List<String> role = sysUserRoleMapper.getRoleByUserName(loginUser.getUsername());
+                if (role.toString().contains("adweb_sub_vip")
+                    || role.toString().contains("adweb_vip")) {
+                  List<AdwebUserWpsite> adwebUserWpsites =
+                      adwebUserWpsiteService.getSitesByUid(loginUser.getId());
+                  config.setWordpressName(adwebUserWpsites.get(0).getWpUsername());
+                } else if (role.toString().contains("admin")
+                    || role.toString().contains("adweb_seo_manager")
+                    || role.toString().contains("adweb_site_manager")
+                    || role.toString().contains("adweb_oem")) {
+                  List<AdwebUserWpsite> sites =
+                      adwebUserWpsiteService.getSitesByUid(adwebSite.getUid());
+                  config.setWordpressName(sites.get(0).getWpUsername());
                 }
+              }
             }
-        } catch (Exception e) {
-            log.error("查询wordpress站点配置失败", e);
-        }
-        return config;
-    }
+          }
 
-    /**
-     * @param id 站点id
-     * @return
-     */
-    @Override
-    public String getSiteCodeById(Integer id) {
-        AdwebSite adwebSite = this.getById(id);
-        if (adwebSite == null) {
-            return null;
+          if (wordpressSettingMap.size() == 1) {
+            config.setProductType(wordpressSettingMap.get("productType").toString());
+          } else {
+            config.setWordpressSetting(wordpressSettingMap.get("setting").toString());
+            List<String> open =
+                FastJsonUtil.parseList(wordpressSettingMap.get("open").toString(), String.class);
+            if (CollectionUtils.isNotEmpty(open)) {
+              config.setOpenSetting(open);
+            }
+            if (wordpressSettingMap.size() > 2) {
+              config.setProductType(wordpressSettingMap.get("productType").toString());
+            }
+          }
         }
-        return adwebSite.getCode();
+      }
+    } catch (Exception e) {
+      log.error("查询wordpress站点配置失败", e);
     }
+    return config;
+  }
 
-    /**
-     * 根据站点id获取主站点的siteCode,如果站点本身就是主站点,则返回自身的code
-     *
-     * @param siteId 站点id
-     * @return 父站点code
-     */
-    @Override
-    public List<Integer> getAllSiteIdBySiteId(Integer siteId) {
-        AdwebSite adwebSite = this.getById(siteId);
-        if (StringUtil.isEmpty(adwebSite.getParentGroupCode())) {
-            return this.getAllSiteIdByParentId(siteId);
-        }
+  /**
+   * @param id 站点id
+   * @return
+   */
+  @Override
+  public String getSiteCodeById(Integer id) {
+    AdwebSite adwebSite = this.getById(id);
+    if (adwebSite == null) {
+      return null;
+    }
+    return adwebSite.getCode();
+  }
 
-        String code = adwebSite.getParentGroupCode();
-        LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(AdwebSite::getCode, code).or().eq(AdwebSite::getParentCode, code);
-        List<AdwebSite> siteList = this.list(queryWrapper);
-        List<Integer> siteIds = new ArrayList<>();
-        for (AdwebSite site : siteList) {
-            siteIds.add(site.getId());
-        }
-        return siteIds;
+  /**
+   * 根据站点id获取主站点的siteCode,如果站点本身就是主站点,则返回自身的code
+   *
+   * @param siteId 站点id
+   * @return 父站点code
+   */
+  @Override
+  public List<Integer> getAllSiteIdBySiteId(Integer siteId) {
+    AdwebSite adwebSite = this.getById(siteId);
+    if (StringUtil.isEmpty(adwebSite.getParentGroupCode())) {
+      return this.getAllSiteIdByParentId(siteId);
     }
 
-    /**
-     * 根据父站点id获取站群所有id
-     *
-     * @param parentId 父站点id
-     * @return 父站点id和子站点id
-     */
-    @Override
-    public List<Integer> getAllSiteIdByParentId(Integer parentId) {
-        String siteCode = this.getSiteCodeById(parentId);
-        LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(AdwebSite::getCode, siteCode).or().eq(AdwebSite::getParentCode, siteCode);
-        List<AdwebSite> siteList = this.list(queryWrapper);
-        List<Integer> siteIds = new ArrayList<>();
-        for (AdwebSite site : siteList) {
-            siteIds.add(site.getId());
-        }
-        return siteIds;
+    String code = adwebSite.getParentGroupCode();
+    LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
+    queryWrapper.eq(AdwebSite::getCode, code).or().eq(AdwebSite::getParentCode, code);
+    List<AdwebSite> siteList = this.list(queryWrapper);
+    List<Integer> siteIds = new ArrayList<>();
+    for (AdwebSite site : siteList) {
+      siteIds.add(site.getId());
     }
+    return siteIds;
+  }
 
-    /**
-     * 根据siteCode返回站点信息
-     *
-     * @param siteCode
-     * @return
-     */
-    @Override
-    public AdwebSite getSiteByCode(String siteCode) {
-        try {
-            List<AdwebSite> adwebSites =
-                    this.list(
-                            new LambdaQueryWrapper<AdwebSite>()
-                                    .eq(AdwebSite::getCode, siteCode)
-                                    .ne(AdwebSite::getStatus, 0));
-            if (!adwebSites.isEmpty()) {
-                return adwebSites.get(0);
-            }
-        } catch (Exception e) {
-            log.error("获取站点失败, code = " + siteCode, e);
-        }
-        return null;
+  /**
+   * 根据父站点id获取站群所有id
+   *
+   * @param parentId 父站点id
+   * @return 父站点id和子站点id
+   */
+  @Override
+  public List<Integer> getAllSiteIdByParentId(Integer parentId) {
+    String siteCode = this.getSiteCodeById(parentId);
+    LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
+    queryWrapper.eq(AdwebSite::getCode, siteCode).or().eq(AdwebSite::getParentCode, siteCode);
+    List<AdwebSite> siteList = this.list(queryWrapper);
+    List<Integer> siteIds = new ArrayList<>();
+    for (AdwebSite site : siteList) {
+      siteIds.add(site.getId());
     }
+    return siteIds;
+  }
 
-    /**
-     * 根据用户id查询所有未删除的站点
-     *
-     * @param uid 用户id
-     * @return 站点id
-     */
-    @Override
-    public List<Integer> getAllSiteIdByUid(String uid) {
-        List<AdwebSite> siteList = null;
-        try {
-            List<String> codeList = siteUserPermissionService.getSiteCodeList(uid);
-            siteList =
-                    this.list(
-                            new LambdaQueryWrapper<AdwebSite>()
-                                    .ne(AdwebSite::getStatus, 0)
-                                    .in(AdwebSite::getCode, codeList));
-        } catch (Exception e) {
-            log.error("查询用户站点失败");
-        }
+  /**
+   * 根据siteCode返回站点信息
+   *
+   * @param siteCode
+   * @return
+   */
+  @Override
+  public AdwebSite getSiteByCode(String siteCode) {
+    try {
+      List<AdwebSite> adwebSites =
+          this.list(
+              new LambdaQueryWrapper<AdwebSite>()
+                  .eq(AdwebSite::getCode, siteCode)
+                  .ne(AdwebSite::getStatus, 0));
+      if (!adwebSites.isEmpty()) {
+        return adwebSites.get(0);
+      }
+    } catch (Exception e) {
+      log.error("获取站点失败, code = " + siteCode, e);
+    }
+    return null;
+  }
 
-        List<Integer> siteIds = new ArrayList<>();
-        for (AdwebSite site : siteList) {
-            siteIds.add(site.getId());
-        }
-        return siteIds;
+  /**
+   * 根据用户id查询所有未删除的站点
+   *
+   * @param uid 用户id
+   * @return 站点id
+   */
+  @Override
+  public List<Integer> getAllSiteIdByUid(String uid) {
+    List<AdwebSite> siteList = null;
+    try {
+      List<String> codeList = siteUserPermissionService.getSiteCodeList(uid);
+      siteList =
+          this.list(
+              new LambdaQueryWrapper<AdwebSite>()
+                  .ne(AdwebSite::getStatus, 0)
+                  .in(AdwebSite::getCode, codeList));
+    } catch (Exception e) {
+      log.error("查询用户站点失败");
     }
 
-    /** 查询全部有效的站点code */
-    @Override
-    public List<String> getAllActiveSiteCodes() {
-        return this.list(
-                        new LambdaQueryWrapper<AdwebSite>()
-                                .eq(AdwebSite::getStatus, 1)
-                                .eq(AdwebSite::getRunStatus, 1))
-                .stream()
-                .map(AdwebSite::getCode)
-                .toList();
+    List<Integer> siteIds = new ArrayList<>();
+    for (AdwebSite site : siteList) {
+      siteIds.add(site.getId());
     }
+    return siteIds;
+  }
 
-    /** 给站点创建建站流程 @Author: chenpeiqing @Date: 2024/11/25 */
-    @Override
-    public boolean updateSiteFlow(String siteCode) {
-        List<DictModel> dictModels = sysBaseAPI.getDictItems("build_website_status");
+  /** 查询全部有效的站点code */
+  @Override
+  public List<String> getAllActiveSiteCodes() {
+    return this.list(
+            new LambdaQueryWrapper<AdwebSite>()
+                .eq(AdwebSite::getStatus, 1)
+                .eq(AdwebSite::getRunStatus, 1))
+        .stream()
+        .map(AdwebSite::getCode)
+        .toList();
+  }
 
-        DictModel currentDictModel =
-                dictModels.stream()
-                        .filter(dictModel -> dictModel.getValue().equals("1"))
-                        .toList()
-                        .get(0);
+  /** 给站点创建建站流程 @Author: chenpeiqing @Date: 2024/11/25 */
+  @Override
+  public boolean updateSiteFlow(String siteCode) {
+    List<DictModel> dictModels = sysBaseAPI.getDictItems("build_website_status");
 
-        LambdaUpdateWrapper<AdwebSite> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper.eq(AdwebSite::getCode, siteCode);
-        updateWrapper.set(AdwebSite::getSiteFlowStatus, 1);
-        updateWrapper.set(AdwebSite::getSiteCurrentStep, currentDictModel.getText());
-        return this.update(updateWrapper);
-    }
+    DictModel currentDictModel =
+        dictModels.stream().filter(dictModel -> dictModel.getValue().equals("1")).toList().get(0);
+
+    LambdaUpdateWrapper<AdwebSite> updateWrapper = new LambdaUpdateWrapper<>();
+    updateWrapper.eq(AdwebSite::getCode, siteCode);
+    updateWrapper.set(AdwebSite::getSiteFlowStatus, 1);
+    updateWrapper.set(AdwebSite::getSiteCurrentStep, currentDictModel.getText());
+    return this.update(updateWrapper);
+  }
 
-    /**
-     * 判断此账户有无子账户
-     *
-     * @return
-     */
-    @Override
-    public boolean hasSub(LoginUser loginUser) {
-        List<String> idList =
-                masterSubAccountRelationService.getSubAccountIdByMaster(loginUser.getId());
-        return CollectionUtils.isNotEmpty(idList);
+  /**
+   * 判断此账户有无子账户
+   *
+   * @return
+   */
+  @Override
+  public boolean hasSub(LoginUser loginUser) {
+    List<String> idList =
+        masterSubAccountRelationService.getSubAccountIdByMaster(loginUser.getId());
+    return CollectionUtils.isNotEmpty(idList);
+  }
+
+  private static final String CHARACTERS = "abcdefghijklmnopqrstuvwxyz0123456789";
+  private static final int USERNAME_LENGTH = 8; // 随机生成的用户名长度
+
+  public static String generateRandomEmail() {
+    SecureRandom random = new SecureRandom();
+    StringBuilder username = new StringBuilder();
+
+    for (int i = 0; i < USERNAME_LENGTH; i++) {
+      int index = random.nextInt(CHARACTERS.length());
+      char randomChar = CHARACTERS.charAt(index);
+      username.append(randomChar);
     }
+
+    return username.toString() + "@qq.com";
+  }
 }

+ 153 - 146
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/impl/SiteUserPermissionServiceImpl.java

@@ -2,11 +2,12 @@ package org.jeecg.modules.adweb.site.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
 import jakarta.annotation.Resource;
-
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
 import lombok.extern.slf4j.Slf4j;
-
 import org.apache.commons.collections4.CollectionUtils;
 import org.jeecg.modules.adweb.common.util.SnowflakeIdUtil;
 import org.jeecg.modules.adweb.site.entity.AdwebSitePermission;
@@ -16,155 +17,161 @@ import org.jeecg.modules.adweb.site.service.ISitePermissionService;
 import org.jeecg.modules.adweb.site.service.ISiteUserPermissionService;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.stream.Collectors;
-
 /**
- * @Description: 站点权限表
- * @Author: liang
- * @Date: 2022-08-09
- * @Version: V1.0
+ * @Description: 站点权限表 @Author: liang @Date: 2022-08-09 @Version: V1.0
  */
 @Service
 @Slf4j
 public class SiteUserPermissionServiceImpl
-        extends ServiceImpl<SiteUserPermissionMapper, AdwebSiteUserPermission>
-        implements ISiteUserPermissionService {
-
-    @Resource private ISitePermissionService sitePermissionService;
-
-    @Resource private SnowflakeIdUtil snowflakeIdUtil;
-
-    @Override
-    public List<String> getSiteCodeList(String uid) {
-        List<String> codeList = new ArrayList<>();
-        List<AdwebSiteUserPermission> AdwebSiteUserPermissionList = null;
-        try {
-            AdwebSiteUserPermissionList =
-                    this.list(
-                            new LambdaQueryWrapper<AdwebSiteUserPermission>()
-                                    .eq(AdwebSiteUserPermission::getUid, uid)
-                                    .eq(AdwebSiteUserPermission::getStatus, 1));
-        } catch (Exception e) {
-            log.error("通过uid获取站点权限失败", e);
-        }
-        if (CollectionUtils.isEmpty(AdwebSiteUserPermissionList)) {
-            codeList.add("-1");
-            return codeList;
-        }
-        List<String> permissionsList =
-                AdwebSiteUserPermissionList.stream()
-                        .map(AdwebSiteUserPermission::getPermissionCode)
-                        .collect(Collectors.toList());
-
-        try {
-            codeList =
-                    sitePermissionService
-                            .list(
-                                    new LambdaQueryWrapper<AdwebSitePermission>()
-                                            .in(
-                                                    AdwebSitePermission::getPermissionCode,
-                                                    permissionsList)
-                                            .eq(AdwebSitePermission::getStatus, 1))
-                            .stream()
-                            .map(AdwebSitePermission::getSiteCode)
-                            .collect(Collectors.toList());
-        } catch (Exception e) {
-            log.error("通过站点权限获取站点code失败", e);
-        }
-        if (CollectionUtils.isEmpty(codeList)) {
-            codeList.add("-1");
-            return codeList;
-        }
-        return codeList;
+    extends ServiceImpl<SiteUserPermissionMapper, AdwebSiteUserPermission>
+    implements ISiteUserPermissionService {
+
+  @Resource private ISitePermissionService sitePermissionService;
+
+  @Resource private SnowflakeIdUtil snowflakeIdUtil;
+
+  @Override
+  public List<String> getSiteCodeList(String uid) {
+    List<String> codeList = new ArrayList<>();
+    List<AdwebSiteUserPermission> AdwebSiteUserPermissionList = null;
+    try {
+      AdwebSiteUserPermissionList =
+          this.list(
+              new LambdaQueryWrapper<AdwebSiteUserPermission>()
+                  .eq(AdwebSiteUserPermission::getUid, uid)
+                  .eq(AdwebSiteUserPermission::getStatus, 1));
+    } catch (Exception e) {
+      log.error("通过uid获取站点权限失败", e);
     }
-
-    @Override
-    public List<String> getSiteCodeListByUids(List<String> list) {
-        List<String> codeList = new ArrayList<>();
-        List<AdwebSiteUserPermission> AdwebSiteUserPermissionList = null;
-        try {
-            AdwebSiteUserPermissionList =
-                    this.list(
-                            new LambdaQueryWrapper<AdwebSiteUserPermission>()
-                                    .in(AdwebSiteUserPermission::getUid, list)
-                                    .eq(AdwebSiteUserPermission::getStatus, 1));
-        } catch (Exception e) {
-            log.error("通过uid获取站点权限失败", e);
-        }
-        if (CollectionUtils.isEmpty(AdwebSiteUserPermissionList)) {
-            codeList.add("-1");
-            return codeList;
-        }
-        List<String> permissionsList =
-                AdwebSiteUserPermissionList.stream()
-                        .map(AdwebSiteUserPermission::getPermissionCode)
-                        .collect(Collectors.toList());
-        try {
-            codeList =
-                    sitePermissionService
-                            .list(
-                                    new LambdaQueryWrapper<AdwebSitePermission>()
-                                            .in(
-                                                    AdwebSitePermission::getPermissionCode,
-                                                    permissionsList)
-                                            .eq(AdwebSitePermission::getStatus, 1))
-                            .stream()
-                            .map(AdwebSitePermission::getSiteCode)
-                            .collect(Collectors.toList());
-        } catch (Exception e) {
-            log.error("通过站点权限获取站点code失败", e);
-        }
-        if (CollectionUtils.isEmpty(codeList)) {
-            codeList.add("-1");
-            return codeList;
-        }
-        return codeList;
+    if (CollectionUtils.isEmpty(AdwebSiteUserPermissionList)) {
+      codeList.add("-1");
+      return codeList;
     }
-
-    /**
-     * 根据uid和siteCode向site_user_permission表中插入一条记录
-     *
-     * @return: @Author: luxiaoxiao @Date: 2021/4/22
-     */
-    @Override
-    public void insertSiteUserPermission(String uid, String siteCode, String siteName) {
-
-        List<AdwebSiteUserPermission> siteUserPermissionList = null;
-        try {
-            LambdaQueryWrapper<AdwebSiteUserPermission> queryWrapper = new LambdaQueryWrapper<>();
-
-            queryWrapper
-                    .eq(AdwebSiteUserPermission::getUid, uid)
-                    .eq(AdwebSiteUserPermission::getStatus, 1);
-
-            siteUserPermissionList = this.list(queryWrapper);
-
-            AdwebSiteUserPermission siteUserPermission = new AdwebSiteUserPermission();
-            String permissionCode = "";
-            if (CollectionUtils.isNotEmpty(siteUserPermissionList)) {
-                siteUserPermission = siteUserPermissionList.get(0);
-                permissionCode = siteUserPermission.getPermissionCode();
-            } else {
-                permissionCode = String.valueOf(snowflakeIdUtil.nextId());
-                siteUserPermission.setUid(uid);
-                siteUserPermission.setPermissionCode(permissionCode);
-                siteUserPermission.setStatus(1);
-                siteUserPermission.setCreateTime(new Date());
-                this.save(siteUserPermission);
-            }
-
-            AdwebSitePermission sitePermission = new AdwebSitePermission();
-            sitePermission.setSiteCode(siteCode);
-            sitePermission.setSiteName(siteName);
-            sitePermission.setPermissionCode(permissionCode);
-            sitePermission.setStatus(1);
-            sitePermission.setCreateTime(new Date());
-            sitePermissionService.save(sitePermission);
-        } catch (Exception e) {
-            log.error("添加站点权限失败", e);
-        }
+    List<String> permissionsList =
+        AdwebSiteUserPermissionList.stream()
+            .map(AdwebSiteUserPermission::getPermissionCode)
+            .collect(Collectors.toList());
+
+    try {
+      codeList =
+          sitePermissionService
+              .list(
+                  new LambdaQueryWrapper<AdwebSitePermission>()
+                      .in(AdwebSitePermission::getPermissionCode, permissionsList)
+                      .eq(AdwebSitePermission::getStatus, 1))
+              .stream()
+              .map(AdwebSitePermission::getSiteCode)
+              .collect(Collectors.toList());
+    } catch (Exception e) {
+      log.error("通过站点权限获取站点code失败", e);
+    }
+    if (CollectionUtils.isEmpty(codeList)) {
+      codeList.add("-1");
+      return codeList;
+    }
+    return codeList;
+  }
+
+  @Override
+  public List<String> getSiteCodeListByUids(List<String> list) {
+    List<String> codeList = new ArrayList<>();
+    List<AdwebSiteUserPermission> AdwebSiteUserPermissionList = null;
+    try {
+      AdwebSiteUserPermissionList =
+          this.list(
+              new LambdaQueryWrapper<AdwebSiteUserPermission>()
+                  .in(AdwebSiteUserPermission::getUid, list)
+                  .eq(AdwebSiteUserPermission::getStatus, 1));
+    } catch (Exception e) {
+      log.error("通过uid获取站点权限失败", e);
+    }
+    if (CollectionUtils.isEmpty(AdwebSiteUserPermissionList)) {
+      codeList.add("-1");
+      return codeList;
+    }
+    List<String> permissionsList =
+        AdwebSiteUserPermissionList.stream()
+            .map(AdwebSiteUserPermission::getPermissionCode)
+            .collect(Collectors.toList());
+    try {
+      codeList =
+          sitePermissionService
+              .list(
+                  new LambdaQueryWrapper<AdwebSitePermission>()
+                      .in(AdwebSitePermission::getPermissionCode, permissionsList)
+                      .eq(AdwebSitePermission::getStatus, 1))
+              .stream()
+              .map(AdwebSitePermission::getSiteCode)
+              .collect(Collectors.toList());
+    } catch (Exception e) {
+      log.error("通过站点权限获取站点code失败", e);
+    }
+    if (CollectionUtils.isEmpty(codeList)) {
+      codeList.add("-1");
+      return codeList;
+    }
+    return codeList;
+  }
+
+  /**
+   * 根据uid和siteCode向site_user_permission表中插入一条记录
+   *
+   * @return: @Author: luxiaoxiao @Date: 2021/4/22
+   */
+  @Override
+  public void insertSiteUserPermission(String uid, String siteCode, String siteName) {
+
+    List<AdwebSiteUserPermission> siteUserPermissionList = null;
+    try {
+      LambdaQueryWrapper<AdwebSiteUserPermission> queryWrapper = new LambdaQueryWrapper<>();
+
+      queryWrapper
+          .eq(AdwebSiteUserPermission::getUid, uid)
+          .eq(AdwebSiteUserPermission::getStatus, 1);
+
+      siteUserPermissionList = this.list(queryWrapper);
+
+      AdwebSiteUserPermission siteUserPermission = new AdwebSiteUserPermission();
+      String permissionCode = "";
+      if (CollectionUtils.isNotEmpty(siteUserPermissionList)) {
+        siteUserPermission = siteUserPermissionList.get(0);
+        permissionCode = siteUserPermission.getPermissionCode();
+      } else {
+        permissionCode = String.valueOf(snowflakeIdUtil.nextId());
+        siteUserPermission.setUid(uid);
+        siteUserPermission.setPermissionCode(permissionCode);
+        siteUserPermission.setStatus(1);
+        siteUserPermission.setCreateTime(new Date());
+        this.save(siteUserPermission);
+      }
+
+      AdwebSitePermission sitePermission = new AdwebSitePermission();
+      sitePermission.setSiteCode(siteCode);
+      sitePermission.setSiteName(siteName);
+      sitePermission.setPermissionCode(permissionCode);
+      sitePermission.setStatus(1);
+      sitePermission.setCreateTime(new Date());
+      sitePermissionService.save(sitePermission);
+    } catch (Exception e) {
+      log.error("添加站点权限失败", e);
+    }
+  }
+
+  @Override
+  public List<AdwebSiteUserPermission> getPermissionCode(String uid) {
+    List<AdwebSiteUserPermission> siteUserPermissionList = new ArrayList<>();
+    try {
+      siteUserPermissionList =
+          this.list(
+              new LambdaQueryWrapper<AdwebSiteUserPermission>()
+                  .eq(AdwebSiteUserPermission::getUid, uid)
+                  .eq(AdwebSiteUserPermission::getStatus, 1));
+    } catch (Exception e) {
+      log.error("通过uid获取站点权限失败", e);
+    }
+    if (CollectionUtils.isEmpty(siteUserPermissionList)) {
+      return siteUserPermissionList;
     }
+    return siteUserPermissionList;
+  }
 }

+ 459 - 470
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/userCountry/controller/AdwebUserCountryController.java

@@ -6,16 +6,14 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
-
 import jakarta.annotation.Resource;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
-
+import java.util.*;
+import java.util.stream.Collectors;
 import lombok.extern.slf4j.Slf4j;
-
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
@@ -42,507 +40,498 @@ import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
 
-import java.util.*;
-import java.util.stream.Collectors;
-
 /**
- * @Description: adweb_user_country
- * @Author: jeecg-boot
- * @Date: 2022-08-19
- * @Version: V1.0
+ * @Description: adweb_user_country @Author: jeecg-boot @Date: 2022-08-19 @Version: V1.0
  */
 @Tag(name = "adweb_user_country")
 @RestController
 @RequestMapping("/usercountry")
 @Slf4j
 public class AdwebUserCountryController
-        extends JeecgController<AdwebUserCountry, IAdwebUserCountryService> {
-
-    @Resource private IAdwebUserCountryService adwebUserCountryService;
-
-    @Resource private IAdwebSiteService adwebSiteService;
-
-    @Resource private AdwebUserCountryMapper adwebUserCountryMapper;
-
-    @Resource private IAdwebCountryService admpCountryService;
-
-    @Resource private IAdwebEnquiryService adwebEnquiryService;
-
-    @Resource private SysAdwebApi sysAdwebApi;
-
-    @Resource private ISysUserService sysUserService;
-
-    /**
-     * 分页列表查询
-     *
-     * @param adwebUserCountry
-     * @param pageNo
-     * @param pageSize
-     * @param req
-     * @return
-     */
-    @AutoLog(value = "adweb_user_country-分页列表查询")
-    @Operation(summary = "adweb_user_country-分页列表查询")
-    @GetMapping(value = "/list")
-    public Result<?> queryPageList(
-            AdwebUserCountry adwebUserCountry,
-            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-            HttpServletRequest req) {
-        QueryWrapper<AdwebUserCountry> queryWrapper =
-                QueryGenerator.initQueryWrapper(adwebUserCountry, req.getParameterMap());
-        Page<AdwebUserCountry> page = new Page<AdwebUserCountry>(pageNo, pageSize);
-        IPage<AdwebUserCountry> pageList = adwebUserCountryService.page(page, queryWrapper);
-        return Result.OK(pageList);
+    extends JeecgController<AdwebUserCountry, IAdwebUserCountryService> {
+
+  @Resource private IAdwebUserCountryService adwebUserCountryService;
+
+  @Resource private IAdwebSiteService adwebSiteService;
+
+  @Resource private AdwebUserCountryMapper adwebUserCountryMapper;
+
+  @Resource private IAdwebCountryService admpCountryService;
+
+  @Resource private IAdwebEnquiryService adwebEnquiryService;
+
+  @Resource private SysAdwebApi sysAdwebApi;
+
+  @Resource private ISysUserService sysUserService;
+
+  /**
+   * 分页列表查询
+   *
+   * @param adwebUserCountry
+   * @param pageNo
+   * @param pageSize
+   * @param req
+   * @return
+   */
+  @AutoLog(value = "adweb_user_country-分页列表查询")
+  @Operation(summary = "adweb_user_country-分页列表查询")
+  @GetMapping(value = "/list")
+  public Result<?> queryPageList(
+      AdwebUserCountry adwebUserCountry,
+      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+      HttpServletRequest req) {
+    QueryWrapper<AdwebUserCountry> queryWrapper =
+        QueryGenerator.initQueryWrapper(adwebUserCountry, req.getParameterMap());
+    Page<AdwebUserCountry> page = new Page<AdwebUserCountry>(pageNo, pageSize);
+    IPage<AdwebUserCountry> pageList = adwebUserCountryService.page(page, queryWrapper);
+    return Result.OK(pageList);
+  }
+
+  /** 查询未分配地区 */
+  @GetMapping(value = "/undistribute")
+  public Result<?> undistribute() {
+    LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    LambdaQueryWrapper<AdwebUserCountry> queryWrapper = new LambdaQueryWrapper<>();
+    queryWrapper.eq(AdwebUserCountry::getMasterUid, loginUser.getId());
+    queryWrapper.eq(AdwebUserCountry::getStatus, 1);
+    List<AdwebUserCountry> userCountries = adwebUserCountryService.list(queryWrapper);
+    List<AdwebCountry> countries = null;
+    if (CollectionUtils.isEmpty(userCountries)) {}
+
+    return Result.OK();
+  }
+
+  /** 获取子账户列表 */
+  @AutoLog(value = "询盘管理-询盘分配-子账户列表")
+  @GetMapping(value = "/subAccounts")
+  public Result<?> subAccounts(
+      @RequestParam(name = "siteId") Integer siteId,
+      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+      @RequestParam(name = "pageSize", defaultValue = "15") Integer pageSize) {
+    LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    List<Integer> siteIds = adwebSiteService.getAllSiteIdByParentId(siteId);
+    Page<SubUser> page = new Page<>(pageNo, pageSize);
+    IPage<SubUser> pageList =
+        adwebUserCountryMapper.getSubUserList(page, loginUser.getId(), siteIds);
+    LambdaQueryWrapper<AdwebEnquiry> enquiryQueryWrapper = new LambdaQueryWrapper<>();
+    enquiryQueryWrapper.eq(AdwebEnquiry::getStatus, 1);
+    enquiryQueryWrapper.in(AdwebEnquiry::getSiteId, siteIds);
+    enquiryQueryWrapper.eq(AdwebEnquiry::getPrincipalType, 1);
+    int count = (int) adwebEnquiryService.count(enquiryQueryWrapper);
+    List<SubUser> subUserList = pageList.getRecords();
+
+    if (subUserList.isEmpty()) {
+      subUserList = new ArrayList<>();
     }
 
-    /** 查询未分配地区 */
-    @GetMapping(value = "/undistribute")
-    public Result<?> undistribute() {
-        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        LambdaQueryWrapper<AdwebUserCountry> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(AdwebUserCountry::getMasterUid, loginUser.getId());
-        queryWrapper.eq(AdwebUserCountry::getStatus, 1);
-        List<AdwebUserCountry> userCountries = adwebUserCountryService.list(queryWrapper);
-        List<AdwebCountry> countries = null;
-        if (CollectionUtils.isEmpty(userCountries)) {}
-
-        return Result.OK();
+    SubUser subUser = new SubUser();
+    subUser.setId("-1");
+    subUser.setUsername("已手动分配跟进人的询盘");
+    subUser.setRealname("已手动分配跟进人的询盘");
+    subUser.setCountryNum(-1);
+    subUser.setEnquiryNum(count);
+    subUserList.add(subUser);
+
+    pageList.setRecords(subUserList);
+    return Result.OK(pageList);
+  }
+
+  /** 获取子账户列表 */
+  @GetMapping(value = "/subAccounts/options")
+  public Result<?> subAccounts2(Integer siteId, String siteCode) {
+    LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    // 获取主账户uid
+    String uid;
+    if (sysAdwebApi.isAdmin() || sysAdwebApi.isChannelAdmin()) {
+      AdwebSite site;
+      if (siteId != null) {
+        site = adwebSiteService.getById(siteId);
+      } else {
+        site =
+            adwebSiteService.getOne(
+                new LambdaQueryWrapper<AdwebSite>().eq(AdwebSite::getCode, siteCode));
+      }
+      if (site == null) {
+        return Result.OK(new ArrayList<SubUser>());
+      }
+      uid = site.getUid();
+    } else if (sysAdwebApi.isAdwebVip()) {
+      uid = loginUser.getId();
+    } else {
+      return Result.OK(new ArrayList<SubUser>());
     }
 
-    /** 获取子账户列表 */
-    @AutoLog(value = "询盘管理-询盘分配-子账户列表")
-    @GetMapping(value = "/subAccounts")
-    public Result<?> subAccounts(
-            @RequestParam(name = "siteId") Integer siteId,
-            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-            @RequestParam(name = "pageSize", defaultValue = "15") Integer pageSize) {
-        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        List<Integer> siteIds = adwebSiteService.getAllSiteIdByParentId(siteId);
-        Page<SubUser> page = new Page<>(pageNo, pageSize);
-        IPage<SubUser> pageList =
-                adwebUserCountryMapper.getSubUserList(page, loginUser.getId(), siteIds);
-        LambdaQueryWrapper<AdwebEnquiry> enquiryQueryWrapper = new LambdaQueryWrapper<>();
-        enquiryQueryWrapper.eq(AdwebEnquiry::getStatus, 1);
-        enquiryQueryWrapper.in(AdwebEnquiry::getSiteId, siteIds);
-        enquiryQueryWrapper.eq(AdwebEnquiry::getPrincipalType, 1);
-        int count = (int) adwebEnquiryService.count(enquiryQueryWrapper);
-        List<SubUser> list = pageList.getRecords();
-        SubUser subUser = new SubUser();
-        subUser.setId("-1");
-        subUser.setUsername("已手动分配跟进人的询盘");
-        subUser.setRealname("已手动分配跟进人的询盘");
-        subUser.setCountryNum(-1);
-        subUser.setEnquiryNum(count);
-        list.add(subUser);
-        return Result.OK(pageList);
-    }
+    // 获取子账户列表
+    List<SubUser> list = adwebUserCountryMapper.getSubUserOptions(uid);
 
-    /** 获取子账户列表 */
-    @GetMapping(value = "/subAccounts/options")
-    public Result<?> subAccounts2(Integer siteId, String siteCode) {
-        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        // 获取主账户uid
-        String uid;
-        if (sysAdwebApi.isAdmin() || sysAdwebApi.isChannelAdmin()) {
-            AdwebSite site;
-            if (siteId != null) {
-                site = adwebSiteService.getById(siteId);
-            } else {
-                site =
-                        adwebSiteService.getOne(
-                                new LambdaQueryWrapper<AdwebSite>()
-                                        .eq(AdwebSite::getCode, siteCode));
-            }
-            if (site == null) {
-                return Result.OK(new ArrayList<SubUser>());
-            }
-            uid = site.getUid();
-        } else if (sysAdwebApi.isAdwebVip()) {
-            uid = loginUser.getId();
-        } else {
-            return Result.OK(new ArrayList<SubUser>());
-        }
-
-        // 获取子账户列表
-        List<SubUser> list = adwebUserCountryMapper.getSubUserOptions(uid);
-
-        // 如果子账户不为空,将主账户也加进去作为选项
-        if (CollectionUtils.isNotEmpty(list)) {
-            SysUser masterAccount = sysUserService.getById(uid);
-            SubUser user = new SubUser();
-            user.setId(masterAccount.getId());
-            user.setUsername(masterAccount.getRealname());
-            list.add(0, user);
-        }
-
-        return Result.OK(list);
+    // 如果子账户不为空,将主账户也加进去作为选项
+    if (CollectionUtils.isNotEmpty(list)) {
+      SysUser masterAccount = sysUserService.getById(uid);
+      SubUser user = new SubUser();
+      user.setId(masterAccount.getId());
+      user.setUsername(masterAccount.getRealname());
+      list.add(0, user);
     }
 
-    /** 获取子账户负责的国家 */
-    @GetMapping(value = "/country/charge")
-    public Result<?> chargeCountry(@RequestParam String id, @RequestParam Integer siteId) {
-        LambdaQueryWrapper<AdwebUserCountry> userCountryQueryWrapper = new LambdaQueryWrapper<>();
-        userCountryQueryWrapper.eq(AdwebUserCountry::getUid, id);
-        userCountryQueryWrapper.eq(AdwebUserCountry::getSiteId, siteId);
-        userCountryQueryWrapper.eq(AdwebUserCountry::getStatus, 1);
-        List<AdwebUserCountry> userCountries =
-                adwebUserCountryService.list(userCountryQueryWrapper);
-        if (CollectionUtils.isEmpty(userCountries)) {
-            return Result.OK();
-        }
-
-        List<Integer> countryIds = new ArrayList<>();
-        for (AdwebUserCountry userCountry : userCountries) {
-            countryIds.add(userCountry.getCountryId());
-        }
-
-        LambdaQueryWrapper<AdwebCountry> countryQueryWrapper = new LambdaQueryWrapper<>();
-        countryQueryWrapper.in(AdwebCountry::getGeonameId, countryIds);
-        List<AdwebCountry> countries = admpCountryService.list(countryQueryWrapper);
-        if (CollectionUtils.isEmpty(countries)) {
-            return Result.OK();
-        }
-
-        // 将国家按大洲分组,然后组装成树结构
-        Map<String, List<AdwebCountry>> map = new HashMap<>();
-        for (AdwebCountry country : countries) {
-            String continentCode = country.getContinentCode();
-            List<AdwebCountry> countryList =
-                    map.computeIfAbsent(continentCode, k -> new ArrayList<>());
-            countryList.add(country);
-        }
-
-        List<TreeOption> options = new ArrayList<>();
-        for (List<AdwebCountry> countryList : map.values()) {
-            TreeOption parentOption = new TreeOption();
-            parentOption.setKey(countryList.get(0).getContinentCode());
-            parentOption.setValue(countryList.get(0).getContinentCode());
-            parentOption.setTitle(countryList.get(0).getContinentName());
-            List<TreeOption> children = new ArrayList<>();
-            for (AdwebCountry country : countryList) {
-                TreeOption option = new TreeOption();
-                option.setKey(country.getGeonameId());
-                option.setValue(country.getGeonameId());
-                option.setTitle(country.getCountryName());
-                children.add(option);
-            }
-            parentOption.setChildren(children);
-            options.add(parentOption);
-        }
-
-        return Result.OK(options);
+    return Result.OK(list);
+  }
+
+  @GetMapping(value = "/subAccounts/optionswithoutself")
+  public Result<?> optionswithoutself() {
+    LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    List<SubUser> list = adwebUserCountryMapper.getSubUserOptions(loginUser.getId());
+    return Result.OK(list);
+  }
+
+  /** 获取子账户负责的国家 */
+  @GetMapping(value = "/country/charge")
+  public Result<?> chargeCountry(@RequestParam String id, @RequestParam Integer siteId) {
+    LambdaQueryWrapper<AdwebUserCountry> userCountryQueryWrapper = new LambdaQueryWrapper<>();
+    userCountryQueryWrapper.eq(AdwebUserCountry::getUid, id);
+    userCountryQueryWrapper.eq(AdwebUserCountry::getSiteId, siteId);
+    userCountryQueryWrapper.eq(AdwebUserCountry::getStatus, 1);
+    List<AdwebUserCountry> userCountries = adwebUserCountryService.list(userCountryQueryWrapper);
+    if (CollectionUtils.isEmpty(userCountries)) {
+      return Result.OK();
     }
 
-    /** 获取未分配的国家 */
-    @GetMapping(value = "/country/uncontribute")
-    public Result<?> uncontributeCountry(Integer siteId) {
-        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        LambdaQueryWrapper<AdwebUserCountry> userCountryQueryWrapper = new LambdaQueryWrapper<>();
-        userCountryQueryWrapper.eq(AdwebUserCountry::getMasterUid, loginUser.getId());
-        userCountryQueryWrapper.eq(AdwebUserCountry::getStatus, 1);
-        userCountryQueryWrapper.eq(AdwebUserCountry::getSiteId, siteId);
-        List<AdwebUserCountry> userCountries =
-                adwebUserCountryService.list(userCountryQueryWrapper);
-
-        List<AdwebCountry> countries;
-        if (CollectionUtils.isEmpty(userCountries)) {
-            countries = admpCountryService.list();
-        } else {
-            List<Integer> countryIds = new ArrayList<>();
-            for (AdwebUserCountry userCountry : userCountries) {
-                countryIds.add(userCountry.getCountryId());
-            }
-
-            LambdaQueryWrapper<AdwebCountry> countryQueryWrapper = new LambdaQueryWrapper<>();
-            countryQueryWrapper.notIn(AdwebCountry::getGeonameId, countryIds);
-            countries = admpCountryService.list(countryQueryWrapper);
-        }
-        if (CollectionUtils.isEmpty(countries)) {
-            return Result.OK();
-        }
-
-        // 将国家按大洲分组,然后组装成树结构
-        Map<String, List<AdwebCountry>> map = new HashMap<>();
-        for (AdwebCountry country : countries) {
-            String continentCode = country.getContinentCode();
-            List<AdwebCountry> countryList =
-                    map.computeIfAbsent(continentCode, k -> new ArrayList<>());
-            countryList.add(country);
-        }
-
-        List<TreeOption> options = new ArrayList<>();
-        for (List<AdwebCountry> countryList : map.values()) {
-            TreeOption parentOption = new TreeOption();
-            parentOption.setKey(countryList.get(0).getContinentCode());
-            parentOption.setValue(countryList.get(0).getContinentCode());
-            parentOption.setTitle(countryList.get(0).getContinentName());
-            List<TreeOption> children = new ArrayList<>();
-            for (AdwebCountry country : countryList) {
-                TreeOption option = new TreeOption();
-                option.setKey(country.getGeonameId());
-                option.setValue(country.getGeonameId());
-                option.setTitle(country.getCountryName());
-                children.add(option);
-            }
-            parentOption.setChildren(children);
-            options.add(parentOption);
-        }
-
-        return Result.OK(options);
+    List<Integer> countryIds = new ArrayList<>();
+    for (AdwebUserCountry userCountry : userCountries) {
+      countryIds.add(userCountry.getCountryId());
     }
 
-    /** 分配国家 */
-    @PostMapping(value = "/contribute/add")
-    public Result<?> contributeCountry(@RequestBody DistributeCountryParam param) {
-        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        //        if(sysUser.isPerform()){
-        //            return Result.FORBIDDEN("\"演示版\"没有操作权限,如果需要操作,请切换到\"正式版\"再操作!");
-        //        }
-        String uid = param.getUid();
-        String countryIds = param.getCountryIds();
-        String[] countryIdArr = countryIds.split(",");
-        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        List<AdwebUserCountry> userCountries = new ArrayList<>();
-        for (String countryId : countryIdArr) {
-            if (StringUtils.isEmpty(countryId) || this.notNum(countryId)) {
-                continue;
-            }
-            AdwebUserCountry country = new AdwebUserCountry();
-            country.setUid(uid);
-            country.setMasterUid(loginUser.getId());
-            country.setSiteId(param.getSiteId());
-            country.setCountryId(Integer.parseInt(countryId));
-            country.setStatus(1);
-            country.setCreateTime(new Date());
-            userCountries.add(country);
-        }
-        adwebUserCountryService.saveBatch(userCountries);
-
-        // 更改相关询盘的负责人
-        LambdaQueryWrapper<AdwebCountry> countryQueryWrapper = new LambdaQueryWrapper<>();
-        countryQueryWrapper.in(AdwebCountry::getGeonameId, countryIdArr);
-        List<AdwebCountry> countries = admpCountryService.list(countryQueryWrapper);
-        List<String> countryCodes =
-                countries.stream()
-                        .map(AdwebCountry::getCountryIsoCode)
-                        .collect(Collectors.toList());
-
-        List<Integer> siteIds = adwebSiteService.getAllSiteIdByParentId(param.getSiteId());
-        LambdaUpdateWrapper<AdwebEnquiry> enquiryUpdateWrapper = new LambdaUpdateWrapper<>();
-        enquiryUpdateWrapper.in(AdwebEnquiry::getCountryCode, countryCodes);
-        enquiryUpdateWrapper.in(AdwebEnquiry::getSiteId, siteIds);
-        enquiryUpdateWrapper.ne(AdwebEnquiry::getPrincipalType, 1);
-        enquiryUpdateWrapper.set(AdwebEnquiry::getPrincipalUid, param.getUid());
-        adwebEnquiryService.update(enquiryUpdateWrapper);
-
-        return Result.OK();
+    LambdaQueryWrapper<AdwebCountry> countryQueryWrapper = new LambdaQueryWrapper<>();
+    countryQueryWrapper.in(AdwebCountry::getGeonameId, countryIds);
+    List<AdwebCountry> countries = admpCountryService.list(countryQueryWrapper);
+    if (CollectionUtils.isEmpty(countries)) {
+      return Result.OK();
     }
 
-    private boolean notNum(String countryId) {
-        if (countryId.charAt(0) < '1' || countryId.charAt(0) > '9') {
-            return true;
-        }
-        return false;
+    // 将国家按大洲分组,然后组装成树结构
+    Map<String, List<AdwebCountry>> map = new HashMap<>();
+    for (AdwebCountry country : countries) {
+      String continentCode = country.getContinentCode();
+      List<AdwebCountry> countryList = map.computeIfAbsent(continentCode, k -> new ArrayList<>());
+      countryList.add(country);
     }
 
-    /** 分配国家 */
-    @PostMapping(value = "/contribute/delete")
-    public Result<?> delete(@RequestBody DistributeCountryParam param) {
-        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        //        if(sysUser.isPerform()){
-        //            return Result.FORBIDDEN("\"演示版\"没有操作权限,如果需要操作,请切换到\"正式版\"再操作!");
-        //        }
-        String uid = param.getUid();
-        String countryIds = param.getCountryIds();
-        List<String> countryIdList = new ArrayList<>();
-        if (StringUtils.isNotBlank(countryIds)) {
-            Collections.addAll(countryIdList, countryIds.split(","));
-        }
-        countryIdList.removeIf(this::notNum);
-        LambdaUpdateWrapper<AdwebUserCountry> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper.eq(AdwebUserCountry::getUid, uid);
-        updateWrapper.eq(AdwebUserCountry::getSiteId, param.getSiteId());
-        if (CollectionUtils.isNotEmpty(countryIdList)) {
-            updateWrapper.notIn(AdwebUserCountry::getCountryId, countryIdList);
-        }
-        updateWrapper.set(AdwebUserCountry::getStatus, 0);
-        adwebUserCountryService.update(updateWrapper);
-
-        // 更改相关询盘的负责人
-        List<Integer> siteIds = adwebSiteService.getAllSiteIdByParentId(param.getSiteId());
-        LambdaUpdateWrapper<AdwebEnquiry> enquiryUpdateWrapper = new LambdaUpdateWrapper<>();
-        if (CollectionUtils.isNotEmpty(countryIdList)) {
-            LambdaQueryWrapper<AdwebCountry> countryQueryWrapper = new LambdaQueryWrapper<>();
-            countryQueryWrapper.in(AdwebCountry::getGeonameId, countryIdList);
-            List<AdwebCountry> countries = admpCountryService.list(countryQueryWrapper);
-            List<String> countryCodes =
-                    countries.stream()
-                            .map(AdwebCountry::getCountryIsoCode)
-                            .collect(Collectors.toList());
-            enquiryUpdateWrapper.notIn(AdwebEnquiry::getCountryCode, countryCodes);
-        }
-        enquiryUpdateWrapper.in(AdwebEnquiry::getSiteId, siteIds);
-        enquiryUpdateWrapper.eq(AdwebEnquiry::getPrincipalUid, param.getUid());
-        enquiryUpdateWrapper.ne(AdwebEnquiry::getPrincipalType, 1);
-        enquiryUpdateWrapper.setSql("principal_uid = uid");
-        adwebEnquiryService.update(enquiryUpdateWrapper);
-        return Result.OK();
+    List<TreeOption> options = new ArrayList<>();
+    for (List<AdwebCountry> countryList : map.values()) {
+      TreeOption parentOption = new TreeOption();
+      parentOption.setKey(countryList.get(0).getContinentCode());
+      parentOption.setValue(countryList.get(0).getContinentCode());
+      parentOption.setTitle(countryList.get(0).getContinentName());
+      List<TreeOption> children = new ArrayList<>();
+      for (AdwebCountry country : countryList) {
+        TreeOption option = new TreeOption();
+        option.setKey(country.getGeonameId());
+        option.setValue(country.getGeonameId());
+        option.setTitle(country.getCountryName());
+        children.add(option);
+      }
+      parentOption.setChildren(children);
+      options.add(parentOption);
     }
 
-    /** 更改分配方式 */
-    @AutoLog(value = "询盘管理-询盘分配-分配规则切换")
-    @PostMapping(value = "/updateDistributeType")
-    public Result<?> updateDistributeType(
-            @RequestParam Integer siteId, @RequestParam String distributeType) {
-        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        //        if(sysUser.isPerform()){
-        //            return Result.FORBIDDEN("\"演示版\"没有操作权限,如果需要操作,请切换到\"正式版\"再操作!");
-        //        }
-        LambdaUpdateWrapper<AdwebSite> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper.eq(AdwebSite::getId, siteId);
-        updateWrapper.set(AdwebSite::getEnquiryDistributeType, distributeType);
-        adwebSiteService.update(updateWrapper);
-
-        // 修改询盘的跟进人
-        if (EnquiryDistributeTypeConstant.MASTER.equals(distributeType)) {
-            LambdaUpdateWrapper<AdwebEnquiry> enquiryUpdateWrapper = new LambdaUpdateWrapper<>();
-            enquiryUpdateWrapper.ne(AdwebEnquiry::getPrincipalType, 1);
-            enquiryUpdateWrapper.setSql("principal_uid = uid");
-            adwebEnquiryService.update(enquiryUpdateWrapper);
-        } else if (EnquiryDistributeTypeConstant.ALL.equals(distributeType)) {
-            LambdaUpdateWrapper<AdwebEnquiry> enquiryUpdateWrapper = new LambdaUpdateWrapper<>();
-            enquiryUpdateWrapper.ne(AdwebEnquiry::getPrincipalType, 1);
-            enquiryUpdateWrapper.set(AdwebEnquiry::getPrincipalUid, "ALL");
-            adwebEnquiryService.update(enquiryUpdateWrapper);
-        } else if (EnquiryDistributeTypeConstant.REGION.equals(distributeType)) {
-            adwebEnquiryService.updatePrincipalUidByRegion(siteId);
-        }
-        return Result.OK();
+    return Result.OK(options);
+  }
+
+  /** 获取未分配的国家 */
+  @GetMapping(value = "/country/uncontribute")
+  public Result<?> uncontributeCountry(Integer siteId) {
+    LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    LambdaQueryWrapper<AdwebUserCountry> userCountryQueryWrapper = new LambdaQueryWrapper<>();
+    userCountryQueryWrapper.eq(AdwebUserCountry::getMasterUid, loginUser.getId());
+    userCountryQueryWrapper.eq(AdwebUserCountry::getStatus, 1);
+    userCountryQueryWrapper.eq(AdwebUserCountry::getSiteId, siteId);
+    List<AdwebUserCountry> userCountries = adwebUserCountryService.list(userCountryQueryWrapper);
+
+    List<AdwebCountry> countries;
+    if (CollectionUtils.isEmpty(userCountries)) {
+      countries = admpCountryService.list();
+    } else {
+      List<Integer> countryIds = new ArrayList<>();
+      for (AdwebUserCountry userCountry : userCountries) {
+        countryIds.add(userCountry.getCountryId());
+      }
+
+      LambdaQueryWrapper<AdwebCountry> countryQueryWrapper = new LambdaQueryWrapper<>();
+      countryQueryWrapper.notIn(AdwebCountry::getGeonameId, countryIds);
+      countries = admpCountryService.list(countryQueryWrapper);
     }
-
-    /** 更改询盘发送规则 */
-    @AutoLog(value = "询盘管理-询盘分配-更改询盘发送规则")
-    @PostMapping(value = "/updateSendEmailType")
-    public Result<?> updateSendEmailType(
-            @RequestParam Integer siteId, @RequestParam String sendEmailType) {
-        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        //        if(sysUser.isPerform()){
-        //            return Result.FORBIDDEN("\"演示版\"没有操作权限,如果需要操作,请切换到\"正式版\"再操作!");
-        //        }
-        LambdaUpdateWrapper<AdwebSite> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper.eq(AdwebSite::getId, siteId);
-        updateWrapper.set(AdwebSite::getEnquirySendEmailType, sendEmailType);
-        adwebSiteService.update(updateWrapper);
-
-        return Result.OK();
+    if (CollectionUtils.isEmpty(countries)) {
+      return Result.OK();
     }
 
-    /** 根据站点id获取站点信息 */
-    @GetMapping(value = "/getSiteBySiteId")
-    public Result<?> getSiteBySiteId(Integer siteId) {
-        AdwebSite site = adwebSiteService.getById(siteId);
-        return Result.OK(site);
+    // 将国家按大洲分组,然后组装成树结构
+    Map<String, List<AdwebCountry>> map = new HashMap<>();
+    for (AdwebCountry country : countries) {
+      String continentCode = country.getContinentCode();
+      List<AdwebCountry> countryList = map.computeIfAbsent(continentCode, k -> new ArrayList<>());
+      countryList.add(country);
     }
 
-    /**
-     * 添加
-     *
-     * @param adwebUserCountry
-     * @return
-     */
-    @AutoLog(value = "adweb_user_country-添加")
-    @Operation(description = "adweb_user_country-添加")
-    @PostMapping(value = "/add")
-    public Result<?> add(@RequestBody AdwebUserCountry adwebUserCountry) {
-        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        //        if(sysUser.isPerform()){
-        //            return Result.FORBIDDEN("\"演示版\"没有操作权限,如果需要操作,请切换到\"正式版\"再操作!");
-        //        }
-        adwebUserCountryService.save(adwebUserCountry);
-        return Result.OK("添加成功!");
+    List<TreeOption> options = new ArrayList<>();
+    for (List<AdwebCountry> countryList : map.values()) {
+      TreeOption parentOption = new TreeOption();
+      parentOption.setKey(countryList.get(0).getContinentCode());
+      parentOption.setValue(countryList.get(0).getContinentCode());
+      parentOption.setTitle(countryList.get(0).getContinentName());
+      List<TreeOption> children = new ArrayList<>();
+      for (AdwebCountry country : countryList) {
+        TreeOption option = new TreeOption();
+        option.setKey(country.getGeonameId());
+        option.setValue(country.getGeonameId());
+        option.setTitle(country.getCountryName());
+        children.add(option);
+      }
+      parentOption.setChildren(children);
+      options.add(parentOption);
     }
 
-    /**
-     * 编辑
-     *
-     * @param adwebUserCountry
-     * @return
-     */
-    @AutoLog(value = "adweb_user_country-编辑")
-    @Operation(description = "adweb_user_country-编辑")
-    @PutMapping(value = "/edit")
-    public Result<?> edit(@RequestBody AdwebUserCountry adwebUserCountry) {
-        adwebUserCountryService.updateById(adwebUserCountry);
-        return Result.OK("编辑成功!");
+    return Result.OK(options);
+  }
+
+  /** 分配国家 */
+  @PostMapping(value = "/contribute/add")
+  public Result<?> contributeCountry(@RequestBody DistributeCountryParam param) {
+    String uid = param.getUid();
+    String countryIds = param.getCountryIds();
+    String[] countryIdArr = countryIds.split(",");
+    LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    List<AdwebUserCountry> userCountries = new ArrayList<>();
+    for (String countryId : countryIdArr) {
+      if (StringUtils.isEmpty(countryId) || this.notNum(countryId)) {
+        continue;
+      }
+      AdwebUserCountry country = new AdwebUserCountry();
+      country.setUid(uid);
+      country.setMasterUid(loginUser.getId());
+      country.setSiteId(param.getSiteId());
+      country.setCountryId(Integer.parseInt(countryId));
+      country.setStatus(1);
+      country.setCreateTime(new Date());
+      userCountries.add(country);
     }
-
-    /**
-     * 通过id删除
-     *
-     * @param id
-     * @return
-     */
-    @AutoLog(value = "adweb_user_country-通过id删除")
-    @Operation(description = "adweb_user_country-通过id删除")
-    @DeleteMapping(value = "/delete")
-    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
-        adwebUserCountryService.removeById(id);
-        return Result.OK("删除成功!");
+    adwebUserCountryService.saveBatch(userCountries);
+
+    // 更改相关询盘的负责人
+    LambdaQueryWrapper<AdwebCountry> countryQueryWrapper = new LambdaQueryWrapper<>();
+    countryQueryWrapper.in(AdwebCountry::getGeonameId, countryIdArr);
+    List<AdwebCountry> countries = admpCountryService.list(countryQueryWrapper);
+    List<String> countryCodes =
+        countries.stream().map(AdwebCountry::getCountryIsoCode).collect(Collectors.toList());
+
+    List<Integer> siteIds = adwebSiteService.getAllSiteIdByParentId(param.getSiteId());
+    LambdaUpdateWrapper<AdwebEnquiry> enquiryUpdateWrapper = new LambdaUpdateWrapper<>();
+    enquiryUpdateWrapper.in(AdwebEnquiry::getCountryCode, countryCodes);
+    enquiryUpdateWrapper.in(AdwebEnquiry::getSiteId, siteIds);
+    enquiryUpdateWrapper.ne(AdwebEnquiry::getPrincipalType, 1);
+    enquiryUpdateWrapper.set(AdwebEnquiry::getPrincipalUid, param.getUid());
+    adwebEnquiryService.update(enquiryUpdateWrapper);
+
+    return Result.OK();
+  }
+
+  private boolean notNum(String countryId) {
+    if (countryId.charAt(0) < '1' || countryId.charAt(0) > '9') {
+      return true;
     }
-
-    /**
-     * 批量删除
-     *
-     * @param ids
-     * @return
-     */
-    @AutoLog(value = "adweb_user_country-批量删除")
-    @Operation(description = "adweb_user_country-批量删除")
-    @DeleteMapping(value = "/deleteBatch")
-    public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
-        this.adwebUserCountryService.removeByIds(Arrays.asList(ids.split(",")));
-        return Result.OK("批量删除成功!");
+    return false;
+  }
+
+  /** 分配国家 */
+  @PostMapping(value = "/contribute/delete")
+  public Result<?> delete(@RequestBody DistributeCountryParam param) {
+    LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    //        if(sysUser.isPerform()){
+    //            return Result.FORBIDDEN("\"演示版\"没有操作权限,如果需要操作,请切换到\"正式版\"再操作!");
+    //        }
+    String uid = param.getUid();
+    String countryIds = param.getCountryIds();
+    List<String> countryIdList = new ArrayList<>();
+    if (StringUtils.isNotBlank(countryIds)) {
+      Collections.addAll(countryIdList, countryIds.split(","));
     }
-
-    /**
-     * 通过id查询
-     *
-     * @param id
-     * @return
-     */
-    @AutoLog(value = "adweb_user_country-通过id查询")
-    @Operation(description = "adweb_user_country-通过id查询")
-    @GetMapping(value = "/queryById")
-    public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
-        AdwebUserCountry adwebUserCountry = adwebUserCountryService.getById(id);
-        if (adwebUserCountry == null) {
-            return Result.error("未找到对应数据");
-        }
-        return Result.OK(adwebUserCountry);
+    countryIdList.removeIf(this::notNum);
+    LambdaUpdateWrapper<AdwebUserCountry> updateWrapper = new LambdaUpdateWrapper<>();
+    updateWrapper.eq(AdwebUserCountry::getUid, uid);
+    updateWrapper.eq(AdwebUserCountry::getSiteId, param.getSiteId());
+    if (CollectionUtils.isNotEmpty(countryIdList)) {
+      updateWrapper.notIn(AdwebUserCountry::getCountryId, countryIdList);
     }
-
-    /**
-     * 导出excel
-     *
-     * @param request
-     * @param adwebUserCountry
-     */
-    @RequestMapping(value = "/exportXls")
-    public ModelAndView exportXls(HttpServletRequest request, AdwebUserCountry adwebUserCountry) {
-        return super.exportXls(
-                request, adwebUserCountry, AdwebUserCountry.class, "adweb_user_country");
+    updateWrapper.set(AdwebUserCountry::getStatus, 0);
+    adwebUserCountryService.update(updateWrapper);
+
+    // 更改相关询盘的负责人
+    List<Integer> siteIds = adwebSiteService.getAllSiteIdByParentId(param.getSiteId());
+    LambdaUpdateWrapper<AdwebEnquiry> enquiryUpdateWrapper = new LambdaUpdateWrapper<>();
+    if (CollectionUtils.isNotEmpty(countryIdList)) {
+      LambdaQueryWrapper<AdwebCountry> countryQueryWrapper = new LambdaQueryWrapper<>();
+      countryQueryWrapper.in(AdwebCountry::getGeonameId, countryIdList);
+      List<AdwebCountry> countries = admpCountryService.list(countryQueryWrapper);
+      List<String> countryCodes =
+          countries.stream().map(AdwebCountry::getCountryIsoCode).collect(Collectors.toList());
+      enquiryUpdateWrapper.notIn(AdwebEnquiry::getCountryCode, countryCodes);
     }
-
-    /**
-     * 通过excel导入数据
-     *
-     * @param request
-     * @param response
-     * @return
-     */
-    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
-    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        return super.importExcel(request, response, AdwebUserCountry.class);
+    enquiryUpdateWrapper.in(AdwebEnquiry::getSiteId, siteIds);
+    enquiryUpdateWrapper.eq(AdwebEnquiry::getPrincipalUid, param.getUid());
+    enquiryUpdateWrapper.ne(AdwebEnquiry::getPrincipalType, 1);
+    enquiryUpdateWrapper.setSql("principal_uid = uid");
+    adwebEnquiryService.update(enquiryUpdateWrapper);
+    return Result.OK();
+  }
+
+  /** 更改分配方式 */
+  @AutoLog(value = "询盘管理-询盘分配-分配规则切换")
+  @PostMapping(value = "/updateDistributeType")
+  public Result<?> updateDistributeType(
+      @RequestParam Integer siteId, @RequestParam String distributeType) {
+
+    LambdaUpdateWrapper<AdwebSite> updateWrapper = new LambdaUpdateWrapper<>();
+    updateWrapper.eq(AdwebSite::getId, siteId);
+    updateWrapper.set(AdwebSite::getEnquiryDistributeType, distributeType);
+    adwebSiteService.update(updateWrapper);
+
+    // 修改询盘的跟进人
+    if (EnquiryDistributeTypeConstant.MASTER.equals(distributeType)) {
+      LambdaUpdateWrapper<AdwebEnquiry> enquiryUpdateWrapper = new LambdaUpdateWrapper<>();
+      enquiryUpdateWrapper.ne(AdwebEnquiry::getPrincipalType, 1);
+      enquiryUpdateWrapper.setSql("principal_uid = uid");
+      adwebEnquiryService.update(enquiryUpdateWrapper);
+    } else if (EnquiryDistributeTypeConstant.ALL.equals(distributeType)) {
+      LambdaUpdateWrapper<AdwebEnquiry> enquiryUpdateWrapper = new LambdaUpdateWrapper<>();
+      enquiryUpdateWrapper.ne(AdwebEnquiry::getPrincipalType, 1);
+      enquiryUpdateWrapper.set(AdwebEnquiry::getPrincipalUid, "ALL");
+      adwebEnquiryService.update(enquiryUpdateWrapper);
+    } else if (EnquiryDistributeTypeConstant.REGION.equals(distributeType)) {
+      adwebEnquiryService.updatePrincipalUidByRegion(siteId);
+    }
+    return Result.OK();
+  }
+
+  /** 更改询盘发送规则 */
+  @AutoLog(value = "询盘管理-询盘分配-更改询盘发送规则")
+  @PostMapping(value = "/updateSendEmailType")
+  public Result<?> updateSendEmailType(
+      @RequestParam Integer siteId, @RequestParam String sendEmailType) {
+    LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    //        if(sysUser.isPerform()){
+    //            return Result.FORBIDDEN("\"演示版\"没有操作权限,如果需要操作,请切换到\"正式版\"再操作!");
+    //        }
+    LambdaUpdateWrapper<AdwebSite> updateWrapper = new LambdaUpdateWrapper<>();
+    updateWrapper.eq(AdwebSite::getId, siteId);
+    updateWrapper.set(AdwebSite::getEnquirySendEmailType, sendEmailType);
+    adwebSiteService.update(updateWrapper);
+
+    return Result.OK();
+  }
+
+  /** 根据站点id获取站点信息 */
+  @GetMapping(value = "/getSiteBySiteId")
+  public Result<?> getSiteBySiteId(Integer siteId) {
+    AdwebSite site = adwebSiteService.getById(siteId);
+    return Result.OK(site);
+  }
+
+  /**
+   * 添加
+   *
+   * @param adwebUserCountry
+   * @return
+   */
+  @AutoLog(value = "adweb_user_country-添加")
+  @Operation(description = "adweb_user_country-添加")
+  @PostMapping(value = "/add")
+  public Result<?> add(@RequestBody AdwebUserCountry adwebUserCountry) {
+    LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    //        if(sysUser.isPerform()){
+    //            return Result.FORBIDDEN("\"演示版\"没有操作权限,如果需要操作,请切换到\"正式版\"再操作!");
+    //        }
+    adwebUserCountryService.save(adwebUserCountry);
+    return Result.OK("添加成功!");
+  }
+
+  /**
+   * 编辑
+   *
+   * @param adwebUserCountry
+   * @return
+   */
+  @AutoLog(value = "adweb_user_country-编辑")
+  @Operation(description = "adweb_user_country-编辑")
+  @PutMapping(value = "/edit")
+  public Result<?> edit(@RequestBody AdwebUserCountry adwebUserCountry) {
+    adwebUserCountryService.updateById(adwebUserCountry);
+    return Result.OK("编辑成功!");
+  }
+
+  /**
+   * 通过id删除
+   *
+   * @param id
+   * @return
+   */
+  @AutoLog(value = "adweb_user_country-通过id删除")
+  @Operation(description = "adweb_user_country-通过id删除")
+  @DeleteMapping(value = "/delete")
+  public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+    adwebUserCountryService.removeById(id);
+    return Result.OK("删除成功!");
+  }
+
+  /**
+   * 批量删除
+   *
+   * @param ids
+   * @return
+   */
+  @AutoLog(value = "adweb_user_country-批量删除")
+  @Operation(description = "adweb_user_country-批量删除")
+  @DeleteMapping(value = "/deleteBatch")
+  public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+    this.adwebUserCountryService.removeByIds(Arrays.asList(ids.split(",")));
+    return Result.OK("批量删除成功!");
+  }
+
+  /**
+   * 通过id查询
+   *
+   * @param id
+   * @return
+   */
+  @AutoLog(value = "adweb_user_country-通过id查询")
+  @Operation(description = "adweb_user_country-通过id查询")
+  @GetMapping(value = "/queryById")
+  public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
+    AdwebUserCountry adwebUserCountry = adwebUserCountryService.getById(id);
+    if (adwebUserCountry == null) {
+      return Result.error("未找到对应数据");
     }
+    return Result.OK(adwebUserCountry);
+  }
+
+  /**
+   * 导出excel
+   *
+   * @param request
+   * @param adwebUserCountry
+   */
+  @RequestMapping(value = "/exportXls")
+  public ModelAndView exportXls(HttpServletRequest request, AdwebUserCountry adwebUserCountry) {
+    return super.exportXls(request, adwebUserCountry, AdwebUserCountry.class, "adweb_user_country");
+  }
+
+  /**
+   * 通过excel导入数据
+   *
+   * @param request
+   * @param response
+   * @return
+   */
+  @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+  public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+    return super.importExcel(request, response, AdwebUserCountry.class);
+  }
 }

+ 39 - 37
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/userCountry/entity/AdwebCountry.java

@@ -2,53 +2,55 @@ package org.jeecg.modules.adweb.userCountry.entity;
 
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.v3.oas.annotations.media.Schema;
+import java.io.Serializable;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
-import java.io.Serializable;
-
 /**
- * @Description: adweb_country
- * @Author: jeecg-boot
- * @Date:   2021-11-16
- * @Version: V1.0
+ * @Description: adweb_country @Author: jeecg-boot @Date: 2021-11-16 @Version: V1.0
  */
 @Data
 @TableName("adweb_country")
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = false)
-@Schema(description="admp_country")
+@Schema(description = "adweb_country")
 public class AdwebCountry implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-	/**geonameId*/
-	@Excel(name = "geonameId", width = 15)
-    @Schema(description = "geonameId")
-    private String geonameId;
-	/**localeCode*/
-	@Excel(name = "localeCode", width = 15)
-    @Schema(description = "localeCode")
-    private String localeCode;
-	/**continentCode*/
-	@Excel(name = "continentCode", width = 15)
-    @Schema(description = "continentCode")
-    private String continentCode;
-	/**continentName*/
-	@Excel(name = "continentName", width = 15)
-    @Schema(description = "continentName")
-    private String continentName;
-	/**countryIsoCode*/
-	@Excel(name = "countryIsoCode", width = 15)
-    @Schema(description = "countryIsoCode")
-    private String countryIsoCode;
-	/**countryName*/
-	@Excel(name = "countryName", width = 15)
-    @Schema(description = "countryName")
-    private String countryName;
-	/**isInEuropeanUnion*/
-	@Excel(name = "isInEuropeanUnion", width = 15)
-    @Schema(description = "isInEuropeanUnion")
-    private String isInEuropeanUnion;
+  private static final long serialVersionUID = 1L;
+
+  /** geonameId */
+  @Excel(name = "geonameId", width = 15)
+  @Schema(description = "geonameId")
+  private String geonameId;
+
+  /** localeCode */
+  @Excel(name = "localeCode", width = 15)
+  @Schema(description = "localeCode")
+  private String localeCode;
+
+  /** continentCode */
+  @Excel(name = "continentCode", width = 15)
+  @Schema(description = "continentCode")
+  private String continentCode;
+
+  /** continentName */
+  @Excel(name = "continentName", width = 15)
+  @Schema(description = "continentName")
+  private String continentName;
+
+  /** countryIsoCode */
+  @Excel(name = "countryIsoCode", width = 15)
+  @Schema(description = "countryIsoCode")
+  private String countryIsoCode;
+
+  /** countryName */
+  @Excel(name = "countryName", width = 15)
+  @Schema(description = "countryName")
+  private String countryName;
+
+  /** isInEuropeanUnion */
+  @Excel(name = "isInEuropeanUnion", width = 15)
+  @Schema(description = "isInEuropeanUnion")
+  private String isInEuropeanUnion;
 }

+ 2 - 7
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/userCountry/mapper/AdwebCountryMapper.java

@@ -4,11 +4,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.adweb.userCountry.entity.AdwebCountry;
 
 /**
- * @Description: admp_country
- * @Author: jeecg-boot
- * @Date:   2021-11-16
- * @Version: V1.0
+ * @Description: adweb_country @Author: jeecg-boot @Date: 2021-11-16 @Version: V1.0
  */
-public interface AdwebCountryMapper extends BaseMapper<AdwebCountry> {
-
-}
+public interface AdwebCountryMapper extends BaseMapper<AdwebCountry> {}

+ 40 - 42
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/userCountry/mapper/xml/AdwebUserCountryMapper.xml

@@ -4,52 +4,50 @@
 
     <select id="getSubUserList" resultType="org.jeecg.modules.adweb.userCountry.dto.SubUser">
         SELECT
-            t0.sub_id id,
-            t4.username,
-            t4.realname,
-            COUNT(DISTINCT t1.country_id) countryNum,
-            enquiryCount enquiryNum
+        t0.sub_id id,
+        t4.username,
+        t4.realname,
+        COUNT(DISTINCT t1.country_id) countryNum,
+        enquiryCount enquiryNum
         FROM
-            adweb_master_sub_account_relation t0
-            LEFT JOIN adweb_user_country t1 ON t0.sub_id = t1.uid AND t1.`status` = 1 AND t1.site_id IN
-            <foreach collection="siteIds" open="(" close=")" separator="," item="siteId">
-                #{siteId}
-            </foreach>
-            LEFT JOIN admp_country t2 ON t1.country_id = t2.geoname_id
-            LEFT JOIN
-            (
-                SELECT
-                    COUNT(id) enquiryCount,
-                    principal_uid
-                FROM
-                    adweb_enquiry
-                WHERE
-                    `status` = 1 AND site_id IN
-                    <foreach collection="siteIds" open="(" close=")" separator="," item="siteId">
-                        #{siteId}
-                    </foreach>
-                GROUP BY
-                    principal_uid
-            ) t3 ON t0.sub_id = t3.principal_uid
-            LEFT JOIN sys_user t4 ON t0.sub_id = t4.id
+        adweb_master_sub_account_relation t0
+        LEFT JOIN adweb_user_country t1 ON t0.sub_id = t1.uid AND t1.`status` = 1 AND t1.site_id IN
+        <foreach collection="siteIds" open="(" close=")" separator="," item="siteId">
+            #{siteId}
+        </foreach>
+        LEFT JOIN adweb_country t2 ON t1.country_id = t2.geoname_id
+        LEFT JOIN
+        (
+        SELECT
+        COUNT(id) enquiryCount,
+        principal_uid
+        FROM
+        adweb_enquiry
+        WHERE
+        `status` = 1 AND site_id IN
+        <foreach collection="siteIds" open="(" close=")" separator="," item="siteId">
+            #{siteId}
+        </foreach>
+        GROUP BY
+        principal_uid
+        ) t3 ON t0.sub_id = t3.principal_uid
+        LEFT JOIN sys_user t4 ON t0.sub_id = t4.id
         WHERE
-            t0.`status` = 1
-            AND t0.master_id = #{uid}
+        t0.`status` = 1
+        AND t0.master_id = #{uid}
         GROUP BY
-            t0.sub_id
+        t0.sub_id,
+        t3.enquiryCount
     </select>
     <select id="getSubUserOptions" resultType="org.jeecg.modules.adweb.userCountry.dto.SubUser">
-        SELECT
-            t1.id,
-            t1.realname username
-        FROM
-            adweb_master_sub_account_relation t0,
-            sys_user t1
-        WHERE
-            t0.sub_id = t1.id
-            AND t0.`status` = 1
-            AND t1.del_flag = 0
-            AND t1.status = 1
-            AND t0.master_id = #{uid}
+        SELECT t1.id,
+               t1.realname username
+        FROM adweb_master_sub_account_relation t0,
+             sys_user t1
+        WHERE t0.sub_id = t1.id
+          AND t0.`status` = 1
+          AND t1.del_flag = 0
+          AND t1.status = 1
+          AND t0.master_id = #{uid}
     </select>
 </mapper>

+ 2 - 7
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/userCountry/service/IAdwebCountryService.java

@@ -4,11 +4,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.adweb.userCountry.entity.AdwebCountry;
 
 /**
- * @Description: admp_country
- * @Author: jeecg-boot
- * @Date:   2021-11-16
- * @Version: V1.0
+ * @Description: adweb_country @Author: jeecg-boot @Date: 2021-11-16 @Version: V1.0
  */
-public interface IAdwebCountryService extends IService<AdwebCountry> {
-
-}
+public interface IAdwebCountryService extends IService<AdwebCountry> {}

+ 2 - 5
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/userCountry/service/impl/AdwebCountryServiceImpl.java

@@ -7,11 +7,8 @@ import org.jeecg.modules.adweb.userCountry.service.IAdwebCountryService;
 import org.springframework.stereotype.Service;
 
 /**
- * @Description: admp_country
- * @Author: jeecg-boot
- * @Date: 2021-11-16
- * @Version: V1.0
+ * @Description: adweb_country @Author: jeecg-boot @Date: 2021-11-16 @Version: V1.0
  */
 @Service
 public class AdwebCountryServiceImpl extends ServiceImpl<AdwebCountryMapper, AdwebCountry>
-        implements IAdwebCountryService {}
+    implements IAdwebCountryService {}

+ 7 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysUserMapper.java

@@ -1,18 +1,17 @@
 package org.jeecg.modules.system.mapper;
 
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import java.util.List;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.jeecg.modules.system.entity.SysUser;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.system.model.SysUserSysDepartModel;
 import org.jeecg.modules.system.vo.SysUserDepVo;
 
-import java.util.List;
-
 /**
  * <p>
  * 用户表 Mapper 接口
@@ -222,4 +221,9 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
 	 */
 	@Select("select id,phone from sys_user where phone = #{phone} and username = #{username}")
     SysUser getUserByNameAndPhone(@Param("phone") String phone, @Param("username") String username);
+
+	/**
+	 * 根据子账号id集合查询所有邮箱
+	 */
+	List<String> getEmailBySubIdList(List<String> idList);
 }

+ 297 - 274
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml

@@ -2,300 +2,323 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.system.mapper.SysUserMapper">
 
-	<!-- 根据用户名查询 -->
-	<select id="getUserByName" resultType="org.jeecg.modules.system.entity.SysUser">
-		select * from  sys_user  where username = #{username} and del_flag = 0
-	</select>
-	
-	<!-- 根据用户名查询用户ID -->
-	<select id="getUserIdByName" resultType="String">
-		select id from  sys_user  where username = #{username} and del_flag = 0
-	</select>
+    <!-- 根据用户名查询 -->
+    <select id="getUserByName" resultType="org.jeecg.modules.system.entity.SysUser">
+        select *
+        from sys_user
+        where username = #{username}
+          and del_flag = 0
+    </select>
 
-	<!-- 根据部门Id查询 -->
-	<select id="getUserByDepId" resultType="org.jeecg.modules.system.entity.SysUser">
-		select * from sys_user where del_flag = 0 and id in (select user_id from sys_user_depart where dep_id=#{departId})
-		<if test="username!=null and username!=''">
-			and username = #{username}
-		</if>
-	</select>
+    <!-- 根据用户名查询用户ID -->
+    <select id="getUserIdByName" resultType="String">
+        select id
+        from sys_user
+        where username = #{username}
+          and del_flag = 0
+    </select>
 
-	<!-- 查询部门和子部门下的所有用户账号 -->
-	<select id="getUserAccountsByDepCode" resultType="String">
-		<if test="orgCode != null">
-			<bind name="bindOrgCode" value="orgCode+'%'"/>
-		</if>
-		select username from sys_user where del_flag = 0 and id in (select user_id from sys_user_depart where dep_id in (select id from sys_depart where org_code LIKE #{bindOrgCode}))
-	</select>
+    <!-- 根据部门Id查询 -->
+    <select id="getUserByDepId" resultType="org.jeecg.modules.system.entity.SysUser">
+        select * from sys_user where del_flag = 0 and id in (select user_id from sys_user_depart where
+        dep_id=#{departId})
+        <if test="username!=null and username!=''">
+            and username = #{username}
+        </if>
+    </select>
 
-	<!-- 查询用户的所属部门名称信息 -->
-	<select id="getDepNamesByUserIds" resultType="org.jeecg.modules.system.vo.SysUserDepVo">
-		select d.depart_name,ud.user_id from sys_user_depart ud,sys_depart d where d.id = ud.dep_id and ud.user_id in
-		<foreach collection="userIds" index="index" item="id" open="(" separator="," close=")">
-			#{id}
-		</foreach>
-	</select>
+    <!-- 查询部门和子部门下的所有用户账号 -->
+    <select id="getUserAccountsByDepCode" resultType="String">
+        <if test="orgCode != null">
+            <bind name="bindOrgCode" value="orgCode+'%'"/>
+        </if>
+        select username from sys_user where del_flag = 0 and id in (select user_id from sys_user_depart where dep_id in
+        (select id from sys_depart where org_code LIKE #{bindOrgCode}))
+    </select>
 
-	<!-- 通过多个部门IDS,查询部门下的用户信息 -->
-	<select id="getUserByDepIds" resultType="org.jeecg.modules.system.entity.SysUser">
-		select * from sys_user where del_flag = 0
-		<if test="departIds!=null  and departIds.size()>0">
-			and id in (select user_id from sys_user_depart where dep_id in
-			<foreach collection="departIds" index="index" item="id" open="(" separator="," close=")">
-				#{id}
-			</foreach>
-			)
-		</if>
-		<if test="username!=null and username!=''">
-			and username = #{username}
-		</if>
-	</select>
+    <!-- 查询用户的所属部门名称信息 -->
+    <select id="getDepNamesByUserIds" resultType="org.jeecg.modules.system.vo.SysUserDepVo">
+        select d.depart_name,ud.user_id from sys_user_depart ud,sys_depart d where d.id = ud.dep_id and ud.user_id in
+        <foreach collection="userIds" index="index" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </select>
 
-	<!-- 根据角色Id查询 -->
-	<select id="getUserByRoleId" resultType="org.jeecg.modules.system.entity.SysUser">
-		select * from sys_user where del_flag = 0 and id in (select user_id from sys_user_role where role_id=#{roleId})
-		<if test="username!=null and username!=''">
-			and username = #{username}
-		</if>
-	</select>
-	
-	<!--  修改用户部门code -->
-	<update id="updateUserDepart">
-		UPDATE sys_user SET
-		<if test="orgCode!=null and loginTenantId!=null">
-			 org_code = #{orgCode}
-			,login_tenant_id = #{loginTenantId}
-		</if>
-		<if test="orgCode==null and loginTenantId!=null">
-			login_tenant_id = #{loginTenantId}
-		</if>
-		<if test="orgCode!=null and loginTenantId==null">
-			org_code = #{orgCode}
-		</if>
-		where username = #{username}
-	</update>
+    <!-- 通过多个部门IDS,查询部门下的用户信息 -->
+    <select id="getUserByDepIds" resultType="org.jeecg.modules.system.entity.SysUser">
+        select * from sys_user where del_flag = 0
+        <if test="departIds!=null  and departIds.size()>0">
+            and id in (select user_id from sys_user_depart where dep_id in
+            <foreach collection="departIds" index="index" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+            )
+        </if>
+        <if test="username!=null and username!=''">
+            and username = #{username}
+        </if>
+    </select>
 
-	<!-- 根据手机号查询 -->
-	<select id="getUserByPhone"  resultType="org.jeecg.modules.system.entity.SysUser">
-		select * from  sys_user  where phone = #{phone} and del_flag = 0
-	</select>
-	
-	<!-- 根据邮箱查询用户信息 -->
-	<select id="getUserByEmail" resultType="org.jeecg.modules.system.entity.SysUser">
-	select * from  sys_user  where email = #{email} and del_flag = 0
-	</select>
+    <!-- 根据角色Id查询 -->
+    <select id="getUserByRoleId" resultType="org.jeecg.modules.system.entity.SysUser">
+        select * from sys_user where del_flag = 0 and id in (select user_id from sys_user_role where role_id=#{roleId})
+        <if test="username!=null and username!=''">
+            and username = #{username}
+        </if>
+    </select>
 
-	<!-- SQL片段:getUserByOrgCode 的 FROM 和 WHERE 部分 -->
-	<sql id="getUserByOrgCodeFromSql">
-		FROM
-		sys_depart
-		INNER JOIN sys_user_depart ON sys_user_depart.dep_id = sys_depart.id
-		INNER JOIN sys_user ON sys_user.id = sys_user_depart.user_id
-		WHERE
-		<if test="orgCode == null">
-			<bind name="bindOrgCode" value="'%'"/>
-		</if>
-		<if test="orgCode != null">
-			<bind name="bindOrgCode" value="orgCode+'%'"/>
-		</if>
-		sys_user.del_flag = 0 AND sys_depart.org_code LIKE #{bindOrgCode}
+    <!--  修改用户部门code -->
+    <update id="updateUserDepart">
+        UPDATE sys_user SET
+        <if test="orgCode!=null and loginTenantId!=null">
+            org_code = #{orgCode}
+            ,login_tenant_id = #{loginTenantId}
+        </if>
+        <if test="orgCode==null and loginTenantId!=null">
+            login_tenant_id = #{loginTenantId}
+        </if>
+        <if test="orgCode!=null and loginTenantId==null">
+            org_code = #{orgCode}
+        </if>
+        where username = #{username}
+    </update>
 
-		<if test="userParams != null">
-			<if test="userParams.realname != null and userParams.realname != ''">
-				AND sys_user.realname LIKE concat(concat('%',#{userParams.realname}),'%')
-			</if>
-			<if test="userParams.workNo != null and userParams.workNo != ''">
-				AND sys_user.work_no LIKE concat(concat('%',#{userParams.workNo}),'%')
-			</if>
-		</if>
-	</sql>
+    <!-- 根据手机号查询 -->
+    <select id="getUserByPhone" resultType="org.jeecg.modules.system.entity.SysUser">
+        select *
+        from sys_user
+        where phone = #{phone}
+          and del_flag = 0
+    </select>
 
-	<!-- 根据 orgCode 查询用户,包括子部门下的用户 -->
-	<select id="getUserByOrgCode" resultType="org.jeecg.modules.system.model.SysUserSysDepartModel">
-		SELECT
-			sys_user.id AS id,
-			sys_user.realname AS realname,
-			sys_user.avatar AS avatar,
-			sys_user.sex AS sex,
-			sys_user.birthday AS birthday,
-			sys_user.work_no AS workNo,
-			sys_user.telephone AS telephone,
-			sys_user.email AS email,
-			sys_user.phone AS phone,
-			sys_depart.id AS departId,
-			sys_depart.depart_name AS departName
-		<include refid="getUserByOrgCodeFromSql"/>
-		ORDER BY
-			sys_depart.org_code ASC
-	</select>
+    <!-- 根据邮箱查询用户信息 -->
+    <select id="getUserByEmail" resultType="org.jeecg.modules.system.entity.SysUser">
+        select *
+        from sys_user
+        where email = #{email}
+          and del_flag = 0
+    </select>
 
-	<!-- 查询 getUserByOrgCode 的总数-->
-	<select id="getUserByOrgCodeTotal" resultType="java.lang.Integer">
-		SELECT COUNT(1) <include refid="getUserByOrgCodeFromSql"/>
-	</select>
+    <!-- SQL片段:getUserByOrgCode 的 FROM 和 WHERE 部分 -->
+    <sql id="getUserByOrgCodeFromSql">
+        FROM
+        sys_depart
+        INNER JOIN sys_user_depart ON sys_user_depart.dep_id = sys_depart.id
+        INNER JOIN sys_user ON sys_user.id = sys_user_depart.user_id
+        WHERE
+        <if test="orgCode == null">
+            <bind name="bindOrgCode" value="'%'"/>
+        </if>
+        <if test="orgCode != null">
+            <bind name="bindOrgCode" value="orgCode+'%'"/>
+        </if>
+        sys_user.del_flag = 0 AND sys_depart.org_code LIKE #{bindOrgCode}
 
-	<!-- 批量删除角色的与用户关系-->
-	<update id="deleteBathRoleUserRelation">
-		delete from sys_user_role
-		where role_id in
-		<foreach item="id" collection="roleIdArray" open="(" separator="," close=")">
-			#{id}
-		</foreach>
-	</update>
-	<!-- 批量删除角色的与权限关系-->
-	<update id="deleteBathRolePermissionRelation">
-		delete from sys_role_permission
-		where role_id in
-		<foreach item="id" collection="roleIdArray" open="(" separator="," close=")">
-			#{id}
-		</foreach>
-	</update>
+        <if test="userParams != null">
+            <if test="userParams.realname != null and userParams.realname != ''">
+                AND sys_user.realname LIKE concat(concat('%',#{userParams.realname}),'%')
+            </if>
+            <if test="userParams.workNo != null and userParams.workNo != ''">
+                AND sys_user.work_no LIKE concat(concat('%',#{userParams.workNo}),'%')
+            </if>
+        </if>
+    </sql>
 
-	<!-- 查询被逻辑删除的用户 -->
-	<select id="selectLogicDeleted" resultType="org.jeecg.modules.system.entity.SysUser">
-		SELECT * FROM sys_user ${ew.customSqlSegment}
-	</select>
+    <!-- 根据 orgCode 查询用户,包括子部门下的用户 -->
+    <select id="getUserByOrgCode" resultType="org.jeecg.modules.system.model.SysUserSysDepartModel">
+        SELECT
+        sys_user.id AS id,
+        sys_user.realname AS realname,
+        sys_user.avatar AS avatar,
+        sys_user.sex AS sex,
+        sys_user.birthday AS birthday,
+        sys_user.work_no AS workNo,
+        sys_user.telephone AS telephone,
+        sys_user.email AS email,
+        sys_user.phone AS phone,
+        sys_depart.id AS departId,
+        sys_depart.depart_name AS departName
+        <include refid="getUserByOrgCodeFromSql"/>
+        ORDER BY
+        sys_depart.org_code ASC
+    </select>
 
-	<!-- 更新被逻辑删除的用户 -->
-	<update id="revertLogicDeleted">
-		UPDATE
-			sys_user
-		SET
-			del_flag = 0,
-			update_by = #{entity.updateBy},
-			update_time = #{entity.updateTime}
-		WHERE
-			del_flag = 1
-			AND id IN
-			<foreach collection="userIds" item="userId" open="(" close=")" separator="," >
-				#{userId}
-			</foreach>
-	</update>
+    <!-- 查询 getUserByOrgCode 的总数-->
+    <select id="getUserByOrgCodeTotal" resultType="java.lang.Integer">
+        SELECT COUNT(1)
+        <include refid="getUserByOrgCodeFromSql"/>
+    </select>
 
-	<!-- 彻底删除被逻辑删除的用户 -->
-	<delete id="deleteLogicDeleted">
-		DELETE FROM sys_user WHERE del_flag = 1 AND id IN
-		<foreach collection="userIds" item="userId" open="(" close=")" separator="," >
-			#{userId}
-		</foreach>
-	</delete>
+    <!-- 批量删除角色的与用户关系-->
+    <update id="deleteBathRoleUserRelation">
+        delete from sys_user_role
+        where role_id in
+        <foreach item="id" collection="roleIdArray" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+    <!-- 批量删除角色的与权限关系-->
+    <update id="deleteBathRolePermissionRelation">
+        delete from sys_role_permission
+        where role_id in
+        <foreach item="id" collection="roleIdArray" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
 
-	<!-- 更新空字符串为null -->
-	<update id="updateNullByEmptyString">
-		UPDATE sys_user
-		<if test="fieldName == 'email'">
-			SET email = NULL WHERE email = ''
-		</if>
-		<if test="fieldName == 'phone'">
-			SET phone = NULL WHERE phone = ''
-		</if>
-	</update>
+    <!-- 查询被逻辑删除的用户 -->
+    <select id="selectLogicDeleted" resultType="org.jeecg.modules.system.entity.SysUser">
+        SELECT *
+        FROM sys_user ${ew.customSqlSegment}
+    </select>
 
-	<!-- 通过多个部门IDS,查询部门下的用户信息 -->
-	<select id="queryByDepIds" resultType="org.jeecg.modules.system.entity.SysUser">
-		select * from sys_user where del_flag = 0
-		<if test="departIds!=null  and departIds.size()>0">
-			and id in (select user_id from sys_user_depart where dep_id in
-			<foreach collection="departIds" index="index" item="id" open="(" separator="," close=")">
-				#{id}
-			</foreach>
-			)
-		</if>
-		<if test="username!=null and username!=''">
-			and username != #{username}
-		</if>
-	</select>
+    <!-- 更新被逻辑删除的用户 -->
+    <update id="revertLogicDeleted">
+        UPDATE
+        sys_user
+        SET
+        del_flag = 0,
+        update_by = #{entity.updateBy},
+        update_time = #{entity.updateTime}
+        WHERE
+        del_flag = 1
+        AND id IN
+        <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
+            #{userId}
+        </foreach>
+    </update>
 
-	<!--根据角色查询用户-->
-	<select id="selectUserListByRoleId" resultType="org.jeecg.modules.system.entity.SysUser">
-		select DISTINCT a.* from sys_user a
-		left join sys_user_role sur on sur.user_id = a.id
-		where
-		a.del_flag = 0 and a.status = 1
-		and a.username!='_reserve_user_external'
-		and sur.role_id=#{roleId}
-		<if test="keyword!=null and keyword!=''">
-			<bind name="bindKeyword" value="'%'+keyword+'%'"/>
-			and (a.username like #{bindKeyword} or a.realname like #{bindKeyword})
-		</if>
+    <!-- 彻底删除被逻辑删除的用户 -->
+    <delete id="deleteLogicDeleted">
+        DELETE FROM sys_user WHERE del_flag = 1 AND id IN
+        <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
+            #{userId}
+        </foreach>
+    </delete>
 
-		<if test="tenantId!=null">
-			and a.id in (
-				select user_id from sys_user_tenant where tenant_id = #{tenantId} and status = '1'
-			)
-		</if>
-		  
-		<!--【QQYUN-8239】用户角色,添加用户 返回2页数据,实际只显示一页 需要将不符合的用户id排除-->
-		<if test="excludeUserIdList!=null and excludeUserIdList.size()>0">
-			and a.id not in
-			<foreach collection="excludeUserIdList" item="userId" open="(" close=")" separator=",">
-				#{userId}
-			</foreach>
-		</if>
-	</select>
+    <!-- 更新空字符串为null -->
+    <update id="updateNullByEmptyString">
+        UPDATE sys_user
+        <if test="fieldName == 'email'">
+            SET email = NULL WHERE email = ''
+        </if>
+        <if test="fieldName == 'phone'">
+            SET phone = NULL WHERE phone = ''
+        </if>
+    </update>
 
-	<!--获取租户下的用户离职列表信息-->
-	<select id="getTenantQuitList" resultType="org.jeecg.modules.system.entity.SysUser">
-		select su.id,su.username,su.realname,su.sex,su.avatar,su.create_time,sut.create_by from sys_user su
-		join sys_user_tenant sut on sut.user_id = su.id and sut.status = '2'
-		where
-		su.status = 1
-		and su.del_flag = 0
-		<if test="tenantId != 0">
-			and sut.tenant_id = #{tenantId}
-		</if>
-	</select>
+    <!-- 通过多个部门IDS,查询部门下的用户信息 -->
+    <select id="queryByDepIds" resultType="org.jeecg.modules.system.entity.SysUser">
+        select * from sys_user where del_flag = 0
+        <if test="departIds!=null  and departIds.size()>0">
+            and id in (select user_id from sys_user_depart where dep_id in
+            <foreach collection="departIds" index="index" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+            )
+        </if>
+        <if test="username!=null and username!=''">
+            and username != #{username}
+        </if>
+    </select>
 
-	<!--获取租户下的有效用户ids信息-->
-	<select id="getTenantUserIdList" resultType="java.lang.String" parameterType="java.lang.Integer">
-		SELECT DISTINCT( su.id ) id
-		FROM sys_user su
-		<choose>
-			<when test="tenantId!=null and tenantId != 0">
-				JOIN sys_user_tenant sut ON sut.user_id = su.id
-				AND sut.STATUS = '1'
-				AND sut.tenant_id = #{tenantId}
-				AND su.STATUS = 1
-				AND su.del_flag = 0
-			</when>
-			<otherwise>
-				WHERE su.STATUS = 1
-				AND su.del_flag = 0
-			</otherwise>
-		</choose>
-	</select>
-	
-  <!--更新刪除状态和离职状态-->
-  <update id="updateStatusAndFlag">
-    UPDATE
-    sys_user
-    SET
-    del_flag = 0,
-    update_by = #{sysUser.updateBy},
-    update_time = #{sysUser.updateTime},
-    status = 1
-    WHERE
-    del_flag = 1
-    AND id IN
-    <foreach collection="userIds" item="userId" open="(" close=")" separator="," >
-      #{userId}
-    </foreach>
-  </update>
+    <!--根据角色查询用户-->
+    <select id="selectUserListByRoleId" resultType="org.jeecg.modules.system.entity.SysUser">
+        select DISTINCT a.* from sys_user a
+        left join sys_user_role sur on sur.user_id = a.id
+        where
+        a.del_flag = 0 and a.status = 1
+        and a.username!='_reserve_user_external'
+        and sur.role_id=#{roleId}
+        <if test="keyword!=null and keyword!=''">
+            <bind name="bindKeyword" value="'%'+keyword+'%'"/>
+            and (a.username like #{bindKeyword} or a.realname like #{bindKeyword})
+        </if>
 
-	<!--根据部门id获取用户数据-->
-	<select id="getUserByDepartsTenantId" resultType="org.jeecg.modules.system.entity.SysUser">
-		select su.* from sys_user su
-		join sys_user_tenant sut on su.id = sut.user_id
-		where su.del_flag = 0
-		<if test="departIds!=null  and departIds.size()>0">
-			and su.id in (select user_id from sys_user_depart
-			where dep_id in
-			<foreach collection="departIds" index="index" item="id" open="(" separator="," close=")">
-				#{id}
-			</foreach>
-			)
-		</if>
-		and sut.tenant_id=#{tenantId}
+        <if test="tenantId!=null">
+            and a.id in (
+            select user_id from sys_user_tenant where tenant_id = #{tenantId} and status = '1'
+            )
+        </if>
+
+        <!--【QQYUN-8239】用户角色,添加用户 返回2页数据,实际只显示一页 需要将不符合的用户id排除-->
+        <if test="excludeUserIdList!=null and excludeUserIdList.size()>0">
+            and a.id not in
+            <foreach collection="excludeUserIdList" item="userId" open="(" close=")" separator=",">
+                #{userId}
+            </foreach>
+        </if>
+    </select>
+
+    <!--获取租户下的用户离职列表信息-->
+    <select id="getTenantQuitList" resultType="org.jeecg.modules.system.entity.SysUser">
+        select su.id,su.username,su.realname,su.sex,su.avatar,su.create_time,sut.create_by from sys_user su
+        join sys_user_tenant sut on sut.user_id = su.id and sut.status = '2'
+        where
+        su.status = 1
+        and su.del_flag = 0
+        <if test="tenantId != 0">
+            and sut.tenant_id = #{tenantId}
+        </if>
+    </select>
+
+    <!--获取租户下的有效用户ids信息-->
+    <select id="getTenantUserIdList" resultType="java.lang.String" parameterType="java.lang.Integer">
+        SELECT DISTINCT( su.id ) id
+        FROM sys_user su
+        <choose>
+            <when test="tenantId!=null and tenantId != 0">
+                JOIN sys_user_tenant sut ON sut.user_id = su.id
+                AND sut.STATUS = '1'
+                AND sut.tenant_id = #{tenantId}
+                AND su.STATUS = 1
+                AND su.del_flag = 0
+            </when>
+            <otherwise>
+                WHERE su.STATUS = 1
+                AND su.del_flag = 0
+            </otherwise>
+        </choose>
+    </select>
+
+    <!--更新刪除状态和离职状态-->
+    <update id="updateStatusAndFlag">
+        UPDATE
+        sys_user
+        SET
+        del_flag = 0,
+        update_by = #{sysUser.updateBy},
+        update_time = #{sysUser.updateTime},
+        status = 1
+        WHERE
+        del_flag = 1
+        AND id IN
+        <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
+            #{userId}
+        </foreach>
+    </update>
+
+    <!--根据部门id获取用户数据-->
+    <select id="getUserByDepartsTenantId" resultType="org.jeecg.modules.system.entity.SysUser">
+        select su.* from sys_user su
+        join sys_user_tenant sut on su.id = sut.user_id
+        where su.del_flag = 0
+        <if test="departIds!=null  and departIds.size()>0">
+            and su.id in (select user_id from sys_user_depart
+            where dep_id in
+            <foreach collection="departIds" index="index" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+            )
+        </if>
+        and sut.tenant_id=#{tenantId}
         and sut.status = '1'
-	</select>
+    </select>
+
+    <select id="getEmailBySubIdList" resultType="java.lang.String">
+        select s.email from sys_user s where s.id in
+        <foreach collection="idList" index="index" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </select>
 </mapper>

+ 56 - 52
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysRoleService.java

@@ -13,65 +13,69 @@ import org.springframework.web.multipart.MultipartFile;
 import java.util.List;
 
 /**
- * <p>
- * 角色表 服务类
- * </p>
+ * 角色表 服务类 @Author scott
  *
- * @Author scott
  * @since 2018-12-19
  */
 public interface ISysRoleService extends IService<SysRole> {
-    /**
-     * 查询全部的角色(不做租户隔离)
-     * @param page
-     * @param role
-     * @return
-     */
-    Page<SysRole> listAllSysRole(@Param("page") Page<SysRole> page, SysRole role);
+  /**
+   * 查询全部的角色(不做租户隔离)
+   *
+   * @param page
+   * @param role
+   * @return
+   */
+  Page<SysRole> listAllSysRole(@Param("page") Page<SysRole> page, SysRole role);
 
-    /**
-     * 查询角色是否存在不做租户隔离
-     *
-     * @param roleCode
-     * @return
-     */
-    SysRole getRoleNoTenant(@Param("roleCode") String roleCode);
-    
-    /**
-     * 导入 excel ,检查 roleCode 的唯一性
-     *
-     * @param file
-     * @param params
-     * @return
-     * @throws Exception
-     */
-    Result importExcelCheckRoleCode(MultipartFile file, ImportParams params) throws Exception;
+  /**
+   * 查询角色是否存在不做租户隔离
+   *
+   * @param roleCode
+   * @return
+   */
+  SysRole getRoleNoTenant(@Param("roleCode") String roleCode);
 
-    /**
-     * 删除角色
-     * @param roleid
-     * @return
-     */
-    public boolean deleteRole(String roleid);
+  /**
+   * 导入 excel ,检查 roleCode 的唯一性
+   *
+   * @param file
+   * @param params
+   * @return
+   * @throws Exception
+   */
+  Result importExcelCheckRoleCode(MultipartFile file, ImportParams params) throws Exception;
 
-    /**
-     * 批量删除角色
-     * @param roleids
-     * @return
-     */
-    public boolean deleteBatchRole(String[] roleids);
+  /**
+   * 删除角色
+   *
+   * @param roleid
+   * @return
+   */
+  public boolean deleteRole(String roleid);
 
-    /**
-     * 根据角色id和当前租户判断当前角色是否存在这个租户中
-     * @param id
-     * @return
-     */
-    Long getRoleCountByTenantId(String id, Integer tenantId);
+  /**
+   * 批量删除角色
+   *
+   * @param roleids
+   * @return
+   */
+  public boolean deleteBatchRole(String[] roleids);
 
-    /**
-     * 验证是否为admin角色
-     * 
-     * @param ids
-     */
-    void checkAdminRoleRejectDel(String ids);
+  /**
+   * 根据角色id和当前租户判断当前角色是否存在这个租户中
+   *
+   * @param id
+   * @return
+   */
+  Long getRoleCountByTenantId(String id, Integer tenantId);
+
+  /**
+   * 验证是否为admin角色
+   *
+   * @param ids
+   */
+  void checkAdminRoleRejectDel(String ids);
+
+  /** 根据对应role_code获取对应id */
+  String getRoleIdByRoleCode(String roleCode);
 }

+ 457 - 413
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysUserService.java

@@ -24,422 +24,466 @@ import java.util.Map;
 import java.util.Set;
 
 /**
- * <p>
- * 用户表 服务类
- * </p>
+ * 用户表 服务类 @Author scott
  *
- * @Author scott
  * @since 2018-12-20
  */
 public interface ISysUserService extends IService<SysUser> {
 
-	/**
-	 * 查询用户数据列表
-	 * 
-	 * @param req
-	 * @param queryWrapper
-	 * @param pageSize
-	 * @param pageNo
-	 * @return
-	 */
-	Result<IPage<SysUser>> queryPageList(HttpServletRequest req, QueryWrapper<SysUser> queryWrapper, Integer pageSize, Integer pageNo);
-	
-	/**
-	 * 重置密码
-	 *
-	 * @param username
-	 * @param oldpassword
-	 * @param newpassword
-	 * @param confirmpassword
-	 * @return
-	 */
-	public Result<?> resetPassword(String username, String oldpassword, String newpassword, String confirmpassword);
-
-	/**
-	 * 修改密码
-	 *
-	 * @param sysUser
-	 * @return
-	 */
-	public Result<?> changePassword(SysUser sysUser);
-
-	/**
-	 * 删除用户
-	 * @param userId
-	 * @return
-	 */
-	public boolean deleteUser(String userId);
-
-	/**
-	 * 批量删除用户
-	 * @param userIds
-	 * @return
-	 */
-	public boolean deleteBatchUsers(String userIds);
-
-    /**
-     * 根据用户名查询
-     * @param username 用户名
-     * @return SysUser
-     */
-	public SysUser getUserByName(String username);
-	
-	/**
-	 * 添加用户和用户角色关系
-	 * @param user
-	 * @param roles
-	 */
-	public void addUserWithRole(SysUser user, String roles);
-	
-	
-	/**
-	 * 修改用户和用户角色关系
-	 * @param user
-	 * @param roles
-	 */
-	public void editUserWithRole(SysUser user, String roles);
-
-	/**
-	 * 获取用户的授权角色
-	 * @param username
-	 * @return
-	 */
-	public List<String> getRole(String username);
-
-	/**
-	 * 获取根据登录用户的角色获取动态首页
-	 *
-	 * @param username
-	 * @param version 前端UI版本
-	 * @return
-	 */
-	public SysRoleIndex getDynamicIndexByUserRole(String username, String version);
-	
-	/**
-	  * 查询用户信息包括 部门信息
-	 * @param username
-	 * @return
-	 */
-	@Deprecated
-	public SysUserCacheInfo getCacheUser(String username);
-
-	/**
-	 * 根据部门Id查询
-	 * @param page
-     * @param departId 部门id
-     * @param username 用户账户名称
-	 * @return
-	 */
-	public IPage<SysUser> getUserByDepId(Page<SysUser> page, String departId, String username);
-
-	/**
-	 * 根据部门Ids查询
-	 * @param page
-     * @param departIds  部门id集合
-     * @param username 用户账户名称
-	 * @return
-	 */
-	public IPage<SysUser> getUserByDepIds(Page<SysUser> page, List<String> departIds, String username);
-
-	/**
-	 * 根据 userIds查询,查询用户所属部门的名称(多个部门名逗号隔开)
-	 * @param userIds
-	 * @return
-	 */
-	public Map<String,String> getDepNamesByUserIds(List<String> userIds);
-
-    /**
-     * 根据部门 Id 和 QueryWrapper 查询
-     *
-     * @param page
-     * @param departId
-     * @param queryWrapper
-     * @return
-     */
-    //update-begin-author:taoyan date:2022-9-13 for: VUEN-2245【漏洞】发现新漏洞待处理20220906 ----sql注入 方法没有使用,注掉
-    // public IPage<SysUser> getUserByDepartIdAndQueryWrapper(Page<SysUser> page, String departId, QueryWrapper<SysUser> queryWrapper);
-	//update-end-author:taoyan date:2022-9-13 for: VUEN-2245【漏洞】发现新漏洞待处理20220906 ----sql注入 方法没有使用,注掉
-
-	/**
-	 * 根据 orgCode 查询用户,包括子部门下的用户
-	 *
-	 * @param orgCode
-	 * @param userParams 用户查询条件,可为空
-	 * @param page 分页参数
-	 * @return
-	 */
-	IPage<SysUserSysDepartModel> queryUserByOrgCode(String orgCode, SysUser userParams, IPage page);
-
-	/**
-	 * 根据角色Id查询
-	 * @param page
-     * @param roleId 角色id
-     * @param username 用户账户名称
-	 * @return
-	 */
-	public IPage<SysUser> getUserByRoleId(Page<SysUser> page, String roleId, String username);
-
-	/**
-	 * 通过用户名获取用户角色集合
-	 *
-	 * @param username 用户名
-	 * @return 角色集合
-	 */
-	Set<String> getUserRolesSet(String username);
-	
-	/**
-	 * 通过用户名获取用户角色集合
-	 *
-	 * @param userId 用户id
-	 * @return 角色集合
-	 */
-	Set<String> getUserRoleSetById(String userId);
-
-	/**
-	 * 通过用户名获取用户权限集合
-	 *
-	 * @param userId 用户id
-	 * @return 权限集合
-	 */
-	Set<String> getUserPermissionsSet(String userId);
-	
-	/**
-	 * 根据用户名设置部门ID
-	 * @param username
-	 * @param orgCode
-	 */
-	void updateUserDepart(String username,String orgCode,Integer loginTenantId);
-	
-	/**
-	 * 根据手机号获取用户名和密码
-     * @param phone 手机号
-     * @return SysUser
-	 */
-	public SysUser getUserByPhone(String phone);
-
-
-	/**
-	 * 根据邮箱获取用户
-     * @param email 邮箱
-     * @return SysUser
-     */
-	public SysUser getUserByEmail(String email);
-
-
-	/**
-	 * 添加用户和用户部门关系
-	 * @param user
-	 * @param selectedParts
-	 */
-	void addUserWithDepart(SysUser user, String selectedParts);
-
-	/**
-	 * 编辑用户和用户部门关系
-	 * @param user
-	 * @param departs
-	 */
-	void editUserWithDepart(SysUser user, String departs);
-	
-	/**
-	   * 校验用户是否有效
-	 * @param sysUser
-	 * @return
-	 */
-	Result checkUserIsEffective(SysUser sysUser);
-
-	/**
-	 * 查询被逻辑删除的用户
-     * @return List<SysUser>
-	 */
-	List<SysUser> queryLogicDeleted();
-
-	/**
-	 * 查询被逻辑删除的用户(可拼装查询条件)
-     * @param wrapper
-     * @return List<SysUser>
-	 */
-	List<SysUser> queryLogicDeleted(LambdaQueryWrapper<SysUser> wrapper);
-
-	/**
-	 * 还原被逻辑删除的用户
-     * @param userIds  存放用户id集合
-     * @param updateEntity
-     * @return boolean
-	 */
-	boolean revertLogicDeleted(List<String> userIds, SysUser updateEntity);
-
-	/**
-	 * 彻底删除被逻辑删除的用户
-     * @param userIds 存放用户id集合
-     * @return boolean
-	 */
-	boolean removeLogicDeleted(List<String> userIds);
-
-    /**
-     * 更新手机号、邮箱空字符串为 null
-     * @return boolean
-     */
-    @Transactional(rollbackFor = Exception.class)
-    boolean updateNullPhoneEmail();
-
-	/**
-	 * 保存第三方用户信息
-	 * @param sysUser
-	 */
-	void saveThirdUser(SysUser sysUser);
-
-	/**
-	 * 根据部门Ids查询
-	 * @param departIds 部门id集合
-     * @param username 用户账户名称
-	 * @return
-	 */
-	List<SysUser> queryByDepIds(List<String> departIds, String username);
-
-	/**
-	 * 保存用户
-	 * @param user 用户
-	 * @param selectedRoles 选择的角色id,多个以逗号隔开
-	 * @param selectedDeparts 选择的部门id,多个以逗号隔开
-	 * @param relTenantIds 多个租户id
-	 */
-	void saveUser(SysUser user, String selectedRoles, String selectedDeparts, String relTenantIds);
-
-	/**
-	 * 编辑用户
-	 * @param user 用户
-	 * @param roles 选择的角色id,多个以逗号隔开
-	 * @param departs 选择的部门id,多个以逗号隔开
-	 * @param relTenantIds 多个租户id
-	 */
-	void editUser(SysUser user, String roles, String departs, String relTenantIds);
-
-	/**
-     * userId转为username
-     * @param userIdList
-     * @return List<String>
-     */
-	List<String> userIdToUsername(Collection<String> userIdList);
-
-
-	/**
-	 * 获取用户信息 字段信息是加密后的 【加密用户信息】
-	 * @param username
-	 * @return
-	 */
-	LoginUser getEncodeUserInfo(String username);
-
-    /**
-     * 用户离职
-     * @param username
-     */
-    void userQuit(String username);
-
-    /**
-     * 获取离职人员列表
-	 * @param tenantId 租户id
-     * @return
-     */
-    List<SysUser> getQuitList(Integer tenantId);
-
-    /**
-     * 更新刪除状态和离职状态
-     * @param userIds  存放用户id集合
-     * @param sysUser
-     * @return boolean
-     */
-    void updateStatusAndFlag(List<String> userIds, SysUser sysUser);
-
-	/**
-	 * 设置登录租户
-	 * @param sysUser
-	 * @return
-	 */
-	Result<JSONObject> setLoginTenant(SysUser sysUser, JSONObject obj, String username, Result<JSONObject> result);
-
-	//--- author:taoyan date:20221231 for: QQYUN-3515【应用】应用下的组织机构管理功能,细节实现 ---
-	/**
-	 * 批量编辑用户信息
-	 * @param json
-	 */
-	void batchEditUsers(JSONObject json);
-
-	/**
-	 * 根据关键词查询用户和部门
-	 * @param keyword
-	 * @return
-	 */
-	DepartAndUserInfo searchByKeyword(String keyword);
-
-	/**
-	 * 查询 部门修改的信息
-	 * @param departId
-	 * @return
-	 */
-	UpdateDepartInfo getUpdateDepartInfo(String departId);
-
-	/**
-	 * 修改部门相关信息
-	 * @param updateDepartInfo
-	 */
-	void doUpdateDepartInfo(UpdateDepartInfo updateDepartInfo);
-
-	/**
-	 * 设置负责人 取消负责人
-	 * @param json
-	 */
-	void changeDepartChargePerson(JSONObject json);
-	//--- author:taoyan date:20221231 for: QQYUN-3515【应用】应用下的组织机构管理功能,细节实现 ---
-	
-	/**
-	 * 编辑租户用户
-	 * @param sysUser
-	 * @param tenantId
-	 * @param departs
-	 */
-	void editTenantUser(SysUser sysUser, String tenantId, String departs, String roles);
-
-	/**
-	 * 修改用户账号状态
-	 * @param id 账号id
-	 * @param status 账号状态
-	 */
-	void updateStatus(String id, String status);
-
-	/**
-	 * 导出应用下的用户Excel
-	 * @param request
-	 * @return
-	 */
-	ModelAndView exportAppUser(HttpServletRequest request);
-
-	/**
-	 * 导入应用下的用户
-	 * @param request
-	 * @return
-	 */
-	Result<?> importAppUser(HttpServletRequest request);
-
-	/**
-	 * 验证用户是否为管理员
-	 * @param ids
-	 */
-	void checkUserAdminRejectDel(String ids);
-
-	/**
-	 * 修改手机号
-	 * 
-	 * @param json
-	 * @param username
-	 */
-    void changePhone(JSONObject json, String username);
-
-	/**
-	 * 发送短信验证码
-	 * 
-	 * @param jsonObject
-	 * @param username 用户名
-	 * @param ipAddress ip地址
-	 */
-	void sendChangePhoneSms(JSONObject jsonObject, String username, String ipAddress);
+  /**
+   * 查询用户数据列表
+   *
+   * @param req
+   * @param queryWrapper
+   * @param pageSize
+   * @param pageNo
+   * @return
+   */
+  Result<IPage<SysUser>> queryPageList(
+      HttpServletRequest req, QueryWrapper<SysUser> queryWrapper, Integer pageSize, Integer pageNo);
+
+  /**
+   * 重置密码
+   *
+   * @param username
+   * @param oldpassword
+   * @param newpassword
+   * @param confirmpassword
+   * @return
+   */
+  public Result<?> resetPassword(
+      String username, String oldpassword, String newpassword, String confirmpassword);
+
+  /**
+   * 修改密码
+   *
+   * @param sysUser
+   * @return
+   */
+  public Result<?> changePassword(SysUser sysUser);
+
+  /**
+   * 删除用户
+   *
+   * @param userId
+   * @return
+   */
+  public boolean deleteUser(String userId);
+
+  /**
+   * 批量删除用户
+   *
+   * @param userIds
+   * @return
+   */
+  public boolean deleteBatchUsers(String userIds);
+
+  /**
+   * 根据用户名查询
+   *
+   * @param username 用户名
+   * @return SysUser
+   */
+  public SysUser getUserByName(String username);
+
+  /**
+   * 添加用户和用户角色关系
+   *
+   * @param user
+   * @param roles
+   */
+  public void addUserWithRole(SysUser user, String roles);
+
+  /**
+   * 修改用户和用户角色关系
+   *
+   * @param user
+   * @param roles
+   */
+  public void editUserWithRole(SysUser user, String roles);
+
+  /**
+   * 获取用户的授权角色
+   *
+   * @param username
+   * @return
+   */
+  public List<String> getRole(String username);
+
+  /**
+   * 获取根据登录用户的角色获取动态首页
+   *
+   * @param username
+   * @param version 前端UI版本
+   * @return
+   */
+  public SysRoleIndex getDynamicIndexByUserRole(String username, String version);
+
+  /**
+   * 查询用户信息包括 部门信息
+   *
+   * @param username
+   * @return
+   */
+  @Deprecated
+  public SysUserCacheInfo getCacheUser(String username);
+
+  /**
+   * 根据部门Id查询
+   *
+   * @param page
+   * @param departId 部门id
+   * @param username 用户账户名称
+   * @return
+   */
+  public IPage<SysUser> getUserByDepId(Page<SysUser> page, String departId, String username);
+
+  /**
+   * 根据部门Ids查询
+   *
+   * @param page
+   * @param departIds 部门id集合
+   * @param username 用户账户名称
+   * @return
+   */
+  public IPage<SysUser> getUserByDepIds(
+      Page<SysUser> page, List<String> departIds, String username);
+
+  /**
+   * 根据 userIds查询,查询用户所属部门的名称(多个部门名逗号隔开)
+   *
+   * @param userIds
+   * @return
+   */
+  public Map<String, String> getDepNamesByUserIds(List<String> userIds);
+
+  /**
+   * 根据部门 Id 和 QueryWrapper 查询
+   *
+   * @param page
+   * @param departId
+   * @param queryWrapper
+   * @return
+   */
+  // update-begin-author:taoyan date:2022-9-13 for: VUEN-2245【漏洞】发现新漏洞待处理20220906 ----sql注入
+  // 方法没有使用,注掉
+  // public IPage<SysUser> getUserByDepartIdAndQueryWrapper(Page<SysUser> page, String departId,
+  // QueryWrapper<SysUser> queryWrapper);
+  // update-end-author:taoyan date:2022-9-13 for: VUEN-2245【漏洞】发现新漏洞待处理20220906 ----sql注入 方法没有使用,注掉
+
+  /**
+   * 根据 orgCode 查询用户,包括子部门下的用户
+   *
+   * @param orgCode
+   * @param userParams 用户查询条件,可为空
+   * @param page 分页参数
+   * @return
+   */
+  IPage<SysUserSysDepartModel> queryUserByOrgCode(String orgCode, SysUser userParams, IPage page);
+
+  /**
+   * 根据角色Id查询
+   *
+   * @param page
+   * @param roleId 角色id
+   * @param username 用户账户名称
+   * @return
+   */
+  public IPage<SysUser> getUserByRoleId(Page<SysUser> page, String roleId, String username);
+
+  /**
+   * 通过用户名获取用户角色集合
+   *
+   * @param username 用户名
+   * @return 角色集合
+   */
+  Set<String> getUserRolesSet(String username);
+
+  /**
+   * 通过用户名获取用户角色集合
+   *
+   * @param userId 用户id
+   * @return 角色集合
+   */
+  Set<String> getUserRoleSetById(String userId);
+
+  /**
+   * 通过用户名获取用户权限集合
+   *
+   * @param userId 用户id
+   * @return 权限集合
+   */
+  Set<String> getUserPermissionsSet(String userId);
+
+  /**
+   * 根据用户名设置部门ID
+   *
+   * @param username
+   * @param orgCode
+   */
+  void updateUserDepart(String username, String orgCode, Integer loginTenantId);
+
+  /**
+   * 根据手机号获取用户名和密码
+   *
+   * @param phone 手机号
+   * @return SysUser
+   */
+  public SysUser getUserByPhone(String phone);
+
+  /**
+   * 根据邮箱获取用户
+   *
+   * @param email 邮箱
+   * @return SysUser
+   */
+  public SysUser getUserByEmail(String email);
+
+  /**
+   * 添加用户和用户部门关系
+   *
+   * @param user
+   * @param selectedParts
+   */
+  void addUserWithDepart(SysUser user, String selectedParts);
+
+  /**
+   * 编辑用户和用户部门关系
+   *
+   * @param user
+   * @param departs
+   */
+  void editUserWithDepart(SysUser user, String departs);
+
+  /**
+   * 校验用户是否有效
+   *
+   * @param sysUser
+   * @return
+   */
+  Result checkUserIsEffective(SysUser sysUser);
+
+  /**
+   * 查询被逻辑删除的用户
+   *
+   * @return List<SysUser>
+   */
+  List<SysUser> queryLogicDeleted();
+
+  /**
+   * 查询被逻辑删除的用户(可拼装查询条件)
+   *
+   * @param wrapper
+   * @return List<SysUser>
+   */
+  List<SysUser> queryLogicDeleted(LambdaQueryWrapper<SysUser> wrapper);
+
+  /**
+   * 还原被逻辑删除的用户
+   *
+   * @param userIds 存放用户id集合
+   * @param updateEntity
+   * @return boolean
+   */
+  boolean revertLogicDeleted(List<String> userIds, SysUser updateEntity);
+
+  /**
+   * 彻底删除被逻辑删除的用户
+   *
+   * @param userIds 存放用户id集合
+   * @return boolean
+   */
+  boolean removeLogicDeleted(List<String> userIds);
+
+  /**
+   * 更新手机号、邮箱空字符串为 null
+   *
+   * @return boolean
+   */
+  @Transactional(rollbackFor = Exception.class)
+  boolean updateNullPhoneEmail();
+
+  /**
+   * 保存第三方用户信息
+   *
+   * @param sysUser
+   */
+  void saveThirdUser(SysUser sysUser);
+
+  /**
+   * 根据部门Ids查询
+   *
+   * @param departIds 部门id集合
+   * @param username 用户账户名称
+   * @return
+   */
+  List<SysUser> queryByDepIds(List<String> departIds, String username);
+
+  /**
+   * 保存用户
+   *
+   * @param user 用户
+   * @param selectedRoles 选择的角色id,多个以逗号隔开
+   * @param selectedDeparts 选择的部门id,多个以逗号隔开
+   * @param relTenantIds 多个租户id
+   */
+  void saveUser(SysUser user, String selectedRoles, String selectedDeparts, String relTenantIds);
+
+  /**
+   * 编辑用户
+   *
+   * @param user 用户
+   * @param roles 选择的角色id,多个以逗号隔开
+   * @param departs 选择的部门id,多个以逗号隔开
+   * @param relTenantIds 多个租户id
+   */
+  void editUser(SysUser user, String roles, String departs, String relTenantIds);
+
+  /**
+   * userId转为username
+   *
+   * @param userIdList
+   * @return List<String>
+   */
+  List<String> userIdToUsername(Collection<String> userIdList);
+
+  /**
+   * 获取用户信息 字段信息是加密后的 【加密用户信息】
+   *
+   * @param username
+   * @return
+   */
+  LoginUser getEncodeUserInfo(String username);
+
+  /**
+   * 用户离职
+   *
+   * @param username
+   */
+  void userQuit(String username);
+
+  /**
+   * 获取离职人员列表
+   *
+   * @param tenantId 租户id
+   * @return
+   */
+  List<SysUser> getQuitList(Integer tenantId);
+
+  /**
+   * 更新刪除状态和离职状态
+   *
+   * @param userIds 存放用户id集合
+   * @param sysUser
+   * @return boolean
+   */
+  void updateStatusAndFlag(List<String> userIds, SysUser sysUser);
+
+  /**
+   * 设置登录租户
+   *
+   * @param sysUser
+   * @return
+   */
+  Result<JSONObject> setLoginTenant(
+      SysUser sysUser, JSONObject obj, String username, Result<JSONObject> result);
+
+  // --- author:taoyan date:20221231 for: QQYUN-3515【应用】应用下的组织机构管理功能,细节实现 ---
+  /**
+   * 批量编辑用户信息
+   *
+   * @param json
+   */
+  void batchEditUsers(JSONObject json);
+
+  /**
+   * 根据关键词查询用户和部门
+   *
+   * @param keyword
+   * @return
+   */
+  DepartAndUserInfo searchByKeyword(String keyword);
+
+  /**
+   * 查询 部门修改的信息
+   *
+   * @param departId
+   * @return
+   */
+  UpdateDepartInfo getUpdateDepartInfo(String departId);
+
+  /**
+   * 修改部门相关信息
+   *
+   * @param updateDepartInfo
+   */
+  void doUpdateDepartInfo(UpdateDepartInfo updateDepartInfo);
+
+  /**
+   * 设置负责人 取消负责人
+   *
+   * @param json
+   */
+  void changeDepartChargePerson(JSONObject json);
+
+  // --- author:taoyan date:20221231 for: QQYUN-3515【应用】应用下的组织机构管理功能,细节实现 ---
+
+  /**
+   * 编辑租户用户
+   *
+   * @param sysUser
+   * @param tenantId
+   * @param departs
+   */
+  void editTenantUser(SysUser sysUser, String tenantId, String departs, String roles);
+
+  /**
+   * 修改用户账号状态
+   *
+   * @param id 账号id
+   * @param status 账号状态
+   */
+  void updateStatus(String id, String status);
+
+  /**
+   * 导出应用下的用户Excel
+   *
+   * @param request
+   * @return
+   */
+  ModelAndView exportAppUser(HttpServletRequest request);
+
+  /**
+   * 导入应用下的用户
+   *
+   * @param request
+   * @return
+   */
+  Result<?> importAppUser(HttpServletRequest request);
+
+  /**
+   * 验证用户是否为管理员
+   *
+   * @param ids
+   */
+  void checkUserAdminRejectDel(String ids);
+
+  /**
+   * 修改手机号
+   *
+   * @param json
+   * @param username
+   */
+  void changePhone(JSONObject json, String username);
+
+  /**
+   * 发送短信验证码
+   *
+   * @param jsonObject
+   * @param username 用户名
+   * @param ipAddress ip地址
+   */
+  void sendChangePhoneSms(JSONObject jsonObject, String username, String ipAddress);
+
+  List<String> getEmailBySubIdList(List<String> idList);
 }

+ 17 - 4
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysRoleServiceImpl.java

@@ -1,8 +1,12 @@
 package org.jeecg.modules.system.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.constant.SymbolConstant;
@@ -19,10 +23,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
 /**
  * <p>
  * 角色表 服务实现类
@@ -116,4 +116,17 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
             throw new JeecgBootException("admin角色,不允许删除!");
         }
     }
+
+    /**
+     * 根据对应role_code获取对应id
+     */
+    public String getRoleIdByRoleCode(String roleCode) {
+        QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("role_code", roleCode);
+        SysRole sysRole = sysRoleMapper.selectOne(queryWrapper);
+        if (sysRole == null) {
+            return null;
+        }
+        return sysRole.getId();
+    }
 }

+ 8 - 4
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java

@@ -14,6 +14,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import jakarta.annotation.Resource;
 import jakarta.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.*;
+import java.util.stream.Collectors;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang3.ObjectUtils;
@@ -65,10 +68,6 @@ import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
 
-import java.io.IOException;
-import java.util.*;
-import java.util.stream.Collectors;
-
 /**
  * <p>
  * 用户表 服务实现类
@@ -2004,6 +2003,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         }
     }
 
+    @Override
+    public List<String> getEmailBySubIdList(List<String> idList) {
+        return userMapper.getEmailBySubIdList(idList);
+    }
+
     /**
      * 验证手机号
      *