mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-10-26 06:57:08 +08:00
feat(system/smsConfig): 短信配置新增设为默认功能
This commit is contained in:
@@ -94,6 +94,11 @@ public class SmsConfigDO extends BaseDO {
|
||||
*/
|
||||
private String supplierConfig;
|
||||
|
||||
/**
|
||||
* 是否为默认存储
|
||||
*/
|
||||
private Boolean isDefault;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
|
||||
@@ -125,6 +125,13 @@ public class SmsConfigResp extends BaseDetailResp {
|
||||
@ExcelProperty(value = "各个厂商独立配置")
|
||||
private String supplierConfig;
|
||||
|
||||
/**
|
||||
* 是否为默认存储
|
||||
*/
|
||||
@Schema(description = "是否为默认存储", example = "true")
|
||||
@ExcelProperty(value = "是否为默认存储")
|
||||
private Boolean isDefault;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package top.continew.admin.system.service;
|
||||
|
||||
import top.continew.admin.system.model.entity.SmsConfigDO;
|
||||
import top.continew.admin.system.model.query.SmsConfigQuery;
|
||||
import top.continew.admin.system.model.req.SmsConfigReq;
|
||||
import top.continew.admin.system.model.resp.SmsConfigResp;
|
||||
@@ -27,4 +28,19 @@ import top.continew.starter.extension.crud.service.BaseService;
|
||||
* @author luoqiz
|
||||
* @since 2025/03/15 18:41
|
||||
*/
|
||||
public interface SmsConfigService extends BaseService<SmsConfigResp, SmsConfigResp, SmsConfigQuery, SmsConfigReq> {}
|
||||
public interface SmsConfigService extends BaseService<SmsConfigResp, SmsConfigResp, SmsConfigQuery, SmsConfigReq> {
|
||||
|
||||
/**
|
||||
* 设置默认配置
|
||||
*
|
||||
* @param id ID
|
||||
*/
|
||||
void setDefaultConfig(Long id);
|
||||
|
||||
/**
|
||||
* 获取默认短信配置
|
||||
*
|
||||
* @return 默认短信配置
|
||||
*/
|
||||
SmsConfigDO getDefaultConfig();
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public interface StorageService extends BaseService<StorageResp, StorageResp, St
|
||||
*
|
||||
* @param id ID
|
||||
*/
|
||||
void setDefault(Long id);
|
||||
void setDefaultStorage(Long id);
|
||||
|
||||
/**
|
||||
* 查询默认存储
|
||||
|
||||
@@ -20,6 +20,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.sms4j.core.factory.SmsFactory;
|
||||
import org.dromara.sms4j.provider.config.BaseConfig;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import top.continew.admin.common.enums.DisEnableStatusEnum;
|
||||
import top.continew.admin.system.config.sms.SmsConfigUtil;
|
||||
import top.continew.admin.system.mapper.SmsConfigMapper;
|
||||
import top.continew.admin.system.model.entity.SmsConfigDO;
|
||||
@@ -27,6 +29,7 @@ import top.continew.admin.system.model.query.SmsConfigQuery;
|
||||
import top.continew.admin.system.model.req.SmsConfigReq;
|
||||
import top.continew.admin.system.model.resp.SmsConfigResp;
|
||||
import top.continew.admin.system.service.SmsConfigService;
|
||||
import top.continew.starter.core.validation.CheckUtils;
|
||||
import top.continew.starter.extension.crud.service.BaseServiceImpl;
|
||||
|
||||
import java.util.List;
|
||||
@@ -62,6 +65,24 @@ public class SmsConfigServiceImpl extends BaseServiceImpl<SmsConfigMapper, SmsCo
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void setDefaultConfig(Long id) {
|
||||
SmsConfigDO smsConfig = super.getById(id);
|
||||
if (Boolean.TRUE.equals(smsConfig.getIsDefault())) {
|
||||
return;
|
||||
}
|
||||
// 启用状态才能设为默认配置
|
||||
CheckUtils.throwIfNotEqual(DisEnableStatusEnum.ENABLE, smsConfig.getStatus(), "请先启用所选配置");
|
||||
baseMapper.lambdaUpdate().eq(SmsConfigDO::getIsDefault, true).set(SmsConfigDO::getIsDefault, false).update();
|
||||
baseMapper.lambdaUpdate().eq(SmsConfigDO::getId, id).set(SmsConfigDO::getIsDefault, true).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SmsConfigDO getDefaultConfig() {
|
||||
return baseMapper.lambdaQuery().eq(SmsConfigDO::getIsDefault, true).eq(SmsConfigDO::getStatus, DisEnableStatusEnum.ENABLE).one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载配置
|
||||
*
|
||||
|
||||
@@ -139,7 +139,7 @@ public class StorageServiceImpl extends BaseServiceImpl<StorageMapper, StorageDO
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void setDefault(Long id) {
|
||||
public void setDefaultStorage(Long id) {
|
||||
StorageDO storage = super.getById(id);
|
||||
if (Boolean.TRUE.equals(storage.getIsDefault())) {
|
||||
return;
|
||||
@@ -152,7 +152,7 @@ public class StorageServiceImpl extends BaseServiceImpl<StorageMapper, StorageDO
|
||||
|
||||
@Override
|
||||
public StorageDO getDefaultStorage() {
|
||||
return baseMapper.lambdaQuery().eq(StorageDO::getIsDefault, true).one();
|
||||
return baseMapper.lambdaQuery().eq(StorageDO::getIsDefault, true).eq(StorageDO::getStatus, DisEnableStatusEnum.ENABLE).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user