diff --git a/pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports b/pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports
new file mode 100644
index 00000000..2fb4a434
--- /dev/null
+++ b/pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports
@@ -0,0 +1 @@
+com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdPartyAuthService
diff --git a/pjcloud-thirdparty/pjcloud-thirdparty-biz/pom.xml b/pjcloud-thirdparty/pjcloud-thirdparty-biz/pom.xml
index ddcd9854..6ae45b44 100644
--- a/pjcloud-thirdparty/pjcloud-thirdparty-biz/pom.xml
+++ b/pjcloud-thirdparty/pjcloud-thirdparty-biz/pom.xml
@@ -13,6 +13,10 @@
pjcloud-thirdparty-biz
+
+ com.bsd
+ pjcloud-upms-api
+
org.springframework.boot
diff --git a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/controller/ThirdPartyOAth2Cotroller.java b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/controller/ThirdPartyOAth2Cotroller.java
index 62501b32..c8d23cb2 100644
--- a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/controller/ThirdPartyOAth2Cotroller.java
+++ b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/java/com/bsd/pjcloud/thirdparty/controller/ThirdPartyOAth2Cotroller.java
@@ -1,17 +1,34 @@
package com.bsd.pjcloud.thirdparty.controller;
+import com.bsd.pjcloud.admin.api.dto.UserDTO;
+import com.bsd.pjcloud.admin.api.dto.UserTokenDTO;
+import com.bsd.pjcloud.admin.api.entity.SysUser;
+import com.bsd.pjcloud.admin.api.feign.RemoteTokenService;
+import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.common.core.util.R;
+import com.bsd.pjcloud.common.security.annotation.Inner;
+import com.bsd.pjcloud.thirdparty.dto.SHJNSSODTO;
+import com.bsd.pjcloud.thirdparty.dto.ZZDUserDTO;
+import com.bsd.pjcloud.thirdparty.entity.ThirdPartyUserEntity;
import com.bsd.pjcloud.thirdparty.service.ThirdPartyOAuth2Service;
+import com.bsd.pjcloud.thirdparty.service.ThirdPartyUserService;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
+import org.apache.seata.spring.annotation.GlobalTransactional;
import org.springframework.http.HttpHeaders;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
@RestController
@RequiredArgsConstructor
@@ -22,6 +39,11 @@ public class ThirdPartyOAth2Cotroller {
private final ThirdPartyOAuth2Service thirdPartyOAuth2Service;
+ private final RemoteUserService remoteUserService;
+
+ private final RemoteTokenService remoteTokenService;
+
+ private final ThirdPartyUserService thirdPartyUserService;
@Operation(summary = "浙政钉token" )
@@ -37,4 +59,171 @@ public class ThirdPartyOAth2Cotroller {
return R.ok(thirdPartyOAuth2Service.shjnsso(accountId,sessionId));
}
+
+ /*
+ *
+ * @param token 浙政钉前端获取的token
+ * @return
+ */
+ @GetMapping("/zzdsso/{token}")
+ @Operation(summary = "浙政钉单点登录")
+ @Inner(value = false)
+ @GlobalTransactional
+ @Transactional(rollbackFor = Exception.class)
+ //todo 引入seata分布式事务
+ public R zzdsso(@PathVariable(name = "token") String token) {
+
+ //获取数字政务token通过浙政钉前端获取的token,调试阶段先写死
+ String json = "{" +
+ "\"username\": \"李宗相\"," +
+ "\"organizationId\": 2," +
+ "\"userId\": 1340," +
+ "\"nickName\": \"李宗相\"," +
+ "\"mobile\": \"18576496089\"," +
+ "\"regionCode\": null," +
+ "\"ext\": {" +
+ "\"employeeCode\": \"GE_ae12bdf21598498eb48bf2cf2c45a3e1\"," +
+ "\"organizationCode\": \"GO_63e77077d5e041789bbbe1d0d20bcf41\"," +
+ "\"nickNameCn\": \"李宗相\"," +
+ "\"openid\": \"1b51f0e11fc73b8adddcbaf7982daab6\"," +
+ "\"realmId\": \"196729\"," +
+ "\"mobile\": null" +
+ "}" +
+ "}";
+
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ ZZDUserDTO zzdUserDTO;
+ try {
+ zzdUserDTO = objectMapper.readValue(json, ZZDUserDTO.class);
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ //暂时先注释,模拟一下就行
+// R zzdsso = remoterThirdPartyAuthService.zzdsso(token);
+// ZZDUserDTO zzdUserDTO = (ZZDUserDTO) zzdsso.getData();
+ ZZDUserDTO.Ext ext = zzdUserDTO.getExt();
+ String employeeCode = ext.getEmployeeCode();
+ String mobile = zzdUserDTO.getMobile();
+
+ //两种方式,手机号+员工钉钉号,查到相同就视为同一个人,然后登录
+ //先系统表里面查看是否有,在第三方数据库表里面看下是否有
+
+ //1.根据手机号或者钉钉号先查询是否有这个人
+ R> userByMobileOrEmployeeCode = remoteUserService.getUserByMobileOrEmployeeCode(employeeCode, mobile);
+ List sysUserList = userByMobileOrEmployeeCode.getData();
+
+ if(!CollectionUtils.isEmpty(sysUserList)){
+ //登录成功生成token
+ UserTokenDTO userTokenDTO = new UserTokenDTO();
+ userTokenDTO.setSysUser(sysUserList.get(0));
+ remoteTokenService.generateToken(userTokenDTO);
+ }
+ //2.根据浙政钉的员工钉钉号查询是否有这个人
+ List thirdPartyUserEntityList = thirdPartyUserService.getUserByEmployeeCode(employeeCode);
+ UserDTO userDTO = new UserDTO();
+ //写死,新加入到部门表的全部归类到其他部门里面,不按照浙政钉的部门
+ userDTO.setDeptId(1865990541445263361L);
+ userDTO.setUsername(zzdUserDTO.getUsername());
+ userDTO.setName(zzdUserDTO.getUsername());
+ userDTO.setNickname(zzdUserDTO.getUsername());
+ //浙里办用户
+ userDTO.setSystemType("1");
+ //取上面的手机号
+ userDTO.setPhone(mobile);
+ userDTO.setDingtalkEmployeeCode(employeeCode);
+ //随便写死给个密码
+ userDTO.setPassword("pj"+mobile);
+ if(!CollectionUtils.isEmpty(thirdPartyUserEntityList)){
+ //todo 这一步现在是没用的,这个最终要考虑是否通过浙政钉里面的人员来限制移动端的使用用户来决定
+ //第三方数据库里面有
+ //这里只在第三方库里查到,所以要对系统用户表进行新增当前用户,插入一条信息进去
+ R booleanR = remoteUserService.registerUser(userDTO);
+ //通过唯一手机号查询到刚注册的用户信息,生成token
+ R> userByMobile=remoteUserService.getUserByMobile(mobile);
+ SysUser sysUser = userByMobile.getData().get(0);
+ UserTokenDTO userTokenDTO = new UserTokenDTO();
+ userTokenDTO.setSysUser(sysUser);
+ //登录成功,根据新注册的用户信息返回token
+ remoteTokenService.generateToken(userTokenDTO);
+ }
+
+ //两个表都没查到人员不能够使用移动端的系统
+
+// log.info("用户不存在,尝试创建用户");
+
+ R booleanR = remoteUserService.registerUser(userDTO);
+ //通过唯一手机号查询到刚注册的用户信息,生成token
+
+ R> userByMobile=remoteUserService.getUserByMobile(mobile);
+ SysUser sysUser = userByMobile.getData().get(0);
+// int i=8/0;
+ UserTokenDTO userTokenDTO = new UserTokenDTO();
+ userTokenDTO.setSysUser(sysUser);
+ //登录成功,根据新注册的用户信息返回token
+ return remoteTokenService.generateToken(userTokenDTO);
+ }
+
+
+
+ /**
+ * 诗画sdk获取参数
+ *
+ * @param
+ * @return
+ */
+ @PostMapping("/shjnsso")
+ @Inner(value = false)
+ @Operation(summary = "诗画江南单点登录")
+ public R shjnsso(@RequestBody @Valid SHJNSSODTO shjnsso) {
+ ZZDUserDTO zzdUserDTO = thirdPartyOAuth2Service.shjnsso(shjnsso.getAccountId(), shjnsso.getSessionId());
+ ZZDUserDTO.Ext ext = zzdUserDTO.getExt();
+ String mobile = zzdUserDTO.getMobile();
+ R> rListSysUser = remoteUserService.getUserByMobileOrEmployeeCode(null, mobile);
+ List sysUsers = rListSysUser.getData();
+ if(!CollectionUtils.isEmpty(sysUsers)){
+ //登录成功生成token
+ UserTokenDTO userTokenDTO = new UserTokenDTO();
+ userTokenDTO.setSysUser(sysUsers.get(0));
+ remoteTokenService.generateToken(userTokenDTO);
+ }
+// log.info("用户不存在,尝试创建用户");
+// CreateUserDto createUserDto = new CreateUserDto();
+// createUserDto.setUsername(zzdUserDTO.getUsername());
+// createUserDto.setMobile(mobile);
+// createUserDto.setNickname(zzdUserDTO.getNickName());
+// createUserDto.setAvatar(ext.getHeadImgUrl());
+// //todo 换成枚举
+// //诗画用户
+// createUserDto.setUserType("2");
+// AdminUserRespDTO adminUserRespDTONew=adminUserApi.createSysUser(createUserDto);
+// log.info("创建用户成功,用户id为:{}",adminUserRespDTONew.getId());
+// return createTokenAfterLoginSuccess(adminUserRespDTONew.getId(), mobile, LoginLogTypeEnum.LOGIN_SSO);
+ return R.failed("不存在用户");
+ }
+
+
+ @Inner(value = false)
+ @GetMapping("/getAuthToken/{token}")
+ public R info(@PathVariable(name = "token") String token) {
+
+ //调用第三方获取基础信息与数据库进行匹配
+// 拼接请求参数
+ UserTokenDTO userTokenDTO = new UserTokenDTO();
+ userTokenDTO.setUsername("admin"); // 只需要用户名,就可以生成 token
+ userTokenDTO.setAuthorities(List.of("sys_user_add")); // 权限列表的字符串,能调用的接口范围
+
+ // feign 调用 auth 模块生成 token
+ R