Commit 8e2388d52db129add6b1ddf753375dbdec155fbf
1 parent
d6040214
短信发送的逻辑,迁移到 yudao-core-service 模块下
Showing
77 changed files
with
1008 additions
and
630 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/SysAuthController.java
| @@ -4,13 +4,13 @@ import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.*; | @@ -4,13 +4,13 @@ import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.*; | ||
| 4 | import cn.iocoder.yudao.adminserver.modules.system.convert.auth.SysAuthConvert; | 4 | import cn.iocoder.yudao.adminserver.modules.system.convert.auth.SysAuthConvert; |
| 5 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysMenuDO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysMenuDO; |
| 6 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysRoleDO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysRoleDO; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 8 | import cn.iocoder.yudao.adminserver.modules.system.enums.permission.MenuTypeEnum; | 7 | import cn.iocoder.yudao.adminserver.modules.system.enums.permission.MenuTypeEnum; |
| 9 | import cn.iocoder.yudao.adminserver.modules.system.service.auth.SysAuthService; | 8 | import cn.iocoder.yudao.adminserver.modules.system.service.auth.SysAuthService; |
| 10 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; | 9 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; |
| 11 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysRoleService; | 10 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysRoleService; |
| 12 | import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialService; | 11 | import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialService; |
| 13 | -import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; | 12 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; |
| 13 | +import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService; | ||
| 14 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 14 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 15 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 15 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 16 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; | 16 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; |
| @@ -43,7 +43,7 @@ public class SysAuthController { | @@ -43,7 +43,7 @@ public class SysAuthController { | ||
| 43 | @Resource | 43 | @Resource |
| 44 | private SysAuthService authService; | 44 | private SysAuthService authService; |
| 45 | @Resource | 45 | @Resource |
| 46 | - private SysUserService userService; | 46 | + private SysUserCoreService userCoreService; |
| 47 | @Resource | 47 | @Resource |
| 48 | private SysRoleService roleService; | 48 | private SysRoleService roleService; |
| 49 | @Resource | 49 | @Resource |
| @@ -64,7 +64,7 @@ public class SysAuthController { | @@ -64,7 +64,7 @@ public class SysAuthController { | ||
| 64 | @ApiOperation("获取登录用户的权限信息") | 64 | @ApiOperation("获取登录用户的权限信息") |
| 65 | public CommonResult<SysAuthPermissionInfoRespVO> getPermissionInfo() { | 65 | public CommonResult<SysAuthPermissionInfoRespVO> getPermissionInfo() { |
| 66 | // 获得用户信息 | 66 | // 获得用户信息 |
| 67 | - SysUserDO user = userService.getUser(getLoginUserId()); | 67 | + SysUserDO user = userCoreService.getUser(getLoginUserId()); |
| 68 | if (user == null) { | 68 | if (user == null) { |
| 69 | return null; | 69 | return null; |
| 70 | } | 70 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/SysUserSessionController.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.auth; | 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.auth; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.auth.SysUserSessionDO; | ||
| 4 | -import cn.iocoder.yudao.coreservice.modules.system.service.auth.SysUserSessionCoreService; | ||
| 5 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 6 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.session.SysUserSessionPageItemRespVO; | 3 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.session.SysUserSessionPageItemRespVO; |
| 8 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.session.SysUserSessionPageReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.session.SysUserSessionPageReqVO; |
| 9 | import cn.iocoder.yudao.adminserver.modules.system.convert.auth.SysUserSessionConvert; | 5 | import cn.iocoder.yudao.adminserver.modules.system.convert.auth.SysUserSessionConvert; |
| 10 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; |
| 11 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 12 | import cn.iocoder.yudao.adminserver.modules.system.service.auth.SysUserSessionService; | 7 | import cn.iocoder.yudao.adminserver.modules.system.service.auth.SysUserSessionService; |
| 13 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; | 8 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; |
| 14 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; | 9 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; |
| 10 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.auth.SysUserSessionDO; | ||
| 11 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 12 | +import cn.iocoder.yudao.coreservice.modules.system.service.auth.SysUserSessionCoreService; | ||
| 13 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 14 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 15 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | 15 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 16 | import io.swagger.annotations.Api; | 16 | import io.swagger.annotations.Api; |
| 17 | import io.swagger.annotations.ApiImplicitParam; | 17 | import io.swagger.annotations.ApiImplicitParam; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/logger/SysOperateLogController.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.logger; | 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.logger; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 6 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogExcelVO; | 3 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogExcelVO; |
| 8 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogExportReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogExportReqVO; |
| 9 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogPageReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogPageReqVO; |
| 10 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogRespVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogRespVO; |
| 11 | import cn.iocoder.yudao.adminserver.modules.system.convert.logger.SysOperateLogConvert; | 7 | import cn.iocoder.yudao.adminserver.modules.system.convert.logger.SysOperateLogConvert; |
| 12 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.logger.SysOperateLogDO; | 8 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.logger.SysOperateLogDO; |
| 13 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 14 | import cn.iocoder.yudao.adminserver.modules.system.service.logger.SysOperateLogService; | 9 | import cn.iocoder.yudao.adminserver.modules.system.service.logger.SysOperateLogService; |
| 15 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; | 10 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; |
| 11 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 12 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 13 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 16 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 14 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 17 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | 15 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 16 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 17 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 18 | import io.swagger.annotations.Api; | 18 | import io.swagger.annotations.Api; |
| 19 | import io.swagger.annotations.ApiOperation; | 19 | import io.swagger.annotations.ApiOperation; |
| 20 | import org.springframework.security.access.prepost.PreAuthorize; | 20 | import org.springframework.security.access.prepost.PreAuthorize; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/sms/SmsCallbackController.java
| @@ -2,10 +2,10 @@ package cn.iocoder.yudao.adminserver.modules.system.controller.sms; | @@ -2,10 +2,10 @@ package cn.iocoder.yudao.adminserver.modules.system.controller.sms; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.URLUtil; | 3 | import cn.hutool.core.util.URLUtil; |
| 4 | import cn.hutool.extra.servlet.ServletUtil; | 4 | import cn.hutool.extra.servlet.ServletUtil; |
| 5 | +import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsCoreService; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 6 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | 7 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 7 | import cn.iocoder.yudao.framework.sms.core.enums.SmsChannelEnum; | 8 | import cn.iocoder.yudao.framework.sms.core.enums.SmsChannelEnum; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsService; | ||
| 9 | import io.swagger.annotations.Api; | 9 | import io.swagger.annotations.Api; |
| 10 | import io.swagger.annotations.ApiImplicitParam; | 10 | import io.swagger.annotations.ApiImplicitParam; |
| 11 | import io.swagger.annotations.ApiOperation; | 11 | import io.swagger.annotations.ApiOperation; |
| @@ -25,7 +25,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | @@ -25,7 +25,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 25 | public class SmsCallbackController { | 25 | public class SmsCallbackController { |
| 26 | 26 | ||
| 27 | @Resource | 27 | @Resource |
| 28 | - private SysSmsService smsService; | 28 | + private SysSmsCoreService smsCoreService; |
| 29 | 29 | ||
| 30 | @PostMapping("/sms/yunpian") | 30 | @PostMapping("/sms/yunpian") |
| 31 | @ApiOperation(value = "云片短信的回调", notes = "参见 https://www.yunpian.com/official/document/sms/zh_cn/domestic_push_report 文档") | 31 | @ApiOperation(value = "云片短信的回调", notes = "参见 https://www.yunpian.com/official/document/sms/zh_cn/domestic_push_report 文档") |
| @@ -33,7 +33,7 @@ public class SmsCallbackController { | @@ -33,7 +33,7 @@ public class SmsCallbackController { | ||
| 33 | @OperateLog(enable = false) | 33 | @OperateLog(enable = false) |
| 34 | public String receiveYunpianSmsStatus(@RequestParam("sms_status") String smsStatus) throws Throwable { | 34 | public String receiveYunpianSmsStatus(@RequestParam("sms_status") String smsStatus) throws Throwable { |
| 35 | String text = URLUtil.decode(smsStatus); // decode 解码参数,因为它被 encode | 35 | String text = URLUtil.decode(smsStatus); // decode 解码参数,因为它被 encode |
| 36 | - smsService.receiveSmsStatus(SmsChannelEnum.YUN_PIAN.getCode(), text); | 36 | + smsCoreService.receiveSmsStatus(SmsChannelEnum.YUN_PIAN.getCode(), text); |
| 37 | return "SUCCESS"; // 约定返回 SUCCESS 为成功 | 37 | return "SUCCESS"; // 约定返回 SUCCESS 为成功 |
| 38 | } | 38 | } |
| 39 | 39 | ||
| @@ -42,7 +42,7 @@ public class SmsCallbackController { | @@ -42,7 +42,7 @@ public class SmsCallbackController { | ||
| 42 | @OperateLog(enable = false) | 42 | @OperateLog(enable = false) |
| 43 | public CommonResult<Boolean> receiveAliyunSmsStatus(HttpServletRequest request) throws Throwable { | 43 | public CommonResult<Boolean> receiveAliyunSmsStatus(HttpServletRequest request) throws Throwable { |
| 44 | String text = ServletUtil.getBody(request); | 44 | String text = ServletUtil.getBody(request); |
| 45 | - smsService.receiveSmsStatus(SmsChannelEnum.ALIYUN.getCode(), text); | 45 | + smsCoreService.receiveSmsStatus(SmsChannelEnum.ALIYUN.getCode(), text); |
| 46 | return success(true); | 46 | return success(true); |
| 47 | } | 47 | } |
| 48 | 48 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/sms/SysSmsChannelController.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.sms; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.*; | 3 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.*; |
| 6 | import cn.iocoder.yudao.adminserver.modules.system.convert.sms.SysSmsChannelConvert; | 4 | import cn.iocoder.yudao.adminserver.modules.system.convert.sms.SysSmsChannelConvert; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsChannelDO; | ||
| 8 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsChannelService; | 5 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsChannelService; |
| 6 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsChannelDO; | ||
| 7 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 8 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 9 | import io.swagger.annotations.Api; | 9 | import io.swagger.annotations.Api; |
| 10 | import io.swagger.annotations.ApiImplicitParam; | 10 | import io.swagger.annotations.ApiImplicitParam; |
| 11 | import io.swagger.annotations.ApiOperation; | 11 | import io.swagger.annotations.ApiOperation; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/sms/SysSmsLogController.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.sms; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 6 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogExcelVO; | 3 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogExcelVO; |
| 8 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogExportReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogExportReqVO; |
| 9 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogPageReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogPageReqVO; |
| 10 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogRespVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogRespVO; |
| 11 | import cn.iocoder.yudao.adminserver.modules.system.convert.sms.SysSmsLogConvert; | 7 | import cn.iocoder.yudao.adminserver.modules.system.convert.sms.SysSmsLogConvert; |
| 12 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsLogDO; | ||
| 13 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsLogService; | 8 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsLogService; |
| 9 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsLogDO; | ||
| 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 cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 14 | import io.swagger.annotations.Api; | 14 | import io.swagger.annotations.Api; |
| 15 | import io.swagger.annotations.ApiOperation; | 15 | import io.swagger.annotations.ApiOperation; |
| 16 | import org.springframework.security.access.prepost.PreAuthorize; | 16 | import org.springframework.security.access.prepost.PreAuthorize; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/sms/SysSmsTemplateController.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.sms; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.*; | ||
| 4 | +import cn.iocoder.yudao.adminserver.modules.system.convert.sms.SysSmsTemplateConvert; | ||
| 5 | +import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsTemplateService; | ||
| 6 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 7 | +import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsCoreService; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 8 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 9 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 10 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 6 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | 11 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.*; | ||
| 8 | -import cn.iocoder.yudao.adminserver.modules.system.convert.sms.SysSmsTemplateConvert; | ||
| 9 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 10 | -import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsService; | ||
| 11 | -import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsTemplateService; | ||
| 12 | import io.swagger.annotations.Api; | 12 | import io.swagger.annotations.Api; |
| 13 | import io.swagger.annotations.ApiImplicitParam; | 13 | import io.swagger.annotations.ApiImplicitParam; |
| 14 | import io.swagger.annotations.ApiOperation; | 14 | import io.swagger.annotations.ApiOperation; |
| @@ -32,7 +32,7 @@ public class SysSmsTemplateController { | @@ -32,7 +32,7 @@ public class SysSmsTemplateController { | ||
| 32 | @Resource | 32 | @Resource |
| 33 | private SysSmsTemplateService smsTemplateService; | 33 | private SysSmsTemplateService smsTemplateService; |
| 34 | @Resource | 34 | @Resource |
| 35 | - private SysSmsService smsService; | 35 | + private SysSmsCoreService smsCoreService; |
| 36 | 36 | ||
| 37 | @PostMapping("/create") | 37 | @PostMapping("/create") |
| 38 | @ApiOperation("创建短信模板") | 38 | @ApiOperation("创建短信模板") |
| @@ -91,7 +91,7 @@ public class SysSmsTemplateController { | @@ -91,7 +91,7 @@ public class SysSmsTemplateController { | ||
| 91 | @ApiOperation("发送短信") | 91 | @ApiOperation("发送短信") |
| 92 | @PreAuthorize("@ss.hasPermission('system:sms-template:send-sms')") | 92 | @PreAuthorize("@ss.hasPermission('system:sms-template:send-sms')") |
| 93 | public CommonResult<Long> sendSms(@Valid @RequestBody SysSmsTemplateSendReqVO sendReqVO) { | 93 | public CommonResult<Long> sendSms(@Valid @RequestBody SysSmsTemplateSendReqVO sendReqVO) { |
| 94 | - return success(smsService.sendSingleSms(sendReqVO.getMobile(), null, null, | 94 | + return success(smsCoreService.sendSingleSms(sendReqVO.getMobile(), null, null, |
| 95 | sendReqVO.getTemplateCode(), sendReqVO.getTemplateParams())); | 95 | sendReqVO.getTemplateCode(), sendReqVO.getTemplateParams())); |
| 96 | } | 96 | } |
| 97 | 97 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/user/SysUserController.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.user; | 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.user; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 5 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 6 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 7 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 8 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 9 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.*; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.*; |
| 10 | import cn.iocoder.yudao.adminserver.modules.system.convert.user.SysUserConvert; | 5 | import cn.iocoder.yudao.adminserver.modules.system.convert.user.SysUserConvert; |
| 11 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; |
| 12 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 13 | -import cn.iocoder.yudao.adminserver.modules.system.enums.common.SysSexEnum; | ||
| 14 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; | 7 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; |
| 15 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; | 8 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; |
| 9 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 10 | +import cn.iocoder.yudao.coreservice.modules.system.enums.common.SysSexEnum; | ||
| 11 | +import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService; | ||
| 12 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 13 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 14 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 16 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 15 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 17 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | 16 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 17 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 18 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 18 | import io.swagger.annotations.Api; | 19 | import io.swagger.annotations.Api; |
| 19 | import io.swagger.annotations.ApiImplicitParam; | 20 | import io.swagger.annotations.ApiImplicitParam; |
| 20 | import io.swagger.annotations.ApiImplicitParams; | 21 | import io.swagger.annotations.ApiImplicitParams; |
| @@ -42,6 +43,8 @@ public class SysUserController { | @@ -42,6 +43,8 @@ public class SysUserController { | ||
| 42 | @Resource | 43 | @Resource |
| 43 | private SysUserService userService; | 44 | private SysUserService userService; |
| 44 | @Resource | 45 | @Resource |
| 46 | + private SysUserCoreService userCoreService; | ||
| 47 | + @Resource | ||
| 45 | private SysDeptService deptService; | 48 | private SysDeptService deptService; |
| 46 | 49 | ||
| 47 | @PostMapping("/create") | 50 | @PostMapping("/create") |
| @@ -113,7 +116,7 @@ public class SysUserController { | @@ -113,7 +116,7 @@ public class SysUserController { | ||
| 113 | @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | 116 | @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) |
| 114 | @PreAuthorize("@ss.hasPermission('system:user:query')") | 117 | @PreAuthorize("@ss.hasPermission('system:user:query')") |
| 115 | public CommonResult<SysUserRespVO> getInfo(@RequestParam("id") Long id) { | 118 | public CommonResult<SysUserRespVO> getInfo(@RequestParam("id") Long id) { |
| 116 | - return success(SysUserConvert.INSTANCE.convert(userService.getUser(id))); | 119 | + return success(SysUserConvert.INSTANCE.convert(userCoreService.getUser(id))); |
| 117 | } | 120 | } |
| 118 | 121 | ||
| 119 | @GetMapping("/export") | 122 | @GetMapping("/export") |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/user/SysUserProfileController.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.user; | 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.user; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social.SysSocialUserDO; | ||
| 5 | -import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialService; | ||
| 6 | -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | ||
| 7 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 8 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileRespVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileRespVO; |
| 9 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; |
| 10 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; |
| @@ -12,12 +8,17 @@ import cn.iocoder.yudao.adminserver.modules.system.convert.user.SysUserConvert; | @@ -12,12 +8,17 @@ import cn.iocoder.yudao.adminserver.modules.system.convert.user.SysUserConvert; | ||
| 12 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; | 8 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; |
| 13 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO; | 9 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO; |
| 14 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysRoleDO; | 10 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysRoleDO; |
| 15 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | 11 | +import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social.SysSocialUserDO; |
| 16 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; | 12 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; |
| 17 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysPostService; | 13 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysPostService; |
| 18 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; | 14 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; |
| 19 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysRoleService; | 15 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysRoleService; |
| 16 | +import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialService; | ||
| 20 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; | 17 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; |
| 18 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 19 | +import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService; | ||
| 20 | +import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | ||
| 21 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 21 | import io.swagger.annotations.Api; | 22 | import io.swagger.annotations.Api; |
| 22 | import io.swagger.annotations.ApiOperation; | 23 | import io.swagger.annotations.ApiOperation; |
| 23 | import lombok.extern.slf4j.Slf4j; | 24 | import lombok.extern.slf4j.Slf4j; |
| @@ -30,9 +31,9 @@ import javax.validation.Valid; | @@ -30,9 +31,9 @@ import javax.validation.Valid; | ||
| 30 | import java.io.IOException; | 31 | import java.io.IOException; |
| 31 | import java.util.List; | 32 | import java.util.List; |
| 32 | 33 | ||
| 34 | +import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.FILE_IS_EMPTY; | ||
| 33 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 35 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 34 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | 36 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 35 | -import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.FILE_IS_EMPTY; | ||
| 36 | 37 | ||
| 37 | @Api(tags = "用户个人中心") | 38 | @Api(tags = "用户个人中心") |
| 38 | @RestController | 39 | @RestController |
| @@ -44,6 +45,8 @@ public class SysUserProfileController { | @@ -44,6 +45,8 @@ public class SysUserProfileController { | ||
| 44 | @Resource | 45 | @Resource |
| 45 | private SysUserService userService; | 46 | private SysUserService userService; |
| 46 | @Resource | 47 | @Resource |
| 48 | + private SysUserCoreService userCoreService; | ||
| 49 | + @Resource | ||
| 47 | private SysDeptService deptService; | 50 | private SysDeptService deptService; |
| 48 | @Resource | 51 | @Resource |
| 49 | private SysPostService postService; | 52 | private SysPostService postService; |
| @@ -58,7 +61,7 @@ public class SysUserProfileController { | @@ -58,7 +61,7 @@ public class SysUserProfileController { | ||
| 58 | @ApiOperation("获得登录用户信息") | 61 | @ApiOperation("获得登录用户信息") |
| 59 | public CommonResult<SysUserProfileRespVO> profile() { | 62 | public CommonResult<SysUserProfileRespVO> profile() { |
| 60 | // 获得用户基本信息 | 63 | // 获得用户基本信息 |
| 61 | - SysUserDO user = userService.getUser(getLoginUserId()); | 64 | + SysUserDO user = userCoreService.getUser(getLoginUserId()); |
| 62 | SysUserProfileRespVO resp = SysUserConvert.INSTANCE.convert03(user); | 65 | SysUserProfileRespVO resp = SysUserConvert.INSTANCE.convert03(user); |
| 63 | // 获得用户角色 | 66 | // 获得用户角色 |
| 64 | List<SysRoleDO> userRoles = roleService.getRolesFromCache(permissionService.listUserRoleIs(user.getId())); | 67 | List<SysRoleDO> userRoles = roleService.getRolesFromCache(permissionService.listUserRoleIs(user.getId())); |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/user/vo/user/SysUserImportExcelVO.java
| @@ -8,6 +8,7 @@ import lombok.AllArgsConstructor; | @@ -8,6 +8,7 @@ import lombok.AllArgsConstructor; | ||
| 8 | import lombok.Builder; | 8 | import lombok.Builder; |
| 9 | import lombok.Data; | 9 | import lombok.Data; |
| 10 | import lombok.NoArgsConstructor; | 10 | import lombok.NoArgsConstructor; |
| 11 | +import lombok.experimental.Accessors; | ||
| 11 | 12 | ||
| 12 | /** | 13 | /** |
| 13 | * 用户 Excel 导入 VO | 14 | * 用户 Excel 导入 VO |
| @@ -16,6 +17,7 @@ import lombok.NoArgsConstructor; | @@ -16,6 +17,7 @@ import lombok.NoArgsConstructor; | ||
| 16 | @Builder | 17 | @Builder |
| 17 | @AllArgsConstructor | 18 | @AllArgsConstructor |
| 18 | @NoArgsConstructor | 19 | @NoArgsConstructor |
| 20 | +@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题 | ||
| 19 | public class SysUserImportExcelVO { | 21 | public class SysUserImportExcelVO { |
| 20 | 22 | ||
| 21 | @ExcelProperty("登录名称") | 23 | @ExcelProperty("登录名称") |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/convert/auth/SysAuthConvert.java
| @@ -2,18 +2,13 @@ package cn.iocoder.yudao.adminserver.modules.system.convert.auth; | @@ -2,18 +2,13 @@ package cn.iocoder.yudao.adminserver.modules.system.convert.auth; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthMenuRespVO; | 3 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthMenuRespVO; |
| 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthPermissionInfoRespVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthPermissionInfoRespVO; |
| 5 | -import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthSocialLogin2ReqVO; | ||
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthSocialLoginReqVO; | ||
| 7 | -import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; | ||
| 8 | -import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; | ||
| 9 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysMenuDO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysMenuDO; |
| 10 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysRoleDO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysRoleDO; |
| 11 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 12 | import cn.iocoder.yudao.adminserver.modules.system.enums.permission.MenuIdEnum; | 7 | import cn.iocoder.yudao.adminserver.modules.system.enums.permission.MenuIdEnum; |
| 8 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 13 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 9 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 14 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 10 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 15 | import cn.iocoder.yudao.framework.security.core.LoginUser; | 11 | import cn.iocoder.yudao.framework.security.core.LoginUser; |
| 16 | -import me.zhyd.oauth.model.AuthCallback; | ||
| 17 | import org.mapstruct.Mapper; | 12 | import org.mapstruct.Mapper; |
| 18 | import org.mapstruct.Mapping; | 13 | import org.mapstruct.Mapping; |
| 19 | import org.mapstruct.factory.Mappers; | 14 | import org.mapstruct.factory.Mappers; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/convert/logger/SysOperateLogConvert.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.convert.logger; | 1 | package cn.iocoder.yudao.adminserver.modules.system.convert.logger; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.framework.operatelog.core.dto.OperateLogCreateReqDTO; | ||
| 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogExcelVO; | 3 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogExcelVO; |
| 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogRespVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogRespVO; |
| 7 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.logger.SysOperateLogDO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.logger.SysOperateLogDO; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | 6 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; |
| 7 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 9 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | 8 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 9 | +import cn.iocoder.yudao.framework.operatelog.core.dto.OperateLogCreateReqDTO; | ||
| 10 | import org.mapstruct.Mapper; | 10 | import org.mapstruct.Mapper; |
| 11 | import org.mapstruct.factory.Mappers; | 11 | import org.mapstruct.factory.Mappers; |
| 12 | 12 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/convert/sms/SysSmsChannelConvert.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.convert.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.convert.sms; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties; | ||
| 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelCreateReqVO; | 3 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelCreateReqVO; |
| 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelRespVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelRespVO; |
| 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelSimpleRespVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelSimpleRespVO; |
| 8 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelUpdateReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelUpdateReqVO; |
| 9 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsChannelDO; | 7 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsChannelDO; |
| 8 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 9 | +import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties; | ||
| 10 | import org.mapstruct.Mapper; | 10 | import org.mapstruct.Mapper; |
| 11 | import org.mapstruct.factory.Mappers; | 11 | import org.mapstruct.factory.Mappers; |
| 12 | 12 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/convert/sms/SysSmsLogConvert.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.convert.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.convert.sms; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogExcelVO; | 3 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogExcelVO; |
| 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogRespVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogRespVO; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsLogDO; | 5 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsLogDO; |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 7 | import org.mapstruct.Mapper; | 7 | import org.mapstruct.Mapper; |
| 8 | import org.mapstruct.factory.Mappers; | 8 | import org.mapstruct.factory.Mappers; |
| 9 | 9 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/convert/sms/SysSmsTemplateConvert.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.convert.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.convert.sms; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateCreateReqVO; | 3 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateCreateReqVO; |
| 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateExcelVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateExcelVO; |
| 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateRespVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateRespVO; |
| 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateUpdateReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateUpdateReqVO; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | 7 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; |
| 8 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 9 | import org.mapstruct.Mapper; | 9 | import org.mapstruct.Mapper; |
| 10 | import org.mapstruct.factory.Mappers; | 10 | import org.mapstruct.factory.Mappers; |
| 11 | 11 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/convert/user/SysUserConvert.java
| @@ -8,7 +8,7 @@ import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO | @@ -8,7 +8,7 @@ import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO | ||
| 8 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO; | 8 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO; |
| 9 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysRoleDO; | 9 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysRoleDO; |
| 10 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social.SysSocialUserDO; | 10 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social.SysSocialUserDO; |
| 11 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | 11 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; |
| 12 | import org.mapstruct.Mapper; | 12 | import org.mapstruct.Mapper; |
| 13 | import org.mapstruct.factory.Mappers; | 13 | import org.mapstruct.factory.Mappers; |
| 14 | 14 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/dataobject/logger/SysOperateLogDO.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.logger; | 1 | package cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.logger; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum; | 5 | import cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 6 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 7 | import com.baomidou.mybatisplus.annotation.TableField; | 7 | import com.baomidou.mybatisplus.annotation.TableField; |
| 8 | import com.baomidou.mybatisplus.annotation.TableId; | 8 | import com.baomidou.mybatisplus.annotation.TableId; |
| 9 | import com.baomidou.mybatisplus.annotation.TableName; | 9 | import com.baomidou.mybatisplus.annotation.TableName; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/dataobject/social/SysSocialUserDO.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social; | 1 | package cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | 3 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; |
| 4 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 4 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 5 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 6 | import com.baomidou.mybatisplus.annotation.TableId; | 6 | import com.baomidou.mybatisplus.annotation.TableId; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/mysql/sms/SysSmsChannelMapper.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelPageReqVO; | ||
| 4 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsChannelDO; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 6 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; | 7 | import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelPageReqVO; | ||
| 7 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsChannelDO; | ||
| 8 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | import org.apache.ibatis.annotations.Select; | 9 | import org.apache.ibatis.annotations.Select; |
| 10 | 10 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/mysql/sms/SysSmsLogMapper.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogExportReqVO; | ||
| 4 | +import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogPageReqVO; | ||
| 5 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsLogDO; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 7 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; | 8 | import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogExportReqVO; | ||
| 7 | -import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogPageReqVO; | ||
| 8 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsLogDO; | ||
| 9 | import org.apache.ibatis.annotations.Mapper; | 9 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 10 | ||
| 11 | import java.util.List; | 11 | import java.util.List; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/mysql/sms/SysSmsTemplateMapper.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateExportReqVO; | ||
| 4 | +import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplatePageReqVO; | ||
| 5 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 7 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; | 8 | import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateExportReqVO; | ||
| 7 | -import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplatePageReqVO; | ||
| 8 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 9 | import org.apache.ibatis.annotations.Mapper; | 9 | import org.apache.ibatis.annotations.Mapper; |
| 10 | -import org.apache.ibatis.annotations.Select; | ||
| 11 | 10 | ||
| 12 | -import java.util.Date; | ||
| 13 | import java.util.List; | 11 | import java.util.List; |
| 14 | 12 | ||
| 15 | @Mapper | 13 | @Mapper |
| @@ -47,7 +45,4 @@ public interface SysSmsTemplateMapper extends BaseMapperX<SysSmsTemplateDO> { | @@ -47,7 +45,4 @@ public interface SysSmsTemplateMapper extends BaseMapperX<SysSmsTemplateDO> { | ||
| 47 | return selectCount("channel_id", channelId); | 45 | return selectCount("channel_id", channelId); |
| 48 | } | 46 | } |
| 49 | 47 | ||
| 50 | - @Select("SELECT id FROM sys_sms_template WHERE update_time > #{maxUpdateTime} LIMIT 1") | ||
| 51 | - Long selectExistsByUpdateTimeAfter(Date maxUpdateTime); | ||
| 52 | - | ||
| 53 | } | 48 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/mysql/user/SysUserMapper.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.dal.mysql.user; | 1 | package cn.iocoder.yudao.adminserver.modules.system.dal.mysql.user; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; |
| 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.SysUserExportReqVO; | 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.SysUserExportReqVO; |
| 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.SysUserPageReqVO; | 8 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.SysUserPageReqVO; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 9 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 9 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 10 | import org.apache.ibatis.annotations.Mapper; | 10 | import org.apache.ibatis.annotations.Mapper; |
| 11 | 11 | ||
| @@ -19,14 +19,14 @@ public interface SysUserMapper extends BaseMapperX<SysUserDO> { | @@ -19,14 +19,14 @@ public interface SysUserMapper extends BaseMapperX<SysUserDO> { | ||
| 19 | return selectOne(new QueryWrapper<SysUserDO>().eq("username", username)); | 19 | return selectOne(new QueryWrapper<SysUserDO>().eq("username", username)); |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | - default SysUserDO selectByMobile(String mobile) { | ||
| 23 | - return selectOne(new QueryWrapper<SysUserDO>().eq("mobile", mobile)); | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | default SysUserDO selectByEmail(String email) { | 22 | default SysUserDO selectByEmail(String email) { |
| 27 | return selectOne(new QueryWrapper<SysUserDO>().eq("email", email)); | 23 | return selectOne(new QueryWrapper<SysUserDO>().eq("email", email)); |
| 28 | } | 24 | } |
| 29 | 25 | ||
| 26 | + default SysUserDO selectByMobile(String mobile) { | ||
| 27 | + return selectOne(new QueryWrapper<SysUserDO>().eq("mobile", mobile)); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | default PageResult<SysUserDO> selectPage(SysUserPageReqVO reqVO, Collection<Long> deptIds) { | 30 | default PageResult<SysUserDO> selectPage(SysUserPageReqVO reqVO, Collection<Long> deptIds) { |
| 31 | return selectPage(reqVO, new QueryWrapperX<SysUserDO>() | 31 | return selectPage(reqVO, new QueryWrapperX<SysUserDO>() |
| 32 | .likeIfPresent("username", reqVO.getUsername()) | 32 | .likeIfPresent("username", reqVO.getUsername()) |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysErrorCodeConstants.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.enums; | 1 | package cn.iocoder.yudao.adminserver.modules.system.enums; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.exception.ErrorCode; | 3 | import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
| 4 | +import javafx.beans.binding.MapExpression; | ||
| 4 | 5 | ||
| 5 | /** | 6 | /** |
| 6 | * System 错误码枚举类 | 7 | * System 错误码枚举类 |
| @@ -85,10 +86,6 @@ public interface SysErrorCodeConstants { | @@ -85,10 +86,6 @@ public interface SysErrorCodeConstants { | ||
| 85 | ErrorCode SMS_TEMPLATE_NOT_EXISTS = new ErrorCode(1002011000, "短信模板不存在"); | 86 | ErrorCode SMS_TEMPLATE_NOT_EXISTS = new ErrorCode(1002011000, "短信模板不存在"); |
| 86 | ErrorCode SMS_TEMPLATE_CODE_DUPLICATE = new ErrorCode(1002011001, "已经存在编码为【{}】的短信模板"); | 87 | ErrorCode SMS_TEMPLATE_CODE_DUPLICATE = new ErrorCode(1002011001, "已经存在编码为【{}】的短信模板"); |
| 87 | 88 | ||
| 88 | - // ========== 短信发送 1002012000 ========== | ||
| 89 | - ErrorCode SMS_SEND_MOBILE_NOT_EXISTS = new ErrorCode(1002012000, "手机号不存在"); | ||
| 90 | - ErrorCode SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS = new ErrorCode(1002012001, "模板参数({})缺失"); | ||
| 91 | - | ||
| 92 | // ========== 错误码模块 1002013000 ========== | 89 | // ========== 错误码模块 1002013000 ========== |
| 93 | ErrorCode ERROR_CODE_NOT_EXISTS = new ErrorCode(1002013000, "错误码不存在"); | 90 | ErrorCode ERROR_CODE_NOT_EXISTS = new ErrorCode(1002013000, "错误码不存在"); |
| 94 | ErrorCode ERROR_CODE_DUPLICATE = new ErrorCode(1002013001, "已经存在编码为【{}】的错误码"); | 91 | ErrorCode ERROR_CODE_DUPLICATE = new ErrorCode(1002013001, "已经存在编码为【{}】的错误码"); |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/mq/consumer/sms/SysSmsSendConsumer.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.mq.consumer.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.mq.consumer.sms; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.mq.message.sms.SysSmsSendMessage; | ||
| 4 | +import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsCoreService; | ||
| 3 | import cn.iocoder.yudao.framework.mq.core.stream.AbstractStreamMessageListener; | 5 | import cn.iocoder.yudao.framework.mq.core.stream.AbstractStreamMessageListener; |
| 4 | -import cn.iocoder.yudao.adminserver.modules.system.mq.message.sms.SysSmsSendMessage; | ||
| 5 | -import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsService; | ||
| 6 | import lombok.extern.slf4j.Slf4j; | 6 | import lombok.extern.slf4j.Slf4j; |
| 7 | import org.springframework.stereotype.Component; | 7 | import org.springframework.stereotype.Component; |
| 8 | 8 | ||
| @@ -19,12 +19,12 @@ import javax.annotation.Resource; | @@ -19,12 +19,12 @@ import javax.annotation.Resource; | ||
| 19 | public class SysSmsSendConsumer extends AbstractStreamMessageListener<SysSmsSendMessage> { | 19 | public class SysSmsSendConsumer extends AbstractStreamMessageListener<SysSmsSendMessage> { |
| 20 | 20 | ||
| 21 | @Resource | 21 | @Resource |
| 22 | - private SysSmsService smsService; | 22 | + private SysSmsCoreService smsCoreService; |
| 23 | 23 | ||
| 24 | @Override | 24 | @Override |
| 25 | public void onMessage(SysSmsSendMessage message) { | 25 | public void onMessage(SysSmsSendMessage message) { |
| 26 | log.info("[onMessage][消息内容({})]", message); | 26 | log.info("[onMessage][消息内容({})]", message); |
| 27 | - smsService.doSendSms(message); | 27 | + smsCoreService.doSendSms(message); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | } | 30 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/mq/consumer/sms/SysSmsTemplateRefreshConsumer.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.mq.consumer.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.mq.consumer.sms; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessageListener; | ||
| 4 | import cn.iocoder.yudao.adminserver.modules.system.mq.message.sms.SysSmsTemplateRefreshMessage; | 3 | import cn.iocoder.yudao.adminserver.modules.system.mq.message.sms.SysSmsTemplateRefreshMessage; |
| 5 | -import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsTemplateService; | 4 | +import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsTemplateCoreService; |
| 5 | +import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessageListener; | ||
| 6 | import lombok.extern.slf4j.Slf4j; | 6 | import lombok.extern.slf4j.Slf4j; |
| 7 | import org.springframework.stereotype.Component; | 7 | import org.springframework.stereotype.Component; |
| 8 | 8 | ||
| @@ -18,12 +18,12 @@ import javax.annotation.Resource; | @@ -18,12 +18,12 @@ import javax.annotation.Resource; | ||
| 18 | public class SysSmsTemplateRefreshConsumer extends AbstractChannelMessageListener<SysSmsTemplateRefreshMessage> { | 18 | public class SysSmsTemplateRefreshConsumer extends AbstractChannelMessageListener<SysSmsTemplateRefreshMessage> { |
| 19 | 19 | ||
| 20 | @Resource | 20 | @Resource |
| 21 | - private SysSmsTemplateService smsTemplateService; | 21 | + private SysSmsTemplateCoreService smsTemplateCoreService; |
| 22 | 22 | ||
| 23 | @Override | 23 | @Override |
| 24 | public void onMessage(SysSmsTemplateRefreshMessage message) { | 24 | public void onMessage(SysSmsTemplateRefreshMessage message) { |
| 25 | log.info("[onMessage][收到 SmsTemplate 刷新消息]"); | 25 | log.info("[onMessage][收到 SmsTemplate 刷新消息]"); |
| 26 | - smsTemplateService.initLocalCache(); | 26 | + smsTemplateCoreService.initLocalCache(); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | } | 29 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/mq/producer/sms/SysSmsProducer.java
| @@ -3,7 +3,6 @@ package cn.iocoder.yudao.adminserver.modules.system.mq.producer.sms; | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.adminserver.modules.system.mq.producer.sms; | ||
| 3 | import cn.iocoder.yudao.framework.common.core.KeyValue; | 3 | import cn.iocoder.yudao.framework.common.core.KeyValue; |
| 4 | import cn.iocoder.yudao.framework.mq.core.util.RedisMessageUtils; | 4 | import cn.iocoder.yudao.framework.mq.core.util.RedisMessageUtils; |
| 5 | import cn.iocoder.yudao.adminserver.modules.system.mq.message.sms.SysSmsChannelRefreshMessage; | 5 | import cn.iocoder.yudao.adminserver.modules.system.mq.message.sms.SysSmsChannelRefreshMessage; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.mq.message.sms.SysSmsSendMessage; | ||
| 7 | import cn.iocoder.yudao.adminserver.modules.system.mq.message.sms.SysSmsTemplateRefreshMessage; | 6 | import cn.iocoder.yudao.adminserver.modules.system.mq.message.sms.SysSmsTemplateRefreshMessage; |
| 8 | import lombok.extern.slf4j.Slf4j; | 7 | import lombok.extern.slf4j.Slf4j; |
| 9 | import org.springframework.data.redis.core.StringRedisTemplate; | 8 | import org.springframework.data.redis.core.StringRedisTemplate; |
| @@ -26,22 +25,6 @@ public class SysSmsProducer { | @@ -26,22 +25,6 @@ public class SysSmsProducer { | ||
| 26 | private StringRedisTemplate stringRedisTemplate; | 25 | private StringRedisTemplate stringRedisTemplate; |
| 27 | 26 | ||
| 28 | /** | 27 | /** |
| 29 | - * 发送 {@link SysSmsSendMessage} 消息 | ||
| 30 | - * | ||
| 31 | - * @param logId 短信日志编号 | ||
| 32 | - * @param mobile 手机号 | ||
| 33 | - * @param channelId 渠道编号 | ||
| 34 | - * @param apiTemplateId 短信模板编号 | ||
| 35 | - * @param templateParams 短信模板参数 | ||
| 36 | - */ | ||
| 37 | - public void sendSmsSendMessage(Long logId, String mobile, | ||
| 38 | - Long channelId, String apiTemplateId, List<KeyValue<String, Object>> templateParams) { | ||
| 39 | - SysSmsSendMessage message = new SysSmsSendMessage().setLogId(logId).setMobile(mobile); | ||
| 40 | - message.setChannelId(channelId).setApiTemplateId(apiTemplateId).setTemplateParams(templateParams); | ||
| 41 | - RedisMessageUtils.sendStreamMessage(stringRedisTemplate, message); | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - /** | ||
| 45 | * 发送 {@link SysSmsChannelRefreshMessage} 消息 | 28 | * 发送 {@link SysSmsChannelRefreshMessage} 消息 |
| 46 | */ | 29 | */ |
| 47 | public void sendSmsChannelRefreshMessage() { | 30 | public void sendSmsChannelRefreshMessage() { |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/auth/impl/SysAuthServiceImpl.java
| @@ -7,7 +7,6 @@ import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAu | @@ -7,7 +7,6 @@ import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAu | ||
| 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthSocialLoginReqVO; | 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthSocialLoginReqVO; |
| 8 | import cn.iocoder.yudao.adminserver.modules.system.convert.auth.SysAuthConvert; | 8 | import cn.iocoder.yudao.adminserver.modules.system.convert.auth.SysAuthConvert; |
| 9 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social.SysSocialUserDO; | 9 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social.SysSocialUserDO; |
| 10 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 11 | import cn.iocoder.yudao.adminserver.modules.system.enums.logger.SysLoginLogTypeEnum; | 10 | import cn.iocoder.yudao.adminserver.modules.system.enums.logger.SysLoginLogTypeEnum; |
| 12 | import cn.iocoder.yudao.adminserver.modules.system.enums.logger.SysLoginResultEnum; | 11 | import cn.iocoder.yudao.adminserver.modules.system.enums.logger.SysLoginResultEnum; |
| 13 | import cn.iocoder.yudao.adminserver.modules.system.service.auth.SysAuthService; | 12 | import cn.iocoder.yudao.adminserver.modules.system.service.auth.SysAuthService; |
| @@ -15,9 +14,11 @@ import cn.iocoder.yudao.adminserver.modules.system.service.common.SysCaptchaServ | @@ -15,9 +14,11 @@ import cn.iocoder.yudao.adminserver.modules.system.service.common.SysCaptchaServ | ||
| 15 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; | 14 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; |
| 16 | import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialService; | 15 | import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialService; |
| 17 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; | 16 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; |
| 17 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 18 | import cn.iocoder.yudao.coreservice.modules.system.service.auth.SysUserSessionCoreService; | 18 | import cn.iocoder.yudao.coreservice.modules.system.service.auth.SysUserSessionCoreService; |
| 19 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.SysLoginLogCoreService; | 19 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.SysLoginLogCoreService; |
| 20 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.dto.SysLoginLogCreateReqDTO; | 20 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.dto.SysLoginLogCreateReqDTO; |
| 21 | +import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService; | ||
| 21 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 22 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 22 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 23 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 23 | import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; | 24 | import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; |
| @@ -62,6 +63,8 @@ public class SysAuthServiceImpl implements SysAuthService { | @@ -62,6 +63,8 @@ public class SysAuthServiceImpl implements SysAuthService { | ||
| 62 | @Resource | 63 | @Resource |
| 63 | private SysUserService userService; | 64 | private SysUserService userService; |
| 64 | @Resource | 65 | @Resource |
| 66 | + private SysUserCoreService userCoreService; | ||
| 67 | + @Resource | ||
| 65 | private SysPermissionService permissionService; | 68 | private SysPermissionService permissionService; |
| 66 | @Resource | 69 | @Resource |
| 67 | private SysCaptchaService captchaService; | 70 | private SysCaptchaService captchaService; |
| @@ -86,7 +89,7 @@ public class SysAuthServiceImpl implements SysAuthService { | @@ -86,7 +89,7 @@ public class SysAuthServiceImpl implements SysAuthService { | ||
| 86 | @Override | 89 | @Override |
| 87 | public LoginUser mockLogin(Long userId) { | 90 | public LoginUser mockLogin(Long userId) { |
| 88 | // 获取用户编号对应的 SysUserDO | 91 | // 获取用户编号对应的 SysUserDO |
| 89 | - SysUserDO user = userService.getUser(userId); | 92 | + SysUserDO user = userCoreService.getUser(userId); |
| 90 | if (user == null) { | 93 | if (user == null) { |
| 91 | throw new UsernameNotFoundException(String.valueOf(userId)); | 94 | throw new UsernameNotFoundException(String.valueOf(userId)); |
| 92 | } | 95 | } |
| @@ -201,7 +204,7 @@ public class SysAuthServiceImpl implements SysAuthService { | @@ -201,7 +204,7 @@ public class SysAuthServiceImpl implements SysAuthService { | ||
| 201 | } | 204 | } |
| 202 | 205 | ||
| 203 | // 自动登录 | 206 | // 自动登录 |
| 204 | - SysUserDO user = userService.getUser(socialUsers.get(0).getUserId()); | 207 | + SysUserDO user = userCoreService.getUser(socialUsers.get(0).getUserId()); |
| 205 | if (user == null) { | 208 | if (user == null) { |
| 206 | throw exception(USER_NOT_EXISTS); | 209 | throw exception(USER_NOT_EXISTS); |
| 207 | } | 210 | } |
| @@ -292,7 +295,7 @@ public class SysAuthServiceImpl implements SysAuthService { | @@ -292,7 +295,7 @@ public class SysAuthServiceImpl implements SysAuthService { | ||
| 292 | } | 295 | } |
| 293 | 296 | ||
| 294 | // 重新加载 SysUserDO 信息 | 297 | // 重新加载 SysUserDO 信息 |
| 295 | - SysUserDO user = userService.getUser(loginUser.getId()); | 298 | + SysUserDO user = userCoreService.getUser(loginUser.getId()); |
| 296 | if (user == null || CommonStatusEnum.DISABLE.getStatus().equals(user.getStatus())) { | 299 | if (user == null || CommonStatusEnum.DISABLE.getStatus().equals(user.getStatus())) { |
| 297 | throw exception(AUTH_TOKEN_EXPIRED); // 校验 token 时,用户被禁用的情况下,也认为 token 过期,方便前端跳转到登录界面 | 300 | throw exception(AUTH_TOKEN_EXPIRED); // 校验 token 时,用户被禁用的情况下,也认为 token 过期,方便前端跳转到登录界面 |
| 298 | } | 301 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/auth/impl/SysUserSessionServiceImpl.java
| @@ -3,18 +3,16 @@ package cn.iocoder.yudao.adminserver.modules.system.service.auth.impl; | @@ -3,18 +3,16 @@ package cn.iocoder.yudao.adminserver.modules.system.service.auth.impl; | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.util.StrUtil; | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.session.SysUserSessionPageReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.session.SysUserSessionPageReqVO; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 7 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.auth.SysUserSessionMapper; | 6 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.auth.SysUserSessionMapper; |
| 8 | import cn.iocoder.yudao.adminserver.modules.system.enums.logger.SysLoginLogTypeEnum; | 7 | import cn.iocoder.yudao.adminserver.modules.system.enums.logger.SysLoginLogTypeEnum; |
| 9 | import cn.iocoder.yudao.adminserver.modules.system.enums.logger.SysLoginResultEnum; | 8 | import cn.iocoder.yudao.adminserver.modules.system.enums.logger.SysLoginResultEnum; |
| 10 | import cn.iocoder.yudao.adminserver.modules.system.service.auth.SysUserSessionService; | 9 | import cn.iocoder.yudao.adminserver.modules.system.service.auth.SysUserSessionService; |
| 11 | -import cn.iocoder.yudao.adminserver.modules.system.service.logger.SysLoginLogService; | ||
| 12 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; | 10 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; |
| 13 | import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.auth.SysUserSessionDO; | 11 | import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.auth.SysUserSessionDO; |
| 12 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 14 | import cn.iocoder.yudao.coreservice.modules.system.dal.redis.auth.SysLoginUserCoreRedisDAO; | 13 | import cn.iocoder.yudao.coreservice.modules.system.dal.redis.auth.SysLoginUserCoreRedisDAO; |
| 15 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.SysLoginLogCoreService; | 14 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.SysLoginLogCoreService; |
| 16 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.dto.SysLoginLogCreateReqDTO; | 15 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.dto.SysLoginLogCreateReqDTO; |
| 17 | -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | ||
| 18 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 16 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 19 | import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; | 17 | import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; |
| 20 | import com.google.common.collect.Lists; | 18 | import com.google.common.collect.Lists; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/logger/impl/SysOperateLogServiceImpl.java
| @@ -2,17 +2,17 @@ package cn.iocoder.yudao.adminserver.modules.system.service.logger.impl; | @@ -2,17 +2,17 @@ package cn.iocoder.yudao.adminserver.modules.system.service.logger.impl; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.util.StrUtil; | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | -import cn.iocoder.yudao.framework.operatelog.core.dto.OperateLogCreateReqDTO; | ||
| 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogExportReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogExportReqVO; |
| 8 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogPageReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogPageReqVO; |
| 9 | import cn.iocoder.yudao.adminserver.modules.system.convert.logger.SysOperateLogConvert; | 7 | import cn.iocoder.yudao.adminserver.modules.system.convert.logger.SysOperateLogConvert; |
| 10 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.logger.SysOperateLogDO; | 8 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.logger.SysOperateLogDO; |
| 11 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 12 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.logger.SysOperateLogMapper; | 9 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.logger.SysOperateLogMapper; |
| 13 | import cn.iocoder.yudao.adminserver.modules.system.service.logger.SysOperateLogService; | 10 | import cn.iocoder.yudao.adminserver.modules.system.service.logger.SysOperateLogService; |
| 14 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; | 11 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; |
| 12 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 13 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 15 | import cn.iocoder.yudao.framework.common.util.string.StrUtils; | 14 | import cn.iocoder.yudao.framework.common.util.string.StrUtils; |
| 15 | +import cn.iocoder.yudao.framework.operatelog.core.dto.OperateLogCreateReqDTO; | ||
| 16 | import lombok.extern.slf4j.Slf4j; | 16 | import lombok.extern.slf4j.Slf4j; |
| 17 | import org.springframework.scheduling.annotation.Async; | 17 | import org.springframework.scheduling.annotation.Async; |
| 18 | import org.springframework.scheduling.annotation.AsyncResult; | 18 | import org.springframework.scheduling.annotation.AsyncResult; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsChannelService.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.service.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.service.sms; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsChannelDO; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelCreateReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelCreateReqVO; |
| 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelPageReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelPageReqVO; |
| 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelUpdateReqVO; | 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelUpdateReqVO; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsChannelDO; | ||
| 8 | 8 | ||
| 9 | import javax.validation.Valid; | 9 | import javax.validation.Valid; |
| 10 | import java.util.Collection; | 10 | import java.util.Collection; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsLogService.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.service.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.service.sms; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogExportReqVO; | 3 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogExportReqVO; |
| 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogPageReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogPageReqVO; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsLogDO; | ||
| 7 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | 5 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsLogDO; |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 8 | 7 | ||
| 9 | -import java.util.Date; | ||
| 10 | import java.util.List; | 8 | import java.util.List; |
| 11 | -import java.util.Map; | ||
| 12 | 9 | ||
| 13 | /** | 10 | /** |
| 14 | - * 短信日志 Service 实现类 | 11 | + * 短信日志 Service 接口 |
| 15 | * | 12 | * |
| 16 | * @author zzf | 13 | * @author zzf |
| 17 | * @date 13:48 2021/3/2 | 14 | * @date 13:48 2021/3/2 |
| @@ -19,46 +16,6 @@ import java.util.Map; | @@ -19,46 +16,6 @@ import java.util.Map; | ||
| 19 | public interface SysSmsLogService { | 16 | public interface SysSmsLogService { |
| 20 | 17 | ||
| 21 | /** | 18 | /** |
| 22 | - * 创建短信日志 | ||
| 23 | - * | ||
| 24 | - * @param mobile 手机号 | ||
| 25 | - * @param userId 用户编号 | ||
| 26 | - * @param userType 用户类型 | ||
| 27 | - * @param isSend 是否发送 | ||
| 28 | - * @param template 短信模板 | ||
| 29 | - * @param templateContent 短信内容 | ||
| 30 | - * @param templateParams 短信参数 | ||
| 31 | - * @return 发送日志编号 | ||
| 32 | - */ | ||
| 33 | - Long createSmsLog(String mobile, Long userId, Integer userType, Boolean isSend, | ||
| 34 | - SysSmsTemplateDO template, String templateContent, Map<String, Object> templateParams); | ||
| 35 | - | ||
| 36 | - /** | ||
| 37 | - * 更新日志的发送结果 | ||
| 38 | - * | ||
| 39 | - * @param id 日志编号 | ||
| 40 | - * @param sendCode 发送结果的编码 | ||
| 41 | - * @param sendMsg 发送结果的提示 | ||
| 42 | - * @param apiSendCode 短信 API 发送结果的编码 | ||
| 43 | - * @param apiSendMsg 短信 API 发送失败的提示 | ||
| 44 | - * @param apiRequestId 短信 API 发送返回的唯一请求 ID | ||
| 45 | - * @param apiSerialNo 短信 API 发送返回的序号 | ||
| 46 | - */ | ||
| 47 | - void updateSmsSendResult(Long id, Integer sendCode, String sendMsg, | ||
| 48 | - String apiSendCode, String apiSendMsg, String apiRequestId, String apiSerialNo); | ||
| 49 | - | ||
| 50 | - /** | ||
| 51 | - * 更新日志的接收结果 | ||
| 52 | - * | ||
| 53 | - * @param id 日志编号 | ||
| 54 | - * @param success 是否接收成功 | ||
| 55 | - * @param receiveTime 用户接收时间 | ||
| 56 | - * @param apiReceiveCode API 接收结果的编码 | ||
| 57 | - * @param apiReceiveMsg API 接收结果的说明 | ||
| 58 | - */ | ||
| 59 | - void updateSmsReceiveResult(Long id, Boolean success, Date receiveTime, String apiReceiveCode, String apiReceiveMsg); | ||
| 60 | - | ||
| 61 | - /** | ||
| 62 | * 获得短信日志分页 | 19 | * 获得短信日志分页 |
| 63 | * | 20 | * |
| 64 | * @param pageReqVO 分页查询 | 21 | * @param pageReqVO 分页查询 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsTemplateService.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.service.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.service.sms; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateCreateReqVO; | 3 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateCreateReqVO; |
| 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateExportReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateExportReqVO; |
| 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplatePageReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplatePageReqVO; |
| 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateUpdateReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateUpdateReqVO; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | 7 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; |
| 8 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 9 | 9 | ||
| 10 | import javax.validation.Valid; | 10 | import javax.validation.Valid; |
| 11 | import java.util.Collection; | 11 | import java.util.Collection; |
| 12 | import java.util.List; | 12 | import java.util.List; |
| 13 | -import java.util.Map; | ||
| 14 | 13 | ||
| 15 | /** | 14 | /** |
| 16 | * 短信模板 Service 接口 | 15 | * 短信模板 Service 接口 |
| @@ -21,11 +20,6 @@ import java.util.Map; | @@ -21,11 +20,6 @@ import java.util.Map; | ||
| 21 | public interface SysSmsTemplateService { | 20 | public interface SysSmsTemplateService { |
| 22 | 21 | ||
| 23 | /** | 22 | /** |
| 24 | - * 初始化短信模板的本地缓存 | ||
| 25 | - */ | ||
| 26 | - void initLocalCache(); | ||
| 27 | - | ||
| 28 | - /** | ||
| 29 | * 获得短信模板 | 23 | * 获得短信模板 |
| 30 | * | 24 | * |
| 31 | * @param code 模板编码 | 25 | * @param code 模板编码 |
| @@ -34,23 +28,6 @@ public interface SysSmsTemplateService { | @@ -34,23 +28,6 @@ public interface SysSmsTemplateService { | ||
| 34 | SysSmsTemplateDO getSmsTemplateByCode(String code); | 28 | SysSmsTemplateDO getSmsTemplateByCode(String code); |
| 35 | 29 | ||
| 36 | /** | 30 | /** |
| 37 | - * 获得短信模板,从缓存中 | ||
| 38 | - * | ||
| 39 | - * @param code 模板编码 | ||
| 40 | - * @return 短信模板 | ||
| 41 | - */ | ||
| 42 | - SysSmsTemplateDO getSmsTemplateByCodeFromCache(String code); | ||
| 43 | - | ||
| 44 | - /** | ||
| 45 | - * 格式化短信内容 | ||
| 46 | - * | ||
| 47 | - * @param content 短信模板的内容 | ||
| 48 | - * @param params 内容的参数 | ||
| 49 | - * @return 格式化后的内容 | ||
| 50 | - */ | ||
| 51 | - String formatSmsTemplateContent(String content, Map<String, Object> params); | ||
| 52 | - | ||
| 53 | - /** | ||
| 54 | * 创建短信模板 | 31 | * 创建短信模板 |
| 55 | * | 32 | * |
| 56 | * @param createReqVO 创建信息 | 33 | * @param createReqVO 创建信息 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/impl/SysSmsChannelServiceImpl.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.service.sms.impl; | 1 | package cn.iocoder.yudao.adminserver.modules.system.service.sms.impl; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 6 | -import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | ||
| 7 | -import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties; | ||
| 8 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelCreateReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelCreateReqVO; |
| 9 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelPageReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelPageReqVO; |
| 10 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelUpdateReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelUpdateReqVO; |
| 11 | import cn.iocoder.yudao.adminserver.modules.system.convert.sms.SysSmsChannelConvert; | 7 | import cn.iocoder.yudao.adminserver.modules.system.convert.sms.SysSmsChannelConvert; |
| 12 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsChannelDO; | ||
| 13 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms.SysSmsChannelMapper; | 8 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms.SysSmsChannelMapper; |
| 14 | import cn.iocoder.yudao.adminserver.modules.system.mq.producer.sms.SysSmsProducer; | 9 | import cn.iocoder.yudao.adminserver.modules.system.mq.producer.sms.SysSmsProducer; |
| 15 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsChannelService; | 10 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsChannelService; |
| 16 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsTemplateService; | 11 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsTemplateService; |
| 12 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsChannelDO; | ||
| 13 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 14 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 15 | +import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | ||
| 16 | +import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties; | ||
| 17 | import lombok.extern.slf4j.Slf4j; | 17 | import lombok.extern.slf4j.Slf4j; |
| 18 | import org.springframework.scheduling.annotation.Scheduled; | 18 | import org.springframework.scheduling.annotation.Scheduled; |
| 19 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
| @@ -25,9 +25,9 @@ import java.util.Comparator; | @@ -25,9 +25,9 @@ import java.util.Comparator; | ||
| 25 | import java.util.Date; | 25 | import java.util.Date; |
| 26 | import java.util.List; | 26 | import java.util.List; |
| 27 | 27 | ||
| 28 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 29 | import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.SMS_CHANNEL_HAS_CHILDREN; | 28 | import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.SMS_CHANNEL_HAS_CHILDREN; |
| 30 | import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.SMS_CHANNEL_NOT_EXISTS; | 29 | import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.SMS_CHANNEL_NOT_EXISTS; |
| 30 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| 33 | * 短信渠道Service实现类 | 33 | * 短信渠道Service实现类 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/impl/SysSmsLogServiceImpl.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.service.sms.impl; | 1 | package cn.iocoder.yudao.adminserver.modules.system.service.sms.impl; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogExportReqVO; | 3 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogExportReqVO; |
| 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogPageReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogPageReqVO; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsLogDO; | ||
| 8 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 9 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms.SysSmsLogMapper; | 5 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms.SysSmsLogMapper; |
| 10 | -import cn.iocoder.yudao.adminserver.modules.system.enums.sms.SysSmsReceiveStatusEnum; | ||
| 11 | -import cn.iocoder.yudao.adminserver.modules.system.enums.sms.SysSmsSendStatusEnum; | ||
| 12 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsLogService; | 6 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsLogService; |
| 7 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsLogDO; | ||
| 8 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 13 | import lombok.extern.slf4j.Slf4j; | 9 | import lombok.extern.slf4j.Slf4j; |
| 14 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
| 15 | 11 | ||
| 16 | import javax.annotation.Resource; | 12 | import javax.annotation.Resource; |
| 17 | -import java.util.Date; | ||
| 18 | import java.util.List; | 13 | import java.util.List; |
| 19 | -import java.util.Map; | ||
| 20 | -import java.util.Objects; | ||
| 21 | 14 | ||
| 22 | /** | 15 | /** |
| 23 | * 短信日志 Service 实现类 | 16 | * 短信日志 Service 实现类 |
| @@ -33,47 +26,6 @@ public class SysSmsLogServiceImpl implements SysSmsLogService { | @@ -33,47 +26,6 @@ public class SysSmsLogServiceImpl implements SysSmsLogService { | ||
| 33 | private SysSmsLogMapper smsLogMapper; | 26 | private SysSmsLogMapper smsLogMapper; |
| 34 | 27 | ||
| 35 | @Override | 28 | @Override |
| 36 | - public Long createSmsLog(String mobile, Long userId, Integer userType, Boolean isSend, | ||
| 37 | - SysSmsTemplateDO template, String templateContent, Map<String, Object> templateParams) { | ||
| 38 | - SysSmsLogDO.SysSmsLogDOBuilder logBuilder = SysSmsLogDO.builder(); | ||
| 39 | - // 根据是否要发送,设置状态 | ||
| 40 | - logBuilder.sendStatus(Objects.equals(isSend, true) ? SysSmsSendStatusEnum.INIT.getStatus() | ||
| 41 | - : SysSmsSendStatusEnum.IGNORE.getStatus()); | ||
| 42 | - // 设置手机相关字段 | ||
| 43 | - logBuilder.mobile(mobile).userId(userId).userType(userType); | ||
| 44 | - // 设置模板相关字段 | ||
| 45 | - logBuilder.templateId(template.getId()).templateCode(template.getCode()).templateType(template.getType()); | ||
| 46 | - logBuilder.templateContent(templateContent).templateParams(templateParams).apiTemplateId(template.getApiTemplateId()); | ||
| 47 | - // 设置渠道相关字段 | ||
| 48 | - logBuilder.channelId(template.getChannelId()).channelCode(template.getChannelCode()); | ||
| 49 | - // 设置接收相关字段 | ||
| 50 | - logBuilder.receiveStatus(SysSmsReceiveStatusEnum.INIT.getStatus()); | ||
| 51 | - | ||
| 52 | - // 插入数据库 | ||
| 53 | - SysSmsLogDO logDO = logBuilder.build(); | ||
| 54 | - smsLogMapper.insert(logDO); | ||
| 55 | - return logDO.getId(); | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | - @Override | ||
| 59 | - public void updateSmsSendResult(Long id, Integer sendCode, String sendMsg, | ||
| 60 | - String apiSendCode, String apiSendMsg, String apiRequestId, String apiSerialNo) { | ||
| 61 | - SysSmsSendStatusEnum sendStatus = CommonResult.isSuccess(sendCode) ? SysSmsSendStatusEnum.SUCCESS | ||
| 62 | - : SysSmsSendStatusEnum.FAILURE; | ||
| 63 | - smsLogMapper.updateById(SysSmsLogDO.builder().id(id).sendStatus(sendStatus.getStatus()).sendTime(new Date()) | ||
| 64 | - .sendCode(sendCode).sendMsg(sendMsg).apiSendCode(apiSendCode).apiSendMsg(apiSendMsg) | ||
| 65 | - .apiRequestId(apiRequestId).apiSerialNo(apiSerialNo).build()); | ||
| 66 | - } | ||
| 67 | - | ||
| 68 | - @Override | ||
| 69 | - public void updateSmsReceiveResult(Long id, Boolean success, Date receiveTime, String apiReceiveCode, String apiReceiveMsg) { | ||
| 70 | - SysSmsReceiveStatusEnum receiveStatus = Objects.equals(success, true) ? SysSmsReceiveStatusEnum.SUCCESS | ||
| 71 | - : SysSmsReceiveStatusEnum.FAILURE; | ||
| 72 | - smsLogMapper.updateById(SysSmsLogDO.builder().id(id).receiveStatus(receiveStatus.getStatus()).receiveTime(receiveTime) | ||
| 73 | - .apiReceiveCode(apiReceiveCode).apiReceiveMsg(apiReceiveMsg).build()); | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - @Override | ||
| 77 | public PageResult<SysSmsLogDO> getSmsLogPage(SysSmsLogPageReqVO pageReqVO) { | 29 | public PageResult<SysSmsLogDO> getSmsLogPage(SysSmsLogPageReqVO pageReqVO) { |
| 78 | return smsLogMapper.selectPage(pageReqVO); | 30 | return smsLogMapper.selectPage(pageReqVO); |
| 79 | } | 31 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/impl/SysSmsTemplateServiceImpl.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.service.sms.impl; | 1 | package cn.iocoder.yudao.adminserver.modules.system.service.sms.impl; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.collection.CollUtil; | ||
| 4 | import cn.hutool.core.util.ReUtil; | 3 | import cn.hutool.core.util.ReUtil; |
| 5 | -import cn.hutool.core.util.StrUtil; | ||
| 6 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 7 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 8 | -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 9 | -import cn.iocoder.yudao.framework.sms.core.client.SmsClient; | ||
| 10 | -import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | ||
| 11 | -import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; | ||
| 12 | -import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO; | ||
| 13 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateCreateReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateCreateReqVO; |
| 14 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateExportReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateExportReqVO; |
| 15 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplatePageReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplatePageReqVO; |
| 16 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateUpdateReqVO; | 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateUpdateReqVO; |
| 17 | import cn.iocoder.yudao.adminserver.modules.system.convert.sms.SysSmsTemplateConvert; | 8 | import cn.iocoder.yudao.adminserver.modules.system.convert.sms.SysSmsTemplateConvert; |
| 18 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsChannelDO; | ||
| 19 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 20 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms.SysSmsTemplateMapper; | 9 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms.SysSmsTemplateMapper; |
| 21 | import cn.iocoder.yudao.adminserver.modules.system.mq.producer.sms.SysSmsProducer; | 10 | import cn.iocoder.yudao.adminserver.modules.system.mq.producer.sms.SysSmsProducer; |
| 22 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsChannelService; | 11 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsChannelService; |
| 23 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsTemplateService; | 12 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsTemplateService; |
| 13 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsChannelDO; | ||
| 14 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 15 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 16 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 17 | +import cn.iocoder.yudao.framework.sms.core.client.SmsClient; | ||
| 18 | +import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | ||
| 19 | +import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; | ||
| 20 | +import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO; | ||
| 24 | import com.google.common.annotations.VisibleForTesting; | 21 | import com.google.common.annotations.VisibleForTesting; |
| 25 | -import com.google.common.collect.ImmutableMap; | ||
| 26 | import lombok.extern.slf4j.Slf4j; | 22 | import lombok.extern.slf4j.Slf4j; |
| 27 | -import org.springframework.scheduling.annotation.Scheduled; | ||
| 28 | import org.springframework.stereotype.Service; | 23 | import org.springframework.stereotype.Service; |
| 29 | import org.springframework.util.Assert; | 24 | import org.springframework.util.Assert; |
| 30 | 25 | ||
| 31 | -import javax.annotation.PostConstruct; | ||
| 32 | import javax.annotation.Resource; | 26 | import javax.annotation.Resource; |
| 33 | -import java.util.*; | 27 | +import java.util.Collection; |
| 28 | +import java.util.List; | ||
| 29 | +import java.util.Objects; | ||
| 34 | import java.util.regex.Pattern; | 30 | import java.util.regex.Pattern; |
| 35 | 31 | ||
| 36 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 37 | import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.*; | 32 | import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.*; |
| 33 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 38 | 34 | ||
| 39 | /** | 35 | /** |
| 40 | * 短信模板Service实现类 | 36 | * 短信模板Service实现类 |
| @@ -51,24 +47,6 @@ public class SysSmsTemplateServiceImpl implements SysSmsTemplateService { | @@ -51,24 +47,6 @@ public class SysSmsTemplateServiceImpl implements SysSmsTemplateService { | ||
| 51 | */ | 47 | */ |
| 52 | private static final Pattern PATTERN_PARAMS = Pattern.compile("\\{(.*?)}"); | 48 | private static final Pattern PATTERN_PARAMS = Pattern.compile("\\{(.*?)}"); |
| 53 | 49 | ||
| 54 | - /** | ||
| 55 | - * 定时执行 {@link #schedulePeriodicRefresh()} 的周期 | ||
| 56 | - * 因为已经通过 Redis Pub/Sub 机制,所以频率不需要高 | ||
| 57 | - */ | ||
| 58 | - private static final long SCHEDULER_PERIOD = 5 * 60 * 1000L; | ||
| 59 | - | ||
| 60 | - /** | ||
| 61 | - * 短信模板缓存 | ||
| 62 | - * key:短信模板编码 {@link SysSmsTemplateDO#getCode()} | ||
| 63 | - * | ||
| 64 | - * 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向 | ||
| 65 | - */ | ||
| 66 | - private volatile Map<String, SysSmsTemplateDO> smsTemplateCache; | ||
| 67 | - /** | ||
| 68 | - * 缓存短信模板的最大更新时间,用于后续的增量轮询,判断是否有更新 | ||
| 69 | - */ | ||
| 70 | - private volatile Date maxUpdateTime; | ||
| 71 | - | ||
| 72 | @Resource | 50 | @Resource |
| 73 | private SysSmsTemplateMapper smsTemplateMapper; | 51 | private SysSmsTemplateMapper smsTemplateMapper; |
| 74 | 52 | ||
| @@ -81,68 +59,11 @@ public class SysSmsTemplateServiceImpl implements SysSmsTemplateService { | @@ -81,68 +59,11 @@ public class SysSmsTemplateServiceImpl implements SysSmsTemplateService { | ||
| 81 | @Resource | 59 | @Resource |
| 82 | private SysSmsProducer smsProducer; | 60 | private SysSmsProducer smsProducer; |
| 83 | 61 | ||
| 84 | - /** | ||
| 85 | - * 初始化 {@link #smsTemplateCache} 缓存 | ||
| 86 | - */ | ||
| 87 | - @Override | ||
| 88 | - @PostConstruct | ||
| 89 | - public void initLocalCache() { | ||
| 90 | - // 获取短信模板列表,如果有更新 | ||
| 91 | - List<SysSmsTemplateDO> smsTemplateList = this.loadSmsTemplateIfUpdate(maxUpdateTime); | ||
| 92 | - if (CollUtil.isEmpty(smsTemplateList)) { | ||
| 93 | - return; | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - // 写入缓存 | ||
| 97 | - ImmutableMap.Builder<String, SysSmsTemplateDO> builder = ImmutableMap.builder(); | ||
| 98 | - smsTemplateList.forEach(sysSmsTemplateDO -> builder.put(sysSmsTemplateDO.getCode(), sysSmsTemplateDO)); | ||
| 99 | - smsTemplateCache = builder.build(); | ||
| 100 | - assert smsTemplateList.size() > 0; // 断言,避免告警 | ||
| 101 | - maxUpdateTime = smsTemplateList.stream().max(Comparator.comparing(BaseDO::getUpdateTime)).get().getUpdateTime(); | ||
| 102 | - log.info("[initLocalCache][初始化 SmsTemplate 数量为 {}]", smsTemplateList.size()); | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - @Scheduled(fixedDelay = SCHEDULER_PERIOD, initialDelay = SCHEDULER_PERIOD) | ||
| 106 | - public void schedulePeriodicRefresh() { | ||
| 107 | - initLocalCache(); | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - /** | ||
| 111 | - * 如果短信模板发生变化,从数据库中获取最新的全量短信模板。 | ||
| 112 | - * 如果未发生变化,则返回空 | ||
| 113 | - * | ||
| 114 | - * @param maxUpdateTime 当前短信模板的最大更新时间 | ||
| 115 | - * @return 短信模板列表 | ||
| 116 | - */ | ||
| 117 | - private List<SysSmsTemplateDO> loadSmsTemplateIfUpdate(Date maxUpdateTime) { | ||
| 118 | - // 第一步,判断是否要更新。 | ||
| 119 | - if (maxUpdateTime == null) { // 如果更新时间为空,说明 DB 一定有新数据 | ||
| 120 | - log.info("[loadSmsTemplateIfUpdate][首次加载全量短信模板]"); | ||
| 121 | - } else { // 判断数据库中是否有更新的短信模板 | ||
| 122 | - if (smsTemplateMapper.selectExistsByUpdateTimeAfter(maxUpdateTime) == null) { | ||
| 123 | - return null; | ||
| 124 | - } | ||
| 125 | - log.info("[loadSmsTemplateIfUpdate][增量加载全量短信模板]"); | ||
| 126 | - } | ||
| 127 | - // 第二步,如果有更新,则从数据库加载所有短信模板 | ||
| 128 | - return smsTemplateMapper.selectList(); | ||
| 129 | - } | ||
| 130 | - | ||
| 131 | @Override | 62 | @Override |
| 132 | public SysSmsTemplateDO getSmsTemplateByCode(String code) { | 63 | public SysSmsTemplateDO getSmsTemplateByCode(String code) { |
| 133 | return smsTemplateMapper.selectByCode(code); | 64 | return smsTemplateMapper.selectByCode(code); |
| 134 | } | 65 | } |
| 135 | 66 | ||
| 136 | - @Override | ||
| 137 | - public SysSmsTemplateDO getSmsTemplateByCodeFromCache(String code) { | ||
| 138 | - return smsTemplateCache.get(code); | ||
| 139 | - } | ||
| 140 | - | ||
| 141 | - @Override | ||
| 142 | - public String formatSmsTemplateContent(String content, Map<String, Object> params) { | ||
| 143 | - return StrUtil.format(content, params); | ||
| 144 | - } | ||
| 145 | - | ||
| 146 | @VisibleForTesting | 67 | @VisibleForTesting |
| 147 | public List<String> parseTemplateContentParams(String content) { | 68 | public List<String> parseTemplateContentParams(String content) { |
| 148 | return ReUtil.findAllGroup1(PATTERN_PARAMS, content); | 69 | return ReUtil.findAllGroup1(PATTERN_PARAMS, content); |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/SysUserService.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.service.user; | 1 | package cn.iocoder.yudao.adminserver.modules.system.service.user; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; |
| 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.SysUserCreateReqVO; | ||
| 8 | -import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.SysUserExportReqVO; | ||
| 9 | -import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.SysUserImportExcelVO; | ||
| 10 | -import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.SysUserImportRespVO; | ||
| 11 | -import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.SysUserPageReqVO; | ||
| 12 | -import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.SysUserUpdateReqVO; | ||
| 13 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | 6 | +import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.*; |
| 7 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 8 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 14 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 9 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 15 | 10 | ||
| 16 | import java.io.InputStream; | 11 | import java.io.InputStream; |
| @@ -105,14 +100,6 @@ public interface SysUserService { | @@ -105,14 +100,6 @@ public interface SysUserService { | ||
| 105 | SysUserDO getUserByUsername(String username); | 100 | SysUserDO getUserByUsername(String username); |
| 106 | 101 | ||
| 107 | /** | 102 | /** |
| 108 | - * 通过用户 ID 查询用户 | ||
| 109 | - * | ||
| 110 | - * @param id 用户ID | ||
| 111 | - * @return 用户对象信息 | ||
| 112 | - */ | ||
| 113 | - SysUserDO getUser(Long id); | ||
| 114 | - | ||
| 115 | - /** | ||
| 116 | * 获得用户分页列表 | 103 | * 获得用户分页列表 |
| 117 | * | 104 | * |
| 118 | * @param reqVO 分页条件 | 105 | * @param reqVO 分页条件 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/impl/SysUserServiceImpl.java
| @@ -11,12 +11,12 @@ import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.*; | @@ -11,12 +11,12 @@ import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.*; | ||
| 11 | import cn.iocoder.yudao.adminserver.modules.system.convert.user.SysUserConvert; | 11 | import cn.iocoder.yudao.adminserver.modules.system.convert.user.SysUserConvert; |
| 12 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; | 12 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; |
| 13 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO; | 13 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO; |
| 14 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 15 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.user.SysUserMapper; | 14 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.user.SysUserMapper; |
| 16 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; | 15 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; |
| 17 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysPostService; | 16 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysPostService; |
| 18 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; | 17 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; |
| 19 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; | 18 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; |
| 19 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 20 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 20 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 21 | import cn.iocoder.yudao.framework.common.exception.ServiceException; | 21 | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| 22 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 22 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| @@ -160,11 +160,6 @@ public class SysUserServiceImpl implements SysUserService { | @@ -160,11 +160,6 @@ public class SysUserServiceImpl implements SysUserService { | ||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | @Override | 162 | @Override |
| 163 | - public SysUserDO getUser(Long id) { | ||
| 164 | - return userMapper.selectById(id); | ||
| 165 | - } | ||
| 166 | - | ||
| 167 | - @Override | ||
| 168 | public PageResult<SysUserDO> getUserPage(SysUserPageReqVO reqVO) { | 163 | public PageResult<SysUserDO> getUserPage(SysUserPageReqVO reqVO) { |
| 169 | return userMapper.selectPage(reqVO, this.getDeptCondition(reqVO.getDeptId())); | 164 | return userMapper.selectPage(reqVO, this.getDeptCondition(reqVO.getDeptId())); |
| 170 | } | 165 | } |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/system/service/auth/SysAuthServiceImplTest.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.service.auth; | 1 | package cn.iocoder.yudao.adminserver.modules.system.service.auth; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 3 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; |
| 4 | -import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialService; | ||
| 5 | -import cn.iocoder.yudao.coreservice.modules.system.service.auth.SysUserSessionCoreService; | ||
| 6 | -import cn.iocoder.yudao.coreservice.modules.system.service.logger.SysLoginLogCoreService; | ||
| 7 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 8 | -import cn.iocoder.yudao.framework.security.core.LoginUser; | ||
| 9 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthLoginReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth.SysAuthLoginReqVO; |
| 10 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 11 | import cn.iocoder.yudao.adminserver.modules.system.enums.logger.SysLoginLogTypeEnum; | 5 | import cn.iocoder.yudao.adminserver.modules.system.enums.logger.SysLoginLogTypeEnum; |
| 12 | import cn.iocoder.yudao.adminserver.modules.system.enums.logger.SysLoginResultEnum; | 6 | import cn.iocoder.yudao.adminserver.modules.system.enums.logger.SysLoginResultEnum; |
| 13 | import cn.iocoder.yudao.adminserver.modules.system.service.auth.impl.SysAuthServiceImpl; | 7 | import cn.iocoder.yudao.adminserver.modules.system.service.auth.impl.SysAuthServiceImpl; |
| 14 | import cn.iocoder.yudao.adminserver.modules.system.service.common.SysCaptchaService; | 8 | import cn.iocoder.yudao.adminserver.modules.system.service.common.SysCaptchaService; |
| 15 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; | 9 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; |
| 10 | +import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialService; | ||
| 16 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; | 11 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; |
| 12 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 13 | +import cn.iocoder.yudao.coreservice.modules.system.service.auth.SysUserSessionCoreService; | ||
| 14 | +import cn.iocoder.yudao.coreservice.modules.system.service.logger.SysLoginLogCoreService; | ||
| 15 | +import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService; | ||
| 16 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 17 | +import cn.iocoder.yudao.framework.security.core.LoginUser; | ||
| 17 | import cn.iocoder.yudao.framework.test.core.util.AssertUtils; | 18 | import cn.iocoder.yudao.framework.test.core.util.AssertUtils; |
| 18 | import org.junit.jupiter.api.Test; | 19 | import org.junit.jupiter.api.Test; |
| 19 | import org.springframework.boot.test.mock.mockito.MockBean; | 20 | import org.springframework.boot.test.mock.mockito.MockBean; |
| @@ -51,6 +52,8 @@ public class SysAuthServiceImplTest extends BaseDbUnitTest { | @@ -51,6 +52,8 @@ public class SysAuthServiceImplTest extends BaseDbUnitTest { | ||
| 51 | @MockBean | 52 | @MockBean |
| 52 | private SysUserService userService; | 53 | private SysUserService userService; |
| 53 | @MockBean | 54 | @MockBean |
| 55 | + private SysUserCoreService userCoreService; | ||
| 56 | + @MockBean | ||
| 54 | private SysPermissionService permissionService; | 57 | private SysPermissionService permissionService; |
| 55 | @MockBean | 58 | @MockBean |
| 56 | private AuthenticationManager authenticationManager; | 59 | private AuthenticationManager authenticationManager; |
| @@ -98,7 +101,7 @@ public class SysAuthServiceImplTest extends BaseDbUnitTest { | @@ -98,7 +101,7 @@ public class SysAuthServiceImplTest extends BaseDbUnitTest { | ||
| 98 | Long userId = randomLongId(); | 101 | Long userId = randomLongId(); |
| 99 | // mock 方法 01 | 102 | // mock 方法 01 |
| 100 | SysUserDO user = randomPojo(SysUserDO.class, o -> o.setId(userId)); | 103 | SysUserDO user = randomPojo(SysUserDO.class, o -> o.setId(userId)); |
| 101 | - when(userService.getUser(eq(userId))).thenReturn(user); | 104 | + when(userCoreService.getUser(eq(userId))).thenReturn(user); |
| 102 | // mock 方法 02 | 105 | // mock 方法 02 |
| 103 | Set<Long> roleIds = randomSet(Long.class); | 106 | Set<Long> roleIds = randomSet(Long.class); |
| 104 | when(permissionService.getUserRoleIds(eq(userId), eq(singleton(CommonStatusEnum.ENABLE.getStatus())))) | 107 | when(permissionService.getUserRoleIds(eq(userId), eq(singleton(CommonStatusEnum.ENABLE.getStatus())))) |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/system/service/auth/SysUserSessionServiceImplTest.java
| @@ -3,14 +3,13 @@ package cn.iocoder.yudao.adminserver.modules.system.service.auth; | @@ -3,14 +3,13 @@ package cn.iocoder.yudao.adminserver.modules.system.service.auth; | ||
| 3 | import cn.hutool.core.date.DateUtil; | 3 | import cn.hutool.core.date.DateUtil; |
| 4 | import cn.iocoder.yudao.adminserver.BaseDbAndRedisUnitTest; | 4 | import cn.iocoder.yudao.adminserver.BaseDbAndRedisUnitTest; |
| 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.session.SysUserSessionPageReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.session.SysUserSessionPageReqVO; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 7 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.auth.SysUserSessionMapper; | 6 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.auth.SysUserSessionMapper; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.system.enums.common.SysSexEnum; | ||
| 9 | import cn.iocoder.yudao.adminserver.modules.system.service.auth.impl.SysUserSessionServiceImpl; | 7 | import cn.iocoder.yudao.adminserver.modules.system.service.auth.impl.SysUserSessionServiceImpl; |
| 10 | -import cn.iocoder.yudao.adminserver.modules.system.service.logger.SysLoginLogService; | ||
| 11 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; | 8 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; |
| 12 | import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.auth.SysUserSessionDO; | 9 | import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.auth.SysUserSessionDO; |
| 10 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 13 | import cn.iocoder.yudao.coreservice.modules.system.dal.redis.auth.SysLoginUserCoreRedisDAO; | 11 | import cn.iocoder.yudao.coreservice.modules.system.dal.redis.auth.SysLoginUserCoreRedisDAO; |
| 12 | +import cn.iocoder.yudao.coreservice.modules.system.enums.common.SysSexEnum; | ||
| 14 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.SysLoginLogCoreService; | 13 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.SysLoginLogCoreService; |
| 15 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 14 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 16 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 15 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/system/service/logger/SysOperateLogServiceImplTest.java
| @@ -2,34 +2,35 @@ package cn.iocoder.yudao.adminserver.modules.system.service.logger; | @@ -2,34 +2,35 @@ package cn.iocoder.yudao.adminserver.modules.system.service.logger; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.map.MapUtil; | 3 | import cn.hutool.core.map.MapUtil; |
| 4 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 4 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; |
| 5 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 6 | -import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; | ||
| 7 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 8 | -import cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum; | ||
| 9 | -import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; | ||
| 10 | -import cn.iocoder.yudao.framework.operatelog.core.dto.OperateLogCreateReqDTO; | ||
| 11 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogExportReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogExportReqVO; |
| 12 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogPageReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.logger.vo.operatelog.SysOperateLogPageReqVO; |
| 13 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.logger.SysOperateLogDO; | 7 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.logger.SysOperateLogDO; |
| 14 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 15 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.logger.SysOperateLogMapper; | 8 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.logger.SysOperateLogMapper; |
| 16 | -import cn.iocoder.yudao.adminserver.modules.system.enums.common.SysSexEnum; | ||
| 17 | import cn.iocoder.yudao.adminserver.modules.system.service.logger.impl.SysOperateLogServiceImpl; | 9 | import cn.iocoder.yudao.adminserver.modules.system.service.logger.impl.SysOperateLogServiceImpl; |
| 18 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; | 10 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; |
| 19 | -import cn.iocoder.yudao.framework.test.core.util.RandomUtils; | 11 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; |
| 12 | +import cn.iocoder.yudao.coreservice.modules.system.enums.common.SysSexEnum; | ||
| 13 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 14 | +import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; | ||
| 15 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 16 | +import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; | ||
| 20 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | 17 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 18 | +import cn.iocoder.yudao.framework.operatelog.core.dto.OperateLogCreateReqDTO; | ||
| 19 | +import cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum; | ||
| 20 | +import cn.iocoder.yudao.framework.test.core.util.RandomUtils; | ||
| 21 | import org.junit.jupiter.api.Test; | 21 | import org.junit.jupiter.api.Test; |
| 22 | import org.springframework.boot.test.mock.mockito.MockBean; | 22 | import org.springframework.boot.test.mock.mockito.MockBean; |
| 23 | import org.springframework.context.annotation.Import; | 23 | import org.springframework.context.annotation.Import; |
| 24 | 24 | ||
| 25 | import javax.annotation.Resource; | 25 | import javax.annotation.Resource; |
| 26 | -import java.util.*; | 26 | +import java.util.Collections; |
| 27 | +import java.util.List; | ||
| 27 | import java.util.concurrent.ExecutionException; | 28 | import java.util.concurrent.ExecutionException; |
| 28 | import java.util.concurrent.Future; | 29 | import java.util.concurrent.Future; |
| 29 | 30 | ||
| 31 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; | ||
| 30 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | 32 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 31 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | 33 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; |
| 32 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; | ||
| 33 | import static org.junit.jupiter.api.Assertions.assertEquals; | 34 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 34 | import static org.mockito.Mockito.when; | 35 | import static org.mockito.Mockito.when; |
| 35 | 36 |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsChannelServiceTest.java
| @@ -2,18 +2,18 @@ package cn.iocoder.yudao.adminserver.modules.system.service.sms; | @@ -2,18 +2,18 @@ package cn.iocoder.yudao.adminserver.modules.system.service.sms; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
| 4 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 4 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; |
| 5 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 6 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 7 | -import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | ||
| 8 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelCreateReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelCreateReqVO; |
| 9 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelPageReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelPageReqVO; |
| 10 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelUpdateReqVO; | 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.channel.SysSmsChannelUpdateReqVO; |
| 11 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsChannelDO; | ||
| 12 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms.SysSmsChannelMapper; | 8 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms.SysSmsChannelMapper; |
| 13 | import cn.iocoder.yudao.adminserver.modules.system.mq.producer.sms.SysSmsProducer; | 9 | import cn.iocoder.yudao.adminserver.modules.system.mq.producer.sms.SysSmsProducer; |
| 14 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.impl.SysSmsChannelServiceImpl; | 10 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.impl.SysSmsChannelServiceImpl; |
| 11 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsChannelDO; | ||
| 12 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 13 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 15 | import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; | 14 | import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; |
| 16 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | 15 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 16 | +import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | ||
| 17 | import org.junit.jupiter.api.Test; | 17 | import org.junit.jupiter.api.Test; |
| 18 | import org.springframework.boot.test.mock.mockito.MockBean; | 18 | import org.springframework.boot.test.mock.mockito.MockBean; |
| 19 | import org.springframework.context.annotation.Import; | 19 | import org.springframework.context.annotation.Import; |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsLogServiceTest.java
| @@ -2,35 +2,32 @@ package cn.iocoder.yudao.adminserver.modules.system.service.sms; | @@ -2,35 +2,32 @@ package cn.iocoder.yudao.adminserver.modules.system.service.sms; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.map.MapUtil; | 3 | import cn.hutool.core.map.MapUtil; |
| 4 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 4 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; |
| 5 | -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | ||
| 6 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 7 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 8 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogExportReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogExportReqVO; |
| 9 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogPageReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.log.SysSmsLogPageReqVO; |
| 10 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsLogDO; | ||
| 11 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 12 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms.SysSmsLogMapper; | 7 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms.SysSmsLogMapper; |
| 13 | -import cn.iocoder.yudao.adminserver.modules.system.enums.sms.SysSmsReceiveStatusEnum; | ||
| 14 | -import cn.iocoder.yudao.adminserver.modules.system.enums.sms.SysSmsSendStatusEnum; | ||
| 15 | -import cn.iocoder.yudao.adminserver.modules.system.enums.sms.SysSmsTemplateTypeEnum; | ||
| 16 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.impl.SysSmsLogServiceImpl; | 8 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.impl.SysSmsLogServiceImpl; |
| 9 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsLogDO; | ||
| 10 | +import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsReceiveStatusEnum; | ||
| 11 | +import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsSendStatusEnum; | ||
| 12 | +import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsTemplateTypeEnum; | ||
| 13 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | ||
| 14 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 17 | import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; | 15 | import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; |
| 18 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | 16 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 19 | import org.junit.jupiter.api.Test; | 17 | import org.junit.jupiter.api.Test; |
| 20 | import org.springframework.context.annotation.Import; | 18 | import org.springframework.context.annotation.Import; |
| 21 | 19 | ||
| 22 | import javax.annotation.Resource; | 20 | import javax.annotation.Resource; |
| 23 | -import java.util.Date; | ||
| 24 | import java.util.List; | 21 | import java.util.List; |
| 25 | import java.util.Map; | 22 | import java.util.Map; |
| 26 | import java.util.function.Consumer; | 23 | import java.util.function.Consumer; |
| 27 | 24 | ||
| 28 | -import static cn.hutool.core.util.RandomUtil.randomBoolean; | ||
| 29 | import static cn.hutool.core.util.RandomUtil.randomEle; | 25 | import static cn.hutool.core.util.RandomUtil.randomEle; |
| 30 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | ||
| 31 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; | 26 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; |
| 32 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | ||
| 33 | -import static org.junit.jupiter.api.Assertions.*; | 27 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 28 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | ||
| 29 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; | ||
| 30 | +import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| 34 | 31 | ||
| 35 | /** | 32 | /** |
| 36 | * {@link SysSmsLogServiceImpl} 的单元测试类 | 33 | * {@link SysSmsLogServiceImpl} 的单元测试类 |
| @@ -47,93 +44,6 @@ public class SysSmsLogServiceTest extends BaseDbUnitTest { | @@ -47,93 +44,6 @@ public class SysSmsLogServiceTest extends BaseDbUnitTest { | ||
| 47 | private SysSmsLogMapper smsLogMapper; | 44 | private SysSmsLogMapper smsLogMapper; |
| 48 | 45 | ||
| 49 | @Test | 46 | @Test |
| 50 | - public void testCreateSmsLog() { | ||
| 51 | - // 准备参数 | ||
| 52 | - String mobile = randomString(); | ||
| 53 | - Long userId = randomLongId(); | ||
| 54 | - Integer userType = randomEle(UserTypeEnum.values()).getValue(); | ||
| 55 | - Boolean isSend = randomBoolean(); | ||
| 56 | - SysSmsTemplateDO templateDO = randomPojo(SysSmsTemplateDO.class, | ||
| 57 | - o -> o.setType(randomEle(SysSmsTemplateTypeEnum.values()).getType())); | ||
| 58 | - String templateContent = randomString(); | ||
| 59 | - Map<String, Object> templateParams = randomTemplateParams(); | ||
| 60 | - // mock 方法 | ||
| 61 | - | ||
| 62 | - // 调用 | ||
| 63 | - Long logId = smsLogService.createSmsLog(mobile, userId, userType, isSend, | ||
| 64 | - templateDO, templateContent, templateParams); | ||
| 65 | - // 断言 | ||
| 66 | - SysSmsLogDO logDO = smsLogMapper.selectById(logId); | ||
| 67 | - assertEquals(isSend ? SysSmsSendStatusEnum.INIT.getStatus() : SysSmsSendStatusEnum.IGNORE.getStatus(), | ||
| 68 | - logDO.getSendStatus()); | ||
| 69 | - assertEquals(mobile, logDO.getMobile()); | ||
| 70 | - assertEquals(userType, logDO.getUserType()); | ||
| 71 | - assertEquals(userId, logDO.getUserId()); | ||
| 72 | - assertEquals(templateDO.getId(), logDO.getTemplateId()); | ||
| 73 | - assertEquals(templateDO.getCode(), logDO.getTemplateCode()); | ||
| 74 | - assertEquals(templateDO.getType(), logDO.getTemplateType()); | ||
| 75 | - assertEquals(templateDO.getChannelId(), logDO.getChannelId()); | ||
| 76 | - assertEquals(templateDO.getChannelCode(), logDO.getChannelCode()); | ||
| 77 | - assertEquals(templateContent, logDO.getTemplateContent()); | ||
| 78 | - assertEquals(templateParams, logDO.getTemplateParams()); | ||
| 79 | - assertEquals(SysSmsReceiveStatusEnum.INIT.getStatus(), logDO.getReceiveStatus()); | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - @Test | ||
| 83 | - public void testUpdateSmsSendResult() { | ||
| 84 | - // mock 数据 | ||
| 85 | - SysSmsLogDO dbSmsLog = randomSmsLogDO( | ||
| 86 | - o -> o.setSendStatus(SysSmsSendStatusEnum.IGNORE.getStatus())); | ||
| 87 | - smsLogMapper.insert(dbSmsLog); | ||
| 88 | - // 准备参数 | ||
| 89 | - Long id = dbSmsLog.getId(); | ||
| 90 | - Integer sendCode = randomInteger(); | ||
| 91 | - String sendMsg = randomString(); | ||
| 92 | - String apiSendCode = randomString(); | ||
| 93 | - String apiSendMsg = randomString(); | ||
| 94 | - String apiRequestId = randomString(); | ||
| 95 | - String apiSerialNo = randomString(); | ||
| 96 | - | ||
| 97 | - // 调用 | ||
| 98 | - smsLogService.updateSmsSendResult(id, sendCode, sendMsg, | ||
| 99 | - apiSendCode, apiSendMsg, apiRequestId, apiSerialNo); | ||
| 100 | - // 断言 | ||
| 101 | - dbSmsLog = smsLogMapper.selectById(id); | ||
| 102 | - assertEquals(CommonResult.isSuccess(sendCode) ? SysSmsSendStatusEnum.SUCCESS.getStatus() | ||
| 103 | - : SysSmsSendStatusEnum.FAILURE.getStatus(), dbSmsLog.getSendStatus()); | ||
| 104 | - assertNotNull(dbSmsLog.getSendTime()); | ||
| 105 | - assertEquals(sendMsg, dbSmsLog.getSendMsg()); | ||
| 106 | - assertEquals(apiSendCode, dbSmsLog.getApiSendCode()); | ||
| 107 | - assertEquals(apiSendMsg, dbSmsLog.getApiSendMsg()); | ||
| 108 | - assertEquals(apiRequestId, dbSmsLog.getApiRequestId()); | ||
| 109 | - assertEquals(apiSerialNo, dbSmsLog.getApiSerialNo()); | ||
| 110 | - } | ||
| 111 | - | ||
| 112 | - @Test | ||
| 113 | - public void testUpdateSmsReceiveResult() { | ||
| 114 | - // mock 数据 | ||
| 115 | - SysSmsLogDO dbSmsLog = randomSmsLogDO( | ||
| 116 | - o -> o.setReceiveStatus(SysSmsReceiveStatusEnum.INIT.getStatus())); | ||
| 117 | - smsLogMapper.insert(dbSmsLog); | ||
| 118 | - // 准备参数 | ||
| 119 | - Long id = dbSmsLog.getId(); | ||
| 120 | - Boolean success = randomBoolean(); | ||
| 121 | - Date receiveTime = randomDate(); | ||
| 122 | - String apiReceiveCode = randomString(); | ||
| 123 | - String apiReceiveMsg = randomString(); | ||
| 124 | - | ||
| 125 | - // 调用 | ||
| 126 | - smsLogService.updateSmsReceiveResult(id, success, receiveTime, apiReceiveCode, apiReceiveMsg); | ||
| 127 | - // 断言 | ||
| 128 | - dbSmsLog = smsLogMapper.selectById(id); | ||
| 129 | - assertEquals(success ? SysSmsReceiveStatusEnum.SUCCESS.getStatus() | ||
| 130 | - : SysSmsReceiveStatusEnum.FAILURE.getStatus(), dbSmsLog.getReceiveStatus()); | ||
| 131 | - assertEquals(receiveTime, dbSmsLog.getReceiveTime()); | ||
| 132 | - assertEquals(apiReceiveCode, dbSmsLog.getApiReceiveCode()); | ||
| 133 | - assertEquals(apiReceiveMsg, dbSmsLog.getApiReceiveMsg()); | ||
| 134 | - } | ||
| 135 | - | ||
| 136 | - @Test | ||
| 137 | public void testGetSmsLogPage() { | 47 | public void testGetSmsLogPage() { |
| 138 | // mock 数据 | 48 | // mock 数据 |
| 139 | SysSmsLogDO dbSmsLog = randomSmsLogDO(o -> { // 等会查询到 | 49 | SysSmsLogDO dbSmsLog = randomSmsLogDO(o -> { // 等会查询到 |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsTemplateServiceTest.java
| 1 | package cn.iocoder.yudao.adminserver.modules.system.service.sms; | 1 | package cn.iocoder.yudao.adminserver.modules.system.service.sms; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 3 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; |
| 4 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 5 | -import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; | ||
| 6 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 7 | -import cn.iocoder.yudao.framework.sms.core.client.SmsClient; | ||
| 8 | -import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | ||
| 9 | -import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; | ||
| 10 | -import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO; | ||
| 11 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateCreateReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateCreateReqVO; |
| 12 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateExportReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateExportReqVO; |
| 13 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplatePageReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplatePageReqVO; |
| 14 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateUpdateReqVO; | 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.SysSmsTemplateUpdateReqVO; |
| 15 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsChannelDO; | ||
| 16 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 17 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms.SysSmsTemplateMapper; | 8 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.sms.SysSmsTemplateMapper; |
| 18 | -import cn.iocoder.yudao.adminserver.modules.system.enums.sms.SysSmsTemplateTypeEnum; | ||
| 19 | import cn.iocoder.yudao.adminserver.modules.system.mq.producer.sms.SysSmsProducer; | 9 | import cn.iocoder.yudao.adminserver.modules.system.mq.producer.sms.SysSmsProducer; |
| 20 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.impl.SysSmsTemplateServiceImpl; | 10 | import cn.iocoder.yudao.adminserver.modules.system.service.sms.impl.SysSmsTemplateServiceImpl; |
| 11 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsChannelDO; | ||
| 12 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 13 | +import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsTemplateTypeEnum; | ||
| 14 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 15 | +import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; | ||
| 16 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 21 | import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; | 17 | import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; |
| 22 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | 18 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 19 | +import cn.iocoder.yudao.framework.sms.core.client.SmsClient; | ||
| 20 | +import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | ||
| 21 | +import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; | ||
| 22 | +import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO; | ||
| 23 | import com.google.common.collect.Lists; | 23 | import com.google.common.collect.Lists; |
| 24 | import org.junit.jupiter.api.Test; | 24 | import org.junit.jupiter.api.Test; |
| 25 | import org.springframework.boot.test.mock.mockito.MockBean; | 25 | import org.springframework.boot.test.mock.mockito.MockBean; |
| 26 | import org.springframework.context.annotation.Import; | 26 | import org.springframework.context.annotation.Import; |
| 27 | 27 | ||
| 28 | import javax.annotation.Resource; | 28 | import javax.annotation.Resource; |
| 29 | -import java.util.Date; | ||
| 30 | import java.util.List; | 29 | import java.util.List; |
| 31 | -import java.util.Map; | ||
| 32 | import java.util.function.Consumer; | 30 | import java.util.function.Consumer; |
| 33 | 31 | ||
| 34 | -import static cn.hutool.core.bean.BeanUtil.getFieldValue; | ||
| 35 | import static cn.hutool.core.util.RandomUtil.randomEle; | 32 | import static cn.hutool.core.util.RandomUtil.randomEle; |
| 36 | import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.*; | 33 | import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.*; |
| 34 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; | ||
| 37 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | 35 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 38 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | 36 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; |
| 39 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; | ||
| 40 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.max; | ||
| 41 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | 37 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; |
| 42 | import static org.junit.jupiter.api.Assertions.*; | 38 | import static org.junit.jupiter.api.Assertions.*; |
| 43 | import static org.mockito.ArgumentMatchers.eq; | 39 | import static org.mockito.ArgumentMatchers.eq; |
| @@ -67,27 +63,6 @@ public class SysSmsTemplateServiceTest extends BaseDbUnitTest { | @@ -67,27 +63,6 @@ public class SysSmsTemplateServiceTest extends BaseDbUnitTest { | ||
| 67 | private SysSmsProducer smsProducer; | 63 | private SysSmsProducer smsProducer; |
| 68 | 64 | ||
| 69 | @Test | 65 | @Test |
| 70 | - @SuppressWarnings("unchecked") | ||
| 71 | - void testInitLocalCache() { | ||
| 72 | - // mock 数据 | ||
| 73 | - SysSmsTemplateDO smsTemplate01 = randomSmsTemplateDO(); | ||
| 74 | - smsTemplateMapper.insert(smsTemplate01); | ||
| 75 | - SysSmsTemplateDO smsTemplate02 = randomSmsTemplateDO(); | ||
| 76 | - smsTemplateMapper.insert(smsTemplate02); | ||
| 77 | - | ||
| 78 | - // 调用 | ||
| 79 | - smsTemplateService.initLocalCache(); | ||
| 80 | - // 断言 deptCache 缓存 | ||
| 81 | - Map<String, SysSmsTemplateDO> smsTemplateCache = (Map<String, SysSmsTemplateDO>) getFieldValue(smsTemplateService, "smsTemplateCache"); | ||
| 82 | - assertEquals(2, smsTemplateCache.size()); | ||
| 83 | - assertPojoEquals(smsTemplate01, smsTemplateCache.get(smsTemplate01.getCode())); | ||
| 84 | - assertPojoEquals(smsTemplate02, smsTemplateCache.get(smsTemplate02.getCode())); | ||
| 85 | - // 断言 maxUpdateTime 缓存 | ||
| 86 | - Date maxUpdateTime = (Date) getFieldValue(smsTemplateService, "maxUpdateTime"); | ||
| 87 | - assertEquals(max(smsTemplate01.getUpdateTime(), smsTemplate02.getUpdateTime()), maxUpdateTime); | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - @Test | ||
| 91 | public void testParseTemplateContentParams() { | 66 | public void testParseTemplateContentParams() { |
| 92 | // 准备参数 | 67 | // 准备参数 |
| 93 | String content = "正在进行登录操作{operation},您的验证码是{code}"; | 68 | String content = "正在进行登录操作{operation},您的验证码是{code}"; |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/system/service/user/SysUserServiceImplTest.java
| @@ -3,21 +3,21 @@ package cn.iocoder.yudao.adminserver.modules.system.service.user; | @@ -3,21 +3,21 @@ package cn.iocoder.yudao.adminserver.modules.system.service.user; | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.util.RandomUtil; | 4 | import cn.hutool.core.util.RandomUtil; |
| 5 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 5 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.service.user.impl.SysUserServiceImpl; | ||
| 7 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 8 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 9 | import cn.iocoder.yudao.adminserver.modules.infra.service.file.InfFileService; | 6 | import cn.iocoder.yudao.adminserver.modules.infra.service.file.InfFileService; |
| 10 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; | 7 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; |
| 11 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; | 8 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; |
| 12 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.*; | 9 | import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.*; |
| 13 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; | 10 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; |
| 14 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO; | 11 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO; |
| 15 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 16 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.user.SysUserMapper; | 12 | import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.user.SysUserMapper; |
| 17 | -import cn.iocoder.yudao.adminserver.modules.system.enums.common.SysSexEnum; | ||
| 18 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; | 13 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; |
| 19 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysPostService; | 14 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysPostService; |
| 20 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; | 15 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; |
| 16 | +import cn.iocoder.yudao.adminserver.modules.system.service.user.impl.SysUserServiceImpl; | ||
| 17 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 18 | +import cn.iocoder.yudao.coreservice.modules.system.enums.common.SysSexEnum; | ||
| 19 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 20 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 21 | import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; | 21 | import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; |
| 22 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 22 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 23 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | 23 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| @@ -36,9 +36,9 @@ import java.util.function.Consumer; | @@ -36,9 +36,9 @@ import java.util.function.Consumer; | ||
| 36 | import static cn.hutool.core.util.RandomUtil.randomBytes; | 36 | import static cn.hutool.core.util.RandomUtil.randomBytes; |
| 37 | import static cn.hutool.core.util.RandomUtil.randomEle; | 37 | import static cn.hutool.core.util.RandomUtil.randomEle; |
| 38 | import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.*; | 38 | import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.*; |
| 39 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; | ||
| 39 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | 40 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 40 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | 41 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; |
| 41 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; | ||
| 42 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | 42 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; |
| 43 | import static org.assertj.core.util.Lists.newArrayList; | 43 | import static org.assertj.core.util.Lists.newArrayList; |
| 44 | import static org.junit.jupiter.api.Assertions.assertEquals; | 44 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| @@ -243,7 +243,7 @@ public class SysUserServiceImplTest extends BaseDbUnitTest { | @@ -243,7 +243,7 @@ public class SysUserServiceImplTest extends BaseDbUnitTest { | ||
| 243 | // 调用数据 | 243 | // 调用数据 |
| 244 | userService.deleteUser(userId); | 244 | userService.deleteUser(userId); |
| 245 | // 校验结果 | 245 | // 校验结果 |
| 246 | - assertNull(userService.getUser(userId)); | 246 | + assertNull(userMapper.selectById(userId)); |
| 247 | // 校验调用次数 | 247 | // 校验调用次数 |
| 248 | verify(permissionService, times(1)).processUserDeleted(eq(userId)); | 248 | verify(permissionService, times(1)).processUserDeleted(eq(userId)); |
| 249 | } | 249 | } |
yudao-core-service/pom.xml
| @@ -67,6 +67,12 @@ | @@ -67,6 +67,12 @@ | ||
| 67 | <artifactId>yudao-spring-boot-starter-config</artifactId> | 67 | <artifactId>yudao-spring-boot-starter-config</artifactId> |
| 68 | </dependency> | 68 | </dependency> |
| 69 | 69 | ||
| 70 | + <!-- 消息队列相关 --> | ||
| 71 | + <dependency> | ||
| 72 | + <groupId>cn.iocoder.boot</groupId> | ||
| 73 | + <artifactId>yudao-spring-boot-starter-mq</artifactId> | ||
| 74 | + </dependency> | ||
| 75 | + | ||
| 70 | <!-- Test 测试相关 --> | 76 | <!-- Test 测试相关 --> |
| 71 | <dependency> | 77 | <dependency> |
| 72 | <groupId>cn.iocoder.boot</groupId> | 78 | <groupId>cn.iocoder.boot</groupId> |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/dataobject/sms/SysSmsChannelDO.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/dataobject/sms/SysSmsChannelDO.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms; | 1 | +package cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/dataobject/sms/SysSmsLogDO.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/dataobject/sms/SysSmsLogDO.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms; | 1 | +package cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsReceiveStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsSendStatusEnum; | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 5 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 6 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 5 | import cn.iocoder.yudao.framework.sms.core.enums.SmsFrameworkErrorCodeConstants; | 7 | import cn.iocoder.yudao.framework.sms.core.enums.SmsFrameworkErrorCodeConstants; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.enums.sms.SysSmsReceiveStatusEnum; | ||
| 7 | -import cn.iocoder.yudao.adminserver.modules.system.enums.sms.SysSmsSendStatusEnum; | ||
| 8 | import com.baomidou.mybatisplus.annotation.TableField; | 8 | import com.baomidou.mybatisplus.annotation.TableField; |
| 9 | import com.baomidou.mybatisplus.annotation.TableName; | 9 | import com.baomidou.mybatisplus.annotation.TableName; |
| 10 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; | 10 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/dataobject/sms/SysSmsTemplateDO.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/dataobject/sms/SysSmsTemplateDO.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms; | 1 | +package cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsTemplateTypeEnum; | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 5 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 5 | -import cn.iocoder.yudao.adminserver.modules.system.enums.sms.SysSmsTemplateTypeEnum; | ||
| 6 | import com.baomidou.mybatisplus.annotation.TableField; | 6 | import com.baomidou.mybatisplus.annotation.TableField; |
| 7 | import com.baomidou.mybatisplus.annotation.TableName; | 7 | import com.baomidou.mybatisplus.annotation.TableName; |
| 8 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; | 8 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/dataobject/user/SysUserDO.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/dataobject/user/SysUserDO.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user; | 1 | +package cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.enums.common.SysSexEnum; | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 5 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; | 6 | import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.enums.common.SysSexEnum; | ||
| 7 | import com.baomidou.mybatisplus.annotation.TableField; | 7 | import com.baomidou.mybatisplus.annotation.TableField; |
| 8 | import com.baomidou.mybatisplus.annotation.TableId; | 8 | import com.baomidou.mybatisplus.annotation.TableId; |
| 9 | import com.baomidou.mybatisplus.annotation.TableName; | 9 | import com.baomidou.mybatisplus.annotation.TableName; |
| @@ -16,7 +16,7 @@ import java.util.Set; | @@ -16,7 +16,7 @@ import java.util.Set; | ||
| 16 | /** | 16 | /** |
| 17 | * 管理后台的用户 DO | 17 | * 管理后台的用户 DO |
| 18 | * | 18 | * |
| 19 | - * @author ruoyi | 19 | + * @author 芋道源码 |
| 20 | */ | 20 | */ |
| 21 | @TableName(value = "sys_user", autoResultMap = true) | 21 | @TableName(value = "sys_user", autoResultMap = true) |
| 22 | @Data | 22 | @Data |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/mysql/sms/SysSmsLogCoreMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.system.dal.mysql.sms; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsLogDO; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; | ||
| 7 | +import org.apache.ibatis.annotations.Mapper; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +@Mapper | ||
| 12 | +public interface SysSmsLogCoreMapper extends BaseMapperX<SysSmsLogDO> { | ||
| 13 | +} |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/mysql/sms/SysSmsTemplateCoreMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.system.dal.mysql.sms; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import org.apache.ibatis.annotations.Mapper; | ||
| 6 | +import org.apache.ibatis.annotations.Select; | ||
| 7 | + | ||
| 8 | +import java.util.Date; | ||
| 9 | + | ||
| 10 | +@Mapper | ||
| 11 | +public interface SysSmsTemplateCoreMapper extends BaseMapperX<SysSmsTemplateDO> { | ||
| 12 | + | ||
| 13 | + @Select("SELECT id FROM sys_sms_template WHERE update_time > #{maxUpdateTime} LIMIT 1") | ||
| 14 | + Long selectExistsByUpdateTimeAfter(Date maxUpdateTime); | ||
| 15 | + | ||
| 16 | +} |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/dal/mysql/user/SysUserCoreMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.system.dal.mysql.user; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 6 | +import org.apache.ibatis.annotations.Mapper; | ||
| 7 | + | ||
| 8 | +@Mapper | ||
| 9 | +public interface SysUserCoreMapper extends BaseMapperX<SysUserDO> { | ||
| 10 | + | ||
| 11 | +} |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/enums/SysErrorCodeConstants.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.system.enums; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.exception.ErrorCode; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * System 错误码枚举类 | ||
| 7 | + * | ||
| 8 | + * system 系统,使用 1-006-000-000 段 | ||
| 9 | + */ | ||
| 10 | +public interface SysErrorCodeConstants { | ||
| 11 | + | ||
| 12 | + // ========== 短信发送 1006000000 ========== | ||
| 13 | + ErrorCode SMS_SEND_MOBILE_NOT_EXISTS = new ErrorCode(1006000000, "手机号不存在"); | ||
| 14 | + ErrorCode SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS = new ErrorCode(1006000001, "模板参数({})缺失"); | ||
| 15 | + ErrorCode SMS_SEND_TEMPLATE_NOT_EXISTS = new ErrorCode(1006000000, "短信模板不存在"); | ||
| 16 | + | ||
| 17 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/common/SysSexEnum.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/enums/common/SysSexEnum.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.system.enums.common; | 1 | +package cn.iocoder.yudao.coreservice.modules.system.enums.common; |
| 2 | 2 | ||
| 3 | import lombok.AllArgsConstructor; | 3 | import lombok.AllArgsConstructor; |
| 4 | import lombok.Getter; | 4 | import lombok.Getter; |
| @@ -11,12 +11,14 @@ import lombok.Getter; | @@ -11,12 +11,14 @@ import lombok.Getter; | ||
| 11 | @Getter | 11 | @Getter |
| 12 | @AllArgsConstructor | 12 | @AllArgsConstructor |
| 13 | public enum SysSexEnum { | 13 | public enum SysSexEnum { |
| 14 | + | ||
| 14 | /** 男 */ | 15 | /** 男 */ |
| 15 | MALE(1), | 16 | MALE(1), |
| 16 | /** 女 */ | 17 | /** 女 */ |
| 17 | FEMALE(2), | 18 | FEMALE(2), |
| 18 | /* 未知 */ | 19 | /* 未知 */ |
| 19 | UNKNOWN(3); | 20 | UNKNOWN(3); |
| 21 | + | ||
| 20 | /** | 22 | /** |
| 21 | * 性别 | 23 | * 性别 |
| 22 | */ | 24 | */ |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/enums/package-info.java deleted
| 1 | -package cn.iocoder.yudao.coreservice.modules.system.enums; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/sms/SysSmsReceiveStatusEnum.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/enums/sms/SysSmsReceiveStatusEnum.java
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/sms/SysSmsSendStatusEnum.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/enums/sms/SysSmsSendStatusEnum.java
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/sms/SysSmsTemplateTypeEnum.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/enums/sms/SysSmsTemplateTypeEnum.java
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/mq/message/package-info.java
0 → 100644
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/mq/message/sms/SysSmsSendMessage.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/mq/message/sms/SysSmsSendMessage.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.system.mq.message.sms; | 1 | +package cn.iocoder.yudao.coreservice.modules.system.mq.message.sms; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.core.KeyValue; | 3 | import cn.iocoder.yudao.framework.common.core.KeyValue; |
| 4 | import cn.iocoder.yudao.framework.mq.core.stream.StreamMessage; | 4 | import cn.iocoder.yudao.framework.mq.core.stream.StreamMessage; |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/mq/producer/package-info.java
0 → 100644
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/mq/producer/sms/SysSmsCoreProducer.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.system.mq.producer.sms; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.mq.message.sms.SysSmsSendMessage; | ||
| 4 | +import cn.iocoder.yudao.framework.common.core.KeyValue; | ||
| 5 | +import cn.iocoder.yudao.framework.mq.core.util.RedisMessageUtils; | ||
| 6 | +import lombok.extern.slf4j.Slf4j; | ||
| 7 | +import org.springframework.data.redis.core.StringRedisTemplate; | ||
| 8 | +import org.springframework.stereotype.Component; | ||
| 9 | + | ||
| 10 | +import javax.annotation.Resource; | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Sms 短信相关消息的 Core Producer | ||
| 15 | + * | ||
| 16 | + * @author zzf | ||
| 17 | + * @date 2021/3/9 16:35 | ||
| 18 | + */ | ||
| 19 | +@Slf4j | ||
| 20 | +@Component | ||
| 21 | +public class SysSmsCoreProducer { | ||
| 22 | + | ||
| 23 | + @Resource | ||
| 24 | + private StringRedisTemplate stringRedisTemplate; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 发送 {@link SysSmsSendMessage} 消息 | ||
| 28 | + * | ||
| 29 | + * @param logId 短信日志编号 | ||
| 30 | + * @param mobile 手机号 | ||
| 31 | + * @param channelId 渠道编号 | ||
| 32 | + * @param apiTemplateId 短信模板编号 | ||
| 33 | + * @param templateParams 短信模板参数 | ||
| 34 | + */ | ||
| 35 | + public void sendSmsSendMessage(Long logId, String mobile, | ||
| 36 | + Long channelId, String apiTemplateId, List<KeyValue<String, Object>> templateParams) { | ||
| 37 | + SysSmsSendMessage message = new SysSmsSendMessage().setLogId(logId).setMobile(mobile); | ||
| 38 | + message.setChannelId(channelId).setApiTemplateId(apiTemplateId).setTemplateParams(templateParams); | ||
| 39 | + RedisMessageUtils.sendStreamMessage(stringRedisTemplate, message); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsService.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/service/sms/SysSmsCoreService.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.system.service.sms; | 1 | +package cn.iocoder.yudao.coreservice.modules.system.service.sms; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.adminserver.modules.system.mq.message.sms.SysSmsSendMessage; | 3 | +import cn.iocoder.yudao.coreservice.modules.system.mq.message.sms.SysSmsSendMessage; |
| 4 | 4 | ||
| 5 | import java.util.List; | 5 | import java.util.List; |
| 6 | import java.util.Map; | 6 | import java.util.Map; |
| 7 | 7 | ||
| 8 | /** | 8 | /** |
| 9 | - * 短信Service接口 | ||
| 10 | - * 只支持异步,因此没有返回值 | 9 | + * 短信 Service Core 接口 |
| 11 | * | 10 | * |
| 12 | - * @author zzf | ||
| 13 | - * @date 2021/1/25 9:24 | 11 | + * 接入方,通过调用 send 开头的方法,创建发送短信的任务到 MQ 中 |
| 12 | + * 后续,yudao-admin-server 监听 MQ,执行真正的短信发送逻辑 | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 14 | */ | 15 | */ |
| 15 | -public interface SysSmsService { | 16 | +public interface SysSmsCoreService { |
| 16 | 17 | ||
| 17 | /** | 18 | /** |
| 18 | - * 发送单条短信给用户(管理员) | 19 | + * 发送单条短信给后台用户 |
| 19 | * | 20 | * |
| 20 | * 在 mobile 为空时,使用 userId 加载对应管理员的手机号 | 21 | * 在 mobile 为空时,使用 userId 加载对应管理员的手机号 |
| 21 | * | 22 | * |
| @@ -29,7 +30,7 @@ public interface SysSmsService { | @@ -29,7 +30,7 @@ public interface SysSmsService { | ||
| 29 | String templateCode, Map<String, Object> templateParams); | 30 | String templateCode, Map<String, Object> templateParams); |
| 30 | 31 | ||
| 31 | /** | 32 | /** |
| 32 | - * 发送单条短信给用户(会员) | 33 | + * 发送单条短信给前台用户 |
| 33 | * | 34 | * |
| 34 | * 在 mobile 为空时,使用 userId 加载对应会员的手机号 | 35 | * 在 mobile 为空时,使用 userId 加载对应会员的手机号 |
| 35 | * | 36 | * |
| @@ -40,7 +41,7 @@ public interface SysSmsService { | @@ -40,7 +41,7 @@ public interface SysSmsService { | ||
| 40 | * @return 发送日志编号 | 41 | * @return 发送日志编号 |
| 41 | */ | 42 | */ |
| 42 | Long sendSingleSmsToMember(String mobile, Long userId, | 43 | Long sendSingleSmsToMember(String mobile, Long userId, |
| 43 | - String templateCode, Map<String, Object> templateParams); | 44 | + String templateCode, Map<String, Object> templateParams); |
| 44 | 45 | ||
| 45 | Long sendSingleSms(String mobile, Long userId, Integer userType, | 46 | Long sendSingleSms(String mobile, Long userId, Integer userType, |
| 46 | String templateCode, Map<String, Object> templateParams); | 47 | String templateCode, Map<String, Object> templateParams); |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/service/sms/SysSmsLogCoreService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.system.service.sms; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 4 | + | ||
| 5 | +import java.util.Date; | ||
| 6 | +import java.util.Map; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 短信日志 Core Service 接口 | ||
| 10 | + * | ||
| 11 | + * @author zzf | ||
| 12 | + * @date 13:48 2021/3/2 | ||
| 13 | + */ | ||
| 14 | +public interface SysSmsLogCoreService { | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 创建短信日志 | ||
| 18 | + * | ||
| 19 | + * @param mobile 手机号 | ||
| 20 | + * @param userId 用户编号 | ||
| 21 | + * @param userType 用户类型 | ||
| 22 | + * @param isSend 是否发送 | ||
| 23 | + * @param template 短信模板 | ||
| 24 | + * @param templateContent 短信内容 | ||
| 25 | + * @param templateParams 短信参数 | ||
| 26 | + * @return 发送日志编号 | ||
| 27 | + */ | ||
| 28 | + Long createSmsLog(String mobile, Long userId, Integer userType, Boolean isSend, | ||
| 29 | + SysSmsTemplateDO template, String templateContent, Map<String, Object> templateParams); | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 更新日志的发送结果 | ||
| 33 | + * | ||
| 34 | + * @param id 日志编号 | ||
| 35 | + * @param sendCode 发送结果的编码 | ||
| 36 | + * @param sendMsg 发送结果的提示 | ||
| 37 | + * @param apiSendCode 短信 API 发送结果的编码 | ||
| 38 | + * @param apiSendMsg 短信 API 发送失败的提示 | ||
| 39 | + * @param apiRequestId 短信 API 发送返回的唯一请求 ID | ||
| 40 | + * @param apiSerialNo 短信 API 发送返回的序号 | ||
| 41 | + */ | ||
| 42 | + void updateSmsSendResult(Long id, Integer sendCode, String sendMsg, | ||
| 43 | + String apiSendCode, String apiSendMsg, String apiRequestId, String apiSerialNo); | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * 更新日志的接收结果 | ||
| 47 | + * | ||
| 48 | + * @param id 日志编号 | ||
| 49 | + * @param success 是否接收成功 | ||
| 50 | + * @param receiveTime 用户接收时间 | ||
| 51 | + * @param apiReceiveCode API 接收结果的编码 | ||
| 52 | + * @param apiReceiveMsg API 接收结果的说明 | ||
| 53 | + */ | ||
| 54 | + void updateSmsReceiveResult(Long id, Boolean success, Date receiveTime, String apiReceiveCode, String apiReceiveMsg); | ||
| 55 | + | ||
| 56 | +} |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/service/sms/SysSmsTemplateCoreService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.system.service.sms; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 4 | + | ||
| 5 | +import java.util.Map; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 短信模板 Core Service 接口 | ||
| 9 | + * | ||
| 10 | + * @author 芋道源码 | ||
| 11 | + */ | ||
| 12 | +public interface SysSmsTemplateCoreService { | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * 初始化短信模板的本地缓存 | ||
| 16 | + */ | ||
| 17 | + void initLocalCache(); | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * 获得短信模板,从缓存中 | ||
| 21 | + * | ||
| 22 | + * @param code 模板编码 | ||
| 23 | + * @return 短信模板 | ||
| 24 | + */ | ||
| 25 | + SysSmsTemplateDO getSmsTemplateByCodeFromCache(String code); | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 格式化短信内容 | ||
| 29 | + * | ||
| 30 | + * @param content 短信模板的内容 | ||
| 31 | + * @param params 内容的参数 | ||
| 32 | + * @return 格式化后的内容 | ||
| 33 | + */ | ||
| 34 | + String formatSmsTemplateContent(String content, Map<String, Object> params); | ||
| 35 | + | ||
| 36 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/impl/SysSmsServiceImpl.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/service/sms/impl/SysSmsCoreServiceImpl.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.system.service.sms.impl; | 1 | +package cn.iocoder.yudao.coreservice.modules.system.service.sms.impl; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.util.StrUtil; | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 6 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 7 | +import cn.iocoder.yudao.coreservice.modules.system.mq.message.sms.SysSmsSendMessage; | ||
| 8 | +import cn.iocoder.yudao.coreservice.modules.system.mq.producer.sms.SysSmsCoreProducer; | ||
| 9 | +import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsCoreService; | ||
| 10 | +import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsLogCoreService; | ||
| 11 | +import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsTemplateCoreService; | ||
| 12 | +import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService; | ||
| 5 | import cn.iocoder.yudao.framework.common.core.KeyValue; | 13 | import cn.iocoder.yudao.framework.common.core.KeyValue; |
| 6 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 14 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 7 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 15 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| @@ -10,16 +18,7 @@ import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | @@ -10,16 +18,7 @@ import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | ||
| 10 | import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; | 18 | import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; |
| 11 | import cn.iocoder.yudao.framework.sms.core.client.dto.SmsReceiveRespDTO; | 19 | import cn.iocoder.yudao.framework.sms.core.client.dto.SmsReceiveRespDTO; |
| 12 | import cn.iocoder.yudao.framework.sms.core.client.dto.SmsSendRespDTO; | 20 | import cn.iocoder.yudao.framework.sms.core.client.dto.SmsSendRespDTO; |
| 13 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 14 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | ||
| 15 | -import cn.iocoder.yudao.adminserver.modules.system.mq.message.sms.SysSmsSendMessage; | ||
| 16 | -import cn.iocoder.yudao.adminserver.modules.system.mq.producer.sms.SysSmsProducer; | ||
| 17 | -import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsLogService; | ||
| 18 | -import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsService; | ||
| 19 | -import cn.iocoder.yudao.adminserver.modules.system.service.sms.SysSmsTemplateService; | ||
| 20 | -import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; | ||
| 21 | import com.google.common.annotations.VisibleForTesting; | 21 | import com.google.common.annotations.VisibleForTesting; |
| 22 | -import lombok.extern.slf4j.Slf4j; | ||
| 23 | import org.springframework.stereotype.Service; | 22 | import org.springframework.stereotype.Service; |
| 24 | import org.springframework.util.Assert; | 23 | import org.springframework.util.Assert; |
| 25 | 24 | ||
| @@ -28,36 +27,35 @@ import java.util.List; | @@ -28,36 +27,35 @@ import java.util.List; | ||
| 28 | import java.util.Map; | 27 | import java.util.Map; |
| 29 | import java.util.stream.Collectors; | 28 | import java.util.stream.Collectors; |
| 30 | 29 | ||
| 30 | +import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.*; | ||
| 31 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 31 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 32 | -import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.*; | ||
| 33 | 32 | ||
| 34 | /** | 33 | /** |
| 35 | - * 短信日志Service实现类 | 34 | + * 短信 Service Core 实现 |
| 36 | * | 35 | * |
| 37 | - * @author zzf | ||
| 38 | - * @date 2021/1/25 9:25 | 36 | + * @author 芋道源码 |
| 39 | */ | 37 | */ |
| 40 | @Service | 38 | @Service |
| 41 | -@Slf4j | ||
| 42 | -public class SysSmsServiceImpl implements SysSmsService { | 39 | +public class SysSmsCoreServiceImpl implements SysSmsCoreService { |
| 43 | 40 | ||
| 44 | @Resource | 41 | @Resource |
| 45 | - private SysSmsTemplateService smsTemplateService; | 42 | + private SysUserCoreService sysUserCoreService; |
| 46 | @Resource | 43 | @Resource |
| 47 | - private SysSmsLogService smsLogService; | 44 | + private SysSmsTemplateCoreService smsTemplateCoreService; |
| 48 | @Resource | 45 | @Resource |
| 49 | - private SysSmsProducer smsProducer; | 46 | + private SysSmsLogCoreService smsLogCoreService; |
| 47 | + | ||
| 50 | @Resource | 48 | @Resource |
| 51 | private SmsClientFactory smsClientFactory; | 49 | private SmsClientFactory smsClientFactory; |
| 52 | 50 | ||
| 53 | @Resource | 51 | @Resource |
| 54 | - private SysUserService userService; | 52 | + private SysSmsCoreProducer smsCoreProducer; |
| 55 | 53 | ||
| 56 | @Override | 54 | @Override |
| 57 | public Long sendSingleSmsToAdmin(String mobile, Long userId, String templateCode, Map<String, Object> templateParams) { | 55 | public Long sendSingleSmsToAdmin(String mobile, Long userId, String templateCode, Map<String, Object> templateParams) { |
| 58 | // 如果 mobile 为空,则加载用户编号对应的手机号 | 56 | // 如果 mobile 为空,则加载用户编号对应的手机号 |
| 59 | if (StrUtil.isEmpty(mobile)) { | 57 | if (StrUtil.isEmpty(mobile)) { |
| 60 | - SysUserDO user = userService.getUser(userId); | 58 | + SysUserDO user = sysUserCoreService.getUser(userId); |
| 61 | if (user != null) { | 59 | if (user != null) { |
| 62 | mobile = user.getMobile(); | 60 | mobile = user.getMobile(); |
| 63 | } | 61 | } |
| @@ -83,12 +81,13 @@ public class SysSmsServiceImpl implements SysSmsService { | @@ -83,12 +81,13 @@ public class SysSmsServiceImpl implements SysSmsService { | ||
| 83 | 81 | ||
| 84 | // 创建发送日志 | 82 | // 创建发送日志 |
| 85 | Boolean isSend = CommonStatusEnum.ENABLE.getStatus().equals(template.getStatus()); // 如果模板被禁用,则不发送短信,只记录日志 | 83 | Boolean isSend = CommonStatusEnum.ENABLE.getStatus().equals(template.getStatus()); // 如果模板被禁用,则不发送短信,只记录日志 |
| 86 | - String content = smsTemplateService.formatSmsTemplateContent(template.getContent(), templateParams); | ||
| 87 | - Long sendLogId = smsLogService.createSmsLog(mobile, userId, userType, isSend, template, content, templateParams); | 84 | + String content = smsTemplateCoreService.formatSmsTemplateContent(template.getContent(), templateParams); |
| 85 | + Long sendLogId = smsLogCoreService.createSmsLog(mobile, userId, userType, isSend, template, content, templateParams); | ||
| 88 | 86 | ||
| 89 | // 发送 MQ 消息,异步执行发送短信 | 87 | // 发送 MQ 消息,异步执行发送短信 |
| 90 | if (isSend) { | 88 | if (isSend) { |
| 91 | - smsProducer.sendSmsSendMessage(sendLogId, mobile, template.getChannelId(), template.getApiTemplateId(), newTemplateParams); | 89 | + smsCoreProducer.sendSmsSendMessage(sendLogId, mobile, template.getChannelId(), |
| 90 | + template.getApiTemplateId(), newTemplateParams); | ||
| 92 | } | 91 | } |
| 93 | return sendLogId; | 92 | return sendLogId; |
| 94 | } | 93 | } |
| @@ -102,10 +101,10 @@ public class SysSmsServiceImpl implements SysSmsService { | @@ -102,10 +101,10 @@ public class SysSmsServiceImpl implements SysSmsService { | ||
| 102 | @VisibleForTesting | 101 | @VisibleForTesting |
| 103 | public SysSmsTemplateDO checkSmsTemplateValid(String templateCode) { | 102 | public SysSmsTemplateDO checkSmsTemplateValid(String templateCode) { |
| 104 | // 获得短信模板。考虑到效率,从缓存中获取 | 103 | // 获得短信模板。考虑到效率,从缓存中获取 |
| 105 | - SysSmsTemplateDO template = smsTemplateService.getSmsTemplateByCodeFromCache(templateCode); | 104 | + SysSmsTemplateDO template = smsTemplateCoreService.getSmsTemplateByCodeFromCache(templateCode); |
| 106 | // 短信模板不存在 | 105 | // 短信模板不存在 |
| 107 | if (template == null) { | 106 | if (template == null) { |
| 108 | - throw exception(SMS_TEMPLATE_NOT_EXISTS); | 107 | + throw exception(SMS_SEND_TEMPLATE_NOT_EXISTS); |
| 109 | } | 108 | } |
| 110 | return template; | 109 | return template; |
| 111 | } | 110 | } |
| @@ -138,6 +137,7 @@ public class SysSmsServiceImpl implements SysSmsService { | @@ -138,6 +137,7 @@ public class SysSmsServiceImpl implements SysSmsService { | ||
| 138 | return mobile; | 137 | return mobile; |
| 139 | } | 138 | } |
| 140 | 139 | ||
| 140 | + | ||
| 141 | @Override | 141 | @Override |
| 142 | public void doSendSms(SysSmsSendMessage message) { | 142 | public void doSendSms(SysSmsSendMessage message) { |
| 143 | // 获得渠道对应的 SmsClient 客户端 | 143 | // 获得渠道对应的 SmsClient 客户端 |
| @@ -146,7 +146,7 @@ public class SysSmsServiceImpl implements SysSmsService { | @@ -146,7 +146,7 @@ public class SysSmsServiceImpl implements SysSmsService { | ||
| 146 | // 发送短信 | 146 | // 发送短信 |
| 147 | SmsCommonResult<SmsSendRespDTO> sendResult = smsClient.sendSms(message.getLogId(), message.getMobile(), | 147 | SmsCommonResult<SmsSendRespDTO> sendResult = smsClient.sendSms(message.getLogId(), message.getMobile(), |
| 148 | message.getApiTemplateId(), message.getTemplateParams()); | 148 | message.getApiTemplateId(), message.getTemplateParams()); |
| 149 | - smsLogService.updateSmsSendResult(message.getLogId(), sendResult.getCode(), sendResult.getMsg(), | 149 | + smsLogCoreService.updateSmsSendResult(message.getLogId(), sendResult.getCode(), sendResult.getMsg(), |
| 150 | sendResult.getApiCode(), sendResult.getApiMsg(), sendResult.getApiRequestId(), | 150 | sendResult.getApiCode(), sendResult.getApiMsg(), sendResult.getApiRequestId(), |
| 151 | sendResult.getData() != null ? sendResult.getData().getSerialNo() : null); | 151 | sendResult.getData() != null ? sendResult.getData().getSerialNo() : null); |
| 152 | } | 152 | } |
| @@ -161,11 +161,9 @@ public class SysSmsServiceImpl implements SysSmsService { | @@ -161,11 +161,9 @@ public class SysSmsServiceImpl implements SysSmsService { | ||
| 161 | if (CollUtil.isEmpty(receiveResults)) { | 161 | if (CollUtil.isEmpty(receiveResults)) { |
| 162 | return; | 162 | return; |
| 163 | } | 163 | } |
| 164 | - // 更新短信日志的接收结果. 因为量一般不打,所以先使用 for 循环更新 | ||
| 165 | - receiveResults.forEach(result -> { | ||
| 166 | - smsLogService.updateSmsReceiveResult(result.getLogId(), result.getSuccess(), result.getReceiveTime(), | ||
| 167 | - result.getErrorCode(), result.getErrorCode()); | ||
| 168 | - }); | 164 | + // 更新短信日志的接收结果. 因为量一般不大,所以先使用 for 循环更新 |
| 165 | + receiveResults.forEach(result -> smsLogCoreService.updateSmsReceiveResult(result.getLogId(), | ||
| 166 | + result.getSuccess(), result.getReceiveTime(), result.getErrorCode(), result.getErrorCode())); | ||
| 169 | } | 167 | } |
| 170 | 168 | ||
| 171 | } | 169 | } |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/service/sms/impl/SysSmsLogCoreServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.system.service.sms.impl; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsLogDO; | ||
| 4 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 5 | +import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.sms.SysSmsLogCoreMapper; | ||
| 6 | +import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsReceiveStatusEnum; | ||
| 7 | +import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsSendStatusEnum; | ||
| 8 | +import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsLogCoreService; | ||
| 9 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 10 | +import lombok.extern.slf4j.Slf4j; | ||
| 11 | +import org.springframework.stereotype.Service; | ||
| 12 | + | ||
| 13 | +import javax.annotation.Resource; | ||
| 14 | +import java.util.Date; | ||
| 15 | +import java.util.Map; | ||
| 16 | +import java.util.Objects; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * 短信日志 Core Service 实现类 | ||
| 20 | + * | ||
| 21 | + * @author zzf | ||
| 22 | + * @date 2021/1/25 9:25 | ||
| 23 | + */ | ||
| 24 | +@Slf4j | ||
| 25 | +@Service | ||
| 26 | +public class SysSmsLogCoreServiceImpl implements SysSmsLogCoreService { | ||
| 27 | + | ||
| 28 | + @Resource | ||
| 29 | + private SysSmsLogCoreMapper smsLogCoreMapper; | ||
| 30 | + | ||
| 31 | + @Override | ||
| 32 | + public Long createSmsLog(String mobile, Long userId, Integer userType, Boolean isSend, | ||
| 33 | + SysSmsTemplateDO template, String templateContent, Map<String, Object> templateParams) { | ||
| 34 | + SysSmsLogDO.SysSmsLogDOBuilder logBuilder = SysSmsLogDO.builder(); | ||
| 35 | + // 根据是否要发送,设置状态 | ||
| 36 | + logBuilder.sendStatus(Objects.equals(isSend, true) ? SysSmsSendStatusEnum.INIT.getStatus() | ||
| 37 | + : SysSmsSendStatusEnum.IGNORE.getStatus()); | ||
| 38 | + // 设置手机相关字段 | ||
| 39 | + logBuilder.mobile(mobile).userId(userId).userType(userType); | ||
| 40 | + // 设置模板相关字段 | ||
| 41 | + logBuilder.templateId(template.getId()).templateCode(template.getCode()).templateType(template.getType()); | ||
| 42 | + logBuilder.templateContent(templateContent).templateParams(templateParams).apiTemplateId(template.getApiTemplateId()); | ||
| 43 | + // 设置渠道相关字段 | ||
| 44 | + logBuilder.channelId(template.getChannelId()).channelCode(template.getChannelCode()); | ||
| 45 | + // 设置接收相关字段 | ||
| 46 | + logBuilder.receiveStatus(SysSmsReceiveStatusEnum.INIT.getStatus()); | ||
| 47 | + | ||
| 48 | + // 插入数据库 | ||
| 49 | + SysSmsLogDO logDO = logBuilder.build(); | ||
| 50 | + smsLogCoreMapper.insert(logDO); | ||
| 51 | + return logDO.getId(); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @Override | ||
| 55 | + public void updateSmsSendResult(Long id, Integer sendCode, String sendMsg, | ||
| 56 | + String apiSendCode, String apiSendMsg, String apiRequestId, String apiSerialNo) { | ||
| 57 | + SysSmsSendStatusEnum sendStatus = CommonResult.isSuccess(sendCode) ? SysSmsSendStatusEnum.SUCCESS | ||
| 58 | + : SysSmsSendStatusEnum.FAILURE; | ||
| 59 | + smsLogCoreMapper.updateById(SysSmsLogDO.builder().id(id).sendStatus(sendStatus.getStatus()).sendTime(new Date()) | ||
| 60 | + .sendCode(sendCode).sendMsg(sendMsg).apiSendCode(apiSendCode).apiSendMsg(apiSendMsg) | ||
| 61 | + .apiRequestId(apiRequestId).apiSerialNo(apiSerialNo).build()); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + public void updateSmsReceiveResult(Long id, Boolean success, Date receiveTime, String apiReceiveCode, String apiReceiveMsg) { | ||
| 66 | + SysSmsReceiveStatusEnum receiveStatus = Objects.equals(success, true) ? SysSmsReceiveStatusEnum.SUCCESS | ||
| 67 | + : SysSmsReceiveStatusEnum.FAILURE; | ||
| 68 | + smsLogCoreMapper.updateById(SysSmsLogDO.builder().id(id).receiveStatus(receiveStatus.getStatus()).receiveTime(receiveTime) | ||
| 69 | + .apiReceiveCode(apiReceiveCode).apiReceiveMsg(apiReceiveMsg).build()); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | +} |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/service/sms/impl/SysSmsTemplateCoreServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.system.service.sms.impl; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.hutool.core.util.StrUtil; | ||
| 5 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 6 | +import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.sms.SysSmsTemplateCoreMapper; | ||
| 7 | +import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsTemplateCoreService; | ||
| 8 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 9 | +import com.google.common.collect.ImmutableMap; | ||
| 10 | +import lombok.extern.slf4j.Slf4j; | ||
| 11 | +import org.springframework.scheduling.annotation.Scheduled; | ||
| 12 | +import org.springframework.stereotype.Service; | ||
| 13 | + | ||
| 14 | +import javax.annotation.PostConstruct; | ||
| 15 | +import javax.annotation.Resource; | ||
| 16 | +import java.util.Comparator; | ||
| 17 | +import java.util.Date; | ||
| 18 | +import java.util.List; | ||
| 19 | +import java.util.Map; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * 短信模板 Core Service 接口 | ||
| 23 | + * | ||
| 24 | + * @author 芋道源码 | ||
| 25 | + */ | ||
| 26 | +@Service | ||
| 27 | +@Slf4j | ||
| 28 | +public class SysSmsTemplateCoreServiceImpl implements SysSmsTemplateCoreService { | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 定时执行 {@link #schedulePeriodicRefresh()} 的周期 | ||
| 32 | + * 因为已经通过 Redis Pub/Sub 机制,所以频率不需要高 | ||
| 33 | + */ | ||
| 34 | + private static final long SCHEDULER_PERIOD = 5 * 60 * 1000L; | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 短信模板缓存 | ||
| 38 | + * key:短信模板编码 {@link SysSmsTemplateDO#getCode()} | ||
| 39 | + * | ||
| 40 | + * 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向 | ||
| 41 | + */ | ||
| 42 | + private volatile Map<String, SysSmsTemplateDO> smsTemplateCache; | ||
| 43 | + /** | ||
| 44 | + * 缓存短信模板的最大更新时间,用于后续的增量轮询,判断是否有更新 | ||
| 45 | + */ | ||
| 46 | + private volatile Date maxUpdateTime; | ||
| 47 | + | ||
| 48 | + @Resource | ||
| 49 | + private SysSmsTemplateCoreMapper smsTemplateCoreMapper; | ||
| 50 | + | ||
| 51 | + @Override | ||
| 52 | + @PostConstruct | ||
| 53 | + public void initLocalCache() { | ||
| 54 | + // 获取短信模板列表,如果有更新 | ||
| 55 | + List<SysSmsTemplateDO> smsTemplateList = this.loadSmsTemplateIfUpdate(maxUpdateTime); | ||
| 56 | + if (CollUtil.isEmpty(smsTemplateList)) { | ||
| 57 | + return; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + // 写入缓存 | ||
| 61 | + ImmutableMap.Builder<String, SysSmsTemplateDO> builder = ImmutableMap.builder(); | ||
| 62 | + smsTemplateList.forEach(sysSmsTemplateDO -> builder.put(sysSmsTemplateDO.getCode(), sysSmsTemplateDO)); | ||
| 63 | + smsTemplateCache = builder.build(); | ||
| 64 | + assert smsTemplateList.size() > 0; // 断言,避免告警 | ||
| 65 | + maxUpdateTime = smsTemplateList.stream().max(Comparator.comparing(BaseDO::getUpdateTime)).get().getUpdateTime(); | ||
| 66 | + log.info("[initLocalCache][初始化 SmsTemplate 数量为 {}]", smsTemplateList.size()); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * 如果短信模板发生变化,从数据库中获取最新的全量短信模板。 | ||
| 71 | + * 如果未发生变化,则返回空 | ||
| 72 | + * | ||
| 73 | + * @param maxUpdateTime 当前短信模板的最大更新时间 | ||
| 74 | + * @return 短信模板列表 | ||
| 75 | + */ | ||
| 76 | + private List<SysSmsTemplateDO> loadSmsTemplateIfUpdate(Date maxUpdateTime) { | ||
| 77 | + // 第一步,判断是否要更新。 | ||
| 78 | + if (maxUpdateTime == null) { // 如果更新时间为空,说明 DB 一定有新数据 | ||
| 79 | + log.info("[loadSmsTemplateIfUpdate][首次加载全量短信模板]"); | ||
| 80 | + } else { // 判断数据库中是否有更新的短信模板 | ||
| 81 | + if (smsTemplateCoreMapper.selectExistsByUpdateTimeAfter(maxUpdateTime) == null) { | ||
| 82 | + return null; | ||
| 83 | + } | ||
| 84 | + log.info("[loadSmsTemplateIfUpdate][增量加载全量短信模板]"); | ||
| 85 | + } | ||
| 86 | + // 第二步,如果有更新,则从数据库加载所有短信模板 | ||
| 87 | + return smsTemplateCoreMapper.selectList(); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + @Scheduled(fixedDelay = SCHEDULER_PERIOD, initialDelay = SCHEDULER_PERIOD) | ||
| 91 | + public void schedulePeriodicRefresh() { | ||
| 92 | + initLocalCache(); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + @Override | ||
| 96 | + public SysSmsTemplateDO getSmsTemplateByCodeFromCache(String code) { | ||
| 97 | + return smsTemplateCache.get(code); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + @Override | ||
| 101 | + public String formatSmsTemplateContent(String content, Map<String, Object> params) { | ||
| 102 | + return StrUtil.format(content, params); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | +} |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/service/user/SysUserCoreService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.system.service.user; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 后台用户 Service Core 接口 | ||
| 7 | + * | ||
| 8 | + * @author 芋道源码 | ||
| 9 | + */ | ||
| 10 | +public interface SysUserCoreService { | ||
| 11 | + | ||
| 12 | + /** | ||
| 13 | + * 通过用户 ID 查询用户 | ||
| 14 | + * | ||
| 15 | + * @param id 用户ID | ||
| 16 | + * @return 用户对象信息 | ||
| 17 | + */ | ||
| 18 | + SysUserDO getUser(Long id); | ||
| 19 | + | ||
| 20 | +} |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/service/user/impl/SysUserCoreServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.system.service.user.impl; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; | ||
| 4 | +import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.user.SysUserCoreMapper; | ||
| 5 | +import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService; | ||
| 6 | +import org.springframework.stereotype.Service; | ||
| 7 | + | ||
| 8 | +import javax.annotation.Resource; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 后台用户 Service Core 实现 | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@Service | ||
| 16 | +public class SysUserCoreServiceImpl implements SysUserCoreService { | ||
| 17 | + | ||
| 18 | + @Resource | ||
| 19 | + private SysUserCoreMapper userCoreMapper; | ||
| 20 | + | ||
| 21 | + @Override | ||
| 22 | + public SysUserDO getUser(Long id) { | ||
| 23 | + return userCoreMapper.selectById(id); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | +} |
yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/system/service/logger/SysLoginLogServiceImplTest.java
| 1 | package cn.iocoder.yudao.coreservice.modules.system.service.logger; | 1 | package cn.iocoder.yudao.coreservice.modules.system.service.logger; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.util.RandomUtil; | ||
| 4 | import cn.iocoder.yudao.coreservice.BaseDbUnitTest; | 3 | import cn.iocoder.yudao.coreservice.BaseDbUnitTest; |
| 5 | import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.logger.SysLoginLogDO; | 4 | import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.logger.SysLoginLogDO; |
| 6 | import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.logger.SysLoginLogCoreMapper; | 5 | import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.logger.SysLoginLogCoreMapper; |
| @@ -8,6 +7,7 @@ import cn.iocoder.yudao.coreservice.modules.system.enums.logger.SysLoginLogTypeE | @@ -8,6 +7,7 @@ import cn.iocoder.yudao.coreservice.modules.system.enums.logger.SysLoginLogTypeE | ||
| 8 | import cn.iocoder.yudao.coreservice.modules.system.enums.logger.SysLoginResultEnum; | 7 | import cn.iocoder.yudao.coreservice.modules.system.enums.logger.SysLoginResultEnum; |
| 9 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.dto.SysLoginLogCreateReqDTO; | 8 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.dto.SysLoginLogCreateReqDTO; |
| 10 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.impl.SysLoginLogCoreServiceImpl; | 9 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.impl.SysLoginLogCoreServiceImpl; |
| 10 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | ||
| 11 | import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; | 11 | import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; |
| 12 | import cn.iocoder.yudao.framework.test.core.util.RandomUtils; | 12 | import cn.iocoder.yudao.framework.test.core.util.RandomUtils; |
| 13 | import org.junit.jupiter.api.Test; | 13 | import org.junit.jupiter.api.Test; |
| @@ -15,6 +15,7 @@ import org.springframework.context.annotation.Import; | @@ -15,6 +15,7 @@ import org.springframework.context.annotation.Import; | ||
| 15 | 15 | ||
| 16 | import javax.annotation.Resource; | 16 | import javax.annotation.Resource; |
| 17 | 17 | ||
| 18 | +import static cn.hutool.core.util.RandomUtil.randomEle; | ||
| 18 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | 19 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 19 | 20 | ||
| 20 | @Import(SysLoginLogCoreServiceImpl.class) | 21 | @Import(SysLoginLogCoreServiceImpl.class) |
| @@ -30,8 +31,9 @@ public class SysLoginLogServiceImplTest extends BaseDbUnitTest { | @@ -30,8 +31,9 @@ public class SysLoginLogServiceImplTest extends BaseDbUnitTest { | ||
| 30 | public void testCreateLoginLog() { | 31 | public void testCreateLoginLog() { |
| 31 | SysLoginLogCreateReqDTO reqDTO = RandomUtils.randomPojo(SysLoginLogCreateReqDTO.class, vo -> { | 32 | SysLoginLogCreateReqDTO reqDTO = RandomUtils.randomPojo(SysLoginLogCreateReqDTO.class, vo -> { |
| 32 | // 指定随机的范围,避免超出范围入库失败 | 33 | // 指定随机的范围,避免超出范围入库失败 |
| 33 | - vo.setLogType(RandomUtil.randomEle(SysLoginLogTypeEnum.values()).getType()); | ||
| 34 | - vo.setResult(RandomUtil.randomEle(SysLoginResultEnum.values()).getResult()); | 34 | + vo.setUserType(randomEle(UserTypeEnum.values()).getValue()); |
| 35 | + vo.setLogType(randomEle(SysLoginLogTypeEnum.values()).getType()); | ||
| 36 | + vo.setResult(randomEle(SysLoginResultEnum.values()).getResult()); | ||
| 35 | vo.setTraceId(TracerUtils.getTraceId()); | 37 | vo.setTraceId(TracerUtils.getTraceId()); |
| 36 | }); | 38 | }); |
| 37 | 39 |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsServiceTest.java renamed to yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/system/service/sms/SysSmsCoreServiceTest.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.system.service.sms; | 1 | +package cn.iocoder.yudao.coreservice.modules.system.service.sms; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.map.MapUtil; | 3 | import cn.hutool.core.map.MapUtil; |
| 4 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 5 | +import cn.iocoder.yudao.coreservice.modules.system.mq.message.sms.SysSmsSendMessage; | ||
| 6 | +import cn.iocoder.yudao.coreservice.modules.system.mq.producer.sms.SysSmsCoreProducer; | ||
| 7 | +import cn.iocoder.yudao.coreservice.modules.system.service.sms.impl.SysSmsCoreServiceImpl; | ||
| 4 | import cn.iocoder.yudao.framework.common.core.KeyValue; | 8 | import cn.iocoder.yudao.framework.common.core.KeyValue; |
| 5 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 9 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 6 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 10 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| @@ -9,10 +13,6 @@ import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | @@ -9,10 +13,6 @@ import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | ||
| 9 | import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; | 13 | import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; |
| 10 | import cn.iocoder.yudao.framework.sms.core.client.dto.SmsReceiveRespDTO; | 14 | import cn.iocoder.yudao.framework.sms.core.client.dto.SmsReceiveRespDTO; |
| 11 | import cn.iocoder.yudao.framework.sms.core.client.dto.SmsSendRespDTO; | 15 | import cn.iocoder.yudao.framework.sms.core.client.dto.SmsSendRespDTO; |
| 12 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 13 | -import cn.iocoder.yudao.adminserver.modules.system.mq.message.sms.SysSmsSendMessage; | ||
| 14 | -import cn.iocoder.yudao.adminserver.modules.system.mq.producer.sms.SysSmsProducer; | ||
| 15 | -import cn.iocoder.yudao.adminserver.modules.system.service.sms.impl.SysSmsServiceImpl; | ||
| 16 | import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; | 16 | import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; |
| 17 | import org.assertj.core.util.Lists; | 17 | import org.assertj.core.util.Lists; |
| 18 | import org.junit.jupiter.api.Test; | 18 | import org.junit.jupiter.api.Test; |
| @@ -24,7 +24,7 @@ import java.util.List; | @@ -24,7 +24,7 @@ import java.util.List; | ||
| 24 | import java.util.Map; | 24 | import java.util.Map; |
| 25 | 25 | ||
| 26 | import static cn.hutool.core.util.RandomUtil.randomEle; | 26 | import static cn.hutool.core.util.RandomUtil.randomEle; |
| 27 | -import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.*; | 27 | +import static cn.iocoder.yudao.coreservice.modules.system.enums.SysErrorCodeConstants.*; |
| 28 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | 28 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; |
| 29 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | 29 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; |
| 30 | import static org.junit.jupiter.api.Assertions.assertEquals; | 30 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| @@ -32,21 +32,21 @@ import static org.mockito.ArgumentMatchers.eq; | @@ -32,21 +32,21 @@ import static org.mockito.ArgumentMatchers.eq; | ||
| 32 | import static org.mockito.Mockito.*; | 32 | import static org.mockito.Mockito.*; |
| 33 | 33 | ||
| 34 | /** | 34 | /** |
| 35 | - * {@link SysSmsServiceImpl} 的单元测试类 | 35 | + * {@link SysSmsCoreService} 的单元测试类 |
| 36 | * | 36 | * |
| 37 | * @author 芋道源码 | 37 | * @author 芋道源码 |
| 38 | */ | 38 | */ |
| 39 | -public class SysSmsServiceTest extends BaseMockitoUnitTest { | 39 | +public class SysSmsCoreServiceTest extends BaseMockitoUnitTest { |
| 40 | 40 | ||
| 41 | @InjectMocks | 41 | @InjectMocks |
| 42 | - private SysSmsServiceImpl smsService; | 42 | + private SysSmsCoreServiceImpl smsCoreService; |
| 43 | 43 | ||
| 44 | @Mock | 44 | @Mock |
| 45 | - private SysSmsTemplateService smsTemplateService; | 45 | + private SysSmsTemplateCoreService smsTemplateCoreService; |
| 46 | @Mock | 46 | @Mock |
| 47 | - private SysSmsLogService smsLogService; | 47 | + private SysSmsLogCoreService smsLogCoreService; |
| 48 | @Mock | 48 | @Mock |
| 49 | - private SysSmsProducer smsProducer; | 49 | + private SysSmsCoreProducer smsCoreProducer; |
| 50 | @Mock | 50 | @Mock |
| 51 | private SmsClientFactory smsClientFactory; | 51 | private SmsClientFactory smsClientFactory; |
| 52 | 52 | ||
| @@ -68,21 +68,21 @@ public class SysSmsServiceTest extends BaseMockitoUnitTest { | @@ -68,21 +68,21 @@ public class SysSmsServiceTest extends BaseMockitoUnitTest { | ||
| 68 | o.setContent("验证码为{code}, 操作为{op}"); | 68 | o.setContent("验证码为{code}, 操作为{op}"); |
| 69 | o.setParams(Lists.newArrayList("code", "op")); | 69 | o.setParams(Lists.newArrayList("code", "op")); |
| 70 | }); | 70 | }); |
| 71 | - when(smsTemplateService.getSmsTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); | 71 | + when(smsTemplateCoreService.getSmsTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); |
| 72 | String content = randomString(); | 72 | String content = randomString(); |
| 73 | - when(smsTemplateService.formatSmsTemplateContent(eq(template.getContent()), eq(templateParams))) | 73 | + when(smsTemplateCoreService.formatSmsTemplateContent(eq(template.getContent()), eq(templateParams))) |
| 74 | .thenReturn(content); | 74 | .thenReturn(content); |
| 75 | // mock SmsLogService 的方法 | 75 | // mock SmsLogService 的方法 |
| 76 | Long smsLogId = randomLongId(); | 76 | Long smsLogId = randomLongId(); |
| 77 | - when(smsLogService.createSmsLog(eq(mobile), eq(userId), eq(userType), eq(Boolean.TRUE), eq(template), | 77 | + when(smsLogCoreService.createSmsLog(eq(mobile), eq(userId), eq(userType), eq(Boolean.TRUE), eq(template), |
| 78 | eq(content), eq(templateParams))).thenReturn(smsLogId); | 78 | eq(content), eq(templateParams))).thenReturn(smsLogId); |
| 79 | 79 | ||
| 80 | // 调用 | 80 | // 调用 |
| 81 | - Long resultSmsLogId = smsService.sendSingleSms(mobile, userId, userType, templateCode, templateParams); | 81 | + Long resultSmsLogId = smsCoreService.sendSingleSms(mobile, userId, userType, templateCode, templateParams); |
| 82 | // 断言 | 82 | // 断言 |
| 83 | assertEquals(smsLogId, resultSmsLogId); | 83 | assertEquals(smsLogId, resultSmsLogId); |
| 84 | // 断言调用 | 84 | // 断言调用 |
| 85 | - verify(smsProducer, times(1)).sendSmsSendMessage(eq(smsLogId), eq(mobile), | 85 | + verify(smsCoreProducer, times(1)).sendSmsSendMessage(eq(smsLogId), eq(mobile), |
| 86 | eq(template.getChannelId()), eq(template.getApiTemplateId()), | 86 | eq(template.getChannelId()), eq(template.getApiTemplateId()), |
| 87 | eq(Lists.newArrayList(new KeyValue<>("code", "1234"), new KeyValue<>("op", "login")))); | 87 | eq(Lists.newArrayList(new KeyValue<>("code", "1234"), new KeyValue<>("op", "login")))); |
| 88 | } | 88 | } |
| @@ -105,21 +105,21 @@ public class SysSmsServiceTest extends BaseMockitoUnitTest { | @@ -105,21 +105,21 @@ public class SysSmsServiceTest extends BaseMockitoUnitTest { | ||
| 105 | o.setContent("验证码为{code}, 操作为{op}"); | 105 | o.setContent("验证码为{code}, 操作为{op}"); |
| 106 | o.setParams(Lists.newArrayList("code", "op")); | 106 | o.setParams(Lists.newArrayList("code", "op")); |
| 107 | }); | 107 | }); |
| 108 | - when(smsTemplateService.getSmsTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); | 108 | + when(smsTemplateCoreService.getSmsTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); |
| 109 | String content = randomString(); | 109 | String content = randomString(); |
| 110 | - when(smsTemplateService.formatSmsTemplateContent(eq(template.getContent()), eq(templateParams))) | 110 | + when(smsTemplateCoreService.formatSmsTemplateContent(eq(template.getContent()), eq(templateParams))) |
| 111 | .thenReturn(content); | 111 | .thenReturn(content); |
| 112 | // mock SmsLogService 的方法 | 112 | // mock SmsLogService 的方法 |
| 113 | Long smsLogId = randomLongId(); | 113 | Long smsLogId = randomLongId(); |
| 114 | - when(smsLogService.createSmsLog(eq(mobile), eq(userId), eq(userType), eq(Boolean.FALSE), eq(template), | 114 | + when(smsLogCoreService.createSmsLog(eq(mobile), eq(userId), eq(userType), eq(Boolean.FALSE), eq(template), |
| 115 | eq(content), eq(templateParams))).thenReturn(smsLogId); | 115 | eq(content), eq(templateParams))).thenReturn(smsLogId); |
| 116 | 116 | ||
| 117 | // 调用 | 117 | // 调用 |
| 118 | - Long resultSmsLogId = smsService.sendSingleSms(mobile, userId, userType, templateCode, templateParams); | 118 | + Long resultSmsLogId = smsCoreService.sendSingleSms(mobile, userId, userType, templateCode, templateParams); |
| 119 | // 断言 | 119 | // 断言 |
| 120 | assertEquals(smsLogId, resultSmsLogId); | 120 | assertEquals(smsLogId, resultSmsLogId); |
| 121 | // 断言调用 | 121 | // 断言调用 |
| 122 | - verify(smsProducer, times(0)).sendSmsSendMessage(anyLong(), anyString(), | 122 | + verify(smsCoreProducer, times(0)).sendSmsSendMessage(anyLong(), anyString(), |
| 123 | anyLong(), any(), anyList()); | 123 | anyLong(), any(), anyList()); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| @@ -130,8 +130,8 @@ public class SysSmsServiceTest extends BaseMockitoUnitTest { | @@ -130,8 +130,8 @@ public class SysSmsServiceTest extends BaseMockitoUnitTest { | ||
| 130 | // mock 方法 | 130 | // mock 方法 |
| 131 | 131 | ||
| 132 | // 调用,并断言异常 | 132 | // 调用,并断言异常 |
| 133 | - assertServiceException(() -> smsService.checkSmsTemplateValid(templateCode), | ||
| 134 | - SMS_TEMPLATE_NOT_EXISTS); | 133 | + assertServiceException(() -> smsCoreService.checkSmsTemplateValid(templateCode), |
| 134 | + SMS_SEND_TEMPLATE_NOT_EXISTS); | ||
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | @Test | 137 | @Test |
| @@ -143,7 +143,7 @@ public class SysSmsServiceTest extends BaseMockitoUnitTest { | @@ -143,7 +143,7 @@ public class SysSmsServiceTest extends BaseMockitoUnitTest { | ||
| 143 | // mock 方法 | 143 | // mock 方法 |
| 144 | 144 | ||
| 145 | // 调用,并断言异常 | 145 | // 调用,并断言异常 |
| 146 | - assertServiceException(() -> smsService.buildTemplateParams(template, templateParams), | 146 | + assertServiceException(() -> smsCoreService.buildTemplateParams(template, templateParams), |
| 147 | SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS, "code"); | 147 | SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS, "code"); |
| 148 | } | 148 | } |
| 149 | 149 | ||
| @@ -153,7 +153,7 @@ public class SysSmsServiceTest extends BaseMockitoUnitTest { | @@ -153,7 +153,7 @@ public class SysSmsServiceTest extends BaseMockitoUnitTest { | ||
| 153 | // mock 方法 | 153 | // mock 方法 |
| 154 | 154 | ||
| 155 | // 调用,并断言异常 | 155 | // 调用,并断言异常 |
| 156 | - assertServiceException(() -> smsService.checkMobile(null), | 156 | + assertServiceException(() -> smsCoreService.checkMobile(null), |
| 157 | SMS_SEND_MOBILE_NOT_EXISTS); | 157 | SMS_SEND_MOBILE_NOT_EXISTS); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| @@ -171,9 +171,9 @@ public class SysSmsServiceTest extends BaseMockitoUnitTest { | @@ -171,9 +171,9 @@ public class SysSmsServiceTest extends BaseMockitoUnitTest { | ||
| 171 | eq(message.getTemplateParams()))).thenReturn(sendResult); | 171 | eq(message.getTemplateParams()))).thenReturn(sendResult); |
| 172 | 172 | ||
| 173 | // 调用 | 173 | // 调用 |
| 174 | - smsService.doSendSms(message); | 174 | + smsCoreService.doSendSms(message); |
| 175 | // 断言 | 175 | // 断言 |
| 176 | - verify(smsLogService, times(1)).updateSmsSendResult(eq(message.getLogId()), | 176 | + verify(smsLogCoreService, times(1)).updateSmsSendResult(eq(message.getLogId()), |
| 177 | eq(sendResult.getCode()), eq(sendResult.getMsg()), eq(sendResult.getApiCode()), | 177 | eq(sendResult.getCode()), eq(sendResult.getMsg()), eq(sendResult.getApiCode()), |
| 178 | eq(sendResult.getApiMsg()), eq(sendResult.getApiRequestId()), eq(sendResult.getData().getSerialNo())); | 178 | eq(sendResult.getApiMsg()), eq(sendResult.getApiRequestId()), eq(sendResult.getData().getSerialNo())); |
| 179 | } | 179 | } |
| @@ -190,12 +190,10 @@ public class SysSmsServiceTest extends BaseMockitoUnitTest { | @@ -190,12 +190,10 @@ public class SysSmsServiceTest extends BaseMockitoUnitTest { | ||
| 190 | List<SmsReceiveRespDTO> receiveResults = randomPojoList(SmsReceiveRespDTO.class); | 190 | List<SmsReceiveRespDTO> receiveResults = randomPojoList(SmsReceiveRespDTO.class); |
| 191 | 191 | ||
| 192 | // 调用 | 192 | // 调用 |
| 193 | - smsService.receiveSmsStatus(channelCode, text); | 193 | + smsCoreService.receiveSmsStatus(channelCode, text); |
| 194 | // 断言 | 194 | // 断言 |
| 195 | - receiveResults.forEach(result -> { | ||
| 196 | - smsLogService.updateSmsReceiveResult(eq(result.getLogId()), eq(result.getSuccess()), | ||
| 197 | - eq(result.getReceiveTime()), eq(result.getErrorCode()), eq(result.getErrorCode())); | ||
| 198 | - }); | 195 | + receiveResults.forEach(result -> smsLogCoreService.updateSmsReceiveResult(eq(result.getLogId()), eq(result.getSuccess()), |
| 196 | + eq(result.getReceiveTime()), eq(result.getErrorCode()), eq(result.getErrorCode()))); | ||
| 199 | } | 197 | } |
| 200 | 198 | ||
| 201 | } | 199 | } |
yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/system/service/sms/SysSmsLogCoreServiceTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.system.service.sms; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.map.MapUtil; | ||
| 4 | +import cn.iocoder.yudao.coreservice.BaseDbUnitTest; | ||
| 5 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsLogDO; | ||
| 6 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 7 | +import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.sms.SysSmsLogCoreMapper; | ||
| 8 | +import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsReceiveStatusEnum; | ||
| 9 | +import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsSendStatusEnum; | ||
| 10 | +import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsTemplateTypeEnum; | ||
| 11 | +import cn.iocoder.yudao.coreservice.modules.system.service.sms.impl.SysSmsLogCoreServiceImpl; | ||
| 12 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | ||
| 13 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 14 | +import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; | ||
| 15 | +import org.junit.jupiter.api.Test; | ||
| 16 | +import org.springframework.context.annotation.Import; | ||
| 17 | + | ||
| 18 | +import javax.annotation.Resource; | ||
| 19 | +import java.util.Date; | ||
| 20 | +import java.util.Map; | ||
| 21 | +import java.util.function.Consumer; | ||
| 22 | + | ||
| 23 | +import static cn.hutool.core.util.RandomUtil.randomBoolean; | ||
| 24 | +import static cn.hutool.core.util.RandomUtil.randomEle; | ||
| 25 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | ||
| 26 | +import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| 27 | +import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| 28 | + | ||
| 29 | +/** | ||
| 30 | +* {@link SysSmsLogCoreServiceImpl} 的单元测试类 | ||
| 31 | +* | ||
| 32 | +* @author 芋道源码 | ||
| 33 | +*/ | ||
| 34 | +@Import(SysSmsLogCoreServiceImpl.class) | ||
| 35 | +public class SysSmsLogCoreServiceTest extends BaseDbUnitTest { | ||
| 36 | + | ||
| 37 | + @Resource | ||
| 38 | + private SysSmsLogCoreServiceImpl smsLogCoreService; | ||
| 39 | + | ||
| 40 | + @Resource | ||
| 41 | + private SysSmsLogCoreMapper smsLogCoreMapper; | ||
| 42 | + | ||
| 43 | + @Test | ||
| 44 | + public void testCreateSmsLog() { | ||
| 45 | + // 准备参数 | ||
| 46 | + String mobile = randomString(); | ||
| 47 | + Long userId = randomLongId(); | ||
| 48 | + Integer userType = randomEle(UserTypeEnum.values()).getValue(); | ||
| 49 | + Boolean isSend = randomBoolean(); | ||
| 50 | + SysSmsTemplateDO templateDO = randomPojo(SysSmsTemplateDO.class, | ||
| 51 | + o -> o.setType(randomEle(SysSmsTemplateTypeEnum.values()).getType())); | ||
| 52 | + String templateContent = randomString(); | ||
| 53 | + Map<String, Object> templateParams = randomTemplateParams(); | ||
| 54 | + // mock 方法 | ||
| 55 | + | ||
| 56 | + // 调用 | ||
| 57 | + Long logId = smsLogCoreService.createSmsLog(mobile, userId, userType, isSend, | ||
| 58 | + templateDO, templateContent, templateParams); | ||
| 59 | + // 断言 | ||
| 60 | + SysSmsLogDO logDO = smsLogCoreMapper.selectById(logId); | ||
| 61 | + assertEquals(isSend ? SysSmsSendStatusEnum.INIT.getStatus() : SysSmsSendStatusEnum.IGNORE.getStatus(), | ||
| 62 | + logDO.getSendStatus()); | ||
| 63 | + assertEquals(mobile, logDO.getMobile()); | ||
| 64 | + assertEquals(userType, logDO.getUserType()); | ||
| 65 | + assertEquals(userId, logDO.getUserId()); | ||
| 66 | + assertEquals(templateDO.getId(), logDO.getTemplateId()); | ||
| 67 | + assertEquals(templateDO.getCode(), logDO.getTemplateCode()); | ||
| 68 | + assertEquals(templateDO.getType(), logDO.getTemplateType()); | ||
| 69 | + assertEquals(templateDO.getChannelId(), logDO.getChannelId()); | ||
| 70 | + assertEquals(templateDO.getChannelCode(), logDO.getChannelCode()); | ||
| 71 | + assertEquals(templateContent, logDO.getTemplateContent()); | ||
| 72 | + assertEquals(templateParams, logDO.getTemplateParams()); | ||
| 73 | + assertEquals(SysSmsReceiveStatusEnum.INIT.getStatus(), logDO.getReceiveStatus()); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Test | ||
| 77 | + public void testUpdateSmsSendResult() { | ||
| 78 | + // mock 数据 | ||
| 79 | + SysSmsLogDO dbSmsLog = randomSmsLogDO( | ||
| 80 | + o -> o.setSendStatus(SysSmsSendStatusEnum.IGNORE.getStatus())); | ||
| 81 | + smsLogCoreMapper.insert(dbSmsLog); | ||
| 82 | + // 准备参数 | ||
| 83 | + Long id = dbSmsLog.getId(); | ||
| 84 | + Integer sendCode = randomInteger(); | ||
| 85 | + String sendMsg = randomString(); | ||
| 86 | + String apiSendCode = randomString(); | ||
| 87 | + String apiSendMsg = randomString(); | ||
| 88 | + String apiRequestId = randomString(); | ||
| 89 | + String apiSerialNo = randomString(); | ||
| 90 | + | ||
| 91 | + // 调用 | ||
| 92 | + smsLogCoreService.updateSmsSendResult(id, sendCode, sendMsg, | ||
| 93 | + apiSendCode, apiSendMsg, apiRequestId, apiSerialNo); | ||
| 94 | + // 断言 | ||
| 95 | + dbSmsLog = smsLogCoreMapper.selectById(id); | ||
| 96 | + assertEquals(CommonResult.isSuccess(sendCode) ? SysSmsSendStatusEnum.SUCCESS.getStatus() | ||
| 97 | + : SysSmsSendStatusEnum.FAILURE.getStatus(), dbSmsLog.getSendStatus()); | ||
| 98 | + assertNotNull(dbSmsLog.getSendTime()); | ||
| 99 | + assertEquals(sendMsg, dbSmsLog.getSendMsg()); | ||
| 100 | + assertEquals(apiSendCode, dbSmsLog.getApiSendCode()); | ||
| 101 | + assertEquals(apiSendMsg, dbSmsLog.getApiSendMsg()); | ||
| 102 | + assertEquals(apiRequestId, dbSmsLog.getApiRequestId()); | ||
| 103 | + assertEquals(apiSerialNo, dbSmsLog.getApiSerialNo()); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + @Test | ||
| 107 | + public void testUpdateSmsReceiveResult() { | ||
| 108 | + // mock 数据 | ||
| 109 | + SysSmsLogDO dbSmsLog = randomSmsLogDO( | ||
| 110 | + o -> o.setReceiveStatus(SysSmsReceiveStatusEnum.INIT.getStatus())); | ||
| 111 | + smsLogCoreMapper.insert(dbSmsLog); | ||
| 112 | + // 准备参数 | ||
| 113 | + Long id = dbSmsLog.getId(); | ||
| 114 | + Boolean success = randomBoolean(); | ||
| 115 | + Date receiveTime = randomDate(); | ||
| 116 | + String apiReceiveCode = randomString(); | ||
| 117 | + String apiReceiveMsg = randomString(); | ||
| 118 | + | ||
| 119 | + // 调用 | ||
| 120 | + smsLogCoreService.updateSmsReceiveResult(id, success, receiveTime, apiReceiveCode, apiReceiveMsg); | ||
| 121 | + // 断言 | ||
| 122 | + dbSmsLog = smsLogCoreMapper.selectById(id); | ||
| 123 | + assertEquals(success ? SysSmsReceiveStatusEnum.SUCCESS.getStatus() | ||
| 124 | + : SysSmsReceiveStatusEnum.FAILURE.getStatus(), dbSmsLog.getReceiveStatus()); | ||
| 125 | + assertEquals(receiveTime, dbSmsLog.getReceiveTime()); | ||
| 126 | + assertEquals(apiReceiveCode, dbSmsLog.getApiReceiveCode()); | ||
| 127 | + assertEquals(apiReceiveMsg, dbSmsLog.getApiReceiveMsg()); | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + // ========== 随机对象 ========== | ||
| 131 | + | ||
| 132 | + @SafeVarargs | ||
| 133 | + private static SysSmsLogDO randomSmsLogDO(Consumer<SysSmsLogDO>... consumers) { | ||
| 134 | + Consumer<SysSmsLogDO> consumer = (o) -> { | ||
| 135 | + o.setTemplateParams(randomTemplateParams()); | ||
| 136 | + o.setTemplateType(randomEle(SysSmsTemplateTypeEnum.values()).getType()); // 保证 templateType 的范围 | ||
| 137 | + o.setUserType(randomEle(UserTypeEnum.values()).getValue()); // 保证 userType 的范围 | ||
| 138 | + o.setSendStatus(randomEle(SysSmsSendStatusEnum.values()).getStatus()); // 保证 sendStatus 的范围 | ||
| 139 | + o.setReceiveStatus(randomEle(SysSmsReceiveStatusEnum.values()).getStatus()); // 保证 receiveStatus 的范围 | ||
| 140 | + }; | ||
| 141 | + return randomPojo(SysSmsLogDO.class, ArrayUtils.append(consumer, consumers)); | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + | ||
| 145 | + private static Map<String, Object> randomTemplateParams() { | ||
| 146 | + return MapUtil.<String, Object>builder().put(randomString(), randomString()) | ||
| 147 | + .put(randomString(), randomString()).build(); | ||
| 148 | + } | ||
| 149 | +} |
yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/system/service/sms/SysSmsTemplateServiceTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.system.service.sms; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.coreservice.BaseDbUnitTest; | ||
| 4 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO; | ||
| 5 | +import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.sms.SysSmsTemplateCoreMapper; | ||
| 6 | +import cn.iocoder.yudao.coreservice.modules.system.enums.sms.SysSmsTemplateTypeEnum; | ||
| 7 | +import cn.iocoder.yudao.coreservice.modules.system.service.sms.impl.SysSmsTemplateCoreServiceImpl; | ||
| 8 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 9 | +import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; | ||
| 10 | +import org.junit.jupiter.api.Test; | ||
| 11 | +import org.springframework.context.annotation.Import; | ||
| 12 | + | ||
| 13 | +import javax.annotation.Resource; | ||
| 14 | +import java.util.Date; | ||
| 15 | +import java.util.Map; | ||
| 16 | +import java.util.function.Consumer; | ||
| 17 | + | ||
| 18 | +import static cn.hutool.core.bean.BeanUtil.getFieldValue; | ||
| 19 | +import static cn.hutool.core.util.RandomUtil.randomEle; | ||
| 20 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.max; | ||
| 21 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | ||
| 22 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | ||
| 23 | +import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| 24 | + | ||
| 25 | +/** | ||
| 26 | +* {@link SysSmsTemplateCoreServiceImpl} 的单元测试类 | ||
| 27 | +* | ||
| 28 | +* @author 芋道源码 | ||
| 29 | +*/ | ||
| 30 | +@Import(SysSmsTemplateCoreServiceImpl.class) | ||
| 31 | +public class SysSmsTemplateServiceTest extends BaseDbUnitTest { | ||
| 32 | + | ||
| 33 | + @Resource | ||
| 34 | + private SysSmsTemplateCoreServiceImpl smsTemplateCoreService; | ||
| 35 | + | ||
| 36 | + @Resource | ||
| 37 | + private SysSmsTemplateCoreMapper smsTemplateCoreMapper; | ||
| 38 | + | ||
| 39 | + @Test | ||
| 40 | + @SuppressWarnings("unchecked") | ||
| 41 | + void testInitLocalCache() { | ||
| 42 | + // mock 数据 | ||
| 43 | + SysSmsTemplateDO smsTemplate01 = randomSmsTemplateDO(); | ||
| 44 | + smsTemplateCoreMapper.insert(smsTemplate01); | ||
| 45 | + SysSmsTemplateDO smsTemplate02 = randomSmsTemplateDO(); | ||
| 46 | + smsTemplateCoreMapper.insert(smsTemplate02); | ||
| 47 | + | ||
| 48 | + // 调用 | ||
| 49 | + smsTemplateCoreService.initLocalCache(); | ||
| 50 | + // 断言 deptCache 缓存 | ||
| 51 | + Map<String, SysSmsTemplateDO> smsTemplateCache = (Map<String, SysSmsTemplateDO>) getFieldValue(smsTemplateCoreService, "smsTemplateCache"); | ||
| 52 | + assertEquals(2, smsTemplateCache.size()); | ||
| 53 | + assertPojoEquals(smsTemplate01, smsTemplateCache.get(smsTemplate01.getCode())); | ||
| 54 | + assertPojoEquals(smsTemplate02, smsTemplateCache.get(smsTemplate02.getCode())); | ||
| 55 | + // 断言 maxUpdateTime 缓存 | ||
| 56 | + Date maxUpdateTime = (Date) getFieldValue(smsTemplateCoreService, "maxUpdateTime"); | ||
| 57 | + assertEquals(max(smsTemplate01.getUpdateTime(), smsTemplate02.getUpdateTime()), maxUpdateTime); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + // ========== 随机对象 ========== | ||
| 61 | + | ||
| 62 | + @SafeVarargs | ||
| 63 | + private static SysSmsTemplateDO randomSmsTemplateDO(Consumer<SysSmsTemplateDO>... consumers) { | ||
| 64 | + Consumer<SysSmsTemplateDO> consumer = (o) -> { | ||
| 65 | + o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 | ||
| 66 | + o.setType(randomEle(SysSmsTemplateTypeEnum.values()).getType()); // 保证 type 的 范围 | ||
| 67 | + }; | ||
| 68 | + return randomPojo(SysSmsTemplateDO.class, ArrayUtils.append(consumer, consumers)); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | +} |
yudao-core-service/src/test/resources/sql/clean.sql
| @@ -5,3 +5,5 @@ DELETE FROM "inf_api_error_log"; | @@ -5,3 +5,5 @@ DELETE FROM "inf_api_error_log"; | ||
| 5 | -- sys 开头的 DB | 5 | -- sys 开头的 DB |
| 6 | DELETE FROM "sys_user_session"; | 6 | DELETE FROM "sys_user_session"; |
| 7 | DELETE FROM "sys_dict_data"; | 7 | DELETE FROM "sys_dict_data"; |
| 8 | +DELETE FROM "sys_sms_template"; | ||
| 9 | +DELETE FROM "sys_sms_log"; |
yudao-core-service/src/test/resources/sql/create_tables.sql
| @@ -56,7 +56,7 @@ CREATE TABLE IF NOT EXISTS "inf_api_access_log" ( | @@ -56,7 +56,7 @@ CREATE TABLE IF NOT EXISTS "inf_api_access_log" ( | ||
| 56 | "update_time" timestamp not null default current_timestamp, | 56 | "update_time" timestamp not null default current_timestamp, |
| 57 | "deleted" bit not null default false, | 57 | "deleted" bit not null default false, |
| 58 | primary key ("id") | 58 | primary key ("id") |
| 59 | - ) COMMENT 'API 访问日志表'; | 59 | +) COMMENT 'API 访问日志表'; |
| 60 | 60 | ||
| 61 | CREATE TABLE IF NOT EXISTS "inf_api_error_log" ( | 61 | CREATE TABLE IF NOT EXISTS "inf_api_error_log" ( |
| 62 | "id" integer not null GENERATED BY DEFAULT AS IDENTITY, | 62 | "id" integer not null GENERATED BY DEFAULT AS IDENTITY, |
| @@ -87,4 +87,75 @@ CREATE TABLE IF NOT EXISTS "inf_api_error_log" ( | @@ -87,4 +87,75 @@ CREATE TABLE IF NOT EXISTS "inf_api_error_log" ( | ||
| 87 | "update_time" timestamp not null default current_timestamp, | 87 | "update_time" timestamp not null default current_timestamp, |
| 88 | "deleted" bit not null default false, | 88 | "deleted" bit not null default false, |
| 89 | primary key ("id") | 89 | primary key ("id") |
| 90 | - ) COMMENT '系统异常日志'; | 90 | +) COMMENT '系统异常日志'; |
| 91 | + | ||
| 92 | +CREATE TABLE IF NOT EXISTS "sys_sms_template" ( | ||
| 93 | + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
| 94 | + "type" tinyint NOT NULL, | ||
| 95 | + "status" tinyint NOT NULL, | ||
| 96 | + "code" varchar(63) NOT NULL, | ||
| 97 | + "name" varchar(63) NOT NULL, | ||
| 98 | + "content" varchar(255) NOT NULL, | ||
| 99 | + "params" varchar(255) NOT NULL, | ||
| 100 | + "remark" varchar(255) DEFAULT NULL, | ||
| 101 | + "api_template_id" varchar(63) NOT NULL, | ||
| 102 | + "channel_id" bigint NOT NULL, | ||
| 103 | + "channel_code" varchar(63) NOT NULL, | ||
| 104 | + "creator" varchar(64) DEFAULT '', | ||
| 105 | + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| 106 | + "updater" varchar(64) DEFAULT '', | ||
| 107 | + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| 108 | + "deleted" bit NOT NULL DEFAULT FALSE, | ||
| 109 | + PRIMARY KEY ("id") | ||
| 110 | +) COMMENT '短信模板'; | ||
| 111 | + | ||
| 112 | +CREATE TABLE IF NOT EXISTS "sys_sms_log" ( | ||
| 113 | + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
| 114 | + "channel_id" bigint NOT NULL, | ||
| 115 | + "channel_code" varchar(63) NOT NULL, | ||
| 116 | + "template_id" bigint NOT NULL, | ||
| 117 | + "template_code" varchar(63) NOT NULL, | ||
| 118 | + "template_type" tinyint NOT NULL, | ||
| 119 | + "template_content" varchar(255) NOT NULL, | ||
| 120 | + "template_params" varchar(255) NOT NULL, | ||
| 121 | + "api_template_id" varchar(63) NOT NULL, | ||
| 122 | + "mobile" varchar(11) NOT NULL, | ||
| 123 | + "user_id" bigint DEFAULT '0', | ||
| 124 | + "user_type" tinyint DEFAULT '0', | ||
| 125 | + "send_status" tinyint NOT NULL DEFAULT '0', | ||
| 126 | + "send_time" timestamp DEFAULT NULL, | ||
| 127 | + "send_code" int DEFAULT NULL, | ||
| 128 | + "send_msg" varchar(255) DEFAULT NULL, | ||
| 129 | + "api_send_code" varchar(63) DEFAULT NULL, | ||
| 130 | + "api_send_msg" varchar(255) DEFAULT NULL, | ||
| 131 | + "api_request_id" varchar(255) DEFAULT NULL, | ||
| 132 | + "api_serial_no" varchar(255) DEFAULT NULL, | ||
| 133 | + "receive_status" tinyint NOT NULL DEFAULT '0', | ||
| 134 | + "receive_time" timestamp DEFAULT NULL, | ||
| 135 | + "api_receive_code" varchar(63) DEFAULT NULL, | ||
| 136 | + "api_receive_msg" varchar(255) DEFAULT NULL, | ||
| 137 | + "creator" varchar(64) DEFAULT '', | ||
| 138 | + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| 139 | + "updater" varchar(64) DEFAULT '', | ||
| 140 | + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| 141 | + "deleted" bit NOT NULL DEFAULT FALSE, | ||
| 142 | + PRIMARY KEY ("id") | ||
| 143 | +) COMMENT '短信日志'; | ||
| 144 | + | ||
| 145 | +CREATE TABLE IF NOT EXISTS `sys_login_log` ( | ||
| 146 | + `id` bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
| 147 | + `log_type` bigint(4) NOT NULL, | ||
| 148 | + "user_id" bigint not null default '0', | ||
| 149 | + "user_type" tinyint NOT NULL, | ||
| 150 | + `trace_id` varchar(64) NOT NULL DEFAULT '', | ||
| 151 | + `username` varchar(50) NOT NULL DEFAULT '', | ||
| 152 | + `result` tinyint(4) NOT NULL, | ||
| 153 | + `user_ip` varchar(50) NOT NULL, | ||
| 154 | + `user_agent` varchar(512) NOT NULL, | ||
| 155 | + `creator` varchar(64) DEFAULT '', | ||
| 156 | + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| 157 | + `updater` varchar(64) DEFAULT '', | ||
| 158 | + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
| 159 | + `deleted` bit(1) NOT NULL DEFAULT '0', | ||
| 160 | + PRIMARY KEY (`id`) | ||
| 161 | +) COMMENT ='系统访问记录'; |
更新日志.md
| @@ -16,9 +16,10 @@ | @@ -16,9 +16,10 @@ | ||
| 16 | 16 | ||
| 17 | * 新增管理后台的企业微信、钉钉等社交登录 | 17 | * 新增管理后台的企业微信、钉钉等社交登录 |
| 18 | * 新增用户前台(例如说,用户使用的小程序)的后端项目 `yudao-user-server` | 18 | * 新增用户前台(例如说,用户使用的小程序)的后端项目 `yudao-user-server` |
| 19 | -* 新增公共服务 `yudao-core-service` 项目,通过 Jar 包的方式,提供 `yudao-user-server` 和 `yudao-admin-server` 的共享逻辑的复用。 | 19 | +* 新增公共服务 `yudao-core-service` 项目,通过 Jar 包的方式,提供 `yudao-user-server` 和 `yudao-admin-server` 的共享逻辑的复用 |
| 20 | * 新增用户前台的手机登录、验证码登录 | 20 | * 新增用户前台的手机登录、验证码登录 |
| 21 | -* 修复管理后台的用户头像上传 404 的问题 | 21 | +* 修复管理后台的用户头像上传 404 的问题,原因是请求路径不对 |
| 22 | +* 修复用户导入失败的问题,原因是 Lombok 链式与 cglib 读取属性有冲突 | ||
| 22 | 23 | ||
| 23 | ## [v1.0.0] 2021.05.03 | 24 | ## [v1.0.0] 2021.05.03 |
| 24 | 25 |