Commit f6edee501b76f2aa5de70f0296c2d5d22db7f33e
1 parent
28bba977
feat: 新增社交客户端批量删除接口
Showing
3 changed files
with
36 additions
and
0 deletions
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java
| ... | ... | @@ -19,6 +19,8 @@ import org.springframework.security.access.prepost.PreAuthorize; |
| 19 | 19 | import org.springframework.validation.annotation.Validated; |
| 20 | 20 | import org.springframework.web.bind.annotation.*; |
| 21 | 21 | |
| 22 | +import java.util.List; | |
| 23 | + | |
| 22 | 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 23 | 25 | |
| 24 | 26 | @Tag(name = "管理后台 - 社交客户端") |
| ... | ... | @@ -56,6 +58,15 @@ public class SocialClientController { |
| 56 | 58 | return success(true); |
| 57 | 59 | } |
| 58 | 60 | |
| 61 | + @DeleteMapping("/delete-list") | |
| 62 | + @Parameter(name = "ids", description = "编号列表", required = true) | |
| 63 | + @Operation(summary = "批量删除社交客户端") | |
| 64 | + @PreAuthorize("@ss.hasPermission('system:social-client:delete')") | |
| 65 | + public CommonResult<Boolean> deleteSocialClientList(@RequestParam("ids") List<Long> ids) { | |
| 66 | + socialClientService.deleteSocialClientList(ids); | |
| 67 | + return success(true); | |
| 68 | + } | |
| 69 | + | |
| 59 | 70 | @GetMapping("/get") |
| 60 | 71 | @Operation(summary = "获得社交客户端") |
| 61 | 72 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientService.java
| ... | ... | @@ -135,6 +135,13 @@ public interface SocialClientService { |
| 135 | 135 | void deleteSocialClient(Long id); |
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | + * 批量删除社交客户端 | |
| 139 | + * | |
| 140 | + * @param ids 编号数组 | |
| 141 | + */ | |
| 142 | + void deleteSocialClientList(List<Long> ids); | |
| 143 | + | |
| 144 | + /** | |
| 138 | 145 | * 获得社交客户端 |
| 139 | 146 | * |
| 140 | 147 | * @param id 编号 | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java
| ... | ... | @@ -466,12 +466,30 @@ public class SocialClientServiceImpl implements SocialClientService { |
| 466 | 466 | socialClientMapper.deleteById(id); |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | + @Override | |
| 470 | + public void deleteSocialClientList(List<Long> ids) { | |
| 471 | + if (CollUtil.isEmpty(ids)) { | |
| 472 | + return; | |
| 473 | + } | |
| 474 | + // 校验存在 | |
| 475 | + validateSocialClientBatchExists(ids); | |
| 476 | + // 批量删除 | |
| 477 | + socialClientMapper.deleteByIds(ids); | |
| 478 | + } | |
| 479 | + | |
| 469 | 480 | private void validateSocialClientExists(Long id) { |
| 470 | 481 | if (socialClientMapper.selectById(id) == null) { |
| 471 | 482 | throw exception(SOCIAL_CLIENT_NOT_EXISTS); |
| 472 | 483 | } |
| 473 | 484 | } |
| 474 | 485 | |
| 486 | + private void validateSocialClientBatchExists(List<Long> ids) { | |
| 487 | + List<SocialClientDO> clients = socialClientMapper.selectByIds(ids); | |
| 488 | + if (clients.size() != ids.size()) { | |
| 489 | + throw exception(SOCIAL_CLIENT_NOT_EXISTS); | |
| 490 | + } | |
| 491 | + } | |
| 492 | + | |
| 475 | 493 | /** |
| 476 | 494 | * 校验社交应用是否重复,需要保证 userType + socialType 唯一 |
| 477 | 495 | * 原因是,不同端(userType)选择某个社交登录(socialType)时,需要通过 {@link #buildAuthRequest(Integer, Integer)} 构建对应的请求 | ... | ... |