Merge remote-tracking branch 'base-version/test' into dev

This commit is contained in:
chenbowen
2026-01-29 14:52:57 +08:00
15 changed files with 109 additions and 305 deletions

View File

@@ -49,4 +49,13 @@ public interface OAuth2TokenCommonApi {
CommonResult<OAuth2AccessTokenRespDTO> refreshAccessToken(@RequestParam("refreshToken") String refreshToken, CommonResult<OAuth2AccessTokenRespDTO> refreshAccessToken(@RequestParam("refreshToken") String refreshToken,
@RequestParam("clientId") String clientId); @RequestParam("clientId") String clientId);
@DeleteMapping(PREFIX + "/remove-by-user")
@Operation(summary = "按 userId + clientId 失效访问令牌")
@Parameters({
@Parameter(name = "userId", description = "用户编号", required = true, example = "1"),
@Parameter(name = "clientId", description = "客户端编号", required = true, example = "default")
})
CommonResult<Boolean> removeAccessTokensByUserIdAndClientId(@RequestParam("userId") Long userId,
@RequestParam("clientId") String clientId);
} }

View File

@@ -48,4 +48,9 @@ public class OAuth2TokenApiImpl implements OAuth2TokenCommonApi {
return success(BeanUtils.toBean(accessTokenDO, OAuth2AccessTokenRespDTO.class)); return success(BeanUtils.toBean(accessTokenDO, OAuth2AccessTokenRespDTO.class));
} }
@Override
public CommonResult<Boolean> removeAccessTokensByUserIdAndClientId(Long userId, String clientId) {
return success(oauth2TokenService.removeAccessTokensByUserIdAndClientId(userId, clientId));
}
} }

View File

@@ -30,6 +30,9 @@ public class AuthLoginReqVO extends CaptchaVerificationReqVO {
// @Length(min = 4, max = 16, message = "密码长度为 4-16 位") // @Length(min = 4, max = 16, message = "密码长度为 4-16 位")
private String password; private String password;
@Schema(description = "客户端编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "default")
private String clientId;
// ========== 绑定社交登录时,需要传递如下参数 ========== // ========== 绑定社交登录时,需要传递如下参数 ==========
@Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") @Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")

View File

@@ -24,4 +24,7 @@ public class AuthSmsLoginReqVO {
@NotEmpty(message = "验证码不能为空") @NotEmpty(message = "验证码不能为空")
private String code; private String code;
@Schema(description = "客户端编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "default")
private String clientId;
} }

View File

@@ -30,4 +30,7 @@ public class AuthSocialLoginReqVO {
@NotEmpty(message = "state 不能为空") @NotEmpty(message = "state 不能为空")
private String state; private String state;
@Schema(description = "客户端编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "default")
private String clientId;
} }

View File

@@ -26,4 +26,7 @@ public class AuthTestLoginReqVO {
@Length(min = 4, max = 16, message = "密码长度为 4-16 位") @Length(min = 4, max = 16, message = "密码长度为 4-16 位")
private String password; private String password;
@Schema(description = "客户端编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "default")
private String clientId;
} }

View File

@@ -176,16 +176,43 @@ public class IWorkIntegrationController {
return success(syncService.fullSyncUsers(reqVO)); return success(syncService.fullSyncUsers(reqVO));
} }
// ----------------- 根据ID同步到本地 ----------------- // ----------------- 根据ID同步到本地(仅传 ID -----------------
@PostMapping("/syncById") @PostMapping("/sync/user-by-id")
@Operation(summary = "根据ID触发 iWork 同步公司") @Operation(summary = "根据ID同步 iWork 人员(单条)")
public CommonResult<IWorkFullSyncRespVO> syncById(@Valid @RequestBody IWorkSyncByIdReqVO reqVO) { public CommonResult<IWorkFullSyncRespVO> syncUserById(@Valid @RequestBody IWorkSyncByIdReqVO reqVO) {
IWorkFullSyncReqVO fullReq = new IWorkFullSyncReqVO();
log.error("IWork集成后端手动录入syncById{}",reqVO); fullReq.setId(reqVO.getId());
return success(syncService.manuallySyncData(reqVO)); fullReq.setStartPage(1);
fullReq.setPageSize(1);
fullReq.setMaxPages(1);
fullReq.setAllowUpdate(Boolean.TRUE);
return success(syncService.fullSyncUsers(fullReq));
} }
@PostMapping("/sync/department-by-id")
@Operation(summary = "根据ID同步 iWork 部门(单条)")
public CommonResult<IWorkFullSyncRespVO> syncDepartmentById(@Valid @RequestBody IWorkSyncByIdReqVO reqVO) {
IWorkFullSyncReqVO fullReq = new IWorkFullSyncReqVO();
fullReq.setId(reqVO.getId());
fullReq.setStartPage(1);
fullReq.setPageSize(1);
fullReq.setMaxPages(1);
fullReq.setAllowUpdate(Boolean.TRUE);
return success(syncService.fullSyncDepartments(fullReq));
}
@PostMapping("/sync/subcompany-by-id")
@Operation(summary = "根据ID同步 iWork 分部(单条)")
public CommonResult<IWorkFullSyncRespVO> syncSubcompanyById(@Valid @RequestBody IWorkSyncByIdReqVO reqVO) {
IWorkFullSyncReqVO fullReq = new IWorkFullSyncReqVO();
fullReq.setId(reqVO.getId());
fullReq.setStartPage(1);
fullReq.setPageSize(1);
fullReq.setMaxPages(1);
fullReq.setAllowUpdate(Boolean.TRUE);
return success(syncService.fullSyncSubcompanies(fullReq));
}
private ResponseEntity<String> buildOaResponse(IWorkOaRawResponse resp) { private ResponseEntity<String> buildOaResponse(IWorkOaRawResponse resp) {
if (resp == null) { if (resp == null) {

View File

@@ -1,99 +1,15 @@
package com.zt.plat.module.system.controller.admin.integration.iwork.vo; package com.zt.plat.module.system.controller.admin.integration.iwork.vo;
import com.zt.plat.module.system.enums.integration.IWorkSyncEntityTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import lombok.Data; import lombok.Data;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/** /**
* iWork 手动同步请求 * iWork 手动同步请求
*/ */
@Data @Data
public class IWorkSyncByIdReqVO { public class IWorkSyncByIdReqVO {
@Schema(description = "起始页码,从 1 开始", example = "1")
@Min(1)
private Integer startPage = 1;
@Schema(description = "最大处理页数null 表示处理至 iWork 返回的末页", example = "10")
@Min(1)
private Integer maxPages;
@Schema(description = "每次分页从 iWork 拉取的记录数", example = "100")
@Min(1)
@Max(500)
private Integer pageSize = 100;
@Schema(description = "同步范围列表默认同步全部。可选subcompany、department、jobTitle、user")
private List<String> scopes;
@Schema(description = "是否包含已失效canceled=1的记录", example = "false")
private Boolean includeCanceled = Boolean.FALSE;
@Schema(description = "是否允许更新已存在的本地实体", example = "false")
private Boolean allowUpdate = Boolean.FALSE;
@Schema(description = "指定同步记录的 iWork ID。传入后仅同步对应记录", example = "12345") @Schema(description = "指定同步记录的 iWork ID。传入后仅同步对应记录", example = "12345")
@NotBlank(message = "ID不能为空") @NotBlank(message = "ID不能为空")
private String id; private String id;
@Schema(description = "部门编码", example = "ZT001")
private String code;
@Schema(description = "部门名称", example = "ZT")
private String name;
@Schema(description = "部门简称", example = "技术")
private String shortName;
@Schema(description = "父部门 ID", example = "1024")
private String parentId;
@Schema(description = "负责人的用户编号", example = "2048")
private String leaderUserId;
@Schema(description = "联系电话", example = "15601691000")
private String phone;
@Schema(description = "邮箱", example = "zt@iocoder.cn")
private String email;
@Schema(description = "状态,见 CommonStatusEnum 枚举0 开启 1 关闭", example = "0")
private Integer status;
private Long tenantId;
@Schema(description = "是否公司", example = "false")
private boolean isCompany;
@Schema(description = "是否集团", example = "false")
private boolean isGroup;
private boolean hasChildren;
public Set<IWorkSyncEntityTypeEnum> resolveScopes() {
EnumSet<IWorkSyncEntityTypeEnum> defaults = EnumSet.allOf(IWorkSyncEntityTypeEnum.class);
if (scopes == null || scopes.isEmpty()) {
return defaults;
}
Set<IWorkSyncEntityTypeEnum> resolved = scopes.stream()
.map(IWorkSyncEntityTypeEnum::fromCode)
.filter(java.util.Objects::nonNull)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(IWorkSyncEntityTypeEnum.class)));
if (resolved.isEmpty()) {
return defaults;
}
return resolved;
}
} }

View File

@@ -31,6 +31,12 @@ public interface OAuth2AccessTokenMapper extends BaseMapperX<OAuth2AccessTokenDO
.eq(OAuth2AccessTokenDO::getClientId, clientId)); .eq(OAuth2AccessTokenDO::getClientId, clientId));
} }
default List<OAuth2AccessTokenDO> selectListByUserIdAndClientId(Long userId, String clientId) {
return selectList(new LambdaQueryWrapperX<OAuth2AccessTokenDO>()
.eq(OAuth2AccessTokenDO::getUserId, userId)
.eq(OAuth2AccessTokenDO::getClientId, clientId));
}
default List<OAuth2AccessTokenDO> selectListByRefreshToken(String refreshToken) { default List<OAuth2AccessTokenDO> selectListByRefreshToken(String refreshToken) {
return selectList(OAuth2AccessTokenDO::getRefreshToken, refreshToken); return selectList(OAuth2AccessTokenDO::getRefreshToken, refreshToken);
} }

View File

@@ -19,4 +19,10 @@ public interface OAuth2RefreshTokenMapper extends BaseMapperX<OAuth2RefreshToken
return selectOne(OAuth2RefreshTokenDO::getRefreshToken, refreshToken); return selectOne(OAuth2RefreshTokenDO::getRefreshToken, refreshToken);
} }
default int deleteByUserIdAndClientId(Long userId, String clientId) {
return delete(new LambdaQueryWrapperX<OAuth2RefreshTokenDO>()
.eq(OAuth2RefreshTokenDO::getUserId, userId)
.eq(OAuth2RefreshTokenDO::getClientId, clientId));
}
} }

Some files were not shown because too many files have changed in this diff Show More