lishuangjiang@potevio.com il y a 1 an
Parent
commit
deedbf33b3

+ 0 - 4
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/dept/vo/dept/DeptRespVO.java

@@ -1,7 +1,6 @@
 package com.poteviohealth.cgp.sso.module.system.controller.admin.dept.vo.dept;
 
 import com.baomidou.mybatisplus.annotation.TableField;
-import com.poteviohealth.cgp.sso.framework.mybatis.core.type.JsonLongSetTypeHandler;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -69,15 +68,12 @@ public class DeptRespVO {
     private String aliasNameOther;
 
     @Schema(description = "已上系统", example = "[机构系统,旅居系统]")
-    @TableField(typeHandler = JsonLongSetTypeHandler.class)
     private Set<Long> applySystems;
 
     @Schema(description = "品牌", example = "[南山有约,萱悦庭]")
-    @TableField(typeHandler = JsonLongSetTypeHandler.class)
     private Set<Long> brand;
 
     @Schema(description = "机构性质", example = "[机构,旅居]")
-    @TableField(typeHandler = JsonLongSetTypeHandler.class)
     private Set<Long> propertypes;
 
     @Schema(description = "经营方式", example = " 0")

+ 0 - 4
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/dept/vo/dept/DeptSaveReqVO.java

@@ -3,7 +3,6 @@ package com.poteviohealth.cgp.sso.module.system.controller.admin.dept.vo.dept;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.poteviohealth.cgp.sso.framework.common.enums.CommonStatusEnum;
 import com.poteviohealth.cgp.sso.framework.common.validation.InEnum;
-import com.poteviohealth.cgp.sso.framework.mybatis.core.type.JsonLongSetTypeHandler;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -85,15 +84,12 @@ public class DeptSaveReqVO {
     private String aliasNameOther;
 
     @Schema(description = "已上系统", example = "[机构系统,旅居系统]")
-    @TableField(typeHandler = JsonLongSetTypeHandler.class)
     private Set<Long> applySystems;
 
     @Schema(description = "品牌", example = "[南山有约,萱悦庭]")
-    @TableField(typeHandler = JsonLongSetTypeHandler.class)
     private Set<Long> brand;
 
     @Schema(description = "机构性质", example = "[机构,旅居]")
-    @TableField(typeHandler = JsonLongSetTypeHandler.class)
     private Set<Long> propertypes;
 
     @Schema(description = "经营方式", example = " 0")

+ 0 - 4
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/dept/vo/dept/DeptSimpleRespVO.java

@@ -1,7 +1,6 @@
 package com.poteviohealth.cgp.sso.module.system.controller.admin.dept.vo.dept;
 
 import com.baomidou.mybatisplus.annotation.TableField;
-import com.poteviohealth.cgp.sso.framework.mybatis.core.type.JsonLongSetTypeHandler;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -60,15 +59,12 @@ public class DeptSimpleRespVO {
     private String aliasNameOther;
 
     @Schema(description = "已上系统", example = "[机构系统,旅居系统]")
-    @TableField(typeHandler = JsonLongSetTypeHandler.class)
     private Set<Long> applySystems;
 
     @Schema(description = "品牌", example = "[南山有约,萱悦庭]")
-    @TableField(typeHandler = JsonLongSetTypeHandler.class)
     private Set<Long> brand;
 
     @Schema(description = "机构性质", example = "[机构,旅居]")
-    @TableField(typeHandler = JsonLongSetTypeHandler.class)
     private Set<Long> propertypes;
 
     @Schema(description = "经营方式", example = " 0")

+ 44 - 17
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/oauth2/OAuth2OpenController.java

@@ -35,6 +35,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 import static com.poteviohealth.cgp.sso.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST;
 import static com.poteviohealth.cgp.sso.framework.common.exception.util.ServiceExceptionUtil.exception0;
@@ -44,11 +45,11 @@ import static com.poteviohealth.cgp.sso.framework.security.core.util.SecurityFra
 
 /**
  * 提供给外部应用调用为主
- *
+ * <p>
  * 一般来说,管理后台的 /system-api/* 是不直接提供给外部应用使用,主要是外部应用能够访问的数据与接口是有限的,而管理后台的 RBAC 无法很好的控制。
  * 参考大量的开放平台,都是独立的一套 OpenAPI,对应到【本系统】就是在 Controller 下新建 open 包,实现 /open-api/* 接口,然后通过 scope 进行控制。
  * 另外,一个公司如果有多个管理后台,它们 client_id 产生的 access token 相互之间是无法互通的,即无法访问它们系统的 API 接口,直到两个 client_id 产生信任授权。
- *
+ * <p>
  * 考虑到【本系统】暂时不想做的过于复杂,默认只有获取到 access token 之后,可以访问【本系统】管理后台的 /system-api/* 所有接口,除非手动添加 scope 控制。
  * scope 的使用示例,可见 {@link OAuth2UserController} 类
  *
@@ -72,13 +73,13 @@ public class OAuth2OpenController {
 
     /**
      * 对应 Spring Security OAuth 的 TokenEndpoint 类的 postAccessToken 方法
-     *
+     * <p>
      * 授权码 authorization_code 模式时:code + redirectUri + state 参数
      * 密码 password 模式时:username + password + scope 参数
      * 刷新 refresh_token 模式时:refreshToken 参数
      * 客户端 client_credentials 模式:scope 参数
      * 简化 implicit 模式时:不支持
-     *
+     * <p>
      * 注意,默认需要传递 client_id + client_secret 参数
      */
     @PostMapping("/token")
@@ -102,7 +103,8 @@ public class OAuth2OpenController {
                                                                      @RequestParam(value = "username", required = false) String username, // 密码模式
                                                                      @RequestParam(value = "password", required = false) String password, // 密码模式
                                                                      @RequestParam(value = "scope", required = false) String scope, // 密码模式
-                                                                     @RequestParam(value = "refresh_token", required = false) String refreshToken) { // 刷新模式
+                                                                     @RequestParam(value = "refresh_token", required = false) String refreshToken,
+                                                                     @RequestBody Map<String, Object> bodyData) { // 刷新模式
         List<String> scopes = OAuth2Utils.buildScopes(scope);
         // 1.1 校验授权类型
         OAuth2GrantTypeEnum grantTypeEnum = OAuth2GrantTypeEnum.getByGranType(grantType);
@@ -117,6 +119,31 @@ public class OAuth2OpenController {
         String[] clientIdAndSecret = obtainBasicAuthorization(request);
         OAuth2ClientDO client = oauth2ClientService.validOAuthClientFromCache(clientIdAndSecret[0], clientIdAndSecret[1],
                 grantType, scopes, redirectUri);
+        //消息体解析
+        if (Objects.nonNull(bodyData) && !bodyData.isEmpty()) {
+            if (bodyData.containsKey("code")) {
+                code =(String) bodyData.get("code");
+            }
+            if (bodyData.containsKey("redirect_uri")) {
+                redirectUri =(String) bodyData.get("redirect_uri");
+            }
+            if (bodyData.containsKey("state")) {
+                state =(String) bodyData.get("state");
+            }
+            if (bodyData.containsKey("username")) {
+                username =(String) bodyData.get("username");
+            }
+            if (bodyData.containsKey("password")) {
+                password =(String) bodyData.get("password");
+            }
+            if (bodyData.containsKey("scope")) {
+                scope =(String) bodyData.get("scope");
+            }
+            if (bodyData.containsKey("refresh_token")) {
+                refreshToken =(String) bodyData.get("refresh_token");
+            }
+        }
+
 
         // 2. 根据授权模式,获取访问令牌
         OAuth2AccessTokenDO accessTokenDO;
@@ -154,14 +181,14 @@ public class OAuth2OpenController {
             @Parameter(name = "refresh_token", example = "123424233"),
     })
     public OAuth2OpenAccessTokenRespVO postStandardAccessToken(HttpServletRequest request,
-                                                                     @RequestParam("grant_type") String grantType,
-                                                                     @RequestParam(value = "code", required = false) String code, // 授权码模式
-                                                                     @RequestParam(value = "redirect_uri", required = false) String redirectUri, // 授权码模式
-                                                                     @RequestParam(value = "state", required = false) String state, // 授权码模式
-                                                                     @RequestParam(value = "username", required = false) String username, // 密码模式
-                                                                     @RequestParam(value = "password", required = false) String password, // 密码模式
-                                                                     @RequestParam(value = "scope", required = false) String scope, // 密码模式
-                                                                     @RequestParam(value = "refresh_token", required = false) String refreshToken) { // 刷新模式
+                                                               @RequestParam("grant_type") String grantType,
+                                                               @RequestParam(value = "code", required = false) String code, // 授权码模式
+                                                               @RequestParam(value = "redirect_uri", required = false) String redirectUri, // 授权码模式
+                                                               @RequestParam(value = "state", required = false) String state, // 授权码模式
+                                                               @RequestParam(value = "username", required = false) String username, // 密码模式
+                                                               @RequestParam(value = "password", required = false) String password, // 密码模式
+                                                               @RequestParam(value = "scope", required = false) String scope, // 密码模式
+                                                               @RequestParam(value = "refresh_token", required = false) String refreshToken) { // 刷新模式
         List<String> scopes = OAuth2Utils.buildScopes(scope);
         // 1.1 校验授权类型
         OAuth2GrantTypeEnum grantTypeEnum = OAuth2GrantTypeEnum.getByGranType(grantType);
@@ -253,12 +280,12 @@ public class OAuth2OpenController {
 
     /**
      * 对应 Spring Security OAuth 的 AuthorizationEndpoint 类的 approveOrDeny 方法
-     *
+     * <p>
      * 场景一:【自动授权 autoApprove = true】
-     *      刚进入 sso.vue 界面,调用该接口,用户历史已经给该应用做过对应的授权,或者 OAuth2Client 支持该 scope 的自动授权
+     * 刚进入 sso.vue 界面,调用该接口,用户历史已经给该应用做过对应的授权,或者 OAuth2Client 支持该 scope 的自动授权
      * 场景二:【手动授权 autoApprove = false】
-     *      在 sso.vue 界面,用户选择好 scope 授权范围,调用该接口,进行授权。此时,approved 为 true 或者 false
-     *
+     * 在 sso.vue 界面,用户选择好 scope 授权范围,调用该接口,进行授权。此时,approved 为 true 或者 false
+     * <p>
      * 因为前后端分离,Axios 无法很好的处理 302 重定向,所以和 Spring Security OAuth 略有不同,返回结果是重定向的 URL,剩余交给前端处理
      */
     @PostMapping("/authorize")

+ 16 - 4
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/userclient/UserClientController.java

@@ -220,6 +220,7 @@ public class UserClientController {
         String url = constructUrl(syncUserInfoUrl, nonce, signature, timestamp, oAuth2Client.getClientId());
         //获取机构信息
         String companyName = null;
+        String companyCode = null;
         String deptName = null;
         String deptCode = null;
         if(Objects.nonNull(user.getDeptId())){
@@ -236,6 +237,7 @@ public class UserClientController {
                     DeptDO company = deptMap.get(rootDept.getId());
                     if (Objects.nonNull(company)){
                         companyName = company.getName();
+                        companyCode = company.getCode();
                         DeptDO deptOrg = deptMap.get(company.getId());
                         if(Objects.nonNull(deptOrg)){
                             deptName = deptOrg.getName();
@@ -253,7 +255,7 @@ public class UserClientController {
         headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
         headers.set(HEADER, Objects.nonNull(oAuth2Client.getAppId())? oAuth2Client.getAppId(): oAuth2Client.getClientId());
         HttpEntity<UserSsoVo> httpEntity = new HttpEntity<>(new UserSsoVo(user.getUsername()
-                , user.getNickname(), user.getIdNumber(), user.getMobile(), null, companyName, deptName,deptName,deptCode),
+                , user.getNickname(), user.getIdNumber(), user.getMobile(), null, companyName,companyCode, deptName,deptName,deptCode),
                 headers);
         ResponseEntity exchange;
         try{
@@ -261,12 +263,22 @@ public class UserClientController {
         }catch (Exception e){
             throw exception(USER_SYNC_ERROR,e.getMessage());
         }
-        System.out.println(exchange);
+        System.out.println("defaultSyncUserInfo###################result:"+exchange.toString());
         if(exchange.getStatusCode()== HttpStatus.OK){
             Map<String,Object> resultRemote = (Map)exchange.getBody();
             if(!Objects.isNull(resultRemote)){
-                Integer respCode = resultRemote.get("resp_code")!=null?(Integer)(resultRemote.get("resp_code")):1;
-                if(respCode==0){
+                Integer respCode = 1;
+                if(oAuth2Client.getResultType()==0){
+                    respCode = resultRemote.get("resp_code")!=null?(Integer)(resultRemote.get("resp_code")):1;
+                }else if(oAuth2Client.getResultType()==1){
+                    Map<String,Object> resultData = (Map) resultRemote.get("data");
+                    if(Objects.isNull(resultData)){
+                        respCode = 1;
+                    }else{
+                        respCode = resultData.get("resp_code")!=null?(Integer)(resultData.get("resp_code")):1;
+                    }
+                }
+                if(respCode == 0){
                     userClientService.updateUserSyncStatus(userClient.getId(),1);
                 }else{
                     userClientService.updateUserStatus(userClient.getId(),2);

+ 7 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/controller/admin/userclient/vo/UserSsoVo.java

@@ -44,6 +44,13 @@ public class UserSsoVo {
     @Schema(description = "分公司名称", name = "companyName", required = false)
     private String companyName;
 
+    /**
+     * 分公司编码
+     */
+    @Schema(description = "分公司编码", name = "companyCode", required = false)
+    private String companyCode;
+
+
     /**
      * 机构名称
      */

+ 5 - 3
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/dal/dataobject/dept/DeptDO.java

@@ -9,8 +9,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
+import lombok.*;
 
 import java.time.LocalDateTime;
 import java.util.Set;
@@ -21,10 +20,13 @@ import java.util.Set;
  * @author ruoyi
  * @author zkk
  */
-@TableName("system_dept")
+@TableName(value = "system_dept", autoResultMap = true)
 @KeySequence("system_dept_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
 @Data
 @EqualsAndHashCode(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
 public class DeptDO extends TenantBaseDO {
 
     public static final Long PARENT_ID_ROOT = 0L;

+ 2 - 0
sso-module-system/sso-module-system-biz/src/main/java/com/poteviohealth/cgp/sso/module/system/dal/dataobject/oauth2/OAuth2ClientDO.java

@@ -135,5 +135,7 @@ public class OAuth2ClientDO extends BaseDO {
     @Schema(description = "授权链接", example = "1")
     private Integer permissionsLink;
 
+    @Schema(description = "返回值类型", example = "1")
+    private Integer resultType;
 
 }