add: 短信登陆接口
This commit is contained in:
parent
50999ad50f
commit
0c2b886de6
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.rax.common.core.util.R;
|
||||
import com.rax.common.security.service.RaxUser;
|
||||
import com.rax.common.security.util.SecurityUtils;
|
||||
import com.rax.dailyplan.dto.DailyPlanDTO;
|
||||
import com.rax.dailyplan.entity.DailyPlan;
|
||||
import com.rax.dailyplan.mapper.DailyPlanMapper;
|
||||
|
|
|
@ -105,13 +105,23 @@
|
|||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.2.21</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 加密模块-->
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.68</version>
|
||||
</dependency>
|
||||
<!-- 阿里云短信-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>4.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>dysmsapi20170525</artifactId>
|
||||
<version>2.0.24</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.rax.admin.config;
|
||||
|
||||
import io.springboot.sms.SmsProperties;
|
||||
import io.springboot.sms.core.SmsClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* project_name:remote-control-backend
|
||||
* time:2024/8/15 14:44
|
||||
*/
|
||||
@Configuration
|
||||
public class SmsConfig {
|
||||
|
||||
@Autowired
|
||||
private SmsProperties smsProperties;
|
||||
|
||||
@Bean
|
||||
public SmsClient smsClient(){
|
||||
SmsClient smsClient = new SmsClient(smsProperties);
|
||||
return smsClient;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.rax.admin.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* project_name:remote-control-backend
|
||||
* time:2024/8/15 14:29
|
||||
* 此properties是自配置的,解决和阿里云短信服务配置冲突, 暂不用
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "ali.sms")
|
||||
@Component
|
||||
@Data
|
||||
public class SmsProperties {
|
||||
private String accessKeyId;
|
||||
private String accessSecret;
|
||||
private String signName;
|
||||
private String templateCode;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
//package com.rax.vital.util;
|
||||
//
|
||||
//import com.aliyun.dysmsapi20170525.Client;
|
||||
//import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
|
||||
//import com.aliyun.teaopenapi.models.Config;
|
||||
//import com.aliyun.teautil.models.RuntimeOptions;
|
||||
//import com.aliyuncs.exceptions.ClientException;
|
||||
//import com.rax.admin.config.SmsProperties;
|
||||
//import lombok.Data;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.beans.factory.annotation.Value;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//
|
||||
//@Component
|
||||
//@Slf4j
|
||||
//@Data
|
||||
//public class SendSmsService {
|
||||
//
|
||||
// @Autowired
|
||||
// private SmsProperties smsProperties;
|
||||
//
|
||||
// private String REGION_ID = "cn-hangzhou";
|
||||
// private String PRODUCT = "Dysmsapi";
|
||||
// private String ENDPOINT = "dysmsapi.aliyuncs.com";
|
||||
//
|
||||
// /**
|
||||
// * 发送短信通知
|
||||
// *
|
||||
// * @param mobile 手机号
|
||||
// * @param code 验证码
|
||||
// * @return 执行结果
|
||||
// */
|
||||
// public boolean sendSMS(String mobile, String code) {
|
||||
// try {
|
||||
// Config config = new Config();
|
||||
// config.setAccessKeyId(smsProperties.getAccessKeyId());
|
||||
// config.setAccessKeySecret(smsProperties.getAccessSecret());
|
||||
// config.endpoint = ENDPOINT;
|
||||
//
|
||||
// Client client = new Client(config);
|
||||
//
|
||||
//
|
||||
// SendSmsRequest request = new SendSmsRequest()
|
||||
// .setSignName(smsProperties.getSignName())
|
||||
// .setTemplateCode(smsProperties.getTemplateCode());
|
||||
//
|
||||
// request.setPhoneNumbers(mobile);
|
||||
// request.setTemplateParam("{\"code\":\"" + code + "\"}");
|
||||
//
|
||||
// RuntimeOptions runtimeOptions = new RuntimeOptions();
|
||||
// client.sendSmsWithOptions(request, runtimeOptions);
|
||||
// return true;
|
||||
// } catch (ClientException e) {
|
||||
// log.error("发送短信失败{}", e.getMessage());
|
||||
// return false;
|
||||
// } catch (Exception e) {
|
||||
// log.error("发送短信失败{}", e.getMessage());
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
|
@ -82,6 +82,7 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean saveLog(SysLog sysLog) {
|
||||
System.out.println("sysLog = " + sysLog);
|
||||
SysUser sysUser = userService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, sysLog.getCreateBy()));
|
||||
sysLog.setHospitalId(sysUser.getHospitalId());
|
||||
baseMapper.insert(sysLog);
|
||||
|
|
|
@ -11,8 +11,10 @@ import com.rax.common.core.constant.SecurityConstants;
|
|||
import com.rax.common.core.exception.ErrorCodes;
|
||||
import com.rax.common.core.util.MsgUtils;
|
||||
import com.rax.common.core.util.R;
|
||||
import io.springboot.sms.core.SmsClient;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -34,6 +36,9 @@ public class SysMobileServiceImpl implements SysMobileService {
|
|||
|
||||
private final SysUserMapper userMapper;
|
||||
|
||||
@Autowired
|
||||
private SmsClient smsClient;
|
||||
|
||||
/**
|
||||
* 发送手机验证码 TODO: 调用短信网关发送验证码,测试返回前端
|
||||
* @param mobile mobile
|
||||
|
@ -58,6 +63,7 @@ public class SysMobileServiceImpl implements SysMobileService {
|
|||
|
||||
String code = RandomUtil.randomNumbers(Integer.parseInt(SecurityConstants.CODE_SIZE));
|
||||
log.debug("手机号生成验证码成功:{},{}", mobile, code);
|
||||
smsClient.sendCode(code, mobile);
|
||||
redisTemplate.opsForValue()
|
||||
.set(CacheConstants.DEFAULT_CODE_KEY + mobile, code, SecurityConstants.CODE_TIME, TimeUnit.SECONDS);
|
||||
return R.ok(Boolean.TRUE, code);
|
||||
|
|
|
@ -197,7 +197,7 @@ public class AIMedicineServiceImpl implements AIMedicineService {
|
|||
@Override
|
||||
public Map getAiMedicine(MongoTemplate template) {
|
||||
Query query = new Query();
|
||||
query.limit(2);
|
||||
query.limit(1);
|
||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
||||
List<Map> aimedicinetable = template.find(query, Map.class, "aimedicinetable");
|
||||
return aimedicinetable.get(0);
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.rax.vital.util;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* project_name:remote-control-backend
|
||||
* time:2024/8/12 17:09
|
||||
*/
|
||||
public class DBNameTest {
|
||||
public static void main(String[] args) {
|
||||
String patientName = DatabaseNameUtil.encrypt("eee");
|
||||
String idNum = DatabaseNameUtil.encrypt("10");
|
||||
System.out.println("DBName = " + patientName + "_" + idNum);
|
||||
|
||||
}
|
||||
}
|
|
@ -66,6 +66,23 @@ security:
|
|||
- /hospital/getHospitalList
|
||||
# 临时白名单
|
||||
|
||||
# 阿里云短信
|
||||
ali:
|
||||
sms:
|
||||
templateCode: SMS_471660037 # 模板code
|
||||
accessKeyId: LTAI5tPrmvr4zavsjHXMozrc #阿里云AK
|
||||
accessKeySecret: R4aGC4qYaYGcl41xc9anpBPQ0gzxD3 #阿里云SK
|
||||
signName: AAceshi #阿里云签名名
|
||||
|
||||
# 使用阿里提供的smsClient类
|
||||
aliyun:
|
||||
sms:
|
||||
SMS_471660037:
|
||||
accessKeyId: LTAI5tPrmvr4zavsjHXMozrc #阿里云AK
|
||||
accessKeySecret: R4aGC4qYaYGcl41xc9anpBPQ0gzxD3 #阿里云SK
|
||||
signName: AAceshi #阿里云签名名
|
||||
templateCode: SMS_471660037 # 模板code
|
||||
|
||||
#--------------如下配置尽量不要变动-------------
|
||||
# mybatis-plus 配置
|
||||
mybatis-plus:
|
||||
|
|
Loading…
Reference in New Issue
Block a user