Commit 5bb8fdca7ef8a9d9303a58e7d40a822e446ff59b
1 parent
e61ecb63
🔧 简化 social 模块的 VO
Showing
17 changed files
with
97 additions
and
195 deletions
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java
| 1 | package cn.iocoder.yudao.module.system.api.social; | 1 | package cn.iocoder.yudao.module.system.api.social; |
| 2 | 2 | ||
| 3 | import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; | 3 | import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; |
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 4 | import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO; | 5 | import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO; |
| 5 | import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO; | 6 | import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO; |
| 6 | -import cn.iocoder.yudao.module.system.convert.social.SocialClientConvert; | ||
| 7 | import cn.iocoder.yudao.module.system.service.social.SocialClientService; | 7 | import cn.iocoder.yudao.module.system.service.social.SocialClientService; |
| 8 | import me.chanjar.weixin.common.bean.WxJsapiSignature; | 8 | import me.chanjar.weixin.common.bean.WxJsapiSignature; |
| 9 | import org.springframework.stereotype.Service; | 9 | import org.springframework.stereotype.Service; |
| @@ -31,13 +31,13 @@ public class SocialClientApiImpl implements SocialClientApi { | @@ -31,13 +31,13 @@ public class SocialClientApiImpl implements SocialClientApi { | ||
| 31 | @Override | 31 | @Override |
| 32 | public SocialWxJsapiSignatureRespDTO createWxMpJsapiSignature(Integer userType, String url) { | 32 | public SocialWxJsapiSignatureRespDTO createWxMpJsapiSignature(Integer userType, String url) { |
| 33 | WxJsapiSignature signature = socialClientService.createWxMpJsapiSignature(userType, url); | 33 | WxJsapiSignature signature = socialClientService.createWxMpJsapiSignature(userType, url); |
| 34 | - return SocialClientConvert.INSTANCE.convert(signature); | 34 | + return BeanUtils.toBean(signature, SocialWxJsapiSignatureRespDTO.class); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | @Override | 37 | @Override |
| 38 | public SocialWxPhoneNumberInfoRespDTO getWxMaPhoneNumberInfo(Integer userType, String phoneCode) { | 38 | public SocialWxPhoneNumberInfoRespDTO getWxMaPhoneNumberInfo(Integer userType, String phoneCode) { |
| 39 | WxMaPhoneNumberInfo info = socialClientService.getWxMaPhoneNumberInfo(userType, phoneCode); | 39 | WxMaPhoneNumberInfo info = socialClientService.getWxMaPhoneNumberInfo(userType, phoneCode); |
| 40 | - return SocialClientConvert.INSTANCE.convert(info); | 40 | + return BeanUtils.toBean(info, SocialWxPhoneNumberInfoRespDTO.class); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | } | 43 | } |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java
| @@ -2,11 +2,10 @@ package cn.iocoder.yudao.module.system.controller.admin.socail; | @@ -2,11 +2,10 @@ package cn.iocoder.yudao.module.system.controller.admin.socail; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientCreateReqVO; | 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; | 6 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; |
| 7 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientRespVO; | 7 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientRespVO; |
| 8 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientUpdateReqVO; | ||
| 9 | -import cn.iocoder.yudao.module.system.convert.social.SocialClientConvert; | 8 | +import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; |
| 10 | import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; | 9 | import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; |
| 11 | import cn.iocoder.yudao.module.system.service.social.SocialClientService; | 10 | import cn.iocoder.yudao.module.system.service.social.SocialClientService; |
| 12 | import io.swagger.v3.oas.annotations.Operation; | 11 | import io.swagger.v3.oas.annotations.Operation; |
| @@ -33,14 +32,14 @@ public class SocialClientController { | @@ -33,14 +32,14 @@ public class SocialClientController { | ||
| 33 | @PostMapping("/create") | 32 | @PostMapping("/create") |
| 34 | @Operation(summary = "创建社交客户端") | 33 | @Operation(summary = "创建社交客户端") |
| 35 | @PreAuthorize("@ss.hasPermission('system:social-client:create')") | 34 | @PreAuthorize("@ss.hasPermission('system:social-client:create')") |
| 36 | - public CommonResult<Long> createSocialClient(@Valid @RequestBody SocialClientCreateReqVO createReqVO) { | 35 | + public CommonResult<Long> createSocialClient(@Valid @RequestBody SocialClientSaveReqVO createReqVO) { |
| 37 | return success(socialClientService.createSocialClient(createReqVO)); | 36 | return success(socialClientService.createSocialClient(createReqVO)); |
| 38 | } | 37 | } |
| 39 | 38 | ||
| 40 | @PutMapping("/update") | 39 | @PutMapping("/update") |
| 41 | @Operation(summary = "更新社交客户端") | 40 | @Operation(summary = "更新社交客户端") |
| 42 | @PreAuthorize("@ss.hasPermission('system:social-client:update')") | 41 | @PreAuthorize("@ss.hasPermission('system:social-client:update')") |
| 43 | - public CommonResult<Boolean> updateSocialClient(@Valid @RequestBody SocialClientUpdateReqVO updateReqVO) { | 42 | + public CommonResult<Boolean> updateSocialClient(@Valid @RequestBody SocialClientSaveReqVO updateReqVO) { |
| 44 | socialClientService.updateSocialClient(updateReqVO); | 43 | socialClientService.updateSocialClient(updateReqVO); |
| 45 | return success(true); | 44 | return success(true); |
| 46 | } | 45 | } |
| @@ -59,8 +58,8 @@ public class SocialClientController { | @@ -59,8 +58,8 @@ public class SocialClientController { | ||
| 59 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 58 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 60 | @PreAuthorize("@ss.hasPermission('system:social-client:query')") | 59 | @PreAuthorize("@ss.hasPermission('system:social-client:query')") |
| 61 | public CommonResult<SocialClientRespVO> getSocialClient(@RequestParam("id") Long id) { | 60 | public CommonResult<SocialClientRespVO> getSocialClient(@RequestParam("id") Long id) { |
| 62 | - SocialClientDO socialClient = socialClientService.getSocialClient(id); | ||
| 63 | - return success(SocialClientConvert.INSTANCE.convert(socialClient)); | 61 | + SocialClientDO client = socialClientService.getSocialClient(id); |
| 62 | + return success(BeanUtils.toBean(client, SocialClientRespVO.class)); | ||
| 64 | } | 63 | } |
| 65 | 64 | ||
| 66 | @GetMapping("/page") | 65 | @GetMapping("/page") |
| @@ -68,7 +67,7 @@ public class SocialClientController { | @@ -68,7 +67,7 @@ public class SocialClientController { | ||
| 68 | @PreAuthorize("@ss.hasPermission('system:social-client:query')") | 67 | @PreAuthorize("@ss.hasPermission('system:social-client:query')") |
| 69 | public CommonResult<PageResult<SocialClientRespVO>> getSocialClientPage(@Valid SocialClientPageReqVO pageVO) { | 68 | public CommonResult<PageResult<SocialClientRespVO>> getSocialClientPage(@Valid SocialClientPageReqVO pageVO) { |
| 70 | PageResult<SocialClientDO> pageResult = socialClientService.getSocialClientPage(pageVO); | 69 | PageResult<SocialClientDO> pageResult = socialClientService.getSocialClientPage(pageVO); |
| 71 | - return success(SocialClientConvert.INSTANCE.convertPage(pageResult)); | 70 | + return success(BeanUtils.toBean(pageResult, SocialClientRespVO.class)); |
| 72 | } | 71 | } |
| 73 | 72 | ||
| 74 | } | 73 | } |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialUserController.java
| @@ -3,8 +3,9 @@ package cn.iocoder.yudao.module.system.controller.admin.socail; | @@ -3,8 +3,9 @@ package cn.iocoder.yudao.module.system.controller.admin.socail; | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 3 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.SocialUserBindReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.SocialUserUnbindReqVO; | 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | +import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserBindReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserUnbindReqVO; | ||
| 8 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserPageReqVO; | 9 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserPageReqVO; |
| 9 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserRespVO; | 10 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserRespVO; |
| 10 | import cn.iocoder.yudao.module.system.convert.social.SocialUserConvert; | 11 | import cn.iocoder.yudao.module.system.convert.social.SocialUserConvert; |
| @@ -35,7 +36,8 @@ public class SocialUserController { | @@ -35,7 +36,8 @@ public class SocialUserController { | ||
| 35 | @PostMapping("/bind") | 36 | @PostMapping("/bind") |
| 36 | @Operation(summary = "社交绑定,使用 code 授权码") | 37 | @Operation(summary = "社交绑定,使用 code 授权码") |
| 37 | public CommonResult<Boolean> socialBind(@RequestBody @Valid SocialUserBindReqVO reqVO) { | 38 | public CommonResult<Boolean> socialBind(@RequestBody @Valid SocialUserBindReqVO reqVO) { |
| 38 | - socialUserService.bindSocialUser(SocialUserConvert.INSTANCE.convert(getLoginUserId(), UserTypeEnum.ADMIN.getValue(), reqVO)); | 39 | + socialUserService.bindSocialUser(SocialUserConvert.INSTANCE.convert( |
| 40 | + getLoginUserId(), UserTypeEnum.ADMIN.getValue(), reqVO)); | ||
| 39 | return CommonResult.success(true); | 41 | return CommonResult.success(true); |
| 40 | } | 42 | } |
| 41 | 43 | ||
| @@ -54,7 +56,7 @@ public class SocialUserController { | @@ -54,7 +56,7 @@ public class SocialUserController { | ||
| 54 | @PreAuthorize("@ss.hasPermission('system:social-user:query')") | 56 | @PreAuthorize("@ss.hasPermission('system:social-user:query')") |
| 55 | public CommonResult<SocialUserRespVO> getSocialUser(@RequestParam("id") Long id) { | 57 | public CommonResult<SocialUserRespVO> getSocialUser(@RequestParam("id") Long id) { |
| 56 | SocialUserDO socialUser = socialUserService.getSocialUser(id); | 58 | SocialUserDO socialUser = socialUserService.getSocialUser(id); |
| 57 | - return success(SocialUserConvert.INSTANCE.convert(socialUser)); | 59 | + return success(BeanUtils.toBean(socialUser, SocialUserRespVO.class)); |
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | @GetMapping("/page") | 62 | @GetMapping("/page") |
| @@ -62,7 +64,7 @@ public class SocialUserController { | @@ -62,7 +64,7 @@ public class SocialUserController { | ||
| 62 | @PreAuthorize("@ss.hasPermission('system:social-user:query')") | 64 | @PreAuthorize("@ss.hasPermission('system:social-user:query')") |
| 63 | public CommonResult<PageResult<SocialUserRespVO>> getSocialUserPage(@Valid SocialUserPageReqVO pageVO) { | 65 | public CommonResult<PageResult<SocialUserRespVO>> getSocialUserPage(@Valid SocialUserPageReqVO pageVO) { |
| 64 | PageResult<SocialUserDO> pageResult = socialUserService.getSocialUserPage(pageVO); | 66 | PageResult<SocialUserDO> pageResult = socialUserService.getSocialUserPage(pageVO); |
| 65 | - return success(SocialUserConvert.INSTANCE.convertPage(pageResult)); | 67 | + return success(BeanUtils.toBean(pageResult, SocialUserRespVO.class)); |
| 66 | } | 68 | } |
| 67 | 69 | ||
| 68 | } | 70 | } |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/client/SocialClientCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.system.controller.admin.socail.vo.client; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import lombok.EqualsAndHashCode; | ||
| 6 | -import lombok.ToString; | ||
| 7 | - | ||
| 8 | -@Schema(description = "管理后台 - 社交客户端创建 Request VO") | ||
| 9 | -@Data | ||
| 10 | -@EqualsAndHashCode(callSuper = true) | ||
| 11 | -@ToString(callSuper = true) | ||
| 12 | -public class SocialClientCreateReqVO extends SocialClientBaseVO { | ||
| 13 | - | ||
| 14 | -} |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/client/SocialClientRespVO.java
| @@ -2,20 +2,37 @@ package cn.iocoder.yudao.module.system.controller.admin.socail.vo.client; | @@ -2,20 +2,37 @@ package cn.iocoder.yudao.module.system.controller.admin.socail.vo.client; | ||
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | -import lombok.EqualsAndHashCode; | ||
| 6 | -import lombok.ToString; | ||
| 7 | 5 | ||
| 8 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
| 9 | 7 | ||
| 10 | @Schema(description = "管理后台 - 社交客户端 Response VO") | 8 | @Schema(description = "管理后台 - 社交客户端 Response VO") |
| 11 | @Data | 9 | @Data |
| 12 | -@EqualsAndHashCode(callSuper = true) | ||
| 13 | -@ToString(callSuper = true) | ||
| 14 | -public class SocialClientRespVO extends SocialClientBaseVO { | 10 | +public class SocialClientRespVO { |
| 15 | 11 | ||
| 16 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27162") | 12 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27162") |
| 17 | private Long id; | 13 | private Long id; |
| 18 | 14 | ||
| 15 | + @Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao商城") | ||
| 16 | + private String name; | ||
| 17 | + | ||
| 18 | + @Schema(description = "社交平台的类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "31") | ||
| 19 | + private Integer socialType; | ||
| 20 | + | ||
| 21 | + @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 22 | + private Integer userType; | ||
| 23 | + | ||
| 24 | + @Schema(description = "客户端编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "wwd411c69a39ad2e54") | ||
| 25 | + private String clientId; | ||
| 26 | + | ||
| 27 | + @Schema(description = "客户端密钥", requiredMode = Schema.RequiredMode.REQUIRED, example = "peter") | ||
| 28 | + private String clientSecret; | ||
| 29 | + | ||
| 30 | + @Schema(description = "授权方的网页应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000045") | ||
| 31 | + private String agentId; | ||
| 32 | + | ||
| 33 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 34 | + private Integer status; | ||
| 35 | + | ||
| 19 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 36 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 20 | private LocalDateTime createTime; | 37 | private LocalDateTime createTime; |
| 21 | 38 |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/client/SocialClientBaseVO.java renamed to yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/client/SocialClientSaveReqVO.java
| @@ -13,12 +13,12 @@ import javax.validation.constraints.AssertTrue; | @@ -13,12 +13,12 @@ import javax.validation.constraints.AssertTrue; | ||
| 13 | import javax.validation.constraints.NotNull; | 13 | import javax.validation.constraints.NotNull; |
| 14 | import java.util.Objects; | 14 | import java.util.Objects; |
| 15 | 15 | ||
| 16 | -/** | ||
| 17 | - * 社交客户端 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 18 | - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 19 | - */ | 16 | +@Schema(description = "管理后台 - 社交客户端创建/修改 Request VO") |
| 20 | @Data | 17 | @Data |
| 21 | -public class SocialClientBaseVO { | 18 | +public class SocialClientSaveReqVO { |
| 19 | + | ||
| 20 | + @Schema(description = "编号", example = "27162") | ||
| 21 | + private Long id; | ||
| 22 | 22 | ||
| 23 | @Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao商城") | 23 | @Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao商城") |
| 24 | @NotNull(message = "应用名不能为空") | 24 | @NotNull(message = "应用名不能为空") |
| @@ -38,7 +38,7 @@ public class SocialClientBaseVO { | @@ -38,7 +38,7 @@ public class SocialClientBaseVO { | ||
| 38 | @NotNull(message = "客户端编号不能为空") | 38 | @NotNull(message = "客户端编号不能为空") |
| 39 | private String clientId; | 39 | private String clientId; |
| 40 | 40 | ||
| 41 | - @Schema(description = "客户端密钥", requiredMode = Schema.RequiredMode.REQUIRED, example = "1wTb7hYxnpT2TUbIeHGXGo7T0odav1ic10mLdyyATOw") | 41 | + @Schema(description = "客户端密钥", requiredMode = Schema.RequiredMode.REQUIRED, example = "peter") |
| 42 | @NotNull(message = "客户端密钥不能为空") | 42 | @NotNull(message = "客户端密钥不能为空") |
| 43 | private String clientSecret; | 43 | private String clientSecret; |
| 44 | 44 | ||
| @@ -50,16 +50,12 @@ public class SocialClientBaseVO { | @@ -50,16 +50,12 @@ public class SocialClientBaseVO { | ||
| 50 | @InEnum(CommonStatusEnum.class) | 50 | @InEnum(CommonStatusEnum.class) |
| 51 | private Integer status; | 51 | private Integer status; |
| 52 | 52 | ||
| 53 | - @SuppressWarnings("RedundantIfStatement") | ||
| 54 | @AssertTrue(message = "agentId 不能为空") | 53 | @AssertTrue(message = "agentId 不能为空") |
| 55 | @JsonIgnore | 54 | @JsonIgnore |
| 56 | public boolean isAgentIdValid() { | 55 | public boolean isAgentIdValid() { |
| 57 | // 如果是企业微信,必须填写 agentId 属性 | 56 | // 如果是企业微信,必须填写 agentId 属性 |
| 58 | - if (Objects.equals(socialType, SocialTypeEnum.WECHAT_ENTERPRISE.getType()) | ||
| 59 | - && StrUtil.isEmpty(agentId)) { | ||
| 60 | - return false; | ||
| 61 | - } | ||
| 62 | - return true; | 57 | + return !Objects.equals(socialType, SocialTypeEnum.WECHAT_ENTERPRISE.getType()) |
| 58 | + || !StrUtil.isEmpty(agentId); | ||
| 63 | } | 59 | } |
| 64 | 60 | ||
| 65 | } | 61 | } |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/client/SocialClientUpdateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.system.controller.admin.socail.vo.client; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import lombok.EqualsAndHashCode; | ||
| 6 | -import lombok.ToString; | ||
| 7 | - | ||
| 8 | -import javax.validation.constraints.NotNull; | ||
| 9 | - | ||
| 10 | -@Schema(description = "管理后台 - 社交客户端更新 Request VO") | ||
| 11 | -@Data | ||
| 12 | -@EqualsAndHashCode(callSuper = true) | ||
| 13 | -@ToString(callSuper = true) | ||
| 14 | -public class SocialClientUpdateReqVO extends SocialClientBaseVO { | ||
| 15 | - | ||
| 16 | - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27162") | ||
| 17 | - @NotNull(message = "编号不能为空") | ||
| 18 | - private Long id; | ||
| 19 | - | ||
| 20 | -} |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserBaseVO.java deleted
| 1 | -package cn.iocoder.yudao.module.system.controller.admin.socail.vo.user; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | - | ||
| 6 | -import javax.validation.constraints.NotNull; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 社交用户 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 10 | - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 11 | - */ | ||
| 12 | -@Data | ||
| 13 | -public class SocialUserBaseVO { | ||
| 14 | - | ||
| 15 | - @Schema(description = "社交平台的类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "30") | ||
| 16 | - @NotNull(message = "社交平台的类型不能为空") | ||
| 17 | - private Integer type; | ||
| 18 | - | ||
| 19 | - @Schema(description = "社交 openid", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") | ||
| 20 | - @NotNull(message = "社交 openid不能为空") | ||
| 21 | - private String openid; | ||
| 22 | - | ||
| 23 | - @Schema(description = "社交 token", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") | ||
| 24 | - private String token; | ||
| 25 | - | ||
| 26 | - @Schema(description = "原始 Token 数据,一般是 JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") | ||
| 27 | - private String rawTokenInfo; | ||
| 28 | - | ||
| 29 | - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 30 | - @NotNull(message = "用户昵称不能为空") | ||
| 31 | - private String nickname; | ||
| 32 | - | ||
| 33 | - @Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png") | ||
| 34 | - private String avatar; | ||
| 35 | - | ||
| 36 | - @Schema(description = "原始用户数据,一般是 JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") | ||
| 37 | - private String rawUserInfo; | ||
| 38 | - | ||
| 39 | - @Schema(description = "最后一次的认证 code", requiredMode = Schema.RequiredMode.REQUIRED, example = "666666") | ||
| 40 | - private String code; | ||
| 41 | - | ||
| 42 | - @Schema(description = "最后一次的认证 state", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") | ||
| 43 | - private String state; | ||
| 44 | - | ||
| 45 | -} |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/SocialUserBindReqVO.java renamed to yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserBindReqVO.java
| 1 | -package cn.iocoder.yudao.module.system.controller.admin.socail.vo; | 1 | +package cn.iocoder.yudao.module.system.controller.admin.socail.vo.user; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; | 3 | import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; |
| 4 | import cn.iocoder.yudao.framework.common.validation.InEnum; | 4 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserRespVO.java
| @@ -2,20 +2,43 @@ package cn.iocoder.yudao.module.system.controller.admin.socail.vo.user; | @@ -2,20 +2,43 @@ package cn.iocoder.yudao.module.system.controller.admin.socail.vo.user; | ||
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | -import lombok.EqualsAndHashCode; | ||
| 6 | -import lombok.ToString; | ||
| 7 | 5 | ||
| 8 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
| 9 | 7 | ||
| 10 | @Schema(description = "管理后台 - 社交用户 Response VO") | 8 | @Schema(description = "管理后台 - 社交用户 Response VO") |
| 11 | @Data | 9 | @Data |
| 12 | -@EqualsAndHashCode(callSuper = true) | ||
| 13 | -@ToString(callSuper = true) | ||
| 14 | -public class SocialUserRespVO extends SocialUserBaseVO { | 10 | +public class SocialUserRespVO { |
| 15 | 11 | ||
| 16 | @Schema(description = "主键(自增策略)", requiredMode = Schema.RequiredMode.REQUIRED, example = "14569") | 12 | @Schema(description = "主键(自增策略)", requiredMode = Schema.RequiredMode.REQUIRED, example = "14569") |
| 17 | private Long id; | 13 | private Long id; |
| 18 | 14 | ||
| 15 | + @Schema(description = "社交平台的类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "30") | ||
| 16 | + private Integer type; | ||
| 17 | + | ||
| 18 | + @Schema(description = "社交 openid", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") | ||
| 19 | + private String openid; | ||
| 20 | + | ||
| 21 | + @Schema(description = "社交 token", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") | ||
| 22 | + private String token; | ||
| 23 | + | ||
| 24 | + @Schema(description = "原始 Token 数据,一般是 JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") | ||
| 25 | + private String rawTokenInfo; | ||
| 26 | + | ||
| 27 | + @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 28 | + private String nickname; | ||
| 29 | + | ||
| 30 | + @Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png") | ||
| 31 | + private String avatar; | ||
| 32 | + | ||
| 33 | + @Schema(description = "原始用户数据,一般是 JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") | ||
| 34 | + private String rawUserInfo; | ||
| 35 | + | ||
| 36 | + @Schema(description = "最后一次的认证 code", requiredMode = Schema.RequiredMode.REQUIRED, example = "666666") | ||
| 37 | + private String code; | ||
| 38 | + | ||
| 39 | + @Schema(description = "最后一次的认证 state", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") | ||
| 40 | + private String state; | ||
| 41 | + | ||
| 19 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 42 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 20 | private LocalDateTime createTime; | 43 | private LocalDateTime createTime; |
| 21 | 44 |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/SocialUserUnbindReqVO.java renamed to yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserUnbindReqVO.java
| 1 | -package cn.iocoder.yudao.module.system.controller.admin.socail.vo; | 1 | +package cn.iocoder.yudao.module.system.controller.admin.socail.vo.user; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; | 4 | import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/social/SocialClientConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.system.convert.social; | ||
| 2 | - | ||
| 3 | -import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; | ||
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO; | ||
| 6 | -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO; | ||
| 7 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientCreateReqVO; | ||
| 8 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientRespVO; | ||
| 9 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientUpdateReqVO; | ||
| 10 | -import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; | ||
| 11 | -import me.chanjar.weixin.common.bean.WxJsapiSignature; | ||
| 12 | -import org.mapstruct.Mapper; | ||
| 13 | -import org.mapstruct.factory.Mappers; | ||
| 14 | - | ||
| 15 | -import java.util.List; | ||
| 16 | - | ||
| 17 | -@Mapper | ||
| 18 | -public interface SocialClientConvert { | ||
| 19 | - | ||
| 20 | - SocialClientConvert INSTANCE = Mappers.getMapper(SocialClientConvert.class); | ||
| 21 | - | ||
| 22 | - SocialWxJsapiSignatureRespDTO convert(WxJsapiSignature bean); | ||
| 23 | - | ||
| 24 | - SocialWxPhoneNumberInfoRespDTO convert(WxMaPhoneNumberInfo bean); | ||
| 25 | - | ||
| 26 | - SocialClientDO convert(SocialClientCreateReqVO bean); | ||
| 27 | - | ||
| 28 | - SocialClientDO convert(SocialClientUpdateReqVO bean); | ||
| 29 | - | ||
| 30 | - SocialClientRespVO convert(SocialClientDO bean); | ||
| 31 | - | ||
| 32 | - List<SocialClientRespVO> convertList(List<SocialClientDO> list); | ||
| 33 | - | ||
| 34 | - PageResult<SocialClientRespVO> convertPage(PageResult<SocialClientDO> page); | ||
| 35 | - | ||
| 36 | - | ||
| 37 | - | ||
| 38 | -} |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/social/SocialUserConvert.java
| 1 | package cn.iocoder.yudao.module.system.convert.social; | 1 | package cn.iocoder.yudao.module.system.convert.social; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; | 3 | import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; |
| 5 | -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserUnbindReqDTO; | ||
| 6 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.SocialUserBindReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.SocialUserUnbindReqVO; | ||
| 8 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserRespVO; | ||
| 9 | -import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO; | 4 | +import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserBindReqVO; |
| 10 | import org.mapstruct.Mapper; | 5 | import org.mapstruct.Mapper; |
| 11 | import org.mapstruct.Mapping; | 6 | import org.mapstruct.Mapping; |
| 12 | import org.mapstruct.factory.Mappers; | 7 | import org.mapstruct.factory.Mappers; |
| 13 | 8 | ||
| 14 | -import java.util.List; | ||
| 15 | - | ||
| 16 | @Mapper | 9 | @Mapper |
| 17 | public interface SocialUserConvert { | 10 | public interface SocialUserConvert { |
| 18 | 11 | ||
| 19 | SocialUserConvert INSTANCE = Mappers.getMapper(SocialUserConvert.class); | 12 | SocialUserConvert INSTANCE = Mappers.getMapper(SocialUserConvert.class); |
| 20 | 13 | ||
| 21 | - @Mapping(target = "socialType", source = "reqVO.type") | 14 | + @Mapping(source = "reqVO.type", target = "socialType") |
| 22 | SocialUserBindReqDTO convert(Long userId, Integer userType, SocialUserBindReqVO reqVO); | 15 | SocialUserBindReqDTO convert(Long userId, Integer userType, SocialUserBindReqVO reqVO); |
| 23 | 16 | ||
| 24 | - SocialUserUnbindReqDTO convert(Long userId, Integer userType, SocialUserUnbindReqVO reqVO); | ||
| 25 | - | ||
| 26 | - SocialUserRespVO convert(SocialUserDO bean); | ||
| 27 | - | ||
| 28 | - List<SocialUserRespVO> convertList(List<SocialUserDO> list); | ||
| 29 | - | ||
| 30 | - PageResult<SocialUserRespVO> convertPage(PageResult<SocialUserDO> page); | ||
| 31 | - | ||
| 32 | } | 17 | } |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/social/SocialClientMapper.java
| @@ -20,7 +20,7 @@ public interface SocialClientMapper extends BaseMapperX<SocialClientDO> { | @@ -20,7 +20,7 @@ public interface SocialClientMapper extends BaseMapperX<SocialClientDO> { | ||
| 20 | .likeIfPresent(SocialClientDO::getName, reqVO.getName()) | 20 | .likeIfPresent(SocialClientDO::getName, reqVO.getName()) |
| 21 | .eqIfPresent(SocialClientDO::getSocialType, reqVO.getSocialType()) | 21 | .eqIfPresent(SocialClientDO::getSocialType, reqVO.getSocialType()) |
| 22 | .eqIfPresent(SocialClientDO::getUserType, reqVO.getUserType()) | 22 | .eqIfPresent(SocialClientDO::getUserType, reqVO.getUserType()) |
| 23 | - .eqIfPresent(SocialClientDO::getClientId, reqVO.getClientId()) | 23 | + .likeIfPresent(SocialClientDO::getClientId, reqVO.getClientId()) |
| 24 | .eqIfPresent(SocialClientDO::getStatus, reqVO.getStatus()) | 24 | .eqIfPresent(SocialClientDO::getStatus, reqVO.getStatus()) |
| 25 | .orderByDesc(SocialClientDO::getId)); | 25 | .orderByDesc(SocialClientDO::getId)); |
| 26 | } | 26 | } |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientService.java
| @@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.system.service.social; | @@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.system.service.social; | ||
| 2 | 2 | ||
| 3 | import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; | 3 | import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientCreateReqVO; | ||
| 6 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; | 5 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; |
| 7 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientUpdateReqVO; | 6 | +import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; |
| 8 | import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; | 7 | import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; |
| 9 | import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; | 8 | import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; |
| 10 | import com.xingyuv.jushauth.model.AuthUser; | 9 | import com.xingyuv.jushauth.model.AuthUser; |
| @@ -70,14 +69,14 @@ public interface SocialClientService { | @@ -70,14 +69,14 @@ public interface SocialClientService { | ||
| 70 | * @param createReqVO 创建信息 | 69 | * @param createReqVO 创建信息 |
| 71 | * @return 编号 | 70 | * @return 编号 |
| 72 | */ | 71 | */ |
| 73 | - Long createSocialClient(@Valid SocialClientCreateReqVO createReqVO); | 72 | + Long createSocialClient(@Valid SocialClientSaveReqVO createReqVO); |
| 74 | 73 | ||
| 75 | /** | 74 | /** |
| 76 | * 更新社交客户端 | 75 | * 更新社交客户端 |
| 77 | * | 76 | * |
| 78 | * @param updateReqVO 更新信息 | 77 | * @param updateReqVO 更新信息 |
| 79 | */ | 78 | */ |
| 80 | - void updateSocialClient(@Valid SocialClientUpdateReqVO updateReqVO); | 79 | + void updateSocialClient(@Valid SocialClientSaveReqVO updateReqVO); |
| 81 | 80 | ||
| 82 | /** | 81 | /** |
| 83 | * 删除社交客户端 | 82 | * 删除社交客户端 |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java
| @@ -12,10 +12,9 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | @@ -12,10 +12,9 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 12 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 12 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 13 | import cn.iocoder.yudao.framework.common.util.cache.CacheUtils; | 13 | import cn.iocoder.yudao.framework.common.util.cache.CacheUtils; |
| 14 | import cn.iocoder.yudao.framework.common.util.http.HttpUtils; | 14 | import cn.iocoder.yudao.framework.common.util.http.HttpUtils; |
| 15 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientCreateReqVO; | 15 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 16 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; | 16 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; |
| 17 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientUpdateReqVO; | ||
| 18 | -import cn.iocoder.yudao.module.system.convert.social.SocialClientConvert; | 17 | +import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; |
| 19 | import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; | 18 | import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; |
| 20 | import cn.iocoder.yudao.module.system.dal.mysql.social.SocialClientMapper; | 19 | import cn.iocoder.yudao.module.system.dal.mysql.social.SocialClientMapper; |
| 21 | import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; | 20 | import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; |
| @@ -267,26 +266,25 @@ public class SocialClientServiceImpl implements SocialClientService { | @@ -267,26 +266,25 @@ public class SocialClientServiceImpl implements SocialClientService { | ||
| 267 | // =================== 客户端管理 =================== | 266 | // =================== 客户端管理 =================== |
| 268 | 267 | ||
| 269 | @Override | 268 | @Override |
| 270 | - public Long createSocialClient(SocialClientCreateReqVO createReqVO) { | 269 | + public Long createSocialClient(SocialClientSaveReqVO createReqVO) { |
| 271 | // 校验重复 | 270 | // 校验重复 |
| 272 | validateSocialClientUnique(null, createReqVO.getUserType(), createReqVO.getSocialType()); | 271 | validateSocialClientUnique(null, createReqVO.getUserType(), createReqVO.getSocialType()); |
| 273 | 272 | ||
| 274 | // 插入 | 273 | // 插入 |
| 275 | - SocialClientDO socialClient = SocialClientConvert.INSTANCE.convert(createReqVO); | ||
| 276 | - socialClientMapper.insert(socialClient); | ||
| 277 | - // 返回 | ||
| 278 | - return socialClient.getId(); | 274 | + SocialClientDO client = BeanUtils.toBean(createReqVO, SocialClientDO.class); |
| 275 | + socialClientMapper.insert(client); | ||
| 276 | + return client.getId(); | ||
| 279 | } | 277 | } |
| 280 | 278 | ||
| 281 | @Override | 279 | @Override |
| 282 | - public void updateSocialClient(SocialClientUpdateReqVO updateReqVO) { | 280 | + public void updateSocialClient(SocialClientSaveReqVO updateReqVO) { |
| 283 | // 校验存在 | 281 | // 校验存在 |
| 284 | validateSocialClientExists(updateReqVO.getId()); | 282 | validateSocialClientExists(updateReqVO.getId()); |
| 285 | // 校验重复 | 283 | // 校验重复 |
| 286 | validateSocialClientUnique(updateReqVO.getId(), updateReqVO.getUserType(), updateReqVO.getSocialType()); | 284 | validateSocialClientUnique(updateReqVO.getId(), updateReqVO.getUserType(), updateReqVO.getSocialType()); |
| 287 | 285 | ||
| 288 | // 更新 | 286 | // 更新 |
| 289 | - SocialClientDO updateObj = SocialClientConvert.INSTANCE.convert(updateReqVO); | 287 | + SocialClientDO updateObj = BeanUtils.toBean(updateReqVO, SocialClientDO.class); |
| 290 | socialClientMapper.updateById(updateObj); | 288 | socialClientMapper.updateById(updateObj); |
| 291 | } | 289 | } |
| 292 | 290 |
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImplTest.java
| @@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.system.service.social; | @@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.system.service.social; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 5 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientCreateReqVO; | ||
| 6 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; | 5 | import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; |
| 7 | -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientUpdateReqVO; | 6 | +import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; |
| 8 | import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; | 7 | import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; |
| 9 | import cn.iocoder.yudao.module.system.dal.mysql.social.SocialClientMapper; | 8 | import cn.iocoder.yudao.module.system.dal.mysql.social.SocialClientMapper; |
| 10 | import org.junit.jupiter.api.Disabled; | 9 | import org.junit.jupiter.api.Disabled; |
| @@ -40,7 +39,8 @@ public class SocialClientServiceImplTest extends BaseDbUnitTest { | @@ -40,7 +39,8 @@ public class SocialClientServiceImplTest extends BaseDbUnitTest { | ||
| 40 | @Test | 39 | @Test |
| 41 | public void testCreateSocialClient_success() { | 40 | public void testCreateSocialClient_success() { |
| 42 | // 准备参数 | 41 | // 准备参数 |
| 43 | - SocialClientCreateReqVO reqVO = randomPojo(SocialClientCreateReqVO.class); | 42 | + SocialClientSaveReqVO reqVO = randomPojo(SocialClientSaveReqVO.class) |
| 43 | + .setId(null); // 防止 id 被赋值 | ||
| 44 | 44 | ||
| 45 | // 调用 | 45 | // 调用 |
| 46 | Long socialClientId = socialClientService.createSocialClient(reqVO); | 46 | Long socialClientId = socialClientService.createSocialClient(reqVO); |
| @@ -48,7 +48,7 @@ public class SocialClientServiceImplTest extends BaseDbUnitTest { | @@ -48,7 +48,7 @@ public class SocialClientServiceImplTest extends BaseDbUnitTest { | ||
| 48 | assertNotNull(socialClientId); | 48 | assertNotNull(socialClientId); |
| 49 | // 校验记录的属性是否正确 | 49 | // 校验记录的属性是否正确 |
| 50 | SocialClientDO socialClient = socialClientMapper.selectById(socialClientId); | 50 | SocialClientDO socialClient = socialClientMapper.selectById(socialClientId); |
| 51 | - assertPojoEquals(reqVO, socialClient); | 51 | + assertPojoEquals(reqVO, socialClient, "id"); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | @Test | 54 | @Test |
| @@ -57,7 +57,7 @@ public class SocialClientServiceImplTest extends BaseDbUnitTest { | @@ -57,7 +57,7 @@ public class SocialClientServiceImplTest extends BaseDbUnitTest { | ||
| 57 | SocialClientDO dbSocialClient = randomPojo(SocialClientDO.class); | 57 | SocialClientDO dbSocialClient = randomPojo(SocialClientDO.class); |
| 58 | socialClientMapper.insert(dbSocialClient);// @Sql: 先插入出一条存在的数据 | 58 | socialClientMapper.insert(dbSocialClient);// @Sql: 先插入出一条存在的数据 |
| 59 | // 准备参数 | 59 | // 准备参数 |
| 60 | - SocialClientUpdateReqVO reqVO = randomPojo(SocialClientUpdateReqVO.class, o -> { | 60 | + SocialClientSaveReqVO reqVO = randomPojo(SocialClientSaveReqVO.class, o -> { |
| 61 | o.setId(dbSocialClient.getId()); // 设置更新的 ID | 61 | o.setId(dbSocialClient.getId()); // 设置更新的 ID |
| 62 | }); | 62 | }); |
| 63 | 63 | ||
| @@ -71,7 +71,7 @@ public class SocialClientServiceImplTest extends BaseDbUnitTest { | @@ -71,7 +71,7 @@ public class SocialClientServiceImplTest extends BaseDbUnitTest { | ||
| 71 | @Test | 71 | @Test |
| 72 | public void testUpdateSocialClient_notExists() { | 72 | public void testUpdateSocialClient_notExists() { |
| 73 | // 准备参数 | 73 | // 准备参数 |
| 74 | - SocialClientUpdateReqVO reqVO = randomPojo(SocialClientUpdateReqVO.class); | 74 | + SocialClientSaveReqVO reqVO = randomPojo(SocialClientSaveReqVO.class); |
| 75 | 75 | ||
| 76 | // 调用, 并断言异常 | 76 | // 调用, 并断言异常 |
| 77 | assertServiceException(() -> socialClientService.updateSocialClient(reqVO), SOCIAL_CLIENT_NOT_EXISTS); | 77 | assertServiceException(() -> socialClientService.updateSocialClient(reqVO), SOCIAL_CLIENT_NOT_EXISTS); |