Commit 1c0c6710bb9b780960d316e93913bb0bd8ac08bf
Committed by
Gitee
!1363 feat: system 模块新增批量删除接口
Merge pull request !1363 from puhui999/master-jdk17
Showing
34 changed files
with
530 additions
and
56 deletions
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailAccountController.java
| ... | ... | @@ -13,11 +13,11 @@ import cn.iocoder.yudao.module.system.service.mail.MailAccountService; |
| 13 | 13 | import io.swagger.v3.oas.annotations.Operation; |
| 14 | 14 | import io.swagger.v3.oas.annotations.Parameter; |
| 15 | 15 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 16 | +import jakarta.annotation.Resource; | |
| 17 | +import jakarta.validation.Valid; | |
| 16 | 18 | import org.springframework.security.access.prepost.PreAuthorize; |
| 17 | 19 | import org.springframework.web.bind.annotation.*; |
| 18 | 20 | |
| 19 | -import jakarta.annotation.Resource; | |
| 20 | -import jakarta.validation.Valid; | |
| 21 | 21 | import java.util.List; |
| 22 | 22 | |
| 23 | 23 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| ... | ... | @@ -54,6 +54,15 @@ public class MailAccountController { |
| 54 | 54 | return success(true); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | + @DeleteMapping("/delete-list") | |
| 58 | + @Operation(summary = "批量删除邮箱账号") | |
| 59 | + @Parameter(name = "ids", description = "编号列表", required = true) | |
| 60 | + @PreAuthorize("@ss.hasPermission('system:mail-account:delete')") | |
| 61 | + public CommonResult<Boolean> deleteMailAccountList(@RequestParam("ids") List<Long> ids) { | |
| 62 | + mailAccountService.deleteMailAccountList(ids); | |
| 63 | + return success(true); | |
| 64 | + } | |
| 65 | + | |
| 57 | 66 | @GetMapping("/get") |
| 58 | 67 | @Operation(summary = "获得邮箱账号") |
| 59 | 68 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailTemplateController.java
| ... | ... | @@ -10,11 +10,11 @@ import cn.iocoder.yudao.module.system.service.mail.MailTemplateService; |
| 10 | 10 | import io.swagger.v3.oas.annotations.Operation; |
| 11 | 11 | import io.swagger.v3.oas.annotations.Parameter; |
| 12 | 12 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 13 | +import jakarta.annotation.Resource; | |
| 14 | +import jakarta.validation.Valid; | |
| 13 | 15 | import org.springframework.security.access.prepost.PreAuthorize; |
| 14 | 16 | import org.springframework.web.bind.annotation.*; |
| 15 | 17 | |
| 16 | -import jakarta.annotation.Resource; | |
| 17 | -import jakarta.validation.Valid; | |
| 18 | 18 | import java.util.List; |
| 19 | 19 | |
| 20 | 20 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| ... | ... | @@ -54,6 +54,15 @@ public class MailTemplateController { |
| 54 | 54 | return success(true); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | + @DeleteMapping("/delete-list") | |
| 58 | + @Operation(summary = "批量删除邮件模版") | |
| 59 | + @Parameter(name = "ids", description = "编号列表", required = true) | |
| 60 | + @PreAuthorize("@ss.hasPermission('system:mail-template:delete')") | |
| 61 | + public CommonResult<Boolean> deleteMailTemplateList(@RequestParam("ids") List<Long> ids) { | |
| 62 | + mailTempleService.deleteMailTemplateList(ids); | |
| 63 | + return success(true); | |
| 64 | + } | |
| 65 | + | |
| 57 | 66 | @GetMapping("/get") |
| 58 | 67 | @Operation(summary = "获得邮件模版") |
| 59 | 68 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notice/NoticeController.java
| ... | ... | @@ -14,12 +14,13 @@ import cn.iocoder.yudao.module.system.service.notice.NoticeService; |
| 14 | 14 | import io.swagger.v3.oas.annotations.Operation; |
| 15 | 15 | import io.swagger.v3.oas.annotations.Parameter; |
| 16 | 16 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 17 | +import jakarta.annotation.Resource; | |
| 18 | +import jakarta.validation.Valid; | |
| 17 | 19 | import org.springframework.security.access.prepost.PreAuthorize; |
| 18 | 20 | import org.springframework.validation.annotation.Validated; |
| 19 | 21 | import org.springframework.web.bind.annotation.*; |
| 20 | 22 | |
| 21 | -import jakarta.annotation.Resource; | |
| 22 | -import jakarta.validation.Valid; | |
| 23 | +import java.util.List; | |
| 23 | 24 | |
| 24 | 25 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 25 | 26 | |
| ... | ... | @@ -60,6 +61,15 @@ public class NoticeController { |
| 60 | 61 | return success(true); |
| 61 | 62 | } |
| 62 | 63 | |
| 64 | + @DeleteMapping("/delete-list") | |
| 65 | + @Operation(summary = "批量删除通知公告") | |
| 66 | + @Parameter(name = "ids", description = "编号列表", required = true) | |
| 67 | + @PreAuthorize("@ss.hasPermission('system:notice:delete')") | |
| 68 | + public CommonResult<Boolean> deleteNoticeList(@RequestParam("ids") List<Long> ids) { | |
| 69 | + noticeService.deleteNoticeList(ids); | |
| 70 | + return success(true); | |
| 71 | + } | |
| 72 | + | |
| 63 | 73 | @GetMapping("/page") |
| 64 | 74 | @Operation(summary = "获取通知公告列表") |
| 65 | 75 | @PreAuthorize("@ss.hasPermission('system:notice:query')") | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
| ... | ... | @@ -4,19 +4,23 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | -import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.*; | |
| 7 | +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateRespVO; | |
| 9 | +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSaveReqVO; | |
| 10 | +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSendReqVO; | |
| 8 | 11 | import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; |
| 9 | 12 | import cn.iocoder.yudao.module.system.service.notify.NotifySendService; |
| 10 | 13 | import cn.iocoder.yudao.module.system.service.notify.NotifyTemplateService; |
| 11 | 14 | import io.swagger.v3.oas.annotations.Operation; |
| 12 | 15 | import io.swagger.v3.oas.annotations.Parameter; |
| 13 | 16 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 17 | +import jakarta.annotation.Resource; | |
| 18 | +import jakarta.validation.Valid; | |
| 14 | 19 | import org.springframework.security.access.prepost.PreAuthorize; |
| 15 | 20 | import org.springframework.validation.annotation.Validated; |
| 16 | 21 | import org.springframework.web.bind.annotation.*; |
| 17 | 22 | |
| 18 | -import jakarta.annotation.Resource; | |
| 19 | -import jakarta.validation.Valid; | |
| 23 | +import java.util.List; | |
| 20 | 24 | |
| 21 | 25 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 22 | 26 | |
| ... | ... | @@ -56,6 +60,15 @@ public class NotifyTemplateController { |
| 56 | 60 | return success(true); |
| 57 | 61 | } |
| 58 | 62 | |
| 63 | + @DeleteMapping("/delete-list") | |
| 64 | + @Operation(summary = "批量删除站内信模版") | |
| 65 | + @Parameter(name = "ids", description = "编号列表", required = true) | |
| 66 | + @PreAuthorize("@ss.hasPermission('system:notify-template:delete')") | |
| 67 | + public CommonResult<Boolean> deleteNotifyTemplateList(@RequestParam("ids") List<Long> ids) { | |
| 68 | + notifyTemplateService.deleteNotifyTemplateList(ids); | |
| 69 | + return success(true); | |
| 70 | + } | |
| 71 | + | |
| 59 | 72 | @GetMapping("/get") |
| 60 | 73 | @Operation(summary = "获得站内信模版") |
| 61 | 74 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2ClientController.java
| ... | ... | @@ -11,12 +11,13 @@ import cn.iocoder.yudao.module.system.service.oauth2.OAuth2ClientService; |
| 11 | 11 | import io.swagger.v3.oas.annotations.Operation; |
| 12 | 12 | import io.swagger.v3.oas.annotations.Parameter; |
| 13 | 13 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 14 | +import jakarta.annotation.Resource; | |
| 15 | +import jakarta.validation.Valid; | |
| 14 | 16 | import org.springframework.security.access.prepost.PreAuthorize; |
| 15 | 17 | import org.springframework.validation.annotation.Validated; |
| 16 | 18 | import org.springframework.web.bind.annotation.*; |
| 17 | 19 | |
| 18 | -import jakarta.annotation.Resource; | |
| 19 | -import jakarta.validation.Valid; | |
| 20 | +import java.util.List; | |
| 20 | 21 | |
| 21 | 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 22 | 23 | |
| ... | ... | @@ -53,6 +54,15 @@ public class OAuth2ClientController { |
| 53 | 54 | return success(true); |
| 54 | 55 | } |
| 55 | 56 | |
| 57 | + @DeleteMapping("/delete-list") | |
| 58 | + @Parameter(name = "ids", description = "编号列表", required = true) | |
| 59 | + @Operation(summary = "批量删除 OAuth2 客户端") | |
| 60 | + @PreAuthorize("@ss.hasPermission('system:oauth2-client:delete')") | |
| 61 | + public CommonResult<Boolean> deleteOAuth2ClientList(@RequestParam("ids") List<Long> ids) { | |
| 62 | + oAuth2ClientService.deleteOAuth2ClientList(ids); | |
| 63 | + return success(true); | |
| 64 | + } | |
| 65 | + | |
| 56 | 66 | @GetMapping("/get") |
| 57 | 67 | @Operation(summary = "获得 OAuth2 客户端") |
| 58 | 68 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2TokenController.java
| ... | ... | @@ -12,11 +12,12 @@ import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; |
| 12 | 12 | import io.swagger.v3.oas.annotations.Operation; |
| 13 | 13 | import io.swagger.v3.oas.annotations.Parameter; |
| 14 | 14 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 15 | +import jakarta.annotation.Resource; | |
| 16 | +import jakarta.validation.Valid; | |
| 15 | 17 | import org.springframework.security.access.prepost.PreAuthorize; |
| 16 | 18 | import org.springframework.web.bind.annotation.*; |
| 17 | 19 | |
| 18 | -import jakarta.annotation.Resource; | |
| 19 | -import jakarta.validation.Valid; | |
| 20 | +import java.util.List; | |
| 20 | 21 | |
| 21 | 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 22 | 23 | |
| ... | ... | @@ -47,4 +48,14 @@ public class OAuth2TokenController { |
| 47 | 48 | return success(true); |
| 48 | 49 | } |
| 49 | 50 | |
| 51 | + @DeleteMapping("/delete-list") | |
| 52 | + @Operation(summary = "批量删除访问令牌") | |
| 53 | + @Parameter(name = "accessTokens", description = "访问令牌数组", required = true) | |
| 54 | + @PreAuthorize("@ss.hasPermission('system:oauth2-token:delete')") | |
| 55 | + public CommonResult<Boolean> deleteAccessTokenList(@RequestParam("accessTokens") List<String> accessTokens) { | |
| 56 | + accessTokens.forEach(accessToken -> | |
| 57 | + authService.logout(accessToken, LoginLogTypeEnum.LOGOUT_DELETE.getType())); | |
| 58 | + return success(true); | |
| 59 | + } | |
| 60 | + | |
| 50 | 61 | } | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsChannelController.java
| ... | ... | @@ -12,11 +12,11 @@ import cn.iocoder.yudao.module.system.service.sms.SmsChannelService; |
| 12 | 12 | import io.swagger.v3.oas.annotations.Operation; |
| 13 | 13 | import io.swagger.v3.oas.annotations.Parameter; |
| 14 | 14 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 15 | +import jakarta.annotation.Resource; | |
| 16 | +import jakarta.validation.Valid; | |
| 15 | 17 | import org.springframework.security.access.prepost.PreAuthorize; |
| 16 | 18 | import org.springframework.web.bind.annotation.*; |
| 17 | 19 | |
| 18 | -import jakarta.annotation.Resource; | |
| 19 | -import jakarta.validation.Valid; | |
| 20 | 20 | import java.util.Comparator; |
| 21 | 21 | import java.util.List; |
| 22 | 22 | |
| ... | ... | @@ -54,6 +54,15 @@ public class SmsChannelController { |
| 54 | 54 | return success(true); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | + @DeleteMapping("/delete-list") | |
| 58 | + @Parameter(name = "ids", description = "编号列表", required = true) | |
| 59 | + @Operation(summary = "批量删除短信渠道") | |
| 60 | + @PreAuthorize("@ss.hasPermission('system:sms-channel:delete')") | |
| 61 | + public CommonResult<Boolean> deleteSmsChannelList(@RequestParam("ids") List<Long> ids) { | |
| 62 | + smsChannelService.deleteSmsChannelList(ids); | |
| 63 | + return success(true); | |
| 64 | + } | |
| 65 | + | |
| 57 | 66 | @GetMapping("/get") |
| 58 | 67 | @Operation(summary = "获得短信渠道") |
| 59 | 68 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsTemplateController.java
| 1 | 1 | package cn.iocoder.yudao.module.system.controller.admin.sms; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | -import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.*; | |
| 8 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 9 | +import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO; | |
| 10 | +import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateRespVO; | |
| 11 | +import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO; | |
| 12 | +import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSendReqVO; | |
| 7 | 13 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; |
| 8 | -import cn.iocoder.yudao.module.system.service.sms.SmsTemplateService; | |
| 9 | 14 | import cn.iocoder.yudao.module.system.service.sms.SmsSendService; |
| 10 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 11 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 12 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 13 | -import io.swagger.v3.oas.annotations.tags.Tag; | |
| 14 | -import io.swagger.v3.oas.annotations.Parameter; | |
| 15 | +import cn.iocoder.yudao.module.system.service.sms.SmsTemplateService; | |
| 15 | 16 | import io.swagger.v3.oas.annotations.Operation; |
| 16 | -import org.springframework.security.access.prepost.PreAuthorize; | |
| 17 | -import org.springframework.web.bind.annotation.*; | |
| 18 | - | |
| 17 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 18 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 19 | 19 | import jakarta.annotation.Resource; |
| 20 | 20 | import jakarta.servlet.http.HttpServletResponse; |
| 21 | 21 | import jakarta.validation.Valid; |
| 22 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 23 | +import org.springframework.web.bind.annotation.*; | |
| 24 | + | |
| 22 | 25 | import java.io.IOException; |
| 23 | 26 | import java.util.List; |
| 24 | 27 | |
| ... | ... | @@ -59,6 +62,15 @@ public class SmsTemplateController { |
| 59 | 62 | return success(true); |
| 60 | 63 | } |
| 61 | 64 | |
| 65 | + @DeleteMapping("/delete-list") | |
| 66 | + @Parameter(name = "ids", description = "编号列表", required = true) | |
| 67 | + @Operation(summary = "批量删除短信模板") | |
| 68 | + @PreAuthorize("@ss.hasPermission('system:sms-template:delete')") | |
| 69 | + public CommonResult<Boolean> deleteSmsTemplateList(@RequestParam("ids") List<Long> ids) { | |
| 70 | + smsTemplateService.deleteSmsTemplateList(ids); | |
| 71 | + return success(true); | |
| 72 | + } | |
| 73 | + | |
| 62 | 74 | @GetMapping("/get") |
| 63 | 75 | @Operation(summary = "获得短信模板") |
| 64 | 76 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | ... | ... |
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/controller/admin/tenant/TenantController.java
| ... | ... | @@ -95,6 +95,15 @@ public class TenantController { |
| 95 | 95 | return success(true); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | + @DeleteMapping("/delete-list") | |
| 99 | + @Parameter(name = "ids", description = "编号列表", required = true) | |
| 100 | + @Operation(summary = "批量删除租户") | |
| 101 | + @PreAuthorize("@ss.hasPermission('system:tenant:delete')") | |
| 102 | + public CommonResult<Boolean> deleteTenantList(@RequestParam("ids") List<Long> ids) { | |
| 103 | + tenantService.deleteTenantList(ids); | |
| 104 | + return success(true); | |
| 105 | + } | |
| 106 | + | |
| 98 | 107 | @GetMapping("/get") |
| 99 | 108 | @Operation(summary = "获得租户") |
| 100 | 109 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantPackageController.java
| ... | ... | @@ -4,18 +4,21 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.*; | |
| 7 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackagePageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageRespVO; | |
| 9 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageSaveReqVO; | |
| 10 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageSimpleRespVO; | |
| 8 | 11 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; |
| 9 | 12 | import cn.iocoder.yudao.module.system.service.tenant.TenantPackageService; |
| 10 | -import io.swagger.v3.oas.annotations.tags.Tag; | |
| 11 | -import io.swagger.v3.oas.annotations.Parameter; | |
| 12 | 13 | import io.swagger.v3.oas.annotations.Operation; |
| 14 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 15 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 16 | +import jakarta.annotation.Resource; | |
| 17 | +import jakarta.validation.Valid; | |
| 13 | 18 | import org.springframework.security.access.prepost.PreAuthorize; |
| 14 | 19 | import org.springframework.validation.annotation.Validated; |
| 15 | 20 | import org.springframework.web.bind.annotation.*; |
| 16 | 21 | |
| 17 | -import jakarta.annotation.Resource; | |
| 18 | -import jakarta.validation.Valid; | |
| 19 | 22 | import java.util.List; |
| 20 | 23 | |
| 21 | 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| ... | ... | @@ -53,6 +56,15 @@ public class TenantPackageController { |
| 53 | 56 | return success(true); |
| 54 | 57 | } |
| 55 | 58 | |
| 59 | + @DeleteMapping("/delete-list") | |
| 60 | + @Parameter(name = "ids", description = "编号列表", required = true) | |
| 61 | + @Operation(summary = "批量删除租户套餐") | |
| 62 | + @PreAuthorize("@ss.hasPermission('system:tenant-package:delete')") | |
| 63 | + public CommonResult<Boolean> deleteTenantPackageList(@RequestParam("ids") List<Long> ids) { | |
| 64 | + tenantPackageService.deleteTenantPackageList(ids); | |
| 65 | + return success(true); | |
| 66 | + } | |
| 67 | + | |
| 56 | 68 | @GetMapping("/get") |
| 57 | 69 | @Operation(summary = "获得租户套餐") |
| 58 | 70 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java
| ... | ... | @@ -71,6 +71,15 @@ public class UserController { |
| 71 | 71 | return success(true); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | + @DeleteMapping("/delete-list") | |
| 75 | + @Parameter(name = "ids", description = "编号列表", required = true) | |
| 76 | + @Operation(summary = "批量删除用户") | |
| 77 | + @PreAuthorize("@ss.hasPermission('system:user:delete')") | |
| 78 | + public CommonResult<Boolean> deleteUserList(@RequestParam("ids") List<Long> ids) { | |
| 79 | + userService.deleteUserList(ids); | |
| 80 | + return success(true); | |
| 81 | + } | |
| 82 | + | |
| 74 | 83 | @PutMapping("/update-password") |
| 75 | 84 | @Operation(summary = "重置用户密码") |
| 76 | 85 | @PreAuthorize("@ss.hasPermission('system:user:update-password')") | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailAccountService.java
| ... | ... | @@ -4,8 +4,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO; |
| 5 | 5 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountSaveReqVO; |
| 6 | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; |
| 7 | - | |
| 8 | 7 | import jakarta.validation.Valid; |
| 8 | + | |
| 9 | 9 | import java.util.List; |
| 10 | 10 | |
| 11 | 11 | /** |
| ... | ... | @@ -39,6 +39,13 @@ public interface MailAccountService { |
| 39 | 39 | void deleteMailAccount(Long id); |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | + * 批量删除邮箱账号 | |
| 43 | + * | |
| 44 | + * @param ids 编号列表 | |
| 45 | + */ | |
| 46 | + void deleteMailAccountList(List<Long> ids); | |
| 47 | + | |
| 48 | + /** | |
| 42 | 49 | * 获取邮箱账号信息 |
| 43 | 50 | * |
| 44 | 51 | * @param id 编号 | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailAccountServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.system.service.mail; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | 6 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO; |
| ... | ... | @@ -7,13 +8,13 @@ import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccou |
| 7 | 8 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; |
| 8 | 9 | import cn.iocoder.yudao.module.system.dal.mysql.mail.MailAccountMapper; |
| 9 | 10 | import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; |
| 11 | +import jakarta.annotation.Resource; | |
| 10 | 12 | import lombok.extern.slf4j.Slf4j; |
| 11 | 13 | import org.springframework.cache.annotation.CacheEvict; |
| 12 | 14 | import org.springframework.cache.annotation.Cacheable; |
| 13 | 15 | import org.springframework.stereotype.Service; |
| 14 | 16 | import org.springframework.validation.annotation.Validated; |
| 15 | 17 | |
| 16 | -import jakarta.annotation.Resource; | |
| 17 | 18 | import java.util.List; |
| 18 | 19 | |
| 19 | 20 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| ... | ... | @@ -69,12 +70,41 @@ public class MailAccountServiceImpl implements MailAccountService { |
| 69 | 70 | mailAccountMapper.deleteById(id); |
| 70 | 71 | } |
| 71 | 72 | |
| 73 | + @Override | |
| 74 | + @CacheEvict(value = RedisKeyConstants.MAIL_ACCOUNT, allEntries = true) | |
| 75 | + public void deleteMailAccountList(List<Long> ids) { | |
| 76 | + if (CollUtil.isEmpty(ids)) { | |
| 77 | + return; | |
| 78 | + } | |
| 79 | + // 校验是否存在 | |
| 80 | + validateMailAccountsExists(ids); | |
| 81 | + // 校验是否存在关联模版 | |
| 82 | + for (Long id : ids) { | |
| 83 | + if (mailTemplateService.getMailTemplateCountByAccountId(id) > 0) { | |
| 84 | + throw exception(MAIL_ACCOUNT_RELATE_TEMPLATE_EXISTS); | |
| 85 | + } | |
| 86 | + } | |
| 87 | + // 批量删除 | |
| 88 | + mailAccountMapper.deleteByIds(ids); | |
| 89 | + } | |
| 90 | + | |
| 72 | 91 | private void validateMailAccountExists(Long id) { |
| 73 | 92 | if (mailAccountMapper.selectById(id) == null) { |
| 74 | 93 | throw exception(MAIL_ACCOUNT_NOT_EXISTS); |
| 75 | 94 | } |
| 76 | 95 | } |
| 77 | 96 | |
| 97 | + private void validateMailAccountsExists(List<Long> ids) { | |
| 98 | + if (CollUtil.isEmpty(ids)) { | |
| 99 | + return; | |
| 100 | + } | |
| 101 | + // 校验存在 | |
| 102 | + List<MailAccountDO> accounts = mailAccountMapper.selectByIds(ids); | |
| 103 | + if (CollUtil.isEmpty(accounts) || accounts.size() != ids.size()) { | |
| 104 | + throw exception(MAIL_ACCOUNT_NOT_EXISTS); | |
| 105 | + } | |
| 106 | + } | |
| 107 | + | |
| 78 | 108 | @Override |
| 79 | 109 | public MailAccountDO getMailAccount(Long id) { |
| 80 | 110 | return mailAccountMapper.selectById(id); | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailTemplateService.java
| ... | ... | @@ -4,8 +4,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplatePageReqVO; |
| 5 | 5 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateSaveReqVO; |
| 6 | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; |
| 7 | - | |
| 8 | 7 | import jakarta.validation.Valid; |
| 8 | + | |
| 9 | 9 | import java.util.List; |
| 10 | 10 | import java.util.Map; |
| 11 | 11 | |
| ... | ... | @@ -40,6 +40,13 @@ public interface MailTemplateService { |
| 40 | 40 | void deleteMailTemplate(Long id); |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | + * 批量删除邮件模版 | |
| 44 | + * | |
| 45 | + * @param ids 编号列表 | |
| 46 | + */ | |
| 47 | + void deleteMailTemplateList(List<Long> ids); | |
| 48 | + | |
| 49 | + /** | |
| 43 | 50 | * 获取邮件模版 |
| 44 | 51 | * |
| 45 | 52 | * @param id 编号 | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailTemplateServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.system.service.mail; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.hutool.core.util.ObjUtil; |
| 4 | 5 | import cn.hutool.core.util.ReUtil; |
| 5 | 6 | import cn.hutool.core.util.StrUtil; |
| ... | ... | @@ -11,14 +12,14 @@ import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; |
| 11 | 12 | import cn.iocoder.yudao.module.system.dal.mysql.mail.MailTemplateMapper; |
| 12 | 13 | import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; |
| 13 | 14 | import com.google.common.annotations.VisibleForTesting; |
| 15 | +import jakarta.annotation.Resource; | |
| 16 | +import jakarta.validation.Valid; | |
| 14 | 17 | import lombok.extern.slf4j.Slf4j; |
| 15 | 18 | import org.springframework.cache.annotation.CacheEvict; |
| 16 | 19 | import org.springframework.cache.annotation.Cacheable; |
| 17 | 20 | import org.springframework.stereotype.Service; |
| 18 | 21 | import org.springframework.validation.annotation.Validated; |
| 19 | 22 | |
| 20 | -import jakarta.annotation.Resource; | |
| 21 | -import jakarta.validation.Valid; | |
| 22 | 23 | import java.util.List; |
| 23 | 24 | import java.util.Map; |
| 24 | 25 | import java.util.regex.Pattern; |
| ... | ... | @@ -97,12 +98,36 @@ public class MailTemplateServiceImpl implements MailTemplateService { |
| 97 | 98 | mailTemplateMapper.deleteById(id); |
| 98 | 99 | } |
| 99 | 100 | |
| 101 | + @Override | |
| 102 | + @CacheEvict(cacheNames = RedisKeyConstants.MAIL_TEMPLATE, | |
| 103 | + allEntries = true) // allEntries 清空所有缓存,因为 id 不是直接的缓存 code,不好清理 | |
| 104 | + public void deleteMailTemplateList(List<Long> ids) { | |
| 105 | + if (CollUtil.isEmpty(ids)) { | |
| 106 | + return; | |
| 107 | + } | |
| 108 | + // 校验存在 | |
| 109 | + validateMailTemplatesExists(ids); | |
| 110 | + // 批量删除 | |
| 111 | + mailTemplateMapper.deleteByIds(ids); | |
| 112 | + } | |
| 113 | + | |
| 100 | 114 | private void validateMailTemplateExists(Long id) { |
| 101 | 115 | if (mailTemplateMapper.selectById(id) == null) { |
| 102 | 116 | throw exception(MAIL_TEMPLATE_NOT_EXISTS); |
| 103 | 117 | } |
| 104 | 118 | } |
| 105 | 119 | |
| 120 | + private void validateMailTemplatesExists(List<Long> ids) { | |
| 121 | + if (CollUtil.isEmpty(ids)) { | |
| 122 | + return; | |
| 123 | + } | |
| 124 | + // 校验存在 | |
| 125 | + List<MailTemplateDO> templates = mailTemplateMapper.selectByIds(ids); | |
| 126 | + if (CollUtil.isEmpty(templates) || templates.size() != ids.size()) { | |
| 127 | + throw exception(MAIL_TEMPLATE_NOT_EXISTS); | |
| 128 | + } | |
| 129 | + } | |
| 130 | + | |
| 106 | 131 | @Override |
| 107 | 132 | public MailTemplateDO getMailTemplate(Long id) {return mailTemplateMapper.selectById(id);} |
| 108 | 133 | |
| ... | ... | @@ -125,14 +150,19 @@ public class MailTemplateServiceImpl implements MailTemplateService { |
| 125 | 150 | return StrUtil.format(content, params); |
| 126 | 151 | } |
| 127 | 152 | |
| 128 | - @VisibleForTesting | |
| 129 | - public List<String> parseTemplateContentParams(String content) { | |
| 130 | - return ReUtil.findAllGroup1(PATTERN_PARAMS, content); | |
| 131 | - } | |
| 132 | - | |
| 133 | 153 | @Override |
| 134 | 154 | public long getMailTemplateCountByAccountId(Long accountId) { |
| 135 | 155 | return mailTemplateMapper.selectCountByAccountId(accountId); |
| 136 | 156 | } |
| 137 | 157 | |
| 158 | + /** | |
| 159 | + * 获得邮件模板中的参数,形如 {key} | |
| 160 | + * | |
| 161 | + * @param content 内容 | |
| 162 | + * @return 参数列表 | |
| 163 | + */ | |
| 164 | + private List<String> parseTemplateContentParams(String content) { | |
| 165 | + return ReUtil.findAllGroup1(PATTERN_PARAMS, content); | |
| 166 | + } | |
| 167 | + | |
| 138 | 168 | } | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/notice/NoticeService.java
| ... | ... | @@ -5,6 +5,8 @@ import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO |
| 5 | 5 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeSaveReqVO; |
| 6 | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; |
| 7 | 7 | |
| 8 | +import java.util.List; | |
| 9 | + | |
| 8 | 10 | /** |
| 9 | 11 | * 通知公告 Service 接口 |
| 10 | 12 | */ |
| ... | ... | @@ -33,6 +35,13 @@ public interface NoticeService { |
| 33 | 35 | void deleteNotice(Long id); |
| 34 | 36 | |
| 35 | 37 | /** |
| 38 | + * 批量删除通知公告 | |
| 39 | + * | |
| 40 | + * @param ids 编号列表 | |
| 41 | + */ | |
| 42 | + void deleteNoticeList(List<Long> ids); | |
| 43 | + | |
| 44 | + /** | |
| 36 | 45 | * 获得通知公告分页列表 |
| 37 | 46 | * |
| 38 | 47 | * @param reqVO 分页条件 | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/notice/NoticeServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.system.service.notice; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | 6 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO; |
| ... | ... | @@ -7,9 +8,10 @@ import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeSaveReqVO |
| 7 | 8 | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; |
| 8 | 9 | import cn.iocoder.yudao.module.system.dal.mysql.notice.NoticeMapper; |
| 9 | 10 | import com.google.common.annotations.VisibleForTesting; |
| 11 | +import jakarta.annotation.Resource; | |
| 10 | 12 | import org.springframework.stereotype.Service; |
| 11 | 13 | |
| 12 | -import jakarta.annotation.Resource; | |
| 14 | +import java.util.List; | |
| 13 | 15 | |
| 14 | 16 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 15 | 17 | import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTICE_NOT_FOUND; |
| ... | ... | @@ -50,6 +52,14 @@ public class NoticeServiceImpl implements NoticeService { |
| 50 | 52 | } |
| 51 | 53 | |
| 52 | 54 | @Override |
| 55 | + public void deleteNoticeList(List<Long> ids) { | |
| 56 | + // 校验是否存在 | |
| 57 | + validateNoticesExists(ids); | |
| 58 | + // 批量删除通知公告 | |
| 59 | + noticeMapper.deleteByIds(ids); | |
| 60 | + } | |
| 61 | + | |
| 62 | + @Override | |
| 53 | 63 | public PageResult<NoticeDO> getNoticePage(NoticePageReqVO reqVO) { |
| 54 | 64 | return noticeMapper.selectPage(reqVO); |
| 55 | 65 | } |
| ... | ... | @@ -70,4 +80,15 @@ public class NoticeServiceImpl implements NoticeService { |
| 70 | 80 | } |
| 71 | 81 | } |
| 72 | 82 | |
| 83 | + private void validateNoticesExists(List<Long> ids) { | |
| 84 | + if (CollUtil.isEmpty(ids)) { | |
| 85 | + return; | |
| 86 | + } | |
| 87 | + // 校验存在 | |
| 88 | + List<NoticeDO> notices = noticeMapper.selectByIds(ids); | |
| 89 | + if (CollUtil.isEmpty(notices) || notices.size() != ids.size()) { | |
| 90 | + throw exception(NOTICE_NOT_FOUND); | |
| 91 | + } | |
| 92 | + } | |
| 93 | + | |
| 73 | 94 | } | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java
| ... | ... | @@ -4,8 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO; |
| 5 | 5 | import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSaveReqVO; |
| 6 | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; |
| 7 | - | |
| 8 | 7 | import jakarta.validation.Valid; |
| 8 | + | |
| 9 | +import java.util.List; | |
| 9 | 10 | import java.util.Map; |
| 10 | 11 | |
| 11 | 12 | /** |
| ... | ... | @@ -38,6 +39,13 @@ public interface NotifyTemplateService { |
| 38 | 39 | void deleteNotifyTemplate(Long id); |
| 39 | 40 | |
| 40 | 41 | /** |
| 42 | + * 批量删除站内信模版 | |
| 43 | + * | |
| 44 | + * @param ids 编号列表 | |
| 45 | + */ | |
| 46 | + void deleteNotifyTemplateList(List<Long> ids); | |
| 47 | + | |
| 48 | + /** | |
| 41 | 49 | * 获得站内信模版 |
| 42 | 50 | * |
| 43 | 51 | * @param id 编号 | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.system.service.notify; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.hutool.core.util.ReUtil; |
| 4 | 5 | import cn.hutool.core.util.StrUtil; |
| 5 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| ... | ... | @@ -10,13 +11,13 @@ import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; |
| 10 | 11 | import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyTemplateMapper; |
| 11 | 12 | import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; |
| 12 | 13 | import com.google.common.annotations.VisibleForTesting; |
| 14 | +import jakarta.annotation.Resource; | |
| 13 | 15 | import lombok.extern.slf4j.Slf4j; |
| 14 | 16 | import org.springframework.cache.annotation.CacheEvict; |
| 15 | 17 | import org.springframework.cache.annotation.Cacheable; |
| 16 | 18 | import org.springframework.stereotype.Service; |
| 17 | 19 | import org.springframework.validation.annotation.Validated; |
| 18 | 20 | |
| 19 | -import jakarta.annotation.Resource; | |
| 20 | 21 | import java.util.List; |
| 21 | 22 | import java.util.Map; |
| 22 | 23 | import java.util.regex.Pattern; |
| ... | ... | @@ -85,6 +86,27 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService { |
| 85 | 86 | notifyTemplateMapper.deleteById(id); |
| 86 | 87 | } |
| 87 | 88 | |
| 89 | + @Override | |
| 90 | + @CacheEvict(cacheNames = RedisKeyConstants.NOTIFY_TEMPLATE, | |
| 91 | + allEntries = true) // allEntries 清空所有缓存,因为 id 不是直接的缓存 code,不好清理 | |
| 92 | + public void deleteNotifyTemplateList(List<Long> ids) { | |
| 93 | + // 校验存在 | |
| 94 | + validateNotifyTemplatesExists(ids); | |
| 95 | + // 批量删除 | |
| 96 | + notifyTemplateMapper.deleteByIds(ids); | |
| 97 | + } | |
| 98 | + | |
| 99 | + private void validateNotifyTemplatesExists(List<Long> ids) { | |
| 100 | + if (CollUtil.isEmpty(ids)) { | |
| 101 | + return; | |
| 102 | + } | |
| 103 | + // 校验存在 | |
| 104 | + List<NotifyTemplateDO> templates = notifyTemplateMapper.selectByIds(ids); | |
| 105 | + if (CollUtil.isEmpty(templates) || templates.size() != ids.size()) { | |
| 106 | + throw exception(NOTIFY_TEMPLATE_NOT_EXISTS); | |
| 107 | + } | |
| 108 | + } | |
| 109 | + | |
| 88 | 110 | private void validateNotifyTemplateExists(Long id) { |
| 89 | 111 | if (notifyTemplateMapper.selectById(id) == null) { |
| 90 | 112 | throw exception(NOTIFY_TEMPLATE_NOT_EXISTS); | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ClientService.java
| ... | ... | @@ -4,9 +4,10 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.client.OAuth2ClientPageReqVO; |
| 5 | 5 | import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.client.OAuth2ClientSaveReqVO; |
| 6 | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; |
| 7 | - | |
| 8 | 7 | import jakarta.validation.Valid; |
| 8 | + | |
| 9 | 9 | import java.util.Collection; |
| 10 | +import java.util.List; | |
| 10 | 11 | |
| 11 | 12 | /** |
| 12 | 13 | * OAuth2.0 Client Service 接口 |
| ... | ... | @@ -40,6 +41,13 @@ public interface OAuth2ClientService { |
| 40 | 41 | void deleteOAuth2Client(Long id); |
| 41 | 42 | |
| 42 | 43 | /** |
| 44 | + * 批量删除 OAuth2 客户端 | |
| 45 | + * | |
| 46 | + * @param ids 编号数组 | |
| 47 | + */ | |
| 48 | + void deleteOAuth2ClientList(List<Long> ids); | |
| 49 | + | |
| 50 | + /** | |
| 43 | 51 | * 获得 OAuth2 客户端 |
| 44 | 52 | * |
| 45 | 53 | * @param id 编号 | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ClientServiceImpl.java
| ... | ... | @@ -14,14 +14,15 @@ import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; |
| 14 | 14 | import cn.iocoder.yudao.module.system.dal.mysql.oauth2.OAuth2ClientMapper; |
| 15 | 15 | import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; |
| 16 | 16 | import com.google.common.annotations.VisibleForTesting; |
| 17 | +import jakarta.annotation.Resource; | |
| 17 | 18 | import lombok.extern.slf4j.Slf4j; |
| 18 | 19 | import org.springframework.cache.annotation.CacheEvict; |
| 19 | 20 | import org.springframework.cache.annotation.Cacheable; |
| 20 | 21 | import org.springframework.stereotype.Service; |
| 21 | 22 | import org.springframework.validation.annotation.Validated; |
| 22 | 23 | |
| 23 | -import jakarta.annotation.Resource; | |
| 24 | 24 | import java.util.Collection; |
| 25 | +import java.util.List; | |
| 25 | 26 | |
| 26 | 27 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 27 | 28 | import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; |
| ... | ... | @@ -72,12 +73,32 @@ public class OAuth2ClientServiceImpl implements OAuth2ClientService { |
| 72 | 73 | oauth2ClientMapper.deleteById(id); |
| 73 | 74 | } |
| 74 | 75 | |
| 76 | + @Override | |
| 77 | + @CacheEvict(cacheNames = RedisKeyConstants.OAUTH_CLIENT, | |
| 78 | + allEntries = true) // allEntries 清空所有缓存,因为 id 不是直接的缓存 key,不好清理 | |
| 79 | + public void deleteOAuth2ClientList(List<Long> ids) { | |
| 80 | + if (CollUtil.isEmpty(ids)) { | |
| 81 | + return; | |
| 82 | + } | |
| 83 | + // 校验存在 | |
| 84 | + validateOAuth2ClientBatchExists(ids); | |
| 85 | + // 批量删除 | |
| 86 | + oauth2ClientMapper.deleteByIds(ids); | |
| 87 | + } | |
| 88 | + | |
| 75 | 89 | private void validateOAuth2ClientExists(Long id) { |
| 76 | 90 | if (oauth2ClientMapper.selectById(id) == null) { |
| 77 | 91 | throw exception(OAUTH2_CLIENT_NOT_EXISTS); |
| 78 | 92 | } |
| 79 | 93 | } |
| 80 | 94 | |
| 95 | + private void validateOAuth2ClientBatchExists(List<Long> ids) { | |
| 96 | + List<OAuth2ClientDO> clients = oauth2ClientMapper.selectByIds(ids); | |
| 97 | + if (clients.size() != ids.size()) { | |
| 98 | + throw exception(OAUTH2_CLIENT_NOT_EXISTS); | |
| 99 | + } | |
| 100 | + } | |
| 101 | + | |
| 81 | 102 | @VisibleForTesting |
| 82 | 103 | void validateClientIdExists(Long id, String clientId) { |
| 83 | 104 | OAuth2ClientDO client = oauth2ClientMapper.selectByClientId(clientId); | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsChannelService.java
| 1 | 1 | package cn.iocoder.yudao.module.system.service.sms; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.system.framework.sms.core.client.SmsClient; | |
| 5 | 4 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO; |
| 6 | 5 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelSaveReqVO; |
| 7 | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; |
| 8 | - | |
| 7 | +import cn.iocoder.yudao.module.system.framework.sms.core.client.SmsClient; | |
| 9 | 8 | import jakarta.validation.Valid; |
| 9 | + | |
| 10 | 10 | import java.util.List; |
| 11 | 11 | |
| 12 | 12 | /** |
| ... | ... | @@ -40,6 +40,13 @@ public interface SmsChannelService { |
| 40 | 40 | void deleteSmsChannel(Long id); |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | + * 批量删除短信渠道 | |
| 44 | + * | |
| 45 | + * @param ids 编号数组 | |
| 46 | + */ | |
| 47 | + void deleteSmsChannelList(List<Long> ids); | |
| 48 | + | |
| 49 | + /** | |
| 43 | 50 | * 获得短信渠道 |
| 44 | 51 | * |
| 45 | 52 | * @param id 编号 | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsChannelServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.system.service.sms; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | 6 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO; |
| ... | ... | @@ -65,6 +66,23 @@ public class SmsChannelServiceImpl implements SmsChannelService { |
| 65 | 66 | smsChannelMapper.deleteById(id); |
| 66 | 67 | } |
| 67 | 68 | |
| 69 | + @Override | |
| 70 | + public void deleteSmsChannelList(List<Long> ids) { | |
| 71 | + if (CollUtil.isEmpty(ids)) { | |
| 72 | + return; | |
| 73 | + } | |
| 74 | + // 校验存在 | |
| 75 | + validateSmsChannelBatchExists(ids); | |
| 76 | + // 校验是否有在使用该账号的模版 | |
| 77 | + for (Long id : ids) { | |
| 78 | + if (smsTemplateService.getSmsTemplateCountByChannelId(id) > 0) { | |
| 79 | + throw exception(SMS_CHANNEL_HAS_CHILDREN); | |
| 80 | + } | |
| 81 | + } | |
| 82 | + // 批量删除 | |
| 83 | + smsChannelMapper.deleteByIds(ids); | |
| 84 | + } | |
| 85 | + | |
| 68 | 86 | private SmsChannelDO validateSmsChannelExists(Long id) { |
| 69 | 87 | SmsChannelDO channel = smsChannelMapper.selectById(id); |
| 70 | 88 | if (channel == null) { |
| ... | ... | @@ -73,6 +91,13 @@ public class SmsChannelServiceImpl implements SmsChannelService { |
| 73 | 91 | return channel; |
| 74 | 92 | } |
| 75 | 93 | |
| 94 | + private void validateSmsChannelBatchExists(List<Long> ids) { | |
| 95 | + List<SmsChannelDO> channels = smsChannelMapper.selectByIds(ids); | |
| 96 | + if (channels.size() != ids.size()) { | |
| 97 | + throw exception(SMS_CHANNEL_NOT_EXISTS); | |
| 98 | + } | |
| 99 | + } | |
| 100 | + | |
| 76 | 101 | @Override |
| 77 | 102 | public SmsChannelDO getSmsChannel(Long id) { |
| 78 | 103 | return smsChannelMapper.selectById(id); | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsTemplateService.java
| ... | ... | @@ -4,8 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO; |
| 5 | 5 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO; |
| 6 | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; |
| 7 | - | |
| 8 | 7 | import jakarta.validation.Valid; |
| 8 | + | |
| 9 | +import java.util.List; | |
| 9 | 10 | import java.util.Map; |
| 10 | 11 | |
| 11 | 12 | /** |
| ... | ... | @@ -39,6 +40,13 @@ public interface SmsTemplateService { |
| 39 | 40 | void deleteSmsTemplate(Long id); |
| 40 | 41 | |
| 41 | 42 | /** |
| 43 | + * 批量删除短信模板 | |
| 44 | + * | |
| 45 | + * @param ids 编号数组 | |
| 46 | + */ | |
| 47 | + void deleteSmsTemplateList(List<Long> ids); | |
| 48 | + | |
| 49 | + /** | |
| 42 | 50 | * 获得短信模板 |
| 43 | 51 | * |
| 44 | 52 | * @param id 编号 | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsTemplateServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.system.service.sms; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.hutool.core.exceptions.ExceptionUtil; |
| 4 | 5 | import cn.hutool.core.lang.Assert; |
| 5 | 6 | import cn.hutool.core.util.ReUtil; |
| ... | ... | @@ -7,22 +8,22 @@ import cn.hutool.core.util.StrUtil; |
| 7 | 8 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 8 | 9 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 9 | 10 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 10 | -import cn.iocoder.yudao.module.system.framework.sms.core.client.SmsClient; | |
| 11 | -import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsTemplateRespDTO; | |
| 12 | -import cn.iocoder.yudao.module.system.framework.sms.core.enums.SmsTemplateAuditStatusEnum; | |
| 13 | 11 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO; |
| 14 | 12 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO; |
| 15 | 13 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; |
| 16 | 14 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; |
| 17 | 15 | import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsTemplateMapper; |
| 18 | 16 | import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; |
| 17 | +import cn.iocoder.yudao.module.system.framework.sms.core.client.SmsClient; | |
| 18 | +import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsTemplateRespDTO; | |
| 19 | +import cn.iocoder.yudao.module.system.framework.sms.core.enums.SmsTemplateAuditStatusEnum; | |
| 19 | 20 | import com.google.common.annotations.VisibleForTesting; |
| 21 | +import jakarta.annotation.Resource; | |
| 20 | 22 | import lombok.extern.slf4j.Slf4j; |
| 21 | 23 | import org.springframework.cache.annotation.CacheEvict; |
| 22 | 24 | import org.springframework.cache.annotation.Cacheable; |
| 23 | 25 | import org.springframework.stereotype.Service; |
| 24 | 26 | |
| 25 | -import jakarta.annotation.Resource; | |
| 26 | 27 | import java.util.List; |
| 27 | 28 | import java.util.Map; |
| 28 | 29 | import java.util.Objects; |
| ... | ... | @@ -100,12 +101,32 @@ public class SmsTemplateServiceImpl implements SmsTemplateService { |
| 100 | 101 | smsTemplateMapper.deleteById(id); |
| 101 | 102 | } |
| 102 | 103 | |
| 104 | + @Override | |
| 105 | + @CacheEvict(cacheNames = RedisKeyConstants.SMS_TEMPLATE, | |
| 106 | + allEntries = true) // allEntries 清空所有缓存,因为 id 不是直接的缓存 code,不好清理 | |
| 107 | + public void deleteSmsTemplateList(List<Long> ids) { | |
| 108 | + if (CollUtil.isEmpty(ids)) { | |
| 109 | + return; | |
| 110 | + } | |
| 111 | + // 校验存在 | |
| 112 | + validateSmsTemplateListExists(ids); | |
| 113 | + // 批量删除 | |
| 114 | + smsTemplateMapper.deleteByIds(ids); | |
| 115 | + } | |
| 116 | + | |
| 103 | 117 | private void validateSmsTemplateExists(Long id) { |
| 104 | 118 | if (smsTemplateMapper.selectById(id) == null) { |
| 105 | 119 | throw exception(SMS_TEMPLATE_NOT_EXISTS); |
| 106 | 120 | } |
| 107 | 121 | } |
| 108 | 122 | |
| 123 | + private void validateSmsTemplateListExists(List<Long> ids) { | |
| 124 | + List<SmsTemplateDO> templates = smsTemplateMapper.selectByIds(ids); | |
| 125 | + if (templates.size() != ids.size()) { | |
| 126 | + throw exception(SMS_TEMPLATE_NOT_EXISTS); | |
| 127 | + } | |
| 128 | + } | |
| 129 | + | |
| 109 | 130 | @Override |
| 110 | 131 | public SmsTemplateDO getSmsTemplate(Long id) { |
| 111 | 132 | return smsTemplateMapper.selectById(id); | ... | ... |
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)} 构建对应的请求 | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageService.java
| ... | ... | @@ -4,8 +4,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackagePageReqVO; |
| 5 | 5 | import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageSaveReqVO; |
| 6 | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; |
| 7 | - | |
| 8 | 7 | import jakarta.validation.Valid; |
| 8 | + | |
| 9 | 9 | import java.util.List; |
| 10 | 10 | |
| 11 | 11 | /** |
| ... | ... | @@ -38,6 +38,13 @@ public interface TenantPackageService { |
| 38 | 38 | void deleteTenantPackage(Long id); |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | + * 批量删除租户套餐 | |
| 42 | + * | |
| 43 | + * @param ids 编号数组 | |
| 44 | + */ | |
| 45 | + void deleteTenantPackageList(List<Long> ids); | |
| 46 | + | |
| 47 | + /** | |
| 41 | 48 | * 获得租户套餐 |
| 42 | 49 | * |
| 43 | 50 | * @param id 编号 | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageServiceImpl.java
| ... | ... | @@ -12,11 +12,11 @@ import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; |
| 12 | 12 | import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantPackageMapper; |
| 13 | 13 | import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
| 14 | 14 | import com.google.common.annotations.VisibleForTesting; |
| 15 | +import jakarta.annotation.Resource; | |
| 15 | 16 | import org.springframework.context.annotation.Lazy; |
| 16 | 17 | import org.springframework.stereotype.Service; |
| 17 | 18 | import org.springframework.validation.annotation.Validated; |
| 18 | 19 | |
| 19 | -import jakarta.annotation.Resource; | |
| 20 | 20 | import java.util.List; |
| 21 | 21 | |
| 22 | 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| ... | ... | @@ -76,6 +76,19 @@ public class TenantPackageServiceImpl implements TenantPackageService { |
| 76 | 76 | tenantPackageMapper.deleteById(id); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | + @Override | |
| 80 | + public void deleteTenantPackageList(List<Long> ids) { | |
| 81 | + if (CollUtil.isEmpty(ids)) { | |
| 82 | + return; | |
| 83 | + } | |
| 84 | + // 校验存在 | |
| 85 | + ids.forEach(this::validateTenantPackageExists); | |
| 86 | + // 校验正在使用 | |
| 87 | + validateTenantUsedBatch(ids); | |
| 88 | + // 批量删除 | |
| 89 | + tenantPackageMapper.deleteByIds(ids); | |
| 90 | + } | |
| 91 | + | |
| 79 | 92 | private TenantPackageDO validateTenantPackageExists(Long id) { |
| 80 | 93 | TenantPackageDO tenantPackage = tenantPackageMapper.selectById(id); |
| 81 | 94 | if (tenantPackage == null) { |
| ... | ... | @@ -90,6 +103,20 @@ public class TenantPackageServiceImpl implements TenantPackageService { |
| 90 | 103 | } |
| 91 | 104 | } |
| 92 | 105 | |
| 106 | + /** | |
| 107 | + * 校验租户套餐是否被使用 - 批量 | |
| 108 | + * | |
| 109 | + * @param ids 租户套餐编号数组 | |
| 110 | + */ | |
| 111 | + private void validateTenantUsedBatch(List<Long> ids) { | |
| 112 | + // 查询是否有租户正在使用该套餐 | |
| 113 | + for (Long id : ids) { | |
| 114 | + if (tenantService.getTenantCountByPackageId(id) > 0) { | |
| 115 | + throw exception(TENANT_PACKAGE_USED); | |
| 116 | + } | |
| 117 | + } | |
| 118 | + } | |
| 119 | + | |
| 93 | 120 | @Override |
| 94 | 121 | public TenantPackageDO getTenantPackage(Long id) { |
| 95 | 122 | return tenantPackageMapper.selectById(id); | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java
| ... | ... | @@ -7,8 +7,8 @@ import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSa |
| 7 | 7 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; |
| 8 | 8 | import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler; |
| 9 | 9 | import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler; |
| 10 | - | |
| 11 | 10 | import jakarta.validation.Valid; |
| 11 | + | |
| 12 | 12 | import java.util.List; |
| 13 | 13 | import java.util.Set; |
| 14 | 14 | |
| ... | ... | @@ -50,6 +50,13 @@ public interface TenantService { |
| 50 | 50 | void deleteTenant(Long id); |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | + * 批量删除租户 | |
| 54 | + * | |
| 55 | + * @param ids 编号数组 | |
| 56 | + */ | |
| 57 | + void deleteTenantList(List<Long> ids); | |
| 58 | + | |
| 59 | + /** | |
| 53 | 60 | * 获得租户 |
| 54 | 61 | * |
| 55 | 62 | * @param id 编号 | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java
| ... | ... | @@ -31,13 +31,13 @@ import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler; |
| 31 | 31 | import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler; |
| 32 | 32 | import cn.iocoder.yudao.module.system.service.user.AdminUserService; |
| 33 | 33 | import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
| 34 | +import jakarta.annotation.Resource; | |
| 34 | 35 | import lombok.extern.slf4j.Slf4j; |
| 35 | 36 | import org.springframework.beans.factory.annotation.Autowired; |
| 36 | 37 | import org.springframework.context.annotation.Lazy; |
| 37 | 38 | import org.springframework.stereotype.Service; |
| 38 | 39 | import org.springframework.validation.annotation.Validated; |
| 39 | 40 | |
| 40 | -import jakarta.annotation.Resource; | |
| 41 | 41 | import java.util.List; |
| 42 | 42 | import java.util.Objects; |
| 43 | 43 | import java.util.Set; |
| ... | ... | @@ -225,6 +225,17 @@ public class TenantServiceImpl implements TenantService { |
| 225 | 225 | tenantMapper.deleteById(id); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | + @Override | |
| 229 | + public void deleteTenantList(List<Long> ids) { | |
| 230 | + if (CollUtil.isEmpty(ids)) { | |
| 231 | + return; | |
| 232 | + } | |
| 233 | + // 校验存在 | |
| 234 | + validateUpdateTenantBatch(ids); | |
| 235 | + // 批量删除 | |
| 236 | + tenantMapper.deleteByIds(ids); | |
| 237 | + } | |
| 238 | + | |
| 228 | 239 | private TenantDO validateUpdateTenant(Long id) { |
| 229 | 240 | TenantDO tenant = tenantMapper.selectById(id); |
| 230 | 241 | if (tenant == null) { |
| ... | ... | @@ -237,6 +248,26 @@ public class TenantServiceImpl implements TenantService { |
| 237 | 248 | return tenant; |
| 238 | 249 | } |
| 239 | 250 | |
| 251 | + /** | |
| 252 | + * 校验租户是否可以更新 - 批量 | |
| 253 | + * | |
| 254 | + * @param ids 租户编号数组 | |
| 255 | + */ | |
| 256 | + private void validateUpdateTenantBatch(List<Long> ids) { | |
| 257 | + // 查询租户 | |
| 258 | + List<TenantDO> tenants = tenantMapper.selectByIds(ids); | |
| 259 | + if (tenants.size() != ids.size()) { | |
| 260 | + throw exception(TENANT_NOT_EXISTS); | |
| 261 | + } | |
| 262 | + | |
| 263 | + // 校验是否有系统内置租户 | |
| 264 | + tenants.forEach(tenant -> { | |
| 265 | + if (isSystemTenant(tenant)) { | |
| 266 | + throw exception(TENANT_CAN_NOT_UPDATE_SYSTEM); | |
| 267 | + } | |
| 268 | + }); | |
| 269 | + } | |
| 270 | + | |
| 240 | 271 | @Override |
| 241 | 272 | public TenantDO getTenant(Long id) { |
| 242 | 273 | return tenantMapper.selectById(id); | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java
| ... | ... | @@ -249,6 +249,28 @@ public class AdminUserServiceImpl implements AdminUserService { |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | @Override |
| 252 | + @Transactional(rollbackFor = Exception.class) | |
| 253 | + public void deleteUserList(List<Long> ids) { | |
| 254 | + if (CollUtil.isEmpty(ids)) { | |
| 255 | + return; | |
| 256 | + } | |
| 257 | + // 1. 校验用户存在 | |
| 258 | + List<AdminUserDO> users = userMapper.selectByIds(ids); | |
| 259 | + if (CollUtil.isEmpty(users)) { | |
| 260 | + return; | |
| 261 | + } | |
| 262 | + | |
| 263 | + // 2. 批量删除用户 | |
| 264 | + userMapper.deleteByIds(ids); | |
| 265 | + | |
| 266 | + // 3. 批量删除用户关联数据 | |
| 267 | + ids.forEach(id -> { | |
| 268 | + permissionService.processUserDeleted(id); | |
| 269 | + userPostMapper.deleteByUserId(id); | |
| 270 | + }); | |
| 271 | + } | |
| 272 | + | |
| 273 | + @Override | |
| 252 | 274 | public AdminUserDO getUserByUsername(String username) { |
| 253 | 275 | return userMapper.selectByUsername(username); |
| 254 | 276 | } | ... | ... |