diff --git a/common-api/src/main/java/cn/lili/controller/common/UploadController.java b/common-api/src/main/java/cn/lili/controller/common/UploadController.java index 83d868b4..499e1787 100644 --- a/common-api/src/main/java/cn/lili/controller/common/UploadController.java +++ b/common-api/src/main/java/cn/lili/controller/common/UploadController.java @@ -63,7 +63,7 @@ public class UploadController { if (authUser == null) { throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR); } - Setting setting = settingService.getById(SettingEnum.OSS_SETTING.name()); + Setting setting = settingService.get(SettingEnum.OSS_SETTING.name()); if (setting == null || StrUtil.isBlank(setting.getSettingValue())) { throw new ServiceException(ResultCode.OSS_NOT_EXIST); } diff --git a/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java b/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java index 0645be6a..fead89fb 100644 --- a/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java +++ b/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java @@ -53,44 +53,61 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { @Override public void sendSmsCode(String mobile, VerificationEnums verificationEnums, String uuid) { + //获取短信配置 + Setting setting = settingService.get(SettingEnum.SMS_SETTING.name()); + if (StrUtil.isBlank(setting.getSettingValue())) { + throw new ServiceException("您还未配置阿里云短信"); + } + SmsSetting smsSetting = new Gson().fromJson(setting.getSettingValue(), SmsSetting.class); + //验证码 String code = CommonUtil.getRandomNum(); - switch (verificationEnums) { - //如果某个模版需要自定义,则在此处进行调整 - case LOGIN: - case REGISTER: - case FIND_USER: { + //准备发送短信参数 + Map params = new HashMap<>(); + // 验证码内容 + params.put("code", code); - //准备发送短信参数 - Map params = new HashMap<>(); - params.put("code", code); - cache.put(cacheKey(verificationEnums, mobile, uuid), code, 300L); - Setting setting = settingService.getById(SettingEnum.SMS_SETTING.name()); - if (StrUtil.isBlank(setting.getSettingValue())) { - throw new ServiceException("您还未配置阿里云短信"); - } - SmsSetting smsSetting = new Gson().fromJson(setting.getSettingValue(), SmsSetting.class); - this.sendSmsCode(smsSetting.getSignName(), mobile, params, "SMS_205755300"); + //模版 默认为登录验证 + String templateCode; + + //如果某个模版需要自定义,则在此处进行调整 + switch (verificationEnums) { + //登录 + case LOGIN: { + templateCode = "SMS_205755300"; break; } + //注册 + case REGISTER: { + templateCode = "SMS_205755298"; + break; + } + //找回密码 + case FIND_USER: { + templateCode = "SMS_205755301"; + break; + } + //修改密码 case UPDATE_PASSWORD: { Member member = memberService.getById(UserContext.getCurrentUser().getId()); if (member == null || StringUtil.isEmpty(member.getMobile())) { return; } - String memberMobile = member.getMobile(); - //准备发送短信参数 - Map params = new HashMap<>(); - params.put("code", code); - cache.put(cacheKey(verificationEnums, memberMobile, uuid), code, 300L); - this.sendSmsCode("北京宏业汇成科技有限公司", mobile, params, "SMS_205755297"); + //更新为用户最新手机号 + mobile = member.getMobile(); + templateCode = "SMS_205755297"; break; } //如果不是有效的验证码手段,则此处不进行短信操作 default: return; } + //缓存中写入要验证的信息 + cache.put(cacheKey(verificationEnums, mobile, uuid), code, 300L); + //发送短信 + this.sendSmsCode(smsSetting.getSignName(), mobile, params, templateCode); + } @Override @@ -314,7 +331,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { */ public com.aliyun.dysmsapi20170525.Client createClient() { try { - Setting setting = settingService.getById(SettingEnum.SMS_SETTING.name()); + Setting setting = settingService.get(SettingEnum.SMS_SETTING.name()); if (StrUtil.isBlank(setting.getSettingValue())) { throw new ServiceException("您还未配置阿里云短信"); } diff --git a/framework/src/main/java/cn/lili/modules/file/plugin/impl/AliFileManagerPlugin.java b/framework/src/main/java/cn/lili/modules/file/plugin/impl/AliFileManagerPlugin.java index cc189f17..731454ca 100644 --- a/framework/src/main/java/cn/lili/modules/file/plugin/impl/AliFileManagerPlugin.java +++ b/framework/src/main/java/cn/lili/modules/file/plugin/impl/AliFileManagerPlugin.java @@ -74,7 +74,7 @@ public class AliFileManagerPlugin implements FileManagerPlugin { private OssSetting getSetting() { //如果没有配置,或者没有下次刷新时间,或者下次刷新时间小于当前时间,则从redis 更新一次 if (ossSetting == null || nextInitSetting == null || nextInitSetting < System.currentTimeMillis()) { - Setting setting = settingService.getById(SettingEnum.OSS_SETTING.name()); + Setting setting = settingService.get(SettingEnum.OSS_SETTING.name()); if (setting == null || StrUtil.isBlank(setting.getSettingValue())) { throw new ServiceException("您还未配置阿里云OSS存储"); } diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java index d211d078..d41a96be 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java @@ -12,7 +12,6 @@ import cn.lili.modules.system.service.SettingService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -62,7 +61,7 @@ public class GoodsGalleryServiceImpl extends ServiceImpl