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,11 +13,11 @@ import cn.iocoder.yudao.module.system.service.mail.MailAccountService; | ||
| 13 | import io.swagger.v3.oas.annotations.Operation; | 13 | import io.swagger.v3.oas.annotations.Operation; |
| 14 | import io.swagger.v3.oas.annotations.Parameter; | 14 | import io.swagger.v3.oas.annotations.Parameter; |
| 15 | import io.swagger.v3.oas.annotations.tags.Tag; | 15 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 16 | +import jakarta.annotation.Resource; | ||
| 17 | +import jakarta.validation.Valid; | ||
| 16 | import org.springframework.security.access.prepost.PreAuthorize; | 18 | import org.springframework.security.access.prepost.PreAuthorize; |
| 17 | import org.springframework.web.bind.annotation.*; | 19 | import org.springframework.web.bind.annotation.*; |
| 18 | 20 | ||
| 19 | -import jakarta.annotation.Resource; | ||
| 20 | -import jakarta.validation.Valid; | ||
| 21 | import java.util.List; | 21 | import java.util.List; |
| 22 | 22 | ||
| 23 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 23 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| @@ -54,6 +54,15 @@ public class MailAccountController { | @@ -54,6 +54,15 @@ public class MailAccountController { | ||
| 54 | return success(true); | 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 | @GetMapping("/get") | 66 | @GetMapping("/get") |
| 58 | @Operation(summary = "获得邮箱账号") | 67 | @Operation(summary = "获得邮箱账号") |
| 59 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 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,11 +10,11 @@ import cn.iocoder.yudao.module.system.service.mail.MailTemplateService; | ||
| 10 | import io.swagger.v3.oas.annotations.Operation; | 10 | import io.swagger.v3.oas.annotations.Operation; |
| 11 | import io.swagger.v3.oas.annotations.Parameter; | 11 | import io.swagger.v3.oas.annotations.Parameter; |
| 12 | import io.swagger.v3.oas.annotations.tags.Tag; | 12 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 13 | +import jakarta.annotation.Resource; | ||
| 14 | +import jakarta.validation.Valid; | ||
| 13 | import org.springframework.security.access.prepost.PreAuthorize; | 15 | import org.springframework.security.access.prepost.PreAuthorize; |
| 14 | import org.springframework.web.bind.annotation.*; | 16 | import org.springframework.web.bind.annotation.*; |
| 15 | 17 | ||
| 16 | -import jakarta.annotation.Resource; | ||
| 17 | -import jakarta.validation.Valid; | ||
| 18 | import java.util.List; | 18 | import java.util.List; |
| 19 | 19 | ||
| 20 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 20 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| @@ -54,6 +54,15 @@ public class MailTemplateController { | @@ -54,6 +54,15 @@ public class MailTemplateController { | ||
| 54 | return success(true); | 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 | @GetMapping("/get") | 66 | @GetMapping("/get") |
| 58 | @Operation(summary = "获得邮件模版") | 67 | @Operation(summary = "获得邮件模版") |
| 59 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 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,12 +14,13 @@ import cn.iocoder.yudao.module.system.service.notice.NoticeService; | ||
| 14 | import io.swagger.v3.oas.annotations.Operation; | 14 | import io.swagger.v3.oas.annotations.Operation; |
| 15 | import io.swagger.v3.oas.annotations.Parameter; | 15 | import io.swagger.v3.oas.annotations.Parameter; |
| 16 | import io.swagger.v3.oas.annotations.tags.Tag; | 16 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 17 | +import jakarta.annotation.Resource; | ||
| 18 | +import jakarta.validation.Valid; | ||
| 17 | import org.springframework.security.access.prepost.PreAuthorize; | 19 | import org.springframework.security.access.prepost.PreAuthorize; |
| 18 | import org.springframework.validation.annotation.Validated; | 20 | import org.springframework.validation.annotation.Validated; |
| 19 | import org.springframework.web.bind.annotation.*; | 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 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 25 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 25 | 26 | ||
| @@ -60,6 +61,15 @@ public class NoticeController { | @@ -60,6 +61,15 @@ public class NoticeController { | ||
| 60 | return success(true); | 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 | @GetMapping("/page") | 73 | @GetMapping("/page") |
| 64 | @Operation(summary = "获取通知公告列表") | 74 | @Operation(summary = "获取通知公告列表") |
| 65 | @PreAuthorize("@ss.hasPermission('system:notice:query')") | 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,19 +4,23 @@ 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.framework.common.util.object.BeanUtils; | 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 | import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; | 11 | import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; |
| 9 | import cn.iocoder.yudao.module.system.service.notify.NotifySendService; | 12 | import cn.iocoder.yudao.module.system.service.notify.NotifySendService; |
| 10 | import cn.iocoder.yudao.module.system.service.notify.NotifyTemplateService; | 13 | import cn.iocoder.yudao.module.system.service.notify.NotifyTemplateService; |
| 11 | import io.swagger.v3.oas.annotations.Operation; | 14 | import io.swagger.v3.oas.annotations.Operation; |
| 12 | import io.swagger.v3.oas.annotations.Parameter; | 15 | import io.swagger.v3.oas.annotations.Parameter; |
| 13 | import io.swagger.v3.oas.annotations.tags.Tag; | 16 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 17 | +import jakarta.annotation.Resource; | ||
| 18 | +import jakarta.validation.Valid; | ||
| 14 | import org.springframework.security.access.prepost.PreAuthorize; | 19 | import org.springframework.security.access.prepost.PreAuthorize; |
| 15 | import org.springframework.validation.annotation.Validated; | 20 | import org.springframework.validation.annotation.Validated; |
| 16 | import org.springframework.web.bind.annotation.*; | 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 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 25 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 22 | 26 | ||
| @@ -56,6 +60,15 @@ public class NotifyTemplateController { | @@ -56,6 +60,15 @@ public class NotifyTemplateController { | ||
| 56 | return success(true); | 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 | @GetMapping("/get") | 72 | @GetMapping("/get") |
| 60 | @Operation(summary = "获得站内信模版") | 73 | @Operation(summary = "获得站内信模版") |
| 61 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 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,12 +11,13 @@ import cn.iocoder.yudao.module.system.service.oauth2.OAuth2ClientService; | ||
| 11 | import io.swagger.v3.oas.annotations.Operation; | 11 | import io.swagger.v3.oas.annotations.Operation; |
| 12 | import io.swagger.v3.oas.annotations.Parameter; | 12 | import io.swagger.v3.oas.annotations.Parameter; |
| 13 | import io.swagger.v3.oas.annotations.tags.Tag; | 13 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 14 | +import jakarta.annotation.Resource; | ||
| 15 | +import jakarta.validation.Valid; | ||
| 14 | import org.springframework.security.access.prepost.PreAuthorize; | 16 | import org.springframework.security.access.prepost.PreAuthorize; |
| 15 | import org.springframework.validation.annotation.Validated; | 17 | import org.springframework.validation.annotation.Validated; |
| 16 | import org.springframework.web.bind.annotation.*; | 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 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 22 | 23 | ||
| @@ -53,6 +54,15 @@ public class OAuth2ClientController { | @@ -53,6 +54,15 @@ public class OAuth2ClientController { | ||
| 53 | return success(true); | 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 | @GetMapping("/get") | 66 | @GetMapping("/get") |
| 57 | @Operation(summary = "获得 OAuth2 客户端") | 67 | @Operation(summary = "获得 OAuth2 客户端") |
| 58 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 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,11 +12,12 @@ import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; | ||
| 12 | import io.swagger.v3.oas.annotations.Operation; | 12 | import io.swagger.v3.oas.annotations.Operation; |
| 13 | import io.swagger.v3.oas.annotations.Parameter; | 13 | import io.swagger.v3.oas.annotations.Parameter; |
| 14 | import io.swagger.v3.oas.annotations.tags.Tag; | 14 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 15 | +import jakarta.annotation.Resource; | ||
| 16 | +import jakarta.validation.Valid; | ||
| 15 | import org.springframework.security.access.prepost.PreAuthorize; | 17 | import org.springframework.security.access.prepost.PreAuthorize; |
| 16 | import org.springframework.web.bind.annotation.*; | 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 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 22 | 23 | ||
| @@ -47,4 +48,14 @@ public class OAuth2TokenController { | @@ -47,4 +48,14 @@ public class OAuth2TokenController { | ||
| 47 | return success(true); | 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,11 +12,11 @@ import cn.iocoder.yudao.module.system.service.sms.SmsChannelService; | ||
| 12 | import io.swagger.v3.oas.annotations.Operation; | 12 | import io.swagger.v3.oas.annotations.Operation; |
| 13 | import io.swagger.v3.oas.annotations.Parameter; | 13 | import io.swagger.v3.oas.annotations.Parameter; |
| 14 | import io.swagger.v3.oas.annotations.tags.Tag; | 14 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 15 | +import jakarta.annotation.Resource; | ||
| 16 | +import jakarta.validation.Valid; | ||
| 15 | import org.springframework.security.access.prepost.PreAuthorize; | 17 | import org.springframework.security.access.prepost.PreAuthorize; |
| 16 | import org.springframework.web.bind.annotation.*; | 18 | import org.springframework.web.bind.annotation.*; |
| 17 | 19 | ||
| 18 | -import jakarta.annotation.Resource; | ||
| 19 | -import jakarta.validation.Valid; | ||
| 20 | import java.util.Comparator; | 20 | import java.util.Comparator; |
| 21 | import java.util.List; | 21 | import java.util.List; |
| 22 | 22 | ||
| @@ -54,6 +54,15 @@ public class SmsChannelController { | @@ -54,6 +54,15 @@ public class SmsChannelController { | ||
| 54 | return success(true); | 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 | @GetMapping("/get") | 66 | @GetMapping("/get") |
| 58 | @Operation(summary = "获得短信渠道") | 67 | @Operation(summary = "获得短信渠道") |
| 59 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 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 | package cn.iocoder.yudao.module.system.controller.admin.sms; | 1 | package cn.iocoder.yudao.module.system.controller.admin.sms; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | 3 | import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageParam; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 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 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; | 13 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; |
| 8 | -import cn.iocoder.yudao.module.system.service.sms.SmsTemplateService; | ||
| 9 | import cn.iocoder.yudao.module.system.service.sms.SmsSendService; | 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 | import io.swagger.v3.oas.annotations.Operation; | 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 | import jakarta.annotation.Resource; | 19 | import jakarta.annotation.Resource; |
| 20 | import jakarta.servlet.http.HttpServletResponse; | 20 | import jakarta.servlet.http.HttpServletResponse; |
| 21 | import jakarta.validation.Valid; | 21 | import jakarta.validation.Valid; |
| 22 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 23 | +import org.springframework.web.bind.annotation.*; | ||
| 24 | + | ||
| 22 | import java.io.IOException; | 25 | import java.io.IOException; |
| 23 | import java.util.List; | 26 | import java.util.List; |
| 24 | 27 | ||
| @@ -59,6 +62,15 @@ public class SmsTemplateController { | @@ -59,6 +62,15 @@ public class SmsTemplateController { | ||
| 59 | return success(true); | 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 | @GetMapping("/get") | 74 | @GetMapping("/get") |
| 63 | @Operation(summary = "获得短信模板") | 75 | @Operation(summary = "获得短信模板") |
| 64 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 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,6 +19,8 @@ import org.springframework.security.access.prepost.PreAuthorize; | ||
| 19 | import org.springframework.validation.annotation.Validated; | 19 | import org.springframework.validation.annotation.Validated; |
| 20 | import org.springframework.web.bind.annotation.*; | 20 | import org.springframework.web.bind.annotation.*; |
| 21 | 21 | ||
| 22 | +import java.util.List; | ||
| 23 | + | ||
| 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 23 | 25 | ||
| 24 | @Tag(name = "管理后台 - 社交客户端") | 26 | @Tag(name = "管理后台 - 社交客户端") |
| @@ -56,6 +58,15 @@ public class SocialClientController { | @@ -56,6 +58,15 @@ public class SocialClientController { | ||
| 56 | return success(true); | 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 | @GetMapping("/get") | 70 | @GetMapping("/get") |
| 60 | @Operation(summary = "获得社交客户端") | 71 | @Operation(summary = "获得社交客户端") |
| 61 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 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,6 +95,15 @@ public class TenantController { | ||
| 95 | return success(true); | 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 | @GetMapping("/get") | 107 | @GetMapping("/get") |
| 99 | @Operation(summary = "获得租户") | 108 | @Operation(summary = "获得租户") |
| 100 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 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,18 +4,21 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 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.framework.common.util.object.BeanUtils; | 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 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; | 11 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; |
| 9 | import cn.iocoder.yudao.module.system.service.tenant.TenantPackageService; | 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 | import io.swagger.v3.oas.annotations.Operation; | 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 | import org.springframework.security.access.prepost.PreAuthorize; | 18 | import org.springframework.security.access.prepost.PreAuthorize; |
| 14 | import org.springframework.validation.annotation.Validated; | 19 | import org.springframework.validation.annotation.Validated; |
| 15 | import org.springframework.web.bind.annotation.*; | 20 | import org.springframework.web.bind.annotation.*; |
| 16 | 21 | ||
| 17 | -import jakarta.annotation.Resource; | ||
| 18 | -import jakarta.validation.Valid; | ||
| 19 | import java.util.List; | 22 | import java.util.List; |
| 20 | 23 | ||
| 21 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| @@ -53,6 +56,15 @@ public class TenantPackageController { | @@ -53,6 +56,15 @@ public class TenantPackageController { | ||
| 53 | return success(true); | 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 | @GetMapping("/get") | 68 | @GetMapping("/get") |
| 57 | @Operation(summary = "获得租户套餐") | 69 | @Operation(summary = "获得租户套餐") |
| 58 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 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,6 +71,15 @@ public class UserController { | ||
| 71 | return success(true); | 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 | @PutMapping("/update-password") | 83 | @PutMapping("/update-password") |
| 75 | @Operation(summary = "重置用户密码") | 84 | @Operation(summary = "重置用户密码") |
| 76 | @PreAuthorize("@ss.hasPermission('system:user:update-password')") | 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,8 +4,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO; | 4 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO; |
| 5 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountSaveReqVO; | 5 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountSaveReqVO; |
| 6 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; |
| 7 | - | ||
| 8 | import jakarta.validation.Valid; | 7 | import jakarta.validation.Valid; |
| 8 | + | ||
| 9 | import java.util.List; | 9 | import java.util.List; |
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| @@ -39,6 +39,13 @@ public interface MailAccountService { | @@ -39,6 +39,13 @@ public interface MailAccountService { | ||
| 39 | void deleteMailAccount(Long id); | 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 | * @param id 编号 | 51 | * @param id 编号 |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailAccountServiceImpl.java
| 1 | package cn.iocoder.yudao.module.system.service.mail; | 1 | package cn.iocoder.yudao.module.system.service.mail; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO; | 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,13 +8,13 @@ import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccou | ||
| 7 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; | 8 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; |
| 8 | import cn.iocoder.yudao.module.system.dal.mysql.mail.MailAccountMapper; | 9 | import cn.iocoder.yudao.module.system.dal.mysql.mail.MailAccountMapper; |
| 9 | import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; | 10 | import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; |
| 11 | +import jakarta.annotation.Resource; | ||
| 10 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 11 | import org.springframework.cache.annotation.CacheEvict; | 13 | import org.springframework.cache.annotation.CacheEvict; |
| 12 | import org.springframework.cache.annotation.Cacheable; | 14 | import org.springframework.cache.annotation.Cacheable; |
| 13 | import org.springframework.stereotype.Service; | 15 | import org.springframework.stereotype.Service; |
| 14 | import org.springframework.validation.annotation.Validated; | 16 | import org.springframework.validation.annotation.Validated; |
| 15 | 17 | ||
| 16 | -import jakarta.annotation.Resource; | ||
| 17 | import java.util.List; | 18 | import java.util.List; |
| 18 | 19 | ||
| 19 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 20 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| @@ -69,12 +70,41 @@ public class MailAccountServiceImpl implements MailAccountService { | @@ -69,12 +70,41 @@ public class MailAccountServiceImpl implements MailAccountService { | ||
| 69 | mailAccountMapper.deleteById(id); | 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 | private void validateMailAccountExists(Long id) { | 91 | private void validateMailAccountExists(Long id) { |
| 73 | if (mailAccountMapper.selectById(id) == null) { | 92 | if (mailAccountMapper.selectById(id) == null) { |
| 74 | throw exception(MAIL_ACCOUNT_NOT_EXISTS); | 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 | @Override | 108 | @Override |
| 79 | public MailAccountDO getMailAccount(Long id) { | 109 | public MailAccountDO getMailAccount(Long id) { |
| 80 | return mailAccountMapper.selectById(id); | 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,8 +4,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplatePageReqVO; | 4 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplatePageReqVO; |
| 5 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateSaveReqVO; | 5 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateSaveReqVO; |
| 6 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; |
| 7 | - | ||
| 8 | import jakarta.validation.Valid; | 7 | import jakarta.validation.Valid; |
| 8 | + | ||
| 9 | import java.util.List; | 9 | import java.util.List; |
| 10 | import java.util.Map; | 10 | import java.util.Map; |
| 11 | 11 | ||
| @@ -40,6 +40,13 @@ public interface MailTemplateService { | @@ -40,6 +40,13 @@ public interface MailTemplateService { | ||
| 40 | void deleteMailTemplate(Long id); | 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 | * @param id 编号 | 52 | * @param id 编号 |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailTemplateServiceImpl.java
| 1 | package cn.iocoder.yudao.module.system.service.mail; | 1 | package cn.iocoder.yudao.module.system.service.mail; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 3 | import cn.hutool.core.util.ObjUtil; | 4 | import cn.hutool.core.util.ObjUtil; |
| 4 | import cn.hutool.core.util.ReUtil; | 5 | import cn.hutool.core.util.ReUtil; |
| 5 | import cn.hutool.core.util.StrUtil; | 6 | import cn.hutool.core.util.StrUtil; |
| @@ -11,14 +12,14 @@ import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; | @@ -11,14 +12,14 @@ import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; | ||
| 11 | import cn.iocoder.yudao.module.system.dal.mysql.mail.MailTemplateMapper; | 12 | import cn.iocoder.yudao.module.system.dal.mysql.mail.MailTemplateMapper; |
| 12 | import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; | 13 | import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; |
| 13 | import com.google.common.annotations.VisibleForTesting; | 14 | import com.google.common.annotations.VisibleForTesting; |
| 15 | +import jakarta.annotation.Resource; | ||
| 16 | +import jakarta.validation.Valid; | ||
| 14 | import lombok.extern.slf4j.Slf4j; | 17 | import lombok.extern.slf4j.Slf4j; |
| 15 | import org.springframework.cache.annotation.CacheEvict; | 18 | import org.springframework.cache.annotation.CacheEvict; |
| 16 | import org.springframework.cache.annotation.Cacheable; | 19 | import org.springframework.cache.annotation.Cacheable; |
| 17 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
| 18 | import org.springframework.validation.annotation.Validated; | 21 | import org.springframework.validation.annotation.Validated; |
| 19 | 22 | ||
| 20 | -import jakarta.annotation.Resource; | ||
| 21 | -import jakarta.validation.Valid; | ||
| 22 | import java.util.List; | 23 | import java.util.List; |
| 23 | import java.util.Map; | 24 | import java.util.Map; |
| 24 | import java.util.regex.Pattern; | 25 | import java.util.regex.Pattern; |
| @@ -97,12 +98,36 @@ public class MailTemplateServiceImpl implements MailTemplateService { | @@ -97,12 +98,36 @@ public class MailTemplateServiceImpl implements MailTemplateService { | ||
| 97 | mailTemplateMapper.deleteById(id); | 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 | private void validateMailTemplateExists(Long id) { | 114 | private void validateMailTemplateExists(Long id) { |
| 101 | if (mailTemplateMapper.selectById(id) == null) { | 115 | if (mailTemplateMapper.selectById(id) == null) { |
| 102 | throw exception(MAIL_TEMPLATE_NOT_EXISTS); | 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 | @Override | 131 | @Override |
| 107 | public MailTemplateDO getMailTemplate(Long id) {return mailTemplateMapper.selectById(id);} | 132 | public MailTemplateDO getMailTemplate(Long id) {return mailTemplateMapper.selectById(id);} |
| 108 | 133 | ||
| @@ -125,14 +150,19 @@ public class MailTemplateServiceImpl implements MailTemplateService { | @@ -125,14 +150,19 @@ public class MailTemplateServiceImpl implements MailTemplateService { | ||
| 125 | return StrUtil.format(content, params); | 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 | @Override | 153 | @Override |
| 134 | public long getMailTemplateCountByAccountId(Long accountId) { | 154 | public long getMailTemplateCountByAccountId(Long accountId) { |
| 135 | return mailTemplateMapper.selectCountByAccountId(accountId); | 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,6 +5,8 @@ import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO | ||
| 5 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeSaveReqVO; | 5 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeSaveReqVO; |
| 6 | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; |
| 7 | 7 | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 8 | /** | 10 | /** |
| 9 | * 通知公告 Service 接口 | 11 | * 通知公告 Service 接口 |
| 10 | */ | 12 | */ |
| @@ -33,6 +35,13 @@ public interface NoticeService { | @@ -33,6 +35,13 @@ public interface NoticeService { | ||
| 33 | void deleteNotice(Long id); | 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 | * @param reqVO 分页条件 | 47 | * @param reqVO 分页条件 |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/notice/NoticeServiceImpl.java
| 1 | package cn.iocoder.yudao.module.system.service.notice; | 1 | package cn.iocoder.yudao.module.system.service.notice; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO; | 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,9 +8,10 @@ import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeSaveReqVO | ||
| 7 | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; | 8 | import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; |
| 8 | import cn.iocoder.yudao.module.system.dal.mysql.notice.NoticeMapper; | 9 | import cn.iocoder.yudao.module.system.dal.mysql.notice.NoticeMapper; |
| 9 | import com.google.common.annotations.VisibleForTesting; | 10 | import com.google.common.annotations.VisibleForTesting; |
| 11 | +import jakarta.annotation.Resource; | ||
| 10 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| 11 | 13 | ||
| 12 | -import jakarta.annotation.Resource; | 14 | +import java.util.List; |
| 13 | 15 | ||
| 14 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 16 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 15 | import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTICE_NOT_FOUND; | 17 | import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTICE_NOT_FOUND; |
| @@ -50,6 +52,14 @@ public class NoticeServiceImpl implements NoticeService { | @@ -50,6 +52,14 @@ public class NoticeServiceImpl implements NoticeService { | ||
| 50 | } | 52 | } |
| 51 | 53 | ||
| 52 | @Override | 54 | @Override |
| 55 | + public void deleteNoticeList(List<Long> ids) { | ||
| 56 | + // 校验是否存在 | ||
| 57 | + validateNoticesExists(ids); | ||
| 58 | + // 批量删除通知公告 | ||
| 59 | + noticeMapper.deleteByIds(ids); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 53 | public PageResult<NoticeDO> getNoticePage(NoticePageReqVO reqVO) { | 63 | public PageResult<NoticeDO> getNoticePage(NoticePageReqVO reqVO) { |
| 54 | return noticeMapper.selectPage(reqVO); | 64 | return noticeMapper.selectPage(reqVO); |
| 55 | } | 65 | } |
| @@ -70,4 +80,15 @@ public class NoticeServiceImpl implements NoticeService { | @@ -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,8 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO; | 4 | import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO; |
| 5 | import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSaveReqVO; | 5 | import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSaveReqVO; |
| 6 | import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; |
| 7 | - | ||
| 8 | import jakarta.validation.Valid; | 7 | import jakarta.validation.Valid; |
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 9 | import java.util.Map; | 10 | import java.util.Map; |
| 10 | 11 | ||
| 11 | /** | 12 | /** |
| @@ -38,6 +39,13 @@ public interface NotifyTemplateService { | @@ -38,6 +39,13 @@ public interface NotifyTemplateService { | ||
| 38 | void deleteNotifyTemplate(Long id); | 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 | * @param id 编号 | 51 | * @param id 编号 |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
| 1 | package cn.iocoder.yudao.module.system.service.notify; | 1 | package cn.iocoder.yudao.module.system.service.notify; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 3 | import cn.hutool.core.util.ReUtil; | 4 | import cn.hutool.core.util.ReUtil; |
| 4 | import cn.hutool.core.util.StrUtil; | 5 | import cn.hutool.core.util.StrUtil; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| @@ -10,13 +11,13 @@ import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; | @@ -10,13 +11,13 @@ import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; | ||
| 10 | import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyTemplateMapper; | 11 | import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyTemplateMapper; |
| 11 | import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; | 12 | import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; |
| 12 | import com.google.common.annotations.VisibleForTesting; | 13 | import com.google.common.annotations.VisibleForTesting; |
| 14 | +import jakarta.annotation.Resource; | ||
| 13 | import lombok.extern.slf4j.Slf4j; | 15 | import lombok.extern.slf4j.Slf4j; |
| 14 | import org.springframework.cache.annotation.CacheEvict; | 16 | import org.springframework.cache.annotation.CacheEvict; |
| 15 | import org.springframework.cache.annotation.Cacheable; | 17 | import org.springframework.cache.annotation.Cacheable; |
| 16 | import org.springframework.stereotype.Service; | 18 | import org.springframework.stereotype.Service; |
| 17 | import org.springframework.validation.annotation.Validated; | 19 | import org.springframework.validation.annotation.Validated; |
| 18 | 20 | ||
| 19 | -import jakarta.annotation.Resource; | ||
| 20 | import java.util.List; | 21 | import java.util.List; |
| 21 | import java.util.Map; | 22 | import java.util.Map; |
| 22 | import java.util.regex.Pattern; | 23 | import java.util.regex.Pattern; |
| @@ -85,6 +86,27 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService { | @@ -85,6 +86,27 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService { | ||
| 85 | notifyTemplateMapper.deleteById(id); | 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 | private void validateNotifyTemplateExists(Long id) { | 110 | private void validateNotifyTemplateExists(Long id) { |
| 89 | if (notifyTemplateMapper.selectById(id) == null) { | 111 | if (notifyTemplateMapper.selectById(id) == null) { |
| 90 | throw exception(NOTIFY_TEMPLATE_NOT_EXISTS); | 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,9 +4,10 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.client.OAuth2ClientPageReqVO; | 4 | import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.client.OAuth2ClientPageReqVO; |
| 5 | import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.client.OAuth2ClientSaveReqVO; | 5 | import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.client.OAuth2ClientSaveReqVO; |
| 6 | import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; |
| 7 | - | ||
| 8 | import jakarta.validation.Valid; | 7 | import jakarta.validation.Valid; |
| 8 | + | ||
| 9 | import java.util.Collection; | 9 | import java.util.Collection; |
| 10 | +import java.util.List; | ||
| 10 | 11 | ||
| 11 | /** | 12 | /** |
| 12 | * OAuth2.0 Client Service 接口 | 13 | * OAuth2.0 Client Service 接口 |
| @@ -40,6 +41,13 @@ public interface OAuth2ClientService { | @@ -40,6 +41,13 @@ public interface OAuth2ClientService { | ||
| 40 | void deleteOAuth2Client(Long id); | 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 | * 获得 OAuth2 客户端 | 51 | * 获得 OAuth2 客户端 |
| 44 | * | 52 | * |
| 45 | * @param id 编号 | 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 +14,15 @@ import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; | ||
| 14 | import cn.iocoder.yudao.module.system.dal.mysql.oauth2.OAuth2ClientMapper; | 14 | import cn.iocoder.yudao.module.system.dal.mysql.oauth2.OAuth2ClientMapper; |
| 15 | import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; | 15 | import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; |
| 16 | import com.google.common.annotations.VisibleForTesting; | 16 | import com.google.common.annotations.VisibleForTesting; |
| 17 | +import jakarta.annotation.Resource; | ||
| 17 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
| 18 | import org.springframework.cache.annotation.CacheEvict; | 19 | import org.springframework.cache.annotation.CacheEvict; |
| 19 | import org.springframework.cache.annotation.Cacheable; | 20 | import org.springframework.cache.annotation.Cacheable; |
| 20 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
| 21 | import org.springframework.validation.annotation.Validated; | 22 | import org.springframework.validation.annotation.Validated; |
| 22 | 23 | ||
| 23 | -import jakarta.annotation.Resource; | ||
| 24 | import java.util.Collection; | 24 | import java.util.Collection; |
| 25 | +import java.util.List; | ||
| 25 | 26 | ||
| 26 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 27 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 27 | import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; | 28 | import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; |
| @@ -72,12 +73,32 @@ public class OAuth2ClientServiceImpl implements OAuth2ClientService { | @@ -72,12 +73,32 @@ public class OAuth2ClientServiceImpl implements OAuth2ClientService { | ||
| 72 | oauth2ClientMapper.deleteById(id); | 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 | private void validateOAuth2ClientExists(Long id) { | 89 | private void validateOAuth2ClientExists(Long id) { |
| 76 | if (oauth2ClientMapper.selectById(id) == null) { | 90 | if (oauth2ClientMapper.selectById(id) == null) { |
| 77 | throw exception(OAUTH2_CLIENT_NOT_EXISTS); | 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 | @VisibleForTesting | 102 | @VisibleForTesting |
| 82 | void validateClientIdExists(Long id, String clientId) { | 103 | void validateClientIdExists(Long id, String clientId) { |
| 83 | OAuth2ClientDO client = oauth2ClientMapper.selectByClientId(clientId); | 104 | OAuth2ClientDO client = oauth2ClientMapper.selectByClientId(clientId); |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsChannelService.java
| 1 | package cn.iocoder.yudao.module.system.service.sms; | 1 | package cn.iocoder.yudao.module.system.service.sms; |
| 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.module.system.framework.sms.core.client.SmsClient; | ||
| 5 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO; | 4 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO; |
| 6 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelSaveReqVO; | 5 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelSaveReqVO; |
| 7 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; | 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 | import jakarta.validation.Valid; | 8 | import jakarta.validation.Valid; |
| 9 | + | ||
| 10 | import java.util.List; | 10 | import java.util.List; |
| 11 | 11 | ||
| 12 | /** | 12 | /** |
| @@ -40,6 +40,13 @@ public interface SmsChannelService { | @@ -40,6 +40,13 @@ public interface SmsChannelService { | ||
| 40 | void deleteSmsChannel(Long id); | 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 | * @param id 编号 | 52 | * @param id 编号 |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsChannelServiceImpl.java
| 1 | package cn.iocoder.yudao.module.system.service.sms; | 1 | package cn.iocoder.yudao.module.system.service.sms; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO; | 6 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO; |
| @@ -65,6 +66,23 @@ public class SmsChannelServiceImpl implements SmsChannelService { | @@ -65,6 +66,23 @@ public class SmsChannelServiceImpl implements SmsChannelService { | ||
| 65 | smsChannelMapper.deleteById(id); | 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 | private SmsChannelDO validateSmsChannelExists(Long id) { | 86 | private SmsChannelDO validateSmsChannelExists(Long id) { |
| 69 | SmsChannelDO channel = smsChannelMapper.selectById(id); | 87 | SmsChannelDO channel = smsChannelMapper.selectById(id); |
| 70 | if (channel == null) { | 88 | if (channel == null) { |
| @@ -73,6 +91,13 @@ public class SmsChannelServiceImpl implements SmsChannelService { | @@ -73,6 +91,13 @@ public class SmsChannelServiceImpl implements SmsChannelService { | ||
| 73 | return channel; | 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 | @Override | 101 | @Override |
| 77 | public SmsChannelDO getSmsChannel(Long id) { | 102 | public SmsChannelDO getSmsChannel(Long id) { |
| 78 | return smsChannelMapper.selectById(id); | 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,8 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO; | 4 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO; |
| 5 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO; | 5 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO; |
| 6 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; |
| 7 | - | ||
| 8 | import jakarta.validation.Valid; | 7 | import jakarta.validation.Valid; |
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 9 | import java.util.Map; | 10 | import java.util.Map; |
| 10 | 11 | ||
| 11 | /** | 12 | /** |
| @@ -39,6 +40,13 @@ public interface SmsTemplateService { | @@ -39,6 +40,13 @@ public interface SmsTemplateService { | ||
| 39 | void deleteSmsTemplate(Long id); | 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 | * @param id 编号 | 52 | * @param id 编号 |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsTemplateServiceImpl.java
| 1 | package cn.iocoder.yudao.module.system.service.sms; | 1 | package cn.iocoder.yudao.module.system.service.sms; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 3 | import cn.hutool.core.exceptions.ExceptionUtil; | 4 | import cn.hutool.core.exceptions.ExceptionUtil; |
| 4 | import cn.hutool.core.lang.Assert; | 5 | import cn.hutool.core.lang.Assert; |
| 5 | import cn.hutool.core.util.ReUtil; | 6 | import cn.hutool.core.util.ReUtil; |
| @@ -7,22 +8,22 @@ import cn.hutool.core.util.StrUtil; | @@ -7,22 +8,22 @@ import cn.hutool.core.util.StrUtil; | ||
| 7 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 8 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 9 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 9 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 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 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO; | 11 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO; |
| 14 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO; | 12 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO; |
| 15 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; | 13 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; |
| 16 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; | 14 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; |
| 17 | import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsTemplateMapper; | 15 | import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsTemplateMapper; |
| 18 | import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; | 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 | import com.google.common.annotations.VisibleForTesting; | 20 | import com.google.common.annotations.VisibleForTesting; |
| 21 | +import jakarta.annotation.Resource; | ||
| 20 | import lombok.extern.slf4j.Slf4j; | 22 | import lombok.extern.slf4j.Slf4j; |
| 21 | import org.springframework.cache.annotation.CacheEvict; | 23 | import org.springframework.cache.annotation.CacheEvict; |
| 22 | import org.springframework.cache.annotation.Cacheable; | 24 | import org.springframework.cache.annotation.Cacheable; |
| 23 | import org.springframework.stereotype.Service; | 25 | import org.springframework.stereotype.Service; |
| 24 | 26 | ||
| 25 | -import jakarta.annotation.Resource; | ||
| 26 | import java.util.List; | 27 | import java.util.List; |
| 27 | import java.util.Map; | 28 | import java.util.Map; |
| 28 | import java.util.Objects; | 29 | import java.util.Objects; |
| @@ -100,12 +101,32 @@ public class SmsTemplateServiceImpl implements SmsTemplateService { | @@ -100,12 +101,32 @@ public class SmsTemplateServiceImpl implements SmsTemplateService { | ||
| 100 | smsTemplateMapper.deleteById(id); | 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 | private void validateSmsTemplateExists(Long id) { | 117 | private void validateSmsTemplateExists(Long id) { |
| 104 | if (smsTemplateMapper.selectById(id) == null) { | 118 | if (smsTemplateMapper.selectById(id) == null) { |
| 105 | throw exception(SMS_TEMPLATE_NOT_EXISTS); | 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 | @Override | 130 | @Override |
| 110 | public SmsTemplateDO getSmsTemplate(Long id) { | 131 | public SmsTemplateDO getSmsTemplate(Long id) { |
| 111 | return smsTemplateMapper.selectById(id); | 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,6 +135,13 @@ public interface SocialClientService { | ||
| 135 | void deleteSocialClient(Long id); | 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 | * @param id 编号 | 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,12 +466,30 @@ public class SocialClientServiceImpl implements SocialClientService { | ||
| 466 | socialClientMapper.deleteById(id); | 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 | private void validateSocialClientExists(Long id) { | 480 | private void validateSocialClientExists(Long id) { |
| 470 | if (socialClientMapper.selectById(id) == null) { | 481 | if (socialClientMapper.selectById(id) == null) { |
| 471 | throw exception(SOCIAL_CLIENT_NOT_EXISTS); | 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 | * 校验社交应用是否重复,需要保证 userType + socialType 唯一 | 494 | * 校验社交应用是否重复,需要保证 userType + socialType 唯一 |
| 477 | * 原因是,不同端(userType)选择某个社交登录(socialType)时,需要通过 {@link #buildAuthRequest(Integer, Integer)} 构建对应的请求 | 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,8 +4,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackagePageReqVO; | 4 | import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackagePageReqVO; |
| 5 | import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageSaveReqVO; | 5 | import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageSaveReqVO; |
| 6 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; |
| 7 | - | ||
| 8 | import jakarta.validation.Valid; | 7 | import jakarta.validation.Valid; |
| 8 | + | ||
| 9 | import java.util.List; | 9 | import java.util.List; |
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| @@ -38,6 +38,13 @@ public interface TenantPackageService { | @@ -38,6 +38,13 @@ public interface TenantPackageService { | ||
| 38 | void deleteTenantPackage(Long id); | 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 | * @param id 编号 | 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,11 +12,11 @@ import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; | ||
| 12 | import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantPackageMapper; | 12 | import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantPackageMapper; |
| 13 | import com.baomidou.dynamic.datasource.annotation.DSTransactional; | 13 | import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
| 14 | import com.google.common.annotations.VisibleForTesting; | 14 | import com.google.common.annotations.VisibleForTesting; |
| 15 | +import jakarta.annotation.Resource; | ||
| 15 | import org.springframework.context.annotation.Lazy; | 16 | import org.springframework.context.annotation.Lazy; |
| 16 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
| 17 | import org.springframework.validation.annotation.Validated; | 18 | import org.springframework.validation.annotation.Validated; |
| 18 | 19 | ||
| 19 | -import jakarta.annotation.Resource; | ||
| 20 | import java.util.List; | 20 | import java.util.List; |
| 21 | 21 | ||
| 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| @@ -76,6 +76,19 @@ public class TenantPackageServiceImpl implements TenantPackageService { | @@ -76,6 +76,19 @@ public class TenantPackageServiceImpl implements TenantPackageService { | ||
| 76 | tenantPackageMapper.deleteById(id); | 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 | private TenantPackageDO validateTenantPackageExists(Long id) { | 92 | private TenantPackageDO validateTenantPackageExists(Long id) { |
| 80 | TenantPackageDO tenantPackage = tenantPackageMapper.selectById(id); | 93 | TenantPackageDO tenantPackage = tenantPackageMapper.selectById(id); |
| 81 | if (tenantPackage == null) { | 94 | if (tenantPackage == null) { |
| @@ -90,6 +103,20 @@ public class TenantPackageServiceImpl implements TenantPackageService { | @@ -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 | @Override | 120 | @Override |
| 94 | public TenantPackageDO getTenantPackage(Long id) { | 121 | public TenantPackageDO getTenantPackage(Long id) { |
| 95 | return tenantPackageMapper.selectById(id); | 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,8 +7,8 @@ import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSa | ||
| 7 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; | 7 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; |
| 8 | import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler; | 8 | import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler; |
| 9 | import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler; | 9 | import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler; |
| 10 | - | ||
| 11 | import jakarta.validation.Valid; | 10 | import jakarta.validation.Valid; |
| 11 | + | ||
| 12 | import java.util.List; | 12 | import java.util.List; |
| 13 | import java.util.Set; | 13 | import java.util.Set; |
| 14 | 14 | ||
| @@ -50,6 +50,13 @@ public interface TenantService { | @@ -50,6 +50,13 @@ public interface TenantService { | ||
| 50 | void deleteTenant(Long id); | 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 | * @param id 编号 | 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,13 +31,13 @@ import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler; | ||
| 31 | import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler; | 31 | import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler; |
| 32 | import cn.iocoder.yudao.module.system.service.user.AdminUserService; | 32 | import cn.iocoder.yudao.module.system.service.user.AdminUserService; |
| 33 | import com.baomidou.dynamic.datasource.annotation.DSTransactional; | 33 | import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
| 34 | +import jakarta.annotation.Resource; | ||
| 34 | import lombok.extern.slf4j.Slf4j; | 35 | import lombok.extern.slf4j.Slf4j; |
| 35 | import org.springframework.beans.factory.annotation.Autowired; | 36 | import org.springframework.beans.factory.annotation.Autowired; |
| 36 | import org.springframework.context.annotation.Lazy; | 37 | import org.springframework.context.annotation.Lazy; |
| 37 | import org.springframework.stereotype.Service; | 38 | import org.springframework.stereotype.Service; |
| 38 | import org.springframework.validation.annotation.Validated; | 39 | import org.springframework.validation.annotation.Validated; |
| 39 | 40 | ||
| 40 | -import jakarta.annotation.Resource; | ||
| 41 | import java.util.List; | 41 | import java.util.List; |
| 42 | import java.util.Objects; | 42 | import java.util.Objects; |
| 43 | import java.util.Set; | 43 | import java.util.Set; |
| @@ -225,6 +225,17 @@ public class TenantServiceImpl implements TenantService { | @@ -225,6 +225,17 @@ public class TenantServiceImpl implements TenantService { | ||
| 225 | tenantMapper.deleteById(id); | 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 | private TenantDO validateUpdateTenant(Long id) { | 239 | private TenantDO validateUpdateTenant(Long id) { |
| 229 | TenantDO tenant = tenantMapper.selectById(id); | 240 | TenantDO tenant = tenantMapper.selectById(id); |
| 230 | if (tenant == null) { | 241 | if (tenant == null) { |
| @@ -237,6 +248,26 @@ public class TenantServiceImpl implements TenantService { | @@ -237,6 +248,26 @@ public class TenantServiceImpl implements TenantService { | ||
| 237 | return tenant; | 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 | @Override | 271 | @Override |
| 241 | public TenantDO getTenant(Long id) { | 272 | public TenantDO getTenant(Long id) { |
| 242 | return tenantMapper.selectById(id); | 273 | return tenantMapper.selectById(id); |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java
| @@ -96,6 +96,13 @@ public interface AdminUserService { | @@ -96,6 +96,13 @@ public interface AdminUserService { | ||
| 96 | void deleteUser(Long id); | 96 | void deleteUser(Long id); |
| 97 | 97 | ||
| 98 | /** | 98 | /** |
| 99 | + * 批量删除用户 | ||
| 100 | + * | ||
| 101 | + * @param ids 用户编号数组 | ||
| 102 | + */ | ||
| 103 | + void deleteUserList(List<Long> ids); | ||
| 104 | + | ||
| 105 | + /** | ||
| 99 | * 通过用户名查询用户 | 106 | * 通过用户名查询用户 |
| 100 | * | 107 | * |
| 101 | * @param username 用户名 | 108 | * @param username 用户名 |
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,6 +249,28 @@ public class AdminUserServiceImpl implements AdminUserService { | ||
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | @Override | 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 | public AdminUserDO getUserByUsername(String username) { | 274 | public AdminUserDO getUserByUsername(String username) { |
| 253 | return userMapper.selectByUsername(username); | 275 | return userMapper.selectByUsername(username); |
| 254 | } | 276 | } |