mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 23:23:55 +08:00
开启手机注册,验证相关参数不可以为空
--SysParamsServiceImpl.java 开启手机注册参数添加验证
This commit is contained in:
+38
-5
@@ -1,9 +1,6 @@
|
||||
package xiaozhi.modules.sys.service.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -82,7 +79,7 @@ public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParam
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(SysParamsDTO dto) {
|
||||
validateParamValue(dto);
|
||||
|
||||
detectingSMSParameters(dto.getParamCode(),dto.getParamValue());
|
||||
SysParamsEntity entity = ConvertUtils.sourceToTarget(dto, SysParamsEntity.class);
|
||||
updateById(entity);
|
||||
|
||||
@@ -204,4 +201,40 @@ public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParam
|
||||
updateValueByCode(Constant.SERVER_SECRET, newSecret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测短信参数是否符合要求
|
||||
* @param paramCode 参数编码
|
||||
* @param paramValue 参数值
|
||||
* @return 是否通过
|
||||
*/
|
||||
private boolean detectingSMSParameters(String paramCode, String paramValue){
|
||||
// 判断是否是开启手机注册的参数编码,如果不是参数编码,着不需要检测其他短信参数,直接返回true
|
||||
if (!Constant.SysMSMParam.SYSTEM_ENABLE_MOBILE_REGISTER.getValue().equals(paramCode)){
|
||||
return true;
|
||||
}
|
||||
// 判断是否为关闭,如果是关闭短信注册,着不需要检测其他短信参数,直接返回true
|
||||
if ("false".equalsIgnoreCase(paramValue)) {
|
||||
return true;
|
||||
}
|
||||
// 检测短信关联参数是否为空
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
list.add(Constant.SysMSMParam.SYSTEM_SMS_MAX_SEND_COUNT.getValue());
|
||||
list.add(Constant.SysMSMParam.ALIYUN_SMS_ACCESS_KEY_ID.getValue());
|
||||
list.add(Constant.SysMSMParam.ALIYUN_SMS_ACCESS_KEY_SECRET.getValue());
|
||||
list.add(Constant.SysMSMParam.ALIYUN_SMS_SIGN_NAME.getValue());
|
||||
list.add(Constant.SysMSMParam.ALIYUN_SMS_SMS_CODE_TEMPLATE_CODE.getValue());
|
||||
StringBuilder str = new StringBuilder();
|
||||
list.forEach( item -> {
|
||||
if (!StringUtils.isNoneBlank(item)) {
|
||||
str.append(",").append(item);
|
||||
}
|
||||
});
|
||||
if (!str.isEmpty()) {
|
||||
String promptStr = "%s这些参数不可以为空";
|
||||
String substring = str.substring(1, str.length());
|
||||
throw new RenException(promptStr.formatted(substring));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user