feat: 新增社交客户端批量删除接口
This commit is contained in:
parent
28bba9776c
commit
f6edee501b
|
@ -19,6 +19,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 社交客户端")
|
||||
|
@ -56,6 +58,15 @@ public class SocialClientController {
|
|||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true)
|
||||
@Operation(summary = "批量删除社交客户端")
|
||||
@PreAuthorize("@ss.hasPermission('system:social-client:delete')")
|
||||
public CommonResult<Boolean> deleteSocialClientList(@RequestParam("ids") List<Long> ids) {
|
||||
socialClientService.deleteSocialClientList(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得社交客户端")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
|
|
|
@ -134,6 +134,13 @@ public interface SocialClientService {
|
|||
*/
|
||||
void deleteSocialClient(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除社交客户端
|
||||
*
|
||||
* @param ids 编号数组
|
||||
*/
|
||||
void deleteSocialClientList(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得社交客户端
|
||||
*
|
||||
|
|
|
@ -466,12 +466,30 @@ public class SocialClientServiceImpl implements SocialClientService {
|
|||
socialClientMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteSocialClientList(List<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
// 校验存在
|
||||
validateSocialClientBatchExists(ids);
|
||||
// 批量删除
|
||||
socialClientMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
private void validateSocialClientExists(Long id) {
|
||||
if (socialClientMapper.selectById(id) == null) {
|
||||
throw exception(SOCIAL_CLIENT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateSocialClientBatchExists(List<Long> ids) {
|
||||
List<SocialClientDO> clients = socialClientMapper.selectByIds(ids);
|
||||
if (clients.size() != ids.size()) {
|
||||
throw exception(SOCIAL_CLIENT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验社交应用是否重复,需要保证 userType + socialType 唯一
|
||||
* 原因是,不同端(userType)选择某个社交登录(socialType)时,需要通过 {@link #buildAuthRequest(Integer, Integer)} 构建对应的请求
|
||||
|
|
Loading…
Reference in New Issue