().ok(thirdLoginService.govLoginInternalDing(formDTO));
+ }
}
diff --git a/epmet-auth/src/main/java/com/epmet/dto/dingres/DingUserDetailDTO.java b/epmet-auth/src/main/java/com/epmet/dto/dingres/DingUserDetailDTO.java
new file mode 100644
index 0000000000..4a46922590
--- /dev/null
+++ b/epmet-auth/src/main/java/com/epmet/dto/dingres/DingUserDetailDTO.java
@@ -0,0 +1,73 @@
+package com.epmet.dto.dingres;
+
+import lombok.Data;
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/22 14:16
+ */
+@Data
+public class DingUserDetailDTO {
+ // 接口文档:https://open.dingtalk.com/document/isvapp-server/query-user-details
+ /**
+ * 员工的userId。
+ */
+ private String userid;
+
+ /**
+ * 员工在当前开发者企业账号范围内的唯一标识。
+ */
+ private String unionid;
+
+ /**
+ * 员工姓名。
+ */
+ private String name;
+ /**
+ * 头像。
+ *
+ * 说明 员工使用默认头像,不返回该字段,手动设置头像会返回
+ */
+ private String avatar;
+ /**
+ * 国际电话区号。
+ *
+ * 说明 第三方企业应用不返回该字段;如需获取state_code,可以使用钉钉统一授权套件方式获取。
+ */
+ private String state_code;
+ /**
+ * 手机号码。
+ *
+ * 说明
+ * 企业内部应用,只有应用开通通讯录邮箱等个人信息权限,才会返回该字段。
+ * 第三方企业应用不返回该字段,如需获取mobile,可以使用钉钉统一授权套件方式获取。
+ */
+ private String mobile;
+ /**
+ * 是否号码隐藏:
+ *
+ * true:隐藏
+ *
+ * false:不隐藏
+ *
+ * 说明 隐藏手机号后,手机号在个人资料页隐藏,但仍可对其发DING、发起钉钉免费商务电话。
+ */
+ private String hide_mobile;
+ /**
+ * 分机号。
+ *
+ * 说明 第三方企业应用不返回该参数。
+ */
+ private String telephone;
+
+ /**
+ * 员工的企业邮箱。
+ *
+ * 如果员工的企业邮箱没有开通,返回信息中不包含该数据。
+ *
+ * 说明 第三方企业应用不返回该参数。
+ */
+ private String org_email;
+}
+
diff --git a/epmet-auth/src/main/java/com/epmet/dto/dingres/V2UserGetuserinfoResDTO.java b/epmet-auth/src/main/java/com/epmet/dto/dingres/V2UserGetuserinfoResDTO.java
new file mode 100644
index 0000000000..ea9eb3b46b
--- /dev/null
+++ b/epmet-auth/src/main/java/com/epmet/dto/dingres/V2UserGetuserinfoResDTO.java
@@ -0,0 +1,54 @@
+package com.epmet.dto.dingres;
+
+import lombok.Data;
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/22 14:08
+ */
+@Data
+public class V2UserGetuserinfoResDTO {
+ // 接口返参:https://open.dingtalk.com/document/orgapp-server/obtain-the-userid-of-a-user-by-using-the-log-free
+ /**
+ * 用户的userid。
+ */
+ private String userid;
+ /**
+ * 设备ID。
+ */
+ private String device_id;
+ /**
+ * 是否是管理员。
+ *
+ * true:是
+ *
+ * false:不是
+ */
+ private Boolean sys;
+ /**
+ * 级别。
+ *
+ * 1:主管理员
+ *
+ * 2:子管理员
+ *
+ * 100:老板
+ *
+ * 0:其他(如普通员工)
+ */
+ private Number sys_level;
+ /**
+ * 用户关联的unionId。
+ */
+ private String associated_unionid;
+ /**
+ * 用户unionId。
+ */
+ private String unionid;
+ /**
+ * 用户名字。
+ */
+ private String name;
+}
+
diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/DingAppLoginMdFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/DingAppLoginMdFormDTO.java
new file mode 100644
index 0000000000..1a8840e949
--- /dev/null
+++ b/epmet-auth/src/main/java/com/epmet/dto/form/DingAppLoginMdFormDTO.java
@@ -0,0 +1,23 @@
+package com.epmet.dto.form;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/22 10:42
+ */
+@Data
+public class DingAppLoginMdFormDTO {
+ @NotBlank(message = "authCode不能为空")
+ private String authCode;
+ /**
+ * 第三方企业应用传应用的SuiteKey
+ */
+ @NotBlank(message = "miniAppId不能为空")
+ private String miniAppId;
+
+}
+
diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgByAccountFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgByAccountFormDTO.java
new file mode 100644
index 0000000000..4996c0cd50
--- /dev/null
+++ b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgByAccountFormDTO.java
@@ -0,0 +1,48 @@
+package com.epmet.dto.form;
+
+import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+
+/**
+ * @Description 选择组织,进入首页入参Dto
+ * @Author yinzuomei
+ * @Date 2020/4/20 13:03
+ */
+@Data
+public class GovWxmpEnteOrgByAccountFormDTO implements Serializable {
+ public interface AddUserInternalGroup {}
+ public interface AddUserShowGroup extends CustomerClientShowGroup {}
+ /**
+ * wxCode
+ */
+ @NotBlank(message = "wxCode不能为空",groups = {AddUserInternalGroup.class})
+ private String wxCode;
+
+ /**
+ * 手机号
+ */
+ @NotBlank(message = "账号不能为空",groups = {AddUserShowGroup.class})
+ private String userAccount;
+
+ /**
+ * 选择的组织所属的id
+ */
+ @NotBlank(message = "客户id不能为空",groups = {AddUserInternalGroup.class})
+ private String customerId;
+
+ /**
+ * 选择的要进入的组织(根组织id)
+ */
+ @NotBlank(message = "组织id不能为空",groups = {AddUserInternalGroup.class})
+ private String rootAgencyId;
+
+ /**
+ * desc:小程序appId
+ */
+ private String appId;
+
+}
+
diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/ResiDingAppLoginFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/ResiDingAppLoginFormDTO.java
new file mode 100644
index 0000000000..b18e95478a
--- /dev/null
+++ b/epmet-auth/src/main/java/com/epmet/dto/form/ResiDingAppLoginFormDTO.java
@@ -0,0 +1,41 @@
+package com.epmet.dto.form;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/14 17:11
+ */
+@Data
+public class ResiDingAppLoginFormDTO {
+ public interface InnerMiniApp {}
+ public interface ThirdMiniApp {}
+ /**
+ * 授权统一后的authCode
+ */
+ @NotBlank(message = "authCode不能为空",groups = InnerMiniApp.class)
+ private String authCode;
+// /**
+// * 第三方企业应用传应用的SuiteKey
+// */
+// @NotBlank(message = "clientId不能为空")
+// private String clientId;
+ /**
+ * 第三方企业应用传应用的SuiteKey
+ */
+ @NotBlank(message = "miniAppId不能为空",groups = InnerMiniApp.class)
+ private String miniAppId;
+
+ // @NotBlank(message = "当前访问用户的企业corpId不能为空")
+ // private String corpId;
+
+ /**
+ * third:第三方应用
+ * company_customize:企业定制应用
+ */
+ private String appType="company_customize";
+}
+
diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/StaffOrgByAccountFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/StaffOrgByAccountFormDTO.java
new file mode 100644
index 0000000000..669a0e7998
--- /dev/null
+++ b/epmet-auth/src/main/java/com/epmet/dto/form/StaffOrgByAccountFormDTO.java
@@ -0,0 +1,43 @@
+package com.epmet.dto.form;
+
+import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+
+/**
+ * @Description 手机验证码获取组织接口入参
+ * @Author zhy
+ * @Date 2020/4/18 10:38
+ */
+@Data
+public class StaffOrgByAccountFormDTO implements Serializable {
+ private static final long serialVersionUID = 4193133227120225342L;
+ /**
+ * 添加用户操作的用户可见异常分组
+ * 该分组用于校验需要返回给前端错误信息提示的列,需要继承CustomerClientShowGroup
+ * 返回错误码为8999,提示信息为DTO中具体的列的校验注解message的内容
+ */
+ public interface AddUserShowGroup extends CustomerClientShowGroup {
+ }
+
+ public interface GetMyOrgByPassWordGroup extends CustomerClientShowGroup {
+ }
+ public interface GetMyOrgByLoginWxmp extends CustomerClientShowGroup{}
+ /**
+ * 手机号
+ */
+ @NotBlank(message = "手机号不能为空", groups = {AddUserShowGroup.class})
+ private String userAccount;
+
+ /**
+ * 验证码
+ */
+ @NotBlank(message="验证码不能为空", groups = {GetMyOrgByLoginWxmp.class})
+ private String smsCode;
+
+ @NotBlank(message = "密码不能为空",groups ={GetMyOrgByPassWordGroup.class})
+ private String password;
+}
+
diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/ThirdStaffOrgByAccountFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/ThirdStaffOrgByAccountFormDTO.java
new file mode 100644
index 0000000000..3cad308ab6
--- /dev/null
+++ b/epmet-auth/src/main/java/com/epmet/dto/form/ThirdStaffOrgByAccountFormDTO.java
@@ -0,0 +1,48 @@
+package com.epmet.dto.form;
+
+import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+
+/**
+ * @Description appId、账号、验证码获取组织-接口入参
+ * @Author zhy
+ */
+@Data
+public class ThirdStaffOrgByAccountFormDTO implements Serializable {
+ private static final long serialVersionUID = 4193133227120225342L;
+ /**
+ * 添加用户操作的用户可见异常分组
+ * 该分组用于校验需要返回给前端错误信息提示的列,需要继承CustomerClientShowGroup
+ * 返回错误码为8999,提示信息为DTO中具体的列的校验注解message的内容
+ */
+ public interface AddUserShowGroup extends CustomerClientShowGroup {
+ }
+
+ public interface GetMyOrgByPassWordGroup extends CustomerClientShowGroup {
+ }
+ public interface GetMyOrgByLoginWxmp extends CustomerClientShowGroup{}
+ /**
+ * 小程序appId
+ */
+ @NotBlank(message = "appId不能为空", groups = {AddUserShowGroup.class})
+ private String appId;
+
+ /**
+ * 手机号
+ */
+ @NotBlank(message = "账号不能为空", groups = {AddUserShowGroup.class})
+ private String userAccount;
+
+ /**
+ * 验证码
+ */
+ @NotBlank(message="验证码不能为空", groups = {GetMyOrgByLoginWxmp.class})
+ private String smsCode;
+
+ @NotBlank(message = "密码不能为空",groups ={GetMyOrgByPassWordGroup.class})
+ private String password;
+}
+
diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/ThirdWxmpEnteOrgByAccountFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/ThirdWxmpEnteOrgByAccountFormDTO.java
new file mode 100644
index 0000000000..e89028eb4c
--- /dev/null
+++ b/epmet-auth/src/main/java/com/epmet/dto/form/ThirdWxmpEnteOrgByAccountFormDTO.java
@@ -0,0 +1,47 @@
+package com.epmet.dto.form;
+
+import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+
+/**
+ * @Description 单客户-选择组织,进入首页入参Dto
+ * @Author sun
+ */
+@Data
+public class ThirdWxmpEnteOrgByAccountFormDTO implements Serializable {
+ public interface AddUserInternalGroup {}
+ public interface AddUserShowGroup extends CustomerClientShowGroup {}
+ /**
+ * wxCode
+ */
+ @NotBlank(message = "wxCode不能为空",groups = {AddUserInternalGroup.class})
+ private String wxCode;
+
+ /**
+ * 手机号
+ */
+ @NotBlank(message = "账号不能为空",groups = {AddUserShowGroup.class})
+ private String userAccount;
+
+ /**
+ * 选择的组织所属的id
+ */
+ @NotBlank(message = "客户id不能为空",groups = {AddUserInternalGroup.class})
+ private String customerId;
+
+ /**
+ * 选择的要进入的组织(根组织id)
+ */
+ @NotBlank(message = "组织id不能为空",groups = {AddUserInternalGroup.class})
+ private String rootAgencyId;
+
+ /**
+ * 客户appId(exJson文件中获取)
+ */
+ @NotBlank(message = "appId不能为空",groups = {AddUserInternalGroup.class})
+ private String appId;
+}
+
diff --git a/epmet-auth/src/main/java/com/epmet/dto/result/ResiDingAppLoginResDTO.java b/epmet-auth/src/main/java/com/epmet/dto/result/ResiDingAppLoginResDTO.java
new file mode 100644
index 0000000000..6658ab5770
--- /dev/null
+++ b/epmet-auth/src/main/java/com/epmet/dto/result/ResiDingAppLoginResDTO.java
@@ -0,0 +1,44 @@
+package com.epmet.dto.result;
+
+import lombok.Data;
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/14 17:20
+ */
+@Data
+public class ResiDingAppLoginResDTO {
+ private String authorization;
+ private String customerId;
+ private String gridId;
+ /**
+ * 网格名
+ */
+ private String gridName;
+ /**
+ * 网格所属的组织id
+ */
+ private String agencyId;
+ /**
+ * 居民端用户id
+ */
+ private String epmetUserId;
+
+ /**
+ * 5.获取用户手机号。使用用户个人access_token调用获取用户通讯录个人信息接口获取
+ * 返参信息
+ * 接口文档:https://open.dingtalk.com/document/isvapp-server/dingtalk-retrieve-user-information
+ */
+ private String extInfo;
+
+ /**
+ * 是否注册居民
+ * true:已注册
+ * false:未注册
+ */
+ private Boolean regFlag;
+
+ private String realName;
+}
+
diff --git a/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
index 44c7d9d3ab..af33d8c632 100644
--- a/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
+++ b/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
@@ -70,6 +70,17 @@ public interface EpmetUserFeignClient {
@GetMapping(value = "epmetuser/customerstaff/getcustsomerstaffbyphone/{mobile}")
Result> checkCustomerStaff(@PathVariable("mobile") String mobile);
+ /**
+ * @param account
+ * @return com.epmet.commons.tools.utils.Result
+ * @Author zhy
+ * @Description 根据账户查询政府端工作人员基本信息,校验用户是否存在
+ * @Date 2020/4/18 14:03
+ **/
+ @GetMapping(value = "epmetuser/customerstaff/getcustsomerstaffbyaccount/{account}")
+ Result> checkCustomerStaffByAccount(@PathVariable("account") String account);
+
+
/**
* @param staffWechatFormDTO
* @return com.epmet.commons.tools.utils.Result
@@ -100,6 +111,17 @@ public interface EpmetUserFeignClient {
@PostMapping(value = "epmetuser/customerstaff/getcustomerstaffinfo", consumes = MediaType.APPLICATION_JSON_VALUE)
Result getCustomerStaffInfo(@RequestBody CustomerStaffFormDTO customerStaffFormDTO);
+ /**
+ * @param customerStaffFormDTO
+ * @return com.epmet.commons.tools.utils.Result
+ * @Author zhy
+ * @Description 根据手机号+客户id获取工作人员基本信息
+ * @Date 2020/4/20 14:16
+ **/
+ @PostMapping(value = "epmetuser/customerstaff/getcustomerstaffinfobyaccount", consumes = MediaType.APPLICATION_JSON_VALUE)
+ Result getCustomerStaffInfoByAccount(@RequestBody CustomerStaffByAccountFormDTO customerStaffFormDTO);
+
+
/**
* @param staffLoginHistoryFormDTO
* @return com.epmet.commons.tools.utils.Result
diff --git a/epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java b/epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java
index 59623a7dc7..d0ce30ab99 100644
--- a/epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java
+++ b/epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java
@@ -44,6 +44,10 @@ public class EpmetUserFeignClientFallback implements EpmetUserFeignClient {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustsomerStaffByPhone", phone);
}
+ @Override
+ public Result> checkCustomerStaffByAccount(String account) {
+ return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustsomerStaffByAccount", account);
+ }
@Override
public Result saveStaffWechat(StaffWechatFormDTO staffWechatFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveStaffWechat", staffWechatFormDTO);
@@ -59,6 +63,11 @@ public class EpmetUserFeignClientFallback implements EpmetUserFeignClient {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffInfo", customerStaffFormDTO);
}
+ @Override
+ public Result getCustomerStaffInfoByAccount(CustomerStaffByAccountFormDTO customerStaffFormDTO) {
+ return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffInfoByAccount", customerStaffFormDTO);
+ }
+
@Override
public Result saveStaffLoginRecord(StaffLoginAgencyRecordFormDTO staffLoginHistoryFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveStaffLoginRecord", staffLoginHistoryFormDTO);
diff --git a/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java b/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java
index ea6329ceda..8ec5697a60 100644
--- a/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java
+++ b/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java
@@ -1,10 +1,7 @@
package com.epmet.service;
import com.epmet.commons.tools.security.dto.TokenDto;
-import com.epmet.dto.form.GovWxmpEnteOrgFormDTO;
-import com.epmet.dto.form.GovWxmpFormDTO;
-import com.epmet.dto.form.SendSmsCodeFormDTO;
-import com.epmet.dto.form.StaffOrgsFormDTO;
+import com.epmet.dto.form.*;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.UserTokenResultDTO;
@@ -52,6 +49,15 @@ public interface GovLoginService {
**/
UserTokenResultDTO enterOrg(GovWxmpEnteOrgFormDTO formDTO);
+ /**
+ * @param formDTO
+ * @return com.epmet.commons.tools.utils.Result
+ * @Author zhy
+ * @Description 4、选择组织,进入首页
+ * @Date 2020/4/20 13:08
+ **/
+ UserTokenResultDTO enterOrgByAccount(GovWxmpEnteOrgByAccountFormDTO formDTO);
+
/**
* @return com.epmet.commons.tools.utils.Result
* @param tokenDto
@@ -76,4 +82,13 @@ public interface GovLoginService {
* @Date 2020/6/30 22:43
**/
List getMyOrgByPassword(StaffOrgsFormDTO formDTO);
+
+ /**
+ * @return java.util.List
+ * @param formDTO
+ * @author zhy
+ * @description 6、账户密码获取组织
+ * @Date 2020/6/30 22:43
+ **/
+ List getMyOrgByAccount(StaffOrgByAccountFormDTO formDTO);
}
diff --git a/epmet-auth/src/main/java/com/epmet/service/GovWebService.java b/epmet-auth/src/main/java/com/epmet/service/GovWebService.java
index 10d86c20b4..6bee4b24b3 100644
--- a/epmet-auth/src/main/java/com/epmet/service/GovWebService.java
+++ b/epmet-auth/src/main/java/com/epmet/service/GovWebService.java
@@ -18,6 +18,14 @@ public interface GovWebService {
**/
UserTokenResultDTO login(GovWebLoginFormDTO formDTO);
+ /**
+ * @param formDTO
+ * @return
+ * @Author sun
+ * @Description PC工作端-工作人员 通过第三方系统登录
+ **/
+ UserTokenResultDTO loginByThirdPlatform(GovWebLoginFormDTO formDTO);
+
/**
* 区块链系统通过用户密码认证身份
* @param mobile
diff --git a/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java
index c79a67d41c..dff5e129e5 100644
--- a/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java
+++ b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java
@@ -1,6 +1,7 @@
package com.epmet.service;
import com.epmet.dto.form.*;
+import com.epmet.dto.result.ResiDingAppLoginResDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.UserTokenResultDTO;
@@ -36,6 +37,15 @@ public interface ThirdLoginService {
**/
UserTokenResultDTO enterOrg(ThirdWxmpEnteOrgFormDTO formDTO);
+
+ /**
+ * @param formDTO
+ * @return
+ * @Author zhy
+ * @Description 单客户-选择组织,进入首页
+ **/
+ UserTokenResultDTO enterOrgByAccount(ThirdWxmpEnteOrgByAccountFormDTO formDTO);
+
/**
* @param formDTO
* @return
@@ -52,6 +62,15 @@ public interface ThirdLoginService {
**/
List getMyOrgByPassword(ThirdStaffOrgsFormDTO formDTO);
+ /**
+ * @param formDTO
+ * @return
+ * @author zhy
+ * @description 单客户-手机号密码获取组织
+ **/
+ List getMyOrgByAccount(ThirdStaffOrgByAccountFormDTO formDTO);
+
+
/**
* @param formDTO
* @return
@@ -66,4 +85,36 @@ public interface ThirdLoginService {
* @description 单客户-工作端微信小程序登录-发送验证码
**/
void sendSmsCode(ThirdSendSmsCodeFormDTO formDTO);
+
+ /**
+ * 钉钉应用的登录-居民端
+ * 产品服务商建立第三方企业应用
+ * 参考文档:https://open.dingtalk.com/document/isvapp-server/unified-authorization-suite-access-process
+ * @param formDTO
+ * @return
+ */
+ ResiDingAppLoginResDTO resiLoginDing(ResiDingAppLoginFormDTO formDTO);
+
+ /**
+ * 企业简历内部应用授权给第三方
+ * 可参考文档: 获取第三方应用授权企业的accessToken https://open.dingtalk.com/document/orgapp-server/obtain-the-access_token-of-the-authorized-enterprise
+ * https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free
+ * @param formDTO
+ * @return
+ */
+ ResiDingAppLoginResDTO resiLoginDingMd(DingAppLoginMdFormDTO formDTO);
+
+ /**
+ * 企业内部应用免登 文档地址:https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free
+ * @param formDTO
+ * @return
+ */
+ ResiDingAppLoginResDTO resiLoginInternalDing(DingAppLoginMdFormDTO formDTO);
+
+ /**
+ * desc:企业内部应用 工作端登录
+ * @param formDTO
+ * @return
+ */
+ UserTokenResultDTO govLoginInternalDing(DingAppLoginMdFormDTO formDTO);
}
diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java
index cbc46e33f1..24267debd1 100644
--- a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java
+++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java
@@ -289,6 +289,36 @@ public class GovLoginServiceImpl implements GovLoginService, ResultDataResolver
return userTokenResultDTO;
}
+ @Override
+ public UserTokenResultDTO enterOrgByAccount(GovWxmpEnteOrgByAccountFormDTO formDTO) {
+ //1、需要校验要登录的客户,是否被禁用
+ CustomerStaffByAccountFormDTO customerStaffFormDTO = new CustomerStaffByAccountFormDTO();
+ customerStaffFormDTO.setCustomerId(formDTO.getCustomerId());
+ customerStaffFormDTO.setUserAccount(formDTO.getUserAccount());
+ Result customerStaffDTOResult = epmetUserFeignClient.getCustomerStaffInfoByAccount(customerStaffFormDTO);
+ if (!customerStaffDTOResult.success() || null == customerStaffDTOResult.getData()) {
+ logger.warn(String.format("获取工作人员信息失败,账户[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getUserAccount(), formDTO.getCustomerId(), customerStaffDTOResult.getCode(), customerStaffDTOResult.getMsg()));
+ throw new RenException(customerStaffDTOResult.getCode());
+ }
+ CustomerStaffDTO customerStaff = customerStaffDTOResult.getData();
+ //2、解析微信用户
+ WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(LoginConstant.APP_GOV, formDTO.getWxCode(), formDTO.getAppId());
+
+ //3、记录staff_wechat,并记录用户激活状态,激活时间
+ this.savestaffwechat(customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid(), formDTO.getCustomerId());
+ //4、记录登录日志
+ GovWxmpEnteOrgFormDTO orgDTO = ConvertUtils.sourceToTarget(formDTO, GovWxmpEnteOrgFormDTO.class);
+ orgDTO.setMobile(customerStaff.getMobile());
+ this.saveStaffLoginRecord(orgDTO, customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid());
+ //5.1、获取用户token
+ String token = this.generateGovWxmpToken(customerStaff.getUserId());
+ //5.2、保存到redis
+ this.saveGovTokenDto(formDTO.getRootAgencyId(), formDTO.getCustomerId(), customerStaff.getUserId(), wxMaJscode2SessionResult, token);
+ UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO();
+ userTokenResultDTO.setToken(token);
+ return userTokenResultDTO;
+ }
+
@Override
public void loginOut(TokenDto tokenDto) {
if(null == tokenDto){
@@ -381,6 +411,63 @@ public class GovLoginServiceImpl implements GovLoginService, ResultDataResolver
return new ArrayList<>();
}
+ @Override
+ public List getMyOrgByAccount(StaffOrgByAccountFormDTO formDTO) {
+ //1、根据手机号查询到用户信息
+ Result> customerStaffResult = epmetUserFeignClient.checkCustomerStaffByAccount(formDTO.getUserAccount());
+ if (!customerStaffResult.success()) {
+ logger.warn(String.format("账户密码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getUserAccount(), customerStaffResult.getCode(), customerStaffResult.getMsg()));
+ throw new RenException(customerStaffResult.getCode());
+ }
+ //2、密码是否正确
+ List customerStaffList=customerStaffResult.getData();
+ //3、查询用户所有的组织信息
+ List customerIdList = new ArrayList<>();
+ //是否设置过密码
+ boolean havePasswordFlag=false;
+ //密码是否正确
+ boolean passwordRightFlag=false;
+ for (CustomerStaffDTO customerStaffDTO : customerStaffList) {
+ if(StringUtils.isNotBlank(customerStaffDTO.getPassword())){
+ havePasswordFlag=true;
+ }else{
+ logger.warn(String.format("当前用户:账户%s,客户Id%s下未设置密码.",formDTO.getUserAccount(),customerStaffDTO.getCustomerId()));
+ continue;
+ }
+ if (!PasswordUtils.matches(formDTO.getPassword(), customerStaffDTO.getPassword())) {
+ logger.warn(String.format("当前用户:账户%s,客户Id%s密码匹配错误.",formDTO.getUserAccount(),customerStaffDTO.getCustomerId()));
+
+ }else{
+ logger.warn(String.format("当前用户:账户%s,客户Id%s密码匹配正确.",formDTO.getUserAccount(),customerStaffDTO.getCustomerId()));
+ passwordRightFlag=true;
+ customerIdList.add(customerStaffDTO.getCustomerId());
+ }
+ }
+ //根据手机号查出来所有用户,密码都为空,表明用户未激活账户,未设置密码
+ if(!havePasswordFlag){
+ logger.warn(String.format("当前账户(%s)下所有账户都未设置密码,请先使用验证码登录激活账户",formDTO.getUserAccount()));
+ throw new RenException(EpmetErrorCode.PASSWORD_ERROR.getCode());
+ }
+ //密码错误
+ if(!passwordRightFlag){
+ logger.warn(String.format("根据当前账户(%s)密码未找到所属组织,密码错误",formDTO.getUserAccount()));
+ throw new RenException(EpmetErrorCode.PASSWORD_ERROR.getCode());
+ }
+ StaffOrgFormDTO staffOrgFormDTO = new StaffOrgFormDTO();
+ staffOrgFormDTO.setCustomerIdList(customerIdList);
+ Result> result = govOrgFeignClient.getStaffOrgList(staffOrgFormDTO);
+ if(result.success()&&null!=result.getData()){
+ return result.getData();
+ }
+ logger.warn(String .format("手机验证码获取组织,调用%s服务失败,入参账户%s,密码%s,返回错误码%s,错误提示信息%s",
+ ServiceConstant.GOV_ORG_SERVER,
+ formDTO.getUserAccount(),
+ formDTO.getPassword(),
+ result.getCode(),
+ result.getMsg()));
+ return new ArrayList<>();
+ }
+
//保存登录日志
private Result saveStaffLoginRecord(GovWxmpEnteOrgFormDTO formDTO, String staffId, String openId) {
StaffLoginAgencyRecordFormDTO staffLoginAgencyRecordFormDTO = new StaffLoginAgencyRecordFormDTO();
diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java
index eab142e6a5..92e1de27a5 100644
--- a/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java
+++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java
@@ -100,6 +100,33 @@ public class GovWebServiceImpl implements GovWebService, ResultDataResolver {
}
+ @Override
+ public UserTokenResultDTO loginByThirdPlatform(GovWebLoginFormDTO formDTO) {
+ formDTO.setApp(LoginConstant.APP_GOV);
+ formDTO.setClient(LoginConstant.CLIENT_WEB);
+// //1.参数校验
+// if (!(LoginConstant.APP_GOV.equals(formDTO.getApp()) && LoginConstant.CLIENT_WEB.equals(formDTO.getClient()))) {
+// logger.error("当前接口只适用于PC工作端运营管理后台");
+// throw new RenException("当前接口只适用于PC工作端运营管理后台");
+// }
+ //3.校验登陆账号是否存在
+ //根据客户Id和手机号查询登陆用户信息(此处不需要判断登陆人是否是有效客户以及是否是客户的根管理员,前一接口获取登陆手机号对应客户列表已经判断了)
+ GovWebOperLoginFormDTO form = new GovWebOperLoginFormDTO();
+ form.setCustomerId(formDTO.getCustomerId());
+ form.setMobile(formDTO.getPhone());
+ Result result = epmetUserFeignClient.getStaffIdAndPwd(form);
+ if (!result.success() || null == result.getData() || null == result.getData().getUserId()) {
+ logger.warn("根据手机号查询PC工作端登陆人员信息失败,返回10003账号不存在");
+ throw new RenException(EpmetErrorCode.ERR10003.getCode());
+ }
+ GovWebOperLoginResultDTO resultDTO = result.getData();
+
+ //5.生成token存到redis并返回
+ UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO();
+ userTokenResultDTO.setToken(this.packagingUserToken(formDTO, resultDTO.getUserId()));
+ return userTokenResultDTO;
+ }
+
/**
* 生成PC工作端token
* @author sun
diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java
index 211fce084e..3e1e580fce 100644
--- a/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java
+++ b/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java
@@ -6,8 +6,10 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
import com.alibaba.fastjson.JSON;
import com.epmet.common.token.constant.LoginConstant;
+import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
+import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.security.password.PasswordUtils;
import com.epmet.commons.tools.utils.CpUserDetailRedis;
@@ -130,13 +132,13 @@ public class LoginServiceImpl implements LoginService {
}
}
} catch (WxErrorException e) {
- log.error("->[getMaOpenId]::error[{}]", "解析微信code失败",e);
+ log.warn("->[getMaOpenId]::error[{}]", "解析微信code失败",e);
}
if (null == wxMaJscode2SessionResult) {
- log.error(String.format("解析微信用户信息失败,app[%s],wxCode[%s],result:[%S]",app,wxCode, JSON.toJSONString(wxMaJscode2SessionResult)));
+ log.warn(String.format("解析微信用户信息失败,app[%s],wxCode[%s],result:[%S]",app,wxCode, JSON.toJSONString(wxMaJscode2SessionResult)));
throw new RenException("解析微信用户信息失败");
} else if (StringUtils.isBlank(wxMaJscode2SessionResult.getOpenid())) {
- log.error(String.format("获取微信openid失败,app[%s],wxCode[%s]",app,wxCode));
+ log.warn(String.format("获取微信openid失败,app[%s],wxCode[%s]",app,wxCode));
throw new RenException("获取微信openid失败");
}
return wxMaJscode2SessionResult;
@@ -366,6 +368,10 @@ public class LoginServiceImpl implements LoginService {
} else {
logger.error(String.format("运营人员%s退出成功,清空菜单和权限redis异常", tokenDto.getUserId()));
}
+ //如果是工作端退出,删除当前工作人员缓存
+ if(AppClientConstant.APP_GOV.equals(tokenDto.getApp())){
+ CustomerStaffRedis.delStaffInfoFormCache(tokenDto.getCustomerId(),tokenDto.getUserId());
+ }
return new Result();
}
diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java
index dd48a5577f..c7c79bb575 100644
--- a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java
+++ b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java
@@ -5,15 +5,21 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.aliyun.dingtalk.module.DingTalkResult;
import com.epmet.auth.constants.AuthOperationConstants;
import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.rocketmq.messages.LoginMQMsg;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.ServiceConstant;
+import com.epmet.commons.tools.constant.StrConstant;
+import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
+import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.ResultDataResolver;
+import com.epmet.commons.tools.redis.common.CustomerDingDingRedis;
+import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache;
import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.security.password.PasswordUtils;
@@ -23,15 +29,24 @@ import com.epmet.commons.tools.validator.PhoneValidatorUtils;
import com.epmet.constant.AuthHttpUrlConstant;
import com.epmet.constant.SmsTemplateConstant;
import com.epmet.dto.*;
+import com.epmet.dto.dingres.DingUserDetailDTO;
+import com.epmet.dto.dingres.V2UserGetuserinfoResDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.feign.EpmetMessageOpenFeignClient;
+import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.jwt.JwtTokenProperties;
import com.epmet.jwt.JwtTokenUtils;
import com.epmet.redis.CaptchaRedis;
+import com.epmet.service.GovWebService;
import com.epmet.service.ThirdLoginService;
+import com.taobao.api.ApiException;
+import com.taobao.dingtalk.client.DingTalkClientToken;
+import com.taobao.dingtalk.client.DingTalkClientUser;
+import com.taobao.dingtalk.vo.result.AccessTokenResult;
+import com.taobao.dingtalk.vo.result.UserBaseInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@@ -73,6 +88,14 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
private EpmetMessageOpenFeignClient messageOpenFeignClient;
@Autowired
private LoginUserUtil loginUserUtil;
+ @Autowired
+ private DingTalkClientToken dingTalkClientToken;
+ @Autowired
+ private DingTalkClientUser dingTalkClientUser;
+ @Autowired
+ private EpmetUserFeignClient epmetUserFeignClient;
+ @Autowired
+ private GovWebService govWebService;
/**
* @param formDTO
@@ -425,6 +448,68 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
return userTokenResultDTO;
}
+ /**
+ * @param formDTO
+ * @return
+ * @Author sun
+ * @Description 单客户-选择组织,进入首页
+ **/
+ @Override
+ public UserTokenResultDTO enterOrgByAccount(ThirdWxmpEnteOrgByAccountFormDTO formDTO) {
+ //1、需要校验要登录的客户,是否被禁用
+ CustomerStaffByAccountFormDTO customerStaffFormDTO = new CustomerStaffByAccountFormDTO();
+ customerStaffFormDTO.setCustomerId(formDTO.getCustomerId());
+ customerStaffFormDTO.setUserAccount(formDTO.getUserAccount());
+ Result customerStaffDTOResult = epmetUserOpenFeignClient.getCustomerStaffInfoByAccount(customerStaffFormDTO);
+ if (!customerStaffDTOResult.success() || null == customerStaffDTOResult.getData()) {
+ logger.error(String.format("获取工作人员信息失败,账户[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getUserAccount(), formDTO.getCustomerId(), customerStaffDTOResult.getCode(), customerStaffDTOResult.getMsg()));
+ throw new RenException(customerStaffDTOResult.getCode());
+ }
+ CustomerStaffDTO customerStaff = customerStaffDTOResult.getData();
+ //2020.7.24 获取微信信息接口调整,改调用微信api的方式 sun start
+ //2.调用epmet_third服务,校验appId是否有效以及是否授权,校验通过的调用微信API获取用户基本信息
+ WxLoginFormDTO resiLoginFormDTO = new WxLoginFormDTO();
+ resiLoginFormDTO.setAppId(formDTO.getAppId());
+ resiLoginFormDTO.setWxCode(formDTO.getWxCode());
+ UserWechatDTO userWechatDTO = this.getUserWeChat(resiLoginFormDTO);
+ WxMaJscode2SessionResult wxMaJscode2SessionResult = new WxMaJscode2SessionResult();
+ wxMaJscode2SessionResult.setOpenid(userWechatDTO.getWxOpenId());
+ wxMaJscode2SessionResult.setSessionKey(userWechatDTO.getSessionKey());
+ wxMaJscode2SessionResult.setUnionid("");
+ // end
+ //3、记录staff_wechat,并记录用户激活状态,激活时间
+ this.savestaffwechat(customerStaff.getUserId(), userWechatDTO.getWxOpenId(), formDTO.getCustomerId());
+ //4、记录登录日志
+ StaffLatestAgencyResultDTO staffLatestAgencyResultDTO = new StaffLatestAgencyResultDTO();
+ staffLatestAgencyResultDTO.setCustomerId(formDTO.getCustomerId());
+ staffLatestAgencyResultDTO.setStaffId(customerStaff.getUserId());
+ staffLatestAgencyResultDTO.setWxOpenId(userWechatDTO.getWxOpenId());
+ staffLatestAgencyResultDTO.setMobile(customerStaff.getMobile());
+ staffLatestAgencyResultDTO.setAgencyId(formDTO.getRootAgencyId());
+ this.saveStaffLoginRecord(staffLatestAgencyResultDTO);
+ //5.1、获取用户token
+ String token = this.generateGovWxmpToken(customerStaff.getUserId());
+ //5.2、保存到redis
+ StaffLatestAgencyResultDTO staffLatestAgency = new StaffLatestAgencyResultDTO();
+ staffLatestAgency.setAgencyId(formDTO.getRootAgencyId());
+ staffLatestAgency.setCustomerId(formDTO.getCustomerId());
+ staffLatestAgency.setStaffId(customerStaff.getUserId());
+ this.saveLatestGovTokenDto(staffLatestAgency, userWechatDTO, token);
+
+ UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO();
+ userTokenResultDTO.setToken(token);
+
+ //6.发送登录事件
+ try {
+ sendLoginEvent(customerStaff.getUserId(), formDTO.getAppId(), AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP);
+ } catch (RenException e) {
+ log.error(e.getInternalMsg());
+ } catch (Exception e) {
+ log.error("【工作端enterOrg登录】发送登录事件失败,程序继续执行。错误信息");
+ }
+ return userTokenResultDTO;
+ }
+
/**
* @param formDTO
* @return
@@ -538,6 +623,69 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
return new ArrayList<>();
}
+ @Override
+ public List getMyOrgByAccount(ThirdStaffOrgByAccountFormDTO formDTO) {
+ //0.根据appId查询对应客户Id
+ PaCustomerDTO customer = this.getCustomerInfo(formDTO.getAppId());
+ //7.28 上边根据appId只能锁定一条客户id,后边的批量循环操作暂不做调整,还是使用之前的代码 sun
+ //1、根据手机号查询到用户信息
+ ThirdCustomerStaffByAccountFormDTO dto = new ThirdCustomerStaffByAccountFormDTO();
+ dto.setCustomerId(customer.getId());
+ dto.setUserAccount(formDTO.getUserAccount());
+ Result> customerStaffResult = epmetUserOpenFeignClient.getCustsomerStaffByIdAndAccount(dto);
+ if (!customerStaffResult.success()) {
+ logger.warn(String.format("账户密码登录异常,账户[%s],code[%s],msg[%s]", formDTO.getUserAccount(), customerStaffResult.getCode(), customerStaffResult.getMsg()));
+ throw new RenException(customerStaffResult.getCode());
+ }
+ //2、密码是否正确
+ List customerStaffList=customerStaffResult.getData();
+ //3、查询用户所有的组织信息
+ List customerIdList = new ArrayList<>();
+ //是否设置过密码
+ boolean havePasswordFlag=false;
+ //密码是否正确
+ boolean passwordRightFlag=false;
+ for (CustomerStaffDTO customerStaffDTO : customerStaffList) {
+ if(StringUtils.isNotBlank(customerStaffDTO.getPassword())){
+ havePasswordFlag=true;
+ }else{
+ logger.warn(String.format("当前用户:账户%s,客户Id%s下未设置密码.",formDTO.getUserAccount(),customerStaffDTO.getCustomerId()));
+ continue;
+ }
+ if (!PasswordUtils.matches(formDTO.getPassword(), customerStaffDTO.getPassword())) {
+ logger.warn(String.format("当前用户:账户%s,客户Id%s密码匹配错误.",formDTO.getUserAccount(),customerStaffDTO.getCustomerId()));
+
+ }else{
+ logger.warn(String.format("当前用户:账户%s,客户Id%s密码匹配正确.",formDTO.getUserAccount(),customerStaffDTO.getCustomerId()));
+ passwordRightFlag=true;
+ customerIdList.add(customerStaffDTO.getCustomerId());
+ }
+ }
+ //根据手机号查出来所有用户,密码都为空,表明用户未激活账户,未设置密码
+ if(!havePasswordFlag){
+ logger.warn(String.format("当前账户(%s)下所有账户都未设置密码,请先使用验证码登录激活账户",formDTO.getUserAccount()));
+ throw new RenException(EpmetErrorCode.PASSWORD_ERROR.getCode());
+ }
+ //密码错误
+ if(!passwordRightFlag){
+ logger.warn(String.format("根据当前账户(%s)密码未找到所属组织,密码错误",formDTO.getUserAccount()));
+ throw new RenException(EpmetErrorCode.PASSWORD_ERROR.getCode());
+ }
+ StaffOrgFormDTO staffOrgFormDTO = new StaffOrgFormDTO();
+ staffOrgFormDTO.setCustomerIdList(customerIdList);
+ Result> result = govOrgOpenFeignClient.getStaffOrgList(staffOrgFormDTO);
+ if(result.success()&&null!=result.getData()){
+ return result.getData();
+ }
+ logger.warn(String .format("手机验证码获取组织,调用%s服务失败,入参账户%s,密码%s,返回错误码%s,错误提示信息%s",
+ ServiceConstant.GOV_ORG_SERVER,
+ formDTO.getUserAccount(),
+ formDTO.getPassword(),
+ result.getCode(),
+ result.getMsg()));
+ return new ArrayList<>();
+ }
+
/**
* @Description 获取客户信息
* @param appId
@@ -690,4 +838,318 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
//getResultDataOrThrowsException(result, ServiceConstant.EPMET_MESSAGE_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用Message服务,发送登录事件到MQ失败");
}
+// 接入流程:https://open.dingtalk.com/document/isvapp-server/unified-authorization-suite-access-process
+// 1、获取个人用户token:https://open.dingtalk.com/document/isvapp-server/obtain-user-token
+// 2、获取用户通讯录个人信息:https://open.dingtalk.com/document/isvapp-server/dingtalk-retrieve-user-information
+// 接口逻辑:
+// (1)根据clientId去XXX表找到customerId
+// (2)通过1、2拿到手机号之后,根据mobile+customerId去user_base_info表找userId,
+// 是否注册居民:register_relation
+// (3)没有则生成user、user_Base_info表记录
+ /**
+ * 钉钉应用的登录-居民端
+ *
+ * @param formDTO
+ * @return
+ */
+ @Override
+ public ResiDingAppLoginResDTO resiLoginDing(ResiDingAppLoginFormDTO formDTO) {
+ //获取用户手机号
+ log.info("1、钉钉居民端应用登录入参:"+ JSON.toJSONString(formDTO));
+ ResiDingAppLoginResDTO resDTO= null;
+ try {
+ resDTO = new ResiDingAppLoginResDTO();
+ resDTO.setCustomerId(getCurrentCustomerId());
+ //1、获取用户手机号
+ String miniAppId = formDTO.getMiniAppId();
+ DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId);
+ DingTalkResult userAccessToken = dingTalkClientToken.getUserAccessToken(formDTO.getAuthCode(), dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret());
+ log.info("2、resiLoginDing userAccessToken:{}",JSON.toJSONString(userAccessToken));
+ if (!userAccessToken.success() || null == userAccessToken.getData()) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "调用微信api异常:" + JSON.toJSONString(userAccessToken), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg());
+ }
+ DingTalkResult me = dingTalkClientUser.getUserInfo("me", userAccessToken.getData().getAccessToken());
+ log.info("3、resiLoginDing me:{}",JSON.toJSONString(me));
+ resDTO.setExtInfo(JSON.toJSONString(me.getData()));
+ if (!me.success() || StringUtils.isBlank(me.getData().getMobile())) {
+ log.error("resilogin-ding登录接口报错,入参:" + JSON.toJSONString(formDTO) + ";获取手机号为空, userAccessToken.getData().getAccessToken()=" + userAccessToken.getData().getAccessToken());
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空");
+ }
+ // 2、调用userfeign接口获取userId、注册网格相关信息 todo
+ DingLoginResiFormDTO dingLoginResiFormDTO=ConvertUtils.sourceToTarget(me.getData(),DingLoginResiFormDTO.class);
+ dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId());
+ Result loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO);
+ if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) {
+ //临时打个日志
+ log.error(String.format("resilogin-ding获取epmetUserId异常,入参:%s,user服务返参:%s", JSON.toJSONString(formDTO), JSON.toJSONString(loginResiResDTOResult)));
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取epmetUserId异常:" + JSON.toJSONString(loginResiResDTOResult), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg());
+ }
+ DingLoginResiResDTO resiResDTO=loginResiResDTOResult.getData();
+ resDTO.setGridId(resiResDTO.getGridId());
+ resDTO.setGridName(resiResDTO.getGridName());
+ resDTO.setAgencyId(resiResDTO.getAgencyId());
+ resDTO.setEpmetUserId(resiResDTO.getEpmetUserId());
+ resDTO.setRegFlag(resiResDTO.getRegFlag());
+
+ //3.生成token,并且存放Redis
+ String token=this.saveTokenDtoDing(formDTO.getMiniAppId(),AppClientConstant.APP_RESI,AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId());
+ resDTO.setAuthorization(token);
+
+ } catch (ApiException e) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getErrMsg(), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg());
+ }
+ return resDTO;
+ }
+
+ private String saveTokenDtoDing(String miniAppId,String app,String client, String userId,String customerId) {
+ //生成token串
+ Map map = new HashMap<>();
+ map.put(AppClientConstant.APP, app);
+ // map.put(AppClientConstant.CLIENT, client);
+ // 第三方企业应用传应用的SuiteKey 作为client
+ map.put(AppClientConstant.CLIENT, client.concat(miniAppId));
+ map.put("userId", userId);
+ String token = jwtTokenUtils.createToken(map);
+ int expire = jwtTokenProperties.getExpire();
+ TokenDto tokenDto = new TokenDto();
+ tokenDto.setCustomerId(customerId);
+ tokenDto.setApp(app);
+ tokenDto.setClient(client.concat(miniAppId));
+ tokenDto.setUserId(userId);
+ tokenDto.setToken(token);
+ tokenDto.setUpdateTime(System.currentTimeMillis());
+ tokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime());
+ cpUserDetailRedis.set(tokenDto, expire);
+ // cpUserDetailRedis.setForDingApp(miniAppId,tokenDto, expire);
+ logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss"));
+ return token;
+ }
+
+ @Override
+ public ResiDingAppLoginResDTO resiLoginDingMd(DingAppLoginMdFormDTO formDTO) {
+ // 获取用户手机号
+ log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO));
+ ResiDingAppLoginResDTO resDTO = null;
+ resDTO = new ResiDingAppLoginResDTO();
+ resDTO.setCustomerId(getCurrentCustomerId());
+ // 1、获取用户手机号
+ DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOMd(formDTO.getMiniAppId(), formDTO.getAuthCode());
+ dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId());
+ // 2、调用userfeign接口获取userId、注册网格相关信息
+ Result loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO);
+ if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) {
+ // 临时打个日志
+ log.error(String.format("resiLoginDingMd获取epmetUserId异常,入参:%s,user服务返参:%s", JSON.toJSONString(formDTO), JSON.toJSONString(loginResiResDTOResult)));
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取epmetUserId异常:" + JSON.toJSONString(loginResiResDTOResult), EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getMsg());
+ }
+ DingLoginResiResDTO resiResDTO = loginResiResDTOResult.getData();
+ resDTO.setGridId(resiResDTO.getGridId());
+ resDTO.setGridName(resiResDTO.getGridName());
+ resDTO.setAgencyId(resiResDTO.getAgencyId());
+ resDTO.setEpmetUserId(resiResDTO.getEpmetUserId());
+ resDTO.setRegFlag(resiResDTO.getRegFlag());
+
+ // 3.生成token,并且存放Redis
+ String token = this.saveTokenDtoDing(formDTO.getMiniAppId(), AppClientConstant.APP_RESI, AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId());
+ resDTO.setAuthorization(token);
+
+ return resDTO;
+ }
+
+ private DingLoginResiFormDTO getDingLoginResiFormDTOMd(String miniAppId, String authCode) {
+ DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId);
+
+ // 1、服务商获取第三方应用授权企业的access_token,文档地址:https://open.dingtalk.com/document/orgapp-server/obtains-the-enterprise-authorized-credential
+ // 烟台的CorpId: dingaae55cbc47a96845f5bf40eda33b7ba0
+ String yantaiCorpId = "dingaae55cbc47a96845f5bf40eda33b7ba0";
+ DingTalkResult res = dingTalkClientToken.getThirdAuthCorpAccessToken(dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret(), "abc", yantaiCorpId);
+ if (!res.success() || StringUtils.isBlank(res.getData())) {
+ log.error(String.format("企业内部应用免登服务商获取第三方应用授权企业的access_token失败,customKey:%s,customSecret:%s,corpId:%s", dingMiniInfo.getSuiteSecret(), dingMiniInfo.getSuiteSecret(), yantaiCorpId));
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "服务商获取第三方应用授权企业的access_token", "服务商获取第三方应用授权企业的access_token");
+ }
+ String accessToken = res.getData();
+ log.info(String.format("1、服务商获取第三方应用授权企业的access_token返参:%s", accessToken));
+
+ // 2、通过免登码获取用户信息,文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-userid-of-a-user-by-using-the-log-free
+ DingTalkResult v2UserGetuserinfoRes = dingTalkClientToken.getUserInfo(accessToken, authCode);
+ if (!v2UserGetuserinfoRes.success() || StringUtils.isBlank(v2UserGetuserinfoRes.getData())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "通过免登码获取用户信息异常", "通过免登码获取用户信息异常");
+ }
+ log.info(String.format("2、通过免登码获取用户信息返参:%s", v2UserGetuserinfoRes.getData()));
+ V2UserGetuserinfoResDTO v2UserGetuserinfoResDTO = JSON.parseObject(v2UserGetuserinfoRes.getData(), V2UserGetuserinfoResDTO.class);
+ if (null == v2UserGetuserinfoResDTO || StringUtils.isBlank(v2UserGetuserinfoResDTO.getUserid())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取钉钉用户userid为空", "获取钉钉用户userid为空");
+ }
+
+
+ // 3、查询用户详情,文档地址:https://open.dingtalk.com/document/isvapp-server/query-user-details
+ DingTalkResult v2UserGetRes = dingTalkClientToken.getUserDetail(v2UserGetuserinfoResDTO.getUserid(), accessToken);
+ if (!v2UserGetRes.success() || StringUtils.isBlank(v2UserGetRes.getData())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "根据userId查询用户详情失败", "根据userId查询用户详情失败");
+ }
+ log.info(String.format("3、查询用户详情:%s", v2UserGetRes.getData()));
+ DingUserDetailDTO dingUserDetailDTO = JSON.parseObject(v2UserGetRes.getData(), DingUserDetailDTO.class);
+ if (null == dingUserDetailDTO || StringUtils.isBlank(dingUserDetailDTO.getMobile())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空");
+ }
+
+ DingLoginResiFormDTO dingLoginResiFormDTO = new DingLoginResiFormDTO();
+ dingLoginResiFormDTO.setAvatarUrl(dingUserDetailDTO.getAvatar());
+ dingLoginResiFormDTO.setEmail(dingUserDetailDTO.getOrg_email());
+ dingLoginResiFormDTO.setMobile(dingUserDetailDTO.getMobile());
+ dingLoginResiFormDTO.setNick(dingUserDetailDTO.getName());
+ dingLoginResiFormDTO.setOpenId(StrConstant.EPMETY_STR);
+ dingLoginResiFormDTO.setStateCode(dingUserDetailDTO.getState_code());
+ dingLoginResiFormDTO.setUnionId(dingUserDetailDTO.getUnionid());
+ return dingLoginResiFormDTO;
+ }
+
+
+ /**
+ * 企业内部应用开发,不授权了
+ * https://open.dingtalk.com/document/orgapp-server/enterprise-internal-application-logon-free
+ * 建议用户信息保存在前端缓存中(dd.setStorage)或者cookie中,避免每次进入应用都调用钉钉接口进行免登。
+ *
+ * 获取免登授权码。
+ * 小程序免登
+ * 微应用免登
+ * 获取AccessToken。
+ * 调用接口获取access_token,详情请参考获取企业内部应用的access_token。
+ *
+ * 获取userid。
+ * 调用接口获取用户的userid,详情请参考通过免登码获取用户信息。
+ *
+ * 获取用户详情。
+ * 调用接口获取用户详细信息,详情请参考根据userId获取用户详情。
+ *
+ * @param formDTO
+ * @return
+ */
+ @Override
+ public ResiDingAppLoginResDTO resiLoginInternalDing(DingAppLoginMdFormDTO formDTO) {
+ // 获取用户手机号
+ log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO));
+ ResiDingAppLoginResDTO resDTO = new ResiDingAppLoginResDTO();
+ resDTO.setCustomerId(getCurrentCustomerId());
+
+ // 1、获取用户手机号
+ DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOInternal(formDTO.getMiniAppId(), formDTO.getAuthCode());
+ dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId());
+ resDTO.setRealName(dingLoginResiFormDTO.getNick());
+ // 2、调用userfeign接口获取userId、注册网格相关信息
+ Result loginResiResDTOResult = epmetUserOpenFeignClient.dingResiLogin(dingLoginResiFormDTO);
+ if (!loginResiResDTOResult.success() || null == loginResiResDTOResult.getData()) {
+ // 临时打个日志
+ log.error(String.format("resiLoginInternalDing获取epmetUserId异常,入参:%s", JSON.toJSONString(dingLoginResiFormDTO)));
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取epmetUserId异常:"+ JSON.toJSONString(loginResiResDTOResult), "获取epmetUserId异常");
+ }
+ DingLoginResiResDTO resiResDTO = loginResiResDTOResult.getData();
+ resDTO.setGridId(resiResDTO.getGridId());
+ resDTO.setGridName(resiResDTO.getGridName());
+ resDTO.setAgencyId(resiResDTO.getAgencyId());
+ resDTO.setEpmetUserId(resiResDTO.getEpmetUserId());
+ resDTO.setRegFlag(resiResDTO.getRegFlag());
+
+ // 3.生成token,并且存放Redis
+ String token = this.saveTokenDtoDing(formDTO.getMiniAppId(), AppClientConstant.APP_RESI, AppClientConstant.MINI_DING, resDTO.getEpmetUserId(), resDTO.getCustomerId());
+ resDTO.setAuthorization(token);
+
+ return resDTO;
+ }
+
+ @Override
+ public UserTokenResultDTO govLoginInternalDing(DingAppLoginMdFormDTO formDTO) {
+ // 获取用户手机号
+ log.info("1、钉钉居民端应用登录入参:" + JSON.toJSONString(formDTO));
+ ResiDingAppLoginResDTO resDTO = null;
+ resDTO = new ResiDingAppLoginResDTO();
+ resDTO.setCustomerId(getCurrentCustomerId());
+
+ // 1、获取用户手机号
+ DingLoginResiFormDTO dingLoginResiFormDTO = getDingLoginResiFormDTOInternal(formDTO.getMiniAppId(), formDTO.getAuthCode());
+ dingLoginResiFormDTO.setCustomerId(resDTO.getCustomerId());
+
+
+ GovWebLoginFormDTO loginGovParam = new GovWebLoginFormDTO();
+ loginGovParam.setCustomerId(dingLoginResiFormDTO.getCustomerId());
+ loginGovParam.setPhone(dingLoginResiFormDTO.getMobile());
+
+ return govWebService.loginByThirdPlatform(loginGovParam);
+ }
+
+ /**
+ * 最原始的企业内部应用开发,不授权给产品服务商
+ * @param miniAppId
+ * @param authCode
+ * @return
+ */
+ private DingLoginResiFormDTO getDingLoginResiFormDTOInternal(String miniAppId, String authCode) {
+ DingMiniInfoCache dingMiniInfo = CustomerDingDingRedis.getDingMiniInfo(miniAppId);
+ if (dingMiniInfo == null){
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取钉钉应用配置异常", "获取钉钉应用配置异常");
+ }
+ // 1、获取企业内部应用的accessToken文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-access_token-of-an-internal-app
+ String accessToken = "";
+ DingTalkResult dingTalkResult = dingTalkClientToken.getAppAccessTokenToken(dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret());
+ if (!dingTalkResult.success() || StringUtils.isBlank(dingTalkResult.getData())) {
+ log.error(String.format("获取企业内部应用的accessToken失败,customKey:%s,customSecret:%s", dingMiniInfo.getSuiteKey(), dingMiniInfo.getSuiteSecret()));
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取企业内部应用的accessToken异常", "获取企业内部应用的accessToken");
+ }
+ accessToken = dingTalkResult.getData();
+ log.info(String.format("1、获取企业内部应用的accessToken返参:%s", accessToken));
+
+
+ // 2、通过免登码获取用户信息,文档地址:https://open.dingtalk.com/document/orgapp-server/obtain-the-userid-of-a-user-by-using-the-log-free
+ DingTalkResult v2UserGetuserinfoRes = dingTalkClientToken.getUserInfo(accessToken, authCode);
+ if (!v2UserGetuserinfoRes.success() || StringUtils.isBlank(v2UserGetuserinfoRes.getData())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "通过免登码获取用户信息异常", "通过免登码获取用户信息异常");
+ }
+ log.info(String.format("2、通过免登码获取用户信息返参:%s", v2UserGetuserinfoRes.getData()));
+ V2UserGetuserinfoResDTO v2UserGetuserinfoResDTO = JSON.parseObject(v2UserGetuserinfoRes.getData(), V2UserGetuserinfoResDTO.class);
+ if (null == v2UserGetuserinfoResDTO || StringUtils.isBlank(v2UserGetuserinfoResDTO.getUserid())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取钉钉用户userid为空", "获取钉钉用户userid为空");
+ }
+
+
+ // 3、查询用户详情,文档地址:https://open.dingtalk.com/document/isvapp-server/query-user-details
+ DingTalkResult v2UserGetRes = dingTalkClientToken.getUserDetail(v2UserGetuserinfoResDTO.getUserid(), accessToken);
+ if (!v2UserGetRes.success() || StringUtils.isBlank(v2UserGetRes.getData())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "根据userId查询用户详情失败", "根据userId查询用户详情失败");
+ }
+ log.info(String.format("3、查询用户详情:%s", v2UserGetRes.getData()));
+ DingUserDetailDTO dingUserDetailDTO = JSON.parseObject(v2UserGetRes.getData(), DingUserDetailDTO.class);
+ if (null == dingUserDetailDTO || StringUtils.isBlank(dingUserDetailDTO.getMobile())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取手机号为空", "获取手机号为空");
+ }
+
+ DingLoginResiFormDTO dingLoginResiFormDTO = new DingLoginResiFormDTO();
+ dingLoginResiFormDTO.setAvatarUrl(dingUserDetailDTO.getAvatar());
+ dingLoginResiFormDTO.setEmail(dingUserDetailDTO.getOrg_email());
+ dingLoginResiFormDTO.setMobile(dingUserDetailDTO.getMobile());
+ dingLoginResiFormDTO.setNick(dingUserDetailDTO.getName());
+ dingLoginResiFormDTO.setOpenId(StrConstant.EPMETY_STR);
+ dingLoginResiFormDTO.setStateCode(dingUserDetailDTO.getState_code());
+ dingLoginResiFormDTO.setUnionId(dingUserDetailDTO.getUnionid());
+ return dingLoginResiFormDTO;
+ }
+
+ /**
+ * 客户写死吧
+ * @return
+ */
+ private String getCurrentCustomerId() {
+ String customerId="";
+ EnvEnum currentEnv = EnvEnum.getCurrentEnv();
+ if (EnvEnum.PROD.getCode().equals(currentEnv.getCode())) {
+ // 烟台的客户id
+ customerId="1535072605621841922";
+ } else if (EnvEnum.TEST.getCode().equals(currentEnv.getCode())) {
+ // 最美琴岛
+ customerId="0c41b272ee9ee95ac6f184ad548a30eb";
+ } else {
+ // 其余统一走开发环境
+ customerId="45687aa479955f9d06204d415238f7cc";
+ }
+ return customerId;
+ }
}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java
index 0b42461f6e..049f335aa4 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java
@@ -32,6 +32,11 @@ public interface AppClientConstant {
*/
String CLIENT_WXMP = "wxmp";
+ /**
+ * 钉钉小程序
+ */
+ String MINI_DING = "mini_ding";
+
/**
* 客户来源App
* */
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java
index 1f0d76e14f..d3e34b119d 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java
@@ -85,6 +85,7 @@ public interface NumConstant {
String POSITIVE_EIGHT_STR = "+8";
String EMPTY_STR = "";
String ONE_NEG_STR = "-1";
+ String ONE_HUNDRED_STR = "100";
String FIFTY_STR="50";
}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingMiniInfoFormDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingMiniInfoFormDTO.java
new file mode 100644
index 0000000000..bd36526985
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingMiniInfoFormDTO.java
@@ -0,0 +1,26 @@
+package com.epmet.commons.tools.dto.form;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+
+/**
+ * @Author zxc
+ * @DateTime 2022/9/15 10:25
+ * @DESC
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class DingMiniInfoFormDTO implements Serializable {
+
+ private static final long serialVersionUID = 2661531490851265637L;
+
+ public interface DingMiniInfoForm{}
+
+ @NotBlank(message = "miniAppId不能为空",groups = DingMiniInfoForm.class)
+ private String miniAppId;
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/HasOperPermissionFormDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/HasOperPermissionFormDTO.java
new file mode 100644
index 0000000000..62faa45150
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/HasOperPermissionFormDTO.java
@@ -0,0 +1,24 @@
+package com.epmet.commons.tools.dto.form;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+@Data
+public class HasOperPermissionFormDTO {
+
+ /**
+ * uri
+ */
+ @NotBlank(message = "uri不能为空")
+ private String uri;
+
+ /**
+ * http方法
+ */
+ @NotBlank(message = "请求http方法不能为空")
+ private String method;
+
+ @NotBlank(message = "操作者ID不能为空")
+ private String operId;
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/OperResouce.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/OperResouce.java
new file mode 100644
index 0000000000..632f013746
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/OperResouce.java
@@ -0,0 +1,13 @@
+package com.epmet.commons.tools.dto.result;
+
+import lombok.Data;
+
+@Data
+public class OperResouce {
+
+ private String userId;
+ private String resourceUrl;
+ private String ResourceMethod;
+
+
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtHsjcResDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtHsjcResDTO.java
new file mode 100644
index 0000000000..4dcf8869a1
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtHsjcResDTO.java
@@ -0,0 +1,22 @@
+package com.epmet.commons.tools.dto.result;
+
+import lombok.Data;
+
+import java.util.List;
+
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/26 17:04
+ */
+@Data
+public class YtHsjcResDTO {
+ private int code = 200;
+ private String msg = "请求成功";
+ /**
+ * 响应数据
+ */
+ private List data;
+ private int total;
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtHsjcResDetailDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtHsjcResDetailDTO.java
new file mode 100644
index 0000000000..4a958a3cf7
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtHsjcResDetailDTO.java
@@ -0,0 +1,48 @@
+package com.epmet.commons.tools.dto.result;
+
+import lombok.Data;
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/26 17:10
+ */
+@Data
+public class YtHsjcResDetailDTO {
+ private String id;
+ private String name;
+ private String card_no;
+ private String telephone;
+ private String address;
+ private String test_time;
+ private String depart_name;
+ private String county;
+ private String upload_time;
+ private String sample_result_pcr;
+ private String sample_time;
+ private String sampling_org_pcr;
+
+ /* {
+ "code":"200",
+ "msg":"请求成功",
+ "data":[
+ {
+ "id":"6a31eb2d38c011eda054fa163ebc7ff4",
+ "name":"杨冠中",// 姓名
+ "card_no":"372527198404130813",// 证件号码
+ "telephone":"13697890860",// 电话
+ "address":"保利香榭里公馆18-1-302",// 联系地址
+ "test_time":"2022-09-20 12:52:28",// 检测时间
+ "depart_name":"天仁医学检验实验室有限公司",// varchar
+ "county":"莱山区",// 所属区县
+ "upload_time":"2022-09-20 21:23:10",// 时间戳
+ "sample_result_pcr":"2",// 核酸检测结果 1:阳性,2:阴性
+ "sample_time":"2022-09-20 06:48:28",// 采样时间
+ "sampling_org_pcr":"采样点327"// 核酸采样机构
+ },
+ ]
+ "total":1
+ }
+*/
+}
+
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DingMiniAppEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DingMiniAppEnum.java
new file mode 100644
index 0000000000..b0c0054ebb
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DingMiniAppEnum.java
@@ -0,0 +1,79 @@
+package com.epmet.commons.tools.enums;
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/14 19:11
+ */
+public enum DingMiniAppEnum {
+ // 亿联云盘CorpId:dingd1e19e397c754c7735c2f4657eb6378f
+ //
+ // //各应用秘钥
+ // 随手拍
+ // SuiteId:27501006
+ // AppId:119450
+ // MiniAppId:5000000002934668
+ // SuiteKey:suitew6ccvkquinmrghqy
+ // SuiteSecret:TooAxiegdsE5BPP6xo1AxK1LdmaUoMpPMyomOcGcBSXtnsxRc8dEfyOlG56oSmEB
+ //
+ // 随时讲
+ // SuiteId:27564007
+ // AppId:119451
+ // MiniAppId:5000000002934374
+ // SuiteKey:suitezhyj12glsrp8em0f
+ // SuiteSecret:-z5Q_lvMP6l7fTzlArEzUT8D_-5pvqBQaJMuTGHoXnz0nuiqGQMZ8aeya_cxTsN-
+ //
+ // 我的报事
+ // SuiteId:27569006
+ // AppId:119452
+ // MiniAppId:5000000002934456
+ // SuiteKey:suite5yxliro6wawv514w
+ // SuiteSecret:aQxiPi7DwJSUa9HlbUU_L7Q4wGCLEDmgf__Ffx75cTn3jZwuHy9vdl-9Iv5FeyJU
+ //
+ // 实时动态
+ // SuiteId:27458011
+ // AppId:119453
+ // MiniAppId:5000000002934488
+ // SuiteKey:suitemcestnonr6y0xigc
+ // SuiteSecret:kKCNCkfDhmLoVnl_wuAiScyDG4776mkTevuSBuiYhHg-Bvz1-vhb_4IA-Km7nK2I
+ SSP("suitew6ccvkquinmrghqy", "随手拍", "TooAxiegdsE5BPP6xo1AxK1LdmaUoMpPMyomOcGcBSXtnsxRc8dEfyOlG56oSmEB"),
+ SSJ("suitezhyj12glsrp8em0f", "随时讲", "-z5Q_lvMP6l7fTzlArEzUT8D_-5pvqBQaJMuTGHoXnz0nuiqGQMZ8aeya_cxTsN-"),
+ MY_REPORT_EVENT("suite5yxliro6wawv514w", "我的报事", "aQxiPi7DwJSUa9HlbUU_L7Q4wGCLEDmgf__Ffx75cTn3jZwuHy9vdl-9Iv5FeyJU"),
+ SSDT("suitemcestnonr6y0xigc", "实时动态", "kKCNCkfDhmLoVnl_wuAiScyDG4776mkTevuSBuiYhHg-Bvz1-vhb_4IA-Km7nK2I");
+
+ private String suiteKey;
+ private String name;
+ private String suiteSecret;
+
+
+ DingMiniAppEnum(String suiteKey, String name, String suiteSecret) {
+ this.suiteKey = suiteKey;
+ this.name = name;
+ this.suiteSecret = suiteSecret;
+ }
+
+ public static DingMiniAppEnum getEnum(String suiteKey) {
+ DingMiniAppEnum[] values = DingMiniAppEnum.values();
+ for (DingMiniAppEnum value : values) {
+ if (value.getSuiteKey().equals(suiteKey)) {
+ return value;
+ }
+ }
+ return null;
+ }
+
+
+ public String getSuiteKey() {
+ return suiteKey;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getSuiteSecret() {
+ return suiteSecret;
+ }
+
+}
+
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
index 405d84d4ae..64688c8990 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
@@ -40,6 +40,7 @@ public enum EpmetErrorCode {
PASSWORD_NOT_FIT(8010,"两次填写的密码不一致"),
PASSWORD_OUT_OF_ORDER(8011,"密码必须8-20个字符,而且同时包含大小写字母和数字"),
PASSWORD_UPDATE_FAILED(8012,"密码修改失败"),
+ GOV_STAFF_ACCOUNT_NOT_EXISTS(8013,"账户未注册,请联系贵单位管理员"),
MOBILE_HAS_BEEN_USED(8101, "该手机号已注册,请更换手机号或使用原绑定的微信账号登录"),
MOBILE_CODE_ERROR(8102, "验证码错误"),
AUTO_CONFIRM_FAILED(8103, "党员注册失败"),
@@ -100,6 +101,7 @@ public enum EpmetErrorCode {
EXIT_PEND_PROJECT(8408,"该工作人员有项目尚在处理,处理完毕方可操作"),
EXIT_PUBLISHED_ACTIVITY(8409,"该工作人员有活动尚在进行,等活动完成方可操作"),
CAN_NOT_SELF(8410,"无法对自己进行操作"),
+ ACCOUNT_USED(8411,"该账号已注册"),
PATROL_IS_NOT_OVER(8520,"巡查尚未结束"),
ALREADY_EVALUATE(8501,"您已评价"),
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonOperAccessOpenFeignClient.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonOperAccessOpenFeignClient.java
new file mode 100644
index 0000000000..15f76dcb62
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonOperAccessOpenFeignClient.java
@@ -0,0 +1,46 @@
+package com.epmet.commons.tools.feign;
+
+import com.epmet.commons.tools.constant.ServiceConstant;
+import com.epmet.commons.tools.dto.form.HasOperPermissionFormDTO;
+import com.epmet.commons.tools.dto.result.OperResouce;
+import com.epmet.commons.tools.feign.fallback.CommonOperAccessOpenFeignClientFallbackFactory;
+import com.epmet.commons.tools.utils.Result;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.List;
+
+/**
+ * @Description 运营端权限模块
+ * @Author yinzuomei
+ * @Date 2020/5/21 15:17 本服务对外开放的API,其他服务通过引用此client调用该服务
+ */
+@FeignClient(name = ServiceConstant.OPER_ACCESS_SERVER, fallbackFactory = CommonOperAccessOpenFeignClientFallbackFactory.class)
+//@FeignClient(name = ServiceConstant.OPER_ACCESS_SERVER, fallbackFactory = CommonOperAccessOpenFeignClientFallbackFactory.class, url = "http://localhost:8093")
+public interface CommonOperAccessOpenFeignClient {
+ /**
+ * @param
+ * @return com.epmet.commons.tools.utils.Result
+ * @Author yinzuomei
+ * @Description 清空运营人员权限信息、菜单信息
+ * @Date 2020/5/21 17:08
+ **/
+ @GetMapping("/oper/access/menu/clearoperuseraccess")
+ Result clearOperUserAccess();
+
+ /**
+ * 是否有该接口的权限
+ * @return
+ */
+ @PostMapping("/oper/access/menu/hasPermission")
+ Result hasOperPermission(@RequestBody HasOperPermissionFormDTO form);
+
+ /**
+ * 需要验证的菜单资源
+ * @return
+ */
+ @PostMapping("/oper/access/menu/getExamineResourceUrls")
+ Result> getExamineResourceUrls();
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonThirdFeignClient.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonThirdFeignClient.java
new file mode 100644
index 0000000000..6bc986aca0
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonThirdFeignClient.java
@@ -0,0 +1,24 @@
+package com.epmet.commons.tools.feign;
+
+import com.epmet.commons.tools.constant.ServiceConstant;
+import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO;
+import com.epmet.commons.tools.feign.fallback.CommonThirdFeignClientFallBackFactory;
+import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache;
+import com.epmet.commons.tools.utils.Result;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+
+/**
+ * @Description
+ * @Author zxc
+ */
+@FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallbackFactory = CommonThirdFeignClientFallBackFactory.class)
+// @FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallbackFactory = CommonAggFeignClientFallBackFactory.class,url = "localhost:8110")
+public interface CommonThirdFeignClient {
+
+ @PostMapping("/third/dingTalk/getDingMiniInfo")
+ Result getDingMiniInfo(@RequestBody DingMiniInfoFormDTO formDTO);
+
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOperAccessOpenFeignClientFallback.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOperAccessOpenFeignClientFallback.java
new file mode 100644
index 0000000000..ba047f1ada
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOperAccessOpenFeignClientFallback.java
@@ -0,0 +1,35 @@
+package com.epmet.commons.tools.feign.fallback;
+
+import com.epmet.commons.tools.constant.ServiceConstant;
+import com.epmet.commons.tools.dto.form.HasOperPermissionFormDTO;
+import com.epmet.commons.tools.dto.result.OperResouce;
+import com.epmet.commons.tools.feign.CommonOperAccessOpenFeignClient;
+import com.epmet.commons.tools.utils.ModuleUtils;
+import com.epmet.commons.tools.utils.Result;
+
+import java.util.List;
+
+/**
+ * @Description 运营端权限模块
+ * @Author yinzuomei
+ * @Date 2020/5/21 15:47
+ */
+//@Component
+public class CommonOperAccessOpenFeignClientFallback implements CommonOperAccessOpenFeignClient {
+ @Override
+ public Result clearOperUserAccess() {
+ return ModuleUtils.feignConError(ServiceConstant.OPER_ACCESS_SERVER, "clearOperUserAccess");
+
+ }
+
+ @Override
+ public Result hasOperPermission(HasOperPermissionFormDTO form) {
+ return ModuleUtils.feignConError(ServiceConstant.OPER_ACCESS_SERVER, "hasOperPermission");
+ }
+
+ @Override
+ public Result> getExamineResourceUrls() {
+ return ModuleUtils.feignConError(ServiceConstant.OPER_ACCESS_SERVER, "getExamineResourceUrls");
+ }
+}
+
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOperAccessOpenFeignClientFallbackFactory.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOperAccessOpenFeignClientFallbackFactory.java
new file mode 100644
index 0000000000..d62f24900c
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOperAccessOpenFeignClientFallbackFactory.java
@@ -0,0 +1,19 @@
+package com.epmet.commons.tools.feign.fallback;
+
+import com.epmet.commons.tools.exception.ExceptionUtils;
+import com.epmet.commons.tools.feign.CommonOperAccessOpenFeignClient;
+import feign.hystrix.FallbackFactory;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+@Component
+@Slf4j
+public class CommonOperAccessOpenFeignClientFallbackFactory implements FallbackFactory {
+ private CommonOperAccessOpenFeignClientFallback fallback = new CommonOperAccessOpenFeignClientFallback();
+
+ @Override
+ public CommonOperAccessOpenFeignClient create(Throwable cause) {
+ log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause)));
+ return fallback;
+ }
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallBackFactory.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallBackFactory.java
new file mode 100644
index 0000000000..4a43935086
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallBackFactory.java
@@ -0,0 +1,20 @@
+package com.epmet.commons.tools.feign.fallback;
+
+import com.epmet.commons.tools.exception.ExceptionUtils;
+import com.epmet.commons.tools.feign.CommonThirdFeignClient;
+import feign.hystrix.FallbackFactory;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+@Component
+@Slf4j
+public class CommonThirdFeignClientFallBackFactory implements FallbackFactory {
+
+ private CommonThirdFeignClientFallback fallback = new CommonThirdFeignClientFallback();
+
+ @Override
+ public CommonThirdFeignClient create(Throwable cause) {
+ log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause)));
+ return fallback;
+ }
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallback.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallback.java
new file mode 100644
index 0000000000..47e278f846
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonThirdFeignClientFallback.java
@@ -0,0 +1,24 @@
+package com.epmet.commons.tools.feign.fallback;
+
+import com.epmet.commons.tools.constant.ServiceConstant;
+import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO;
+import com.epmet.commons.tools.feign.CommonThirdFeignClient;
+import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache;
+import com.epmet.commons.tools.utils.ModuleUtils;
+import com.epmet.commons.tools.utils.Result;
+import org.springframework.stereotype.Component;
+
+/**
+ *
+ * @Author zxc
+ * @Description
+ * @Date
+ **/
+@Component
+public class CommonThirdFeignClientFallback implements CommonThirdFeignClient {
+
+ @Override
+ public Result getDingMiniInfo(DingMiniInfoFormDTO formDTO) {
+ return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "getDingMiniInfo", formDTO);
+ }
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
index bb7edb3e2a..c09f13f2f4 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
@@ -104,6 +104,10 @@ public class RedisKeys {
return rootPrefix.concat("sys:security:user:").concat(app).concat(StrConstant.COLON).concat(client).concat(StrConstant.COLON).concat(userId);
}
+ public static String getCpUserKeyForDingApp(String suiteKey,String app, String client, String userId) {
+ return rootPrefix.concat("sys:security:user:").concat(app).concat(StrConstant.COLON).concat(client).concat(StrConstant.COLON).concat(suiteKey).concat(StrConstant.COLON).concat(userId);
+ }
+
/**
* 拼接手机验证码key---后面需要改!!!
*
@@ -871,4 +875,39 @@ public class RedisKeys {
public static String getDhToken() {
return rootPrefix.concat("dh:token");
}
+
+ /**
+ * Desc: 票据
+ * @param suiteKey
+ * @author zxc
+ * @date 2022/9/14 10:46
+ */
+ public static String getSuiteTicketKey(String suiteKey) {
+ return rootPrefix.concat("ding:suiteTicket:" + suiteKey);
+ }
+
+ public static String getDingMiniInfoKey(String suiteKey) {
+ return rootPrefix.concat("ding:miniInfo:" + suiteKey);
+ }
+
+ /**
+ * 运营人员-资源权限
+ * @param operId
+ * @return
+ */
+ public static String operResourcesBaseDir() {
+ return rootPrefix.concat("oper:access:resources:");
+ }
+
+ public static String operResourcesByUserId(String operId) {
+ return operResourcesBaseDir().concat(operId);
+ }
+
+ /**
+ * 获取需要检查的资源url
+ * @return
+ */
+ public static String getOperExamineResourceUrls() {
+ return rootPrefix.concat("oper:access:examineresources");
+ }
}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerDingDingRedis.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerDingDingRedis.java
new file mode 100644
index 0000000000..8a57fb1ca7
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerDingDingRedis.java
@@ -0,0 +1,58 @@
+package com.epmet.commons.tools.redis.common;
+
+import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO;
+import com.epmet.commons.tools.exception.EpmetException;
+import com.epmet.commons.tools.feign.CommonThirdFeignClient;
+import com.epmet.commons.tools.redis.RedisKeys;
+import com.epmet.commons.tools.redis.RedisUtils;
+import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache;
+import com.epmet.commons.tools.utils.ConvertUtils;
+import com.epmet.commons.tools.utils.Result;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.PostConstruct;
+import java.util.Map;
+
+/**
+ * @Author zxc
+ * @DateTime 2022/9/15 10:01
+ * @DESC
+ */
+@Slf4j
+@Component
+public class CustomerDingDingRedis {
+
+ @Autowired
+ private CommonThirdFeignClient thirdFeignClient;
+ @Autowired
+ private RedisUtils redisUtils;
+
+ private static CustomerDingDingRedis customerDingDingRedis;
+
+ @PostConstruct
+ public void init() {
+ customerDingDingRedis = this;
+ customerDingDingRedis.thirdFeignClient = this.thirdFeignClient;
+ customerDingDingRedis.redisUtils = this.redisUtils;
+ }
+
+ public static DingMiniInfoCache getDingMiniInfo(String miniAppId){
+ String key = RedisKeys.getDingMiniInfoKey(miniAppId);
+ Map miniInfoMap = customerDingDingRedis.redisUtils.hGetAll(key);
+ if (!CollectionUtils.isEmpty(miniInfoMap)){
+ return ConvertUtils.mapToEntity(miniInfoMap,DingMiniInfoCache.class);
+ }
+ Result dingMiniInfoResult = customerDingDingRedis.thirdFeignClient.getDingMiniInfo(new DingMiniInfoFormDTO(miniAppId));
+ if (!dingMiniInfoResult.success()){
+ throw new EpmetException("查询dingMiniInfo失败...");
+ }
+ if (null == dingMiniInfoResult.getData()){
+ return null;
+ }
+ return dingMiniInfoResult.getData();
+ }
+
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/DingMiniInfoCache.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/DingMiniInfoCache.java
new file mode 100644
index 0000000000..bd656c9a7e
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/DingMiniInfoCache.java
@@ -0,0 +1,52 @@
+package com.epmet.commons.tools.redis.common.bean;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @Author zxc
+ * @DateTime 2022/9/15 10:11
+ * @DESC
+ */
+@Data
+public class DingMiniInfoCache implements Serializable {
+
+ private static final long serialVersionUID = -6956910978074595334L;
+
+ private String id;
+
+ /**
+ *
+ */
+ private String suiteId;
+
+ /**
+ *
+ */
+ private String appId;
+
+ /**
+ *
+ */
+ private String miniAppId;
+
+ /**
+ *
+ */
+ private String suiteName;
+
+ /**
+ *
+ */
+ private String suiteKey;
+
+ /**
+ *
+ */
+ private String suiteSecret;
+
+ private String token;
+
+ private String aesKey;
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/password/PasswordUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/password/PasswordUtils.java
index d7a685b2f2..fdae188e6b 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/password/PasswordUtils.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/password/PasswordUtils.java
@@ -37,6 +37,43 @@ public class PasswordUtils {
return passwordEncoder.matches(str, password);
}
+ /**
+ * desc:校验密码规则是否
+ * 校验密码规则:密码必须8-20个字符,而且同时包含大小写字母和数字
+ * @param password
+ * @return
+ */
+ public static boolean checkPassWordRule(String password) {
+ boolean flag=false;
+ if(password.length()<8||password.length()>20){
+ return flag;
+ }
+ boolean numFlag=false;
+ boolean bigLetter=false;
+ boolean smallLetter=false;
+ char[] passwordArray = password.toCharArray();
+ for(int i=0;i < passwordArray.length;i++) {
+ char currentStr=passwordArray[i];
+ // 判断ch是否是数字字符,如'1','2‘,是返回true。否则返回false
+ if(Character.isDigit(currentStr)){
+ numFlag=true;
+ continue;
+ }
+ // 判断ch是否是字母字符,如'a','b‘,是返回true。否则返回false
+ if(Character.isUpperCase(currentStr)){
+ bigLetter=true;
+ continue;
+ }
+ if(Character.isLowerCase(currentStr)){
+ smallLetter=true;
+ }
+ }
+ if(numFlag&&bigLetter&&smallLetter){
+ flag=true;
+ }
+ return flag;
+ }
+
public static void main(String[] args) {
String str = "wangqing";
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java
index 4c0845fc6c..856cb6449d 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java
@@ -41,6 +41,15 @@ public class CpUserDetailRedis {
redisUtils.hMSet(key, map, expire);
}
+ public void setForDingApp(String suiteKey,TokenDto user, long expire) {
+ if (user == null) {
+ return;
+ }
+ String key = RedisKeys.getCpUserKeyForDingApp(suiteKey,user.getApp(), user.getClient(), user.getUserId());
+ //bean to map
+ Map map = BeanUtil.beanToMap(user, false, true);
+ redisUtils.hMSet(key, map, expire);
+ }
/**
* 获取token信息
*
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/NameUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/NameUtils.java
new file mode 100644
index 0000000000..8dec710c4a
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/NameUtils.java
@@ -0,0 +1,89 @@
+package com.epmet.commons.tools.utils;
+
+import com.epmet.commons.tools.constant.NumConstant;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @Description
+ * @Author zhaoqifeng
+ * @Date 2022/9/14 14:40
+ */
+public class NameUtils {
+ /**
+ * 复姓(两字),国内现存81个。末尾添加三字以上的部分满姓
+ */
+ private static final String[] SURNAME_NOW = {"百里", "北堂", "北野", "北宫", "辟闾", "孛尔", "淳于", "成公", "陈生", "褚师",
+ "端木", "东方", "东郭", "东野", "东门", "第五", "大狐", "段干", "段阳", "带曰", "第二", "东宫", "公孙", "公冶", "公羊",
+ "公良", "公西", "公孟", "高堂", "高阳", "公析", "公肩", "公坚", "郭公", "谷梁", "毌将", "公乘", "毌丘", "公户", "公广",
+ "公仪", "公祖", "皇甫", "黄龙", "胡母", "何阳", "夹谷", "九方", "即墨", "梁丘", "闾丘", "洛阳", "陵尹", "冷富", "龙丘",
+ "令狐", "林彭", "南宫", "南郭", "女娲", "南伯", "南容", "南门", "南野", "欧阳", "欧侯", "濮阳", "青阳", "漆雕", "亓官",
+ "渠丘", "壤驷", "上官", "少室", "少叔", "司徒", "司马", "司空", "司寇", "士孙", "申屠", "申徒", "申鲜", "申叔", "夙沙",
+ "叔先", "叔仲", "侍其", "叔孙", "澹台", "太史", "太叔", "太公", "屠岸", "唐古", "闻人", "巫马", "微生", "王孙", "无庸",
+ "夏侯", "西门", "信平", "鲜于", "轩辕", "相里", "新垣", "徐离", "羊舌", "羊角", "延陵", "於陵", "伊祁", "吾丘", "乐正",
+ "只斤", "诸葛", "颛孙", "仲孙", "仲长", "钟离", "宗政", "主父", "中叔", "左人", "左丘", "宰父", "长儿", "仉督", "单于",
+ "叱干", "叱利", "车非", "车公", "车侯", "车长", "车绵", "独孤", "大野", "独吉", "达奚", "达官", "达仲", "达品", "哥舒",
+ "哥夜", "哥翰", "哥汗", "赫连", "呼延", "贺兰", "黑齿", "斛律", "斛粟", "贺若", "贺奴", "贺远", "贺元", "夹谷", "吉胡",
+ "吉利", "吉家", "可频", "慕容", "万俟", "万红", "万中", "抹捻", "纳兰", "纳西", "纳吉", "纳罕", "纳塞", "纳博", "纳称",
+ "纳勉", "普周", "仆固", "仆散", "蒲察", "屈突", "屈卢", "钳耳", "是云", "索卢", "厍狄", "拓跋", "同蹄", "秃发", "完颜",
+ "完明", "完忠", "宇文", "尉迟", "耶律", "耶红", "也先", "耶鲜", "耶闻", "长孙", "长南", "长北", "长西", "长红", "长元",
+ "长秋", "长寸", "长李", "长云", "萨嘛喇","赫舍里","萨克达","钮祜禄","他塔喇","喜塔腊","库雅喇","瓜尔佳","舒穆禄","索绰络",
+ "叶赫那拉","依尔觉罗","额尔德特","讷殷富察","叶赫那兰","爱新觉罗","依尔根觉罗"};
+
+ /**
+ * 获取复姓,非单字姓氏。未匹配上则依旧返回单字姓氏
+ * @param name
+ * @return
+ */
+ public static String getSurNameComplex(String name){
+ for (String s : SURNAME_NOW) {
+ if (name.startsWith(s)) {
+ return name.substring(0, s.length());
+ }
+ }
+ return name.substring(0,1);
+ }
+
+ /**
+ * 获取复姓名,去除姓氏后名
+ * @param name
+ * @return
+ */
+ public static String getNameComplex(String name){
+ for (String s : SURNAME_NOW) {
+ if (name.startsWith(s)) {
+ return name.substring(s.length());
+ }
+ }
+ return name.substring(1);
+ }
+
+ /**
+ * 获取姓氏与姓名
+ * 姓名在两字时,首字为姓。
+ * 姓名大于两字时,优先匹配复姓。
+ * 姓氏未匹配且姓名多于5字时,姓与名均在姓氏中,名为空;少于5字时则采用第一个字为姓。
+ * @param name 姓名
+ * @return map类型数据,姓氏为key值“X”,名字为value值“M”
+ */
+ public static Map getSurName(String name) {
+ Map mapData = new HashMap<>(NumConstant.TWO);
+ if (name.length() > NumConstant.ZERO && name.length() <= NumConstant.TWO){
+ mapData.put("X", name.substring(NumConstant.ZERO, NumConstant.ONE));
+ mapData.put("M", name.substring(NumConstant.ONE));
+ } else if (name.length() > NumConstant.TWO) {
+ for (String s : SURNAME_NOW) {//遍历复姓数组
+ if (name.startsWith(s)) {
+ mapData.put("X", s);
+ mapData.put("M", name.substring(s.length()));
+ return mapData;
+ }
+ }
+ //姓氏没有匹配时采用第一个字为姓
+ mapData.put("X", name.substring(NumConstant.ZERO, NumConstant.ONE));
+ mapData.put("M", name.substring(NumConstant.ONE));
+ }
+ return mapData;
+ }
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YtHsResUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YtHsResUtils.java
new file mode 100644
index 0000000000..0ea496de19
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YtHsResUtils.java
@@ -0,0 +1,53 @@
+package com.epmet.commons.tools.utils;
+
+import com.alibaba.fastjson.JSON;
+import com.epmet.commons.tools.dto.result.YtHsjcResDTO;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @Description
+ * @Author yzm
+ * @Date 2022/9/26 16:56
+ */
+@Slf4j
+public class YtHsResUtils {
+ private static String URL = "http://10.2.2.60:8191/sjzt/server/hsjcxx";
+ private static final String APP_KEY_VALUE = "DR4jF5Be7sCsqDmCamq2tmYCl";
+ private static final String APP_KEY = "appkey";
+ private static final String CARD_NO = "card_no";
+ private static final String ROW_NUM = "ROWNUM";
+ private static final String PAGE_SIZE = "PAGESIZE";
+ /**
+ * desc:图片同步扫描
+ *
+ * @return
+ */
+ public static YtHsjcResDTO hsjc(String cardNo, Integer rowNum, Integer pageSize) {
+ try {
+ //String param = String.format("&card_no=%s&ROWNUM=%s&PAGESIZE=%s", cardNo, rowNum, pageSize);
+ //String apiUrl = url.concat(param);
+ Map param = new HashMap<>();
+ param.put(APP_KEY,APP_KEY_VALUE);
+ param.put(CARD_NO,cardNo);
+ param.put(ROW_NUM,rowNum);
+ param.put(PAGE_SIZE,pageSize);
+ log.info("hsjc api param:{}",param);
+ Result result = HttpClientManager.getInstance().sendGet(URL, param);
+ log.info("hsjc api result:{}",JSON.toJSONString(result));
+ if (result.success()) {
+ return JSON.parseObject(result.getData(), YtHsjcResDTO.class);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.warn(String.format("烟台核酸检测结果查询异常cardNo:%s,异常信息:%s", cardNo, e.getMessage()));
+ }
+ YtHsjcResDTO resultResult = new YtHsjcResDTO();
+ resultResult.setData(new ArrayList<>());
+ return resultResult;
+ }
+}
+
diff --git a/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java b/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java
index cf7493a300..399f574dd9 100644
--- a/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java
+++ b/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java
@@ -8,9 +8,15 @@
package com.epmet;
+import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.aspect.ServletExceptionHandler;
import com.epmet.commons.tools.config.RedissonConfig;
import com.epmet.commons.tools.config.ThreadDispatcherConfig;
+import com.epmet.commons.tools.redis.RedisKeys;
+import com.epmet.commons.tools.redis.RedisUtils;
+import com.epmet.filter.CpProperty;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@@ -18,6 +24,9 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
+import javax.annotation.PostConstruct;
+import java.util.List;
+
/**
* 网关服务
*
@@ -31,7 +40,24 @@ import org.springframework.context.annotation.FilterType;
@ComponentScan(basePackages = {"com.epmet.*"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {RedissonConfig.class, ThreadDispatcherConfig.class, ServletExceptionHandler.class}))
public class GatewayApplication {
+ @Autowired
+ private CpProperty cpProperty;
+
+ @Autowired
+ private RedisUtils redisUtils;
+
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args);
}
+
+ /**
+ * 初始化运营端校验资源列表
+ */
+// @PostConstruct
+// public void initOperExamineResources() {
+// if (!redisUtils.hasKey(RedisKeys.getOperExamineResourceUrls())) {
+// List operExamineResourceUrls = cpProperty.getOperExamineResourceUrls();
+// redisUtils.setString(RedisKeys.getOperExamineResourceUrls(), JSON.toJSONString(operExamineResourceUrls));
+// }
+// }
}
diff --git a/epmet-gateway/src/main/java/com/epmet/auth/InternalAuthProcessor.java b/epmet-gateway/src/main/java/com/epmet/auth/InternalAuthProcessor.java
index 305bf2b3a4..c857f97159 100644
--- a/epmet-gateway/src/main/java/com/epmet/auth/InternalAuthProcessor.java
+++ b/epmet-gateway/src/main/java/com/epmet/auth/InternalAuthProcessor.java
@@ -1,11 +1,22 @@
package com.epmet.auth;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.Constant;
+import com.epmet.commons.tools.constant.ServiceConstant;
+import com.epmet.commons.tools.dto.form.HasOperPermissionFormDTO;
+import com.epmet.commons.tools.dto.result.OperResouce;
import com.epmet.commons.tools.exception.EpmetErrorCode;
+import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException;
+import com.epmet.commons.tools.feign.CommonOperAccessOpenFeignClient;
+import com.epmet.commons.tools.feign.ResultDataResolver;
+import com.epmet.commons.tools.redis.RedisKeys;
+import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.security.dto.BaseTokenDto;
import com.epmet.commons.tools.utils.CpUserDetailRedis;
+import com.epmet.commons.tools.utils.Result;
import com.epmet.filter.CpProperty;
import com.epmet.jwt.JwtTokenUtils;
import io.jsonwebtoken.Claims;
@@ -15,18 +26,20 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.server.ServerWebExchange;
import java.util.Date;
+import java.util.List;
/**
* 内部认证处理器
*/
@Component
-public class InternalAuthProcessor extends AuthProcessor {
+public class InternalAuthProcessor extends AuthProcessor implements ResultDataResolver {
private Logger logger = LoggerFactory.getLogger(getClass());
@@ -41,6 +54,12 @@ public class InternalAuthProcessor extends AuthProcessor {
@Autowired
private CpProperty cpProperty;
+ @Autowired
+ private CommonOperAccessOpenFeignClient operAccessOpenFeignClient;
+
+ @Autowired
+ private RedisUtils redisUtils;
+
@Override
public ServerWebExchange auth(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest();
@@ -104,10 +123,59 @@ public class InternalAuthProcessor extends AuthProcessor {
builder.header(AppClientConstant.CUSTOMER_ID, customerId);
}
+ // 针对运营端的url拦截和校验
+ if (AppClientConstant.APP_OPER.equals(app)) {
+ HttpMethod method = request.getMethod();
+ Boolean hasAccess = checkRequestOperResource(userId, requestUri, method.toString());
+ if (!hasAccess) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "资源未授权", "资源未授权");
+ }
+ }
+
ServerHttpRequest shr = builder.build();
return exchange.mutate().request(shr).build();
}
+ /**
+ * 校验运营端用户是否有权访问该资源
+ * @param uri
+ * @param method
+ * @return
+ */
+ private Boolean checkRequestOperResource(String userId, String uri, String method) {
+ String resourceJsonString = redisUtils.getString(RedisKeys.getOperExamineResourceUrls());
+ List resources = JSON.parseObject(resourceJsonString, new TypeReference>() {});
+
+ if (resources == null) {
+ // redis中没有缓存,需要api获取
+ resources = getResultDataOrThrowsException(operAccessOpenFeignClient.getExamineResourceUrls(), ServiceConstant.OPER_ACCESS_SERVER,
+ EpmetErrorCode.SERVER_ERROR.getCode(), "调用operaccess获取要校验的资源失败", "调用operaccess获取要校验的资源失败");
+
+ // 缓存
+ redisUtils.setString(RedisKeys.getOperExamineResourceUrls(), JSON.toJSONString(resources));
+ }
+
+ for (OperResouce resource : resources) {
+ if (antPathMatcher.match(resource.getResourceUrl(), uri)
+ && resource.getResourceMethod().equals(method)) {
+
+ //需要校验权限的url
+ HasOperPermissionFormDTO form = new HasOperPermissionFormDTO();
+ form.setUri(uri);
+ form.setMethod(method);
+ form.setOperId(userId);
+ Result result = operAccessOpenFeignClient.hasOperPermission(form);
+ if (result == null || !result.success()) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ // 如果当前请求url不需要校验权限,那么返回true
+ return true;
+ }
+
/**
* 是否需要认证
* @param requestUri
diff --git a/epmet-gateway/src/main/java/com/epmet/filter/CpProperty.java b/epmet-gateway/src/main/java/com/epmet/filter/CpProperty.java
index 2ea01e1c32..71dce075fe 100644
--- a/epmet-gateway/src/main/java/com/epmet/filter/CpProperty.java
+++ b/epmet-gateway/src/main/java/com/epmet/filter/CpProperty.java
@@ -42,4 +42,15 @@ public class CpProperty {
*/
private List swaggerUrls;
+ /**
+ * 运营端,需要校验的url资源列表
+ */
+ private List operExamineResourceUrls;
+
+ @Data
+ public static class OperExamineResource {
+ private String resourceUrl;
+ private String resourceMethod;
+ }
+
}
diff --git a/epmet-gateway/src/main/java/com/epmet/filter/EpmetGatewayFilter.java b/epmet-gateway/src/main/java/com/epmet/filter/EpmetGatewayFilter.java
index 7cca3c4b36..ea02f75376 100644
--- a/epmet-gateway/src/main/java/com/epmet/filter/EpmetGatewayFilter.java
+++ b/epmet-gateway/src/main/java/com/epmet/filter/EpmetGatewayFilter.java
@@ -5,6 +5,7 @@ import com.epmet.auth.ExternalAuthProcessor;
import com.epmet.auth.InternalAuthProcessor;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
+import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.IpUtils;
@@ -64,6 +65,10 @@ public class EpmetGatewayFilter implements GatewayFilter {
}
return doFilter(exchange, chain);
+ } catch (EpmetException re) {
+ // 人为抛出,则携带错误码和错误信息响应给前端
+ log.error("EpmetGatewayFilter认证出错RenException,错误信息:{}", ExceptionUtils.getErrorStackTrace(re));
+ return response(exchange, new Result<>().error(re.getCode(), re.getMessage()));
} catch (RenException re) {
// 人为抛出,则携带错误码和错误信息响应给前端
log.error("EpmetGatewayFilter认证出错RenException,错误信息:{}", ExceptionUtils.getErrorStackTrace(re));
diff --git a/epmet-gateway/src/main/resources/bootstrap-urls.yml b/epmet-gateway/src/main/resources/bootstrap-urls.yml
new file mode 100644
index 0000000000..dded0b1b86
--- /dev/null
+++ b/epmet-gateway/src/main/resources/bootstrap-urls.yml
@@ -0,0 +1,5 @@
+epmet:
+ oper-examine-resource-urls:
+ # 角色编辑
+ - resourceUrl: /oper/access/operrole
+ resourceMethod: PUT
\ No newline at end of file
diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml
index b0b2492d33..483f545f43 100644
--- a/epmet-gateway/src/main/resources/bootstrap.yml
+++ b/epmet-gateway/src/main/resources/bootstrap.yml
@@ -12,6 +12,7 @@ spring:
name: epmet-gateway-server
#环境 dev|test|prod
profiles:
+ include: urls
active: @spring.profiles.active@
messages:
encoding: UTF-8
@@ -498,6 +499,7 @@ epmet:
- /resi/voice/**
- /point/**
- /heart/**
+ - /oss/**
# 内部认证url白名单(在白名单中的,就不会再校验登录了)
internalAuthUrlsWhiteList:
diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java
index 58109b1b89..a8621ce09d 100644
--- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java
+++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java
@@ -73,4 +73,9 @@ public interface ImportTaskConstants {
* 社会组织
*/
String IC_SOCIETY_ORG="ic_society_org";
+
+ /**
+ * 未做核酸比对
+ */
+ String IC_NAT_COMPARE_RECORD="ic_nat_compare_record";
}
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java
index b0f519a3ac..418b3dc251 100644
--- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java
@@ -833,7 +833,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl uploadResiEventFile(@RequestPart(value = "file") MultipartFile file, @RequestParam("customerId") String customerId) {
-
+ public Result uploadResiEventFile(@LoginUser TokenDto tokenDto, @RequestPart(value = "file") MultipartFile file, @RequestParam(value = "customerId",required = false) String customerId) {
+ if (StringUtils.isBlank(customerId)){
+ customerId = tokenDto.getCustomerId();
+ }
// 体积限制
int sizeMb = 10;
int sizeThreshold = sizeMb * 1024 * 1024; // 大小限制10m
diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/impl/OssServiceImpl.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/impl/OssServiceImpl.java
index d55751762c..140d57ead6 100644
--- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/impl/OssServiceImpl.java
+++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/service/impl/OssServiceImpl.java
@@ -279,6 +279,7 @@ public class OssServiceImpl extends BaseServiceImpl implement
UploadImgResultDTO dto = new UploadImgResultDTO();
dto.setUrl(url);
dto.setDomain(ossDomain);
+ dto.setFileName(file.getOriginalFilename());
return new Result().ok(dto);
}
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/DingMiniInfoDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/DingMiniInfoDTO.java
new file mode 100644
index 0000000000..19ebfacdd9
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/DingMiniInfoDTO.java
@@ -0,0 +1,89 @@
+package com.epmet.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * 钉钉小程序信息
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2022-09-14
+ */
+@Data
+public class DingMiniInfoDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * ID
+ */
+ private String id;
+
+ /**
+ *
+ */
+ private String suiteId;
+
+ /**
+ *
+ */
+ private String appId;
+
+ /**
+ *
+ */
+ private String miniAppId;
+
+ /**
+ *
+ */
+ private String suiteName;
+
+ /**
+ *
+ */
+ private String suiteKey;
+
+ /**
+ *
+ */
+ private String suiteSecret;
+
+ private String token;
+
+ private String aesKey;
+
+ /**
+ *
+ */
+ private Integer delFlag;
+
+ /**
+ * 乐观锁
+ */
+ private Integer revision;
+
+ /**
+ * 创建人
+ */
+ private String createdBy;
+
+ /**
+ * 创建时间
+ */
+ private Date createdTime;
+
+ /**
+ * 更新人
+ */
+ private String updatedBy;
+
+ /**
+ * 更新时间
+ */
+ private Date updatedTime;
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/OpenSyncBizDataDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/OpenSyncBizDataDTO.java
new file mode 100644
index 0000000000..12dac445f0
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/OpenSyncBizDataDTO.java
@@ -0,0 +1,99 @@
+package com.epmet.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ *
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2022-09-14
+ */
+@Data
+public class OpenSyncBizDataDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ *
+ */
+ private String id;
+
+ /**
+ * 第三方企业应用的suiteid加下划线0
+ */
+ private String subscribeId;
+
+ private String suiteKey;
+
+ /**
+ * 第三方企业应用的corpid
+ */
+ private String corpId;
+
+ /**
+ * 第三方企业应用的suiteid
+ */
+ private String bizId;
+
+ /**
+ * 数据为Json格式
+ */
+ private String bizData;
+
+ /**
+ * 2:第三方企业应用票据;
+4:企业授权变更,包含授权、解除授权、授权变更;
+7:第三方企业应用变更,包含停用、启用、删除(删除保留授权);
+13:企业用户变更,包含用户添加、修改、删除;
+14:企业部门变更,包含部门添加、修改、删除;
+15:企业角色变更,包含角色添加、修改、删除;
+16:企业变更,包含企业修改、删除;
+17:市场订单;
+20:企业外部联系人变更,包含添加、修改、删除;
+22:ISV自定义审批;
+25:家校通讯录1.0(Deprecated)信息变更。家校通讯录升级,请查看家校通讯录2.0数据推送;
+32:智能硬件绑定类型;
+37:因订单到期或者用户退款等导致的服务关闭,目前仅推送因退款等导致的服务关闭;
+50:家校通讯录2.0,部门信息变更;
+51:家校通讯录2.0,人员信息变更;
+63:应用试用记录回调信息;
+66:工作台组件变更回调事件;
+67:钉钉假期相关回调事件;
+133:CRM客户动态相关数据回调事件;
+137:人事平台员工异动V2相关数据回调事件;
+139:异步转译通讯录id任务完成通知;
+165:人事平台员工档案变动事件相关数据的回调事件;
+175:人事解决方案变更事件;
+ */
+ private String bizType;
+
+ /**
+ *
+ */
+ private Integer delFlag;
+
+ /**
+ *
+ */
+ private Date createdTime;
+
+ /**
+ *
+ */
+ private String createdBy;
+
+ /**
+ *
+ */
+ private Date updatedTime;
+
+ /**
+ *
+ */
+ private String updatedBy;
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ExemptLoginUserDetailFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ExemptLoginUserDetailFormDTO.java
new file mode 100644
index 0000000000..7e84993d2f
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ExemptLoginUserDetailFormDTO.java
@@ -0,0 +1,28 @@
+package com.epmet.dto.form;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+
+/**
+ * @Author zxc
+ * @DateTime 2022/9/14 14:52
+ * @DESC
+ */
+@Data
+public class ExemptLoginUserDetailFormDTO implements Serializable {
+
+ private static final long serialVersionUID = -4333806195203619201L;
+
+ public interface ExemptLoginUserDetailForm{}
+
+ @NotBlank(message = "code不能为空",groups = ExemptLoginUserDetailForm.class)
+ private String code;
+
+ @NotBlank(message = "corpId不能为空",groups = ExemptLoginUserDetailForm.class)
+ private String corpId;
+
+ @NotBlank(message = "miniAppId不能为空",groups = ExemptLoginUserDetailForm.class)
+ private String miniAppId;
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/pom.xml b/epmet-module/epmet-third/epmet-third-server/pom.xml
index e991b981f3..a70d2ac789 100644
--- a/epmet-module/epmet-third/epmet-third-server/pom.xml
+++ b/epmet-module/epmet-third/epmet-third-server/pom.xml
@@ -157,7 +157,16 @@
rocketmq-acl
4.9.2
-
+
+ dingtalk-spring-boot-starter
+ com.taobao
+ 1.0.0
+
+
+ commons-codec
+ commons-codec
+ 1.15
+
@@ -229,7 +238,7 @@
SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd
-
+
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java
index 3efd642c87..21c518e033 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java
@@ -1,6 +1,7 @@
package com.epmet;
import com.epmet.mq.properties.RocketMQProperties;
+import com.taobao.dingtalk.spring.annotations.EnableDingTalk;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -8,6 +9,7 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
+@EnableDingTalk
@EnableConfigurationProperties(RocketMQProperties.class)
@SpringBootApplication
@EnableDiscoveryClient
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/DingMiniInfoController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/DingMiniInfoController.java
new file mode 100644
index 0000000000..ada1f1d0ff
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/DingMiniInfoController.java
@@ -0,0 +1,71 @@
+package com.epmet.controller;
+
+import com.epmet.commons.tools.aop.NoRepeatSubmit;
+import com.epmet.commons.tools.page.PageData;
+import com.epmet.commons.tools.utils.Result;
+import com.epmet.commons.tools.validator.AssertUtils;
+import com.epmet.commons.tools.validator.ValidatorUtils;
+import com.epmet.commons.tools.validator.group.AddGroup;
+import com.epmet.commons.tools.validator.group.DefaultGroup;
+import com.epmet.commons.tools.validator.group.UpdateGroup;
+import com.epmet.dto.DingMiniInfoDTO;
+import com.epmet.service.DingMiniInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+
+/**
+ * 钉钉小程序信息
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2022-09-14
+ */
+@RestController
+@RequestMapping("dingMiniInfo")
+public class DingMiniInfoController {
+
+ @Autowired
+ private DingMiniInfoService dingMiniInfoService;
+
+ @RequestMapping("page")
+ public Result> page(@RequestParam Map params){
+ PageData page = dingMiniInfoService.page(params);
+ return new Result>().ok(page);
+ }
+
+ @RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET})
+ public Result get(@PathVariable("id") String id){
+ DingMiniInfoDTO data = dingMiniInfoService.get(id);
+ return new Result().ok(data);
+ }
+
+ @NoRepeatSubmit
+ @PostMapping("save")
+ public Result save(@RequestBody DingMiniInfoDTO dto){
+ //效验数据
+ ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
+ dingMiniInfoService.save(dto);
+ return new Result();
+ }
+
+ @NoRepeatSubmit
+ @PostMapping("update")
+ public Result update(@RequestBody DingMiniInfoDTO dto){
+ //效验数据
+ ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
+ dingMiniInfoService.update(dto);
+ return new Result();
+ }
+
+ @PostMapping("delete")
+ public Result delete(@RequestBody String[] ids){
+ //效验数据
+ AssertUtils.isArrayEmpty(ids, "id");
+ dingMiniInfoService.delete(ids);
+ return new Result();
+ }
+
+
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/dingtalk/CallbackController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/dingtalk/CallbackController.java
new file mode 100644
index 0000000000..8164c4cdbe
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/dingtalk/CallbackController.java
@@ -0,0 +1,155 @@
+package com.epmet.controller.dingtalk;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.aliyun.dingtalk.util.DingCallbackCrypto;
+import com.epmet.commons.tools.constant.NumConstant;
+import com.epmet.commons.tools.dto.form.DingMiniInfoFormDTO;
+import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache;
+import com.epmet.commons.tools.utils.Result;
+import com.epmet.commons.tools.validator.ValidatorUtils;
+import com.epmet.dao.OpenSyncBizDataDao;
+import com.epmet.dto.DingMiniInfoDTO;
+import com.epmet.dto.form.ExemptLoginUserDetailFormDTO;
+import com.epmet.entity.OpenSyncBizDataEntity;
+import com.epmet.redis.DingDingCallbackRedis;
+import com.epmet.service.DingTalkService;
+import com.epmet.service.OpenSyncBizDataService;
+import org.apache.commons.collections4.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * ISV 小程序回调信息处理
+ */
+@RestController
+@RequestMapping("/dingTalk")
+public class CallbackController {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ /**
+ * 创建应用,验证回调URL创建有效事件(第一次保存回调URL之前)
+ */
+ private static final String EVENT_CHECK_CREATE_SUITE_URL = "check_create_suite_url";
+
+ /**
+ * 创建应用,验证回调URL变更有效事件(第一次保存回调URL之后)
+ */
+ private static final String EVENT_CHECK_UPADTE_SUITE_URL = "check_update_suite_url";
+
+ /**
+ * suite_ticket推送事件
+ */
+ private static final String EVENT_SUITE_TICKET = "suite_ticket";
+
+ /**
+ * 企业授权开通应用事件
+ */
+ private static final String EVENT_TMP_AUTH_CODE = "tmp_auth_code";
+
+ private static final String EVENT_SYNC_HTTP_PUSH_HIGH = "SYNC_HTTP_PUSH_HIGH";
+
+ @Autowired
+ private OpenSyncBizDataService openSyncBizDataService;
+ @Autowired
+ private OpenSyncBizDataDao openSyncBizDataDao;
+ @Autowired
+ private DingDingCallbackRedis dingCallbackRedis;
+ @Autowired
+ private DingTalkService dingTalkService;
+
+ @PostMapping(value = "dingCallback")
+ public Object dingCallback(
+ @RequestParam(value = "signature") String signature,
+ @RequestParam(value = "timestamp") Long timestamp,
+ @RequestParam(value = "nonce") String nonce,
+ @RequestParam(value = "suiteKey") String suiteKey,
+ @RequestBody(required = false) JSONObject body
+ ) {
+ String params = "signature:" + signature + " timestamp:" + timestamp + " nonce:" + nonce + " body:" + body + "suiteKey::"+suiteKey;
+ try {
+ log.info("begin callback:" + params);
+ DingMiniInfoDTO dingMiniInfo = openSyncBizDataDao.getDingMiniInfo(suiteKey);
+ DingCallbackCrypto dingTalkEncryptor = new DingCallbackCrypto(dingMiniInfo.getToken(), dingMiniInfo.getAesKey(), suiteKey);
+
+ // 从post请求的body中获取回调信息的加密数据进行解密处理
+ String encrypt = body.getString("encrypt");
+ String plainText = dingTalkEncryptor.getDecryptMsg(signature, timestamp.toString(), nonce, encrypt);
+ JSONObject callBackContent = JSON.parseObject(plainText);
+
+ log.info("推来的消息体:"+plainText);
+
+ // 根据回调事件类型做不同的业务处理
+ String eventType = callBackContent.getString("EventType");
+ if (EVENT_CHECK_CREATE_SUITE_URL.equals(eventType)) {
+ log.info("验证新创建的回调URL有效性: " + plainText);
+ } else if (EVENT_CHECK_UPADTE_SUITE_URL.equals(eventType)) {
+ log.info("验证更新回调URL有效性: " + plainText);
+ } else if (EVENT_SUITE_TICKET.equals(eventType)) {
+ // suite_ticket用于用签名形式生成accessToken(访问钉钉服务端的凭证),需要保存到应用的db。
+ // 钉钉会定期向本callback url推送suite_ticket新值用以提升安全性。
+ // 应用在获取到新的时值时,保存db成功后,返回给钉钉success加密串(如本demo的return)
+ log.info("应用suite_ticket数据推送: " + plainText);
+ } else if (EVENT_TMP_AUTH_CODE.equals(eventType)) {
+ // 本事件应用应该异步进行授权开通企业的初始化,目的是尽最大努力快速返回给钉钉服务端。用以提升企业管理员开通应用体验
+ // 即使本接口没有收到数据或者收到事件后处理初始化失败都可以后续再用户试用应用时从前端获取到corpId并拉取授权企业信息,进而初始化开通及企业。
+ log.info("企业授权开通应用事件: " + plainText);
+ } else if (EVENT_SYNC_HTTP_PUSH_HIGH.equals(eventType)){
+ List