mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 21:32:07 +08:00
sonarqube质量修复
This commit is contained in:
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.cf.imes.module.system.controller.admin.oauth2.vo.open;
|
||||
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -20,7 +20,7 @@ public class OAuth2OpenAuthorizeInfoRespVO {
|
||||
private Client client;
|
||||
|
||||
@Schema(description = "scope 的选中信息,使用 List 保证有序性,Key 是 scope,Value 为是否选中", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<KeyValue<String, Boolean>> scopes;
|
||||
private List<Pair<String, Boolean>> scopes;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package com.cf.imes.module.system.convert.oauth2;
|
||||
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.cf.imes.framework.common.enums.UserTypeEnum;
|
||||
import com.cf.imes.framework.common.util.collection.CollectionUtils;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
@@ -42,11 +42,11 @@ public interface OAuth2OpenConvert {
|
||||
|
||||
default OAuth2OpenAuthorizeInfoRespVO convert(OAuth2ClientDO client, List<OAuth2ApproveDO> approves) {
|
||||
// 构建 scopes
|
||||
List<KeyValue<String, Boolean>> scopes = new ArrayList<>(client.getScopes().size());
|
||||
List<Pair<String, Boolean>> scopes = new ArrayList<>(client.getScopes().size());
|
||||
Map<String, OAuth2ApproveDO> approveMap = CollectionUtils.convertMap(approves, OAuth2ApproveDO::getScope);
|
||||
client.getScopes().forEach(scope -> {
|
||||
OAuth2ApproveDO approve = approveMap.get(scope);
|
||||
scopes.add(new KeyValue<>(scope, approve != null ? approve.getApproved() : false));
|
||||
scopes.add(new Pair<>(scope, approve != null ? approve.getApproved() : false));
|
||||
});
|
||||
// 拼接返回
|
||||
return new OAuth2OpenAuthorizeInfoRespVO(
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.cf.imes.module.system.mq.message.sms;
|
||||
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
@@ -37,7 +37,7 @@ public class SmsSendMessage {
|
||||
/**
|
||||
* 短信模板参数
|
||||
*/
|
||||
private List<KeyValue<String, Object>> templateParams;
|
||||
private List<Pair<String, Object>> templateParams;
|
||||
|
||||
/**
|
||||
* 短信消息模板类型:system_sms_template.type
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.cf.imes.module.system.mq.producer.sms;
|
||||
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.cf.imes.module.system.dal.dataobject.sms.SmsTemplateDO;
|
||||
import com.cf.imes.module.system.mq.message.sms.SmsSendMessage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -32,7 +32,7 @@ public class SmsProducer {
|
||||
* @param template 模板信息
|
||||
* @param templateParams 短信模板参数
|
||||
*/
|
||||
public void sendSmsSendMessage(Long logId, String mobile, SmsTemplateDO template, List<KeyValue<String, Object>> templateParams) {
|
||||
public void sendSmsSendMessage(Long logId, String mobile, SmsTemplateDO template, List<Pair<String, Object>> templateParams) {
|
||||
SmsSendMessage message = new SmsSendMessage().setLogId(logId).setMobile(mobile);
|
||||
message.setChannelId(template.getChannelId()).setApiTemplateId(template.getApiTemplateId()).setTemplateType(template.getType()).setTemplateParams(templateParams);
|
||||
// event异步发送短信,保证子线程内部request不为空
|
||||
|
||||
+5
-5
@@ -3,7 +3,7 @@ package com.cf.imes.module.system.service.sms;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.common.enums.UserTypeEnum;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
@@ -88,7 +88,7 @@ public class SmsSendServiceImpl implements SmsSendService {
|
||||
// 校验手机号码是否存在
|
||||
mobile = validateMobile(mobile);
|
||||
// 构建有序的模板参数。为什么放在这个位置,是提前保证模板参数的正确性,而不是到了插入发送日志
|
||||
List<KeyValue<String, Object>> newTemplateParams = buildTemplateParams(template, templateParams);
|
||||
List<Pair<String, Object>> newTemplateParams = buildTemplateParams(template, templateParams);
|
||||
|
||||
// 创建发送日志。如果模板被禁用,则不发送短信,只记录日志
|
||||
Boolean isSend = CommonStatusEnum.ENABLE.getStatus().equals(template.getStatus());
|
||||
@@ -123,13 +123,13 @@ public class SmsSendServiceImpl implements SmsSendService {
|
||||
* @return 处理后的参数
|
||||
*/
|
||||
@VisibleForTesting
|
||||
List<KeyValue<String, Object>> buildTemplateParams(SmsTemplateDO template, Map<String, Object> templateParams) {
|
||||
List<Pair<String, Object>> buildTemplateParams(SmsTemplateDO template, Map<String, Object> templateParams) {
|
||||
return template.getParams().stream().map(key -> {
|
||||
Object value = templateParams.get(key);
|
||||
if (value == null) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS, key);
|
||||
}
|
||||
return new KeyValue<>(key, value);
|
||||
return new Pair<>(key, value);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public class SmsSendServiceImpl implements SmsSendService {
|
||||
SmsClient smsClient = smsChannelService.getSmsClient();
|
||||
Assert.notNull(smsClient, "短信客户端({}) 不存在", message.getChannelId());
|
||||
|
||||
List<KeyValue<String, Object>> templateParams = message.getTemplateParams();
|
||||
List<Pair<String, Object>> templateParams = message.getTemplateParams();
|
||||
String channelCode = null;
|
||||
// 发送短信
|
||||
try {
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.cf.imes.module.system.service.sms.handler;
|
||||
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.cf.imes.framework.sms.core.client.dto.SmsSendRespDTO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -21,5 +21,5 @@ public interface SmsSendAfterSendHandler {
|
||||
boolean checkTemplateType(Integer templateType);
|
||||
|
||||
|
||||
void afterSend(SmsSendRespDTO sendResponse, List<KeyValue<String, Object>> params);
|
||||
void afterSend(SmsSendRespDTO sendResponse, List<Pair<String, Object>> params);
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package com.cf.imes.module.system.service.sms.handler.impl;
|
||||
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.core.KeyValue;
|
||||
import com.cf.imes.framework.sms.core.client.dto.SmsSendRespDTO;
|
||||
import com.cf.imes.module.system.dal.redis.RedisKeyConstants;
|
||||
import com.cf.imes.module.system.enums.sms.SmsTemplateTypeEnum;
|
||||
@@ -33,10 +33,10 @@ public class SmsSendAfterSendHandlerImpl implements SmsSendAfterSendHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSend(SmsSendRespDTO sendResponse, List<KeyValue<String, Object>> params) {
|
||||
public void afterSend(SmsSendRespDTO sendResponse, List<Pair<String, Object>> params) {
|
||||
// 发送成功把验证码存入redis
|
||||
if (sendResponse.getSuccess()) {
|
||||
for (KeyValue<String, Object> keyValue : params) {
|
||||
for (Pair<String, Object> keyValue : params) {
|
||||
if ("code".equals(keyValue.getKey())) {
|
||||
redisTemplate.opsForValue().set(String.format(RedisKeyConstants.SMS_CAPTCHA_VERIFICATION, sendResponse.getMobile()), keyValue.getValue(), smsCodeProperties.getExpireTimes());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user