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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.rax.common.core.util.R;
|
import com.rax.common.core.util.R;
|
||||||
import com.rax.common.security.service.RaxUser;
|
import com.rax.common.security.service.RaxUser;
|
||||||
|
import com.rax.common.security.util.SecurityUtils;
|
||||||
import com.rax.dailyplan.dto.DailyPlanDTO;
|
import com.rax.dailyplan.dto.DailyPlanDTO;
|
||||||
import com.rax.dailyplan.entity.DailyPlan;
|
import com.rax.dailyplan.entity.DailyPlan;
|
||||||
import com.rax.dailyplan.mapper.DailyPlanMapper;
|
import com.rax.dailyplan.mapper.DailyPlanMapper;
|
||||||
|
|
|
@ -1,93 +1,93 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
<artifactId>upms</artifactId>
|
<artifactId>upms</artifactId>
|
||||||
<version>3.7.3</version>
|
<version>3.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>upms-biz</artifactId>
|
<artifactId>upms-biz</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>通用用户权限管理系统业务处理模块</description>
|
<description>通用用户权限管理系统业务处理模块</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!--upms api、model 模块-->
|
<!--upms api、model 模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
<artifactId>auth</artifactId>
|
<artifactId>auth</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 引入quartz依赖 -->
|
<!-- 引入quartz依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
<artifactId>quartz</artifactId>
|
<artifactId>quartz</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--upms api、model 模块-->
|
<!--upms api、model 模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
<artifactId>upms-api</artifactId>
|
<artifactId>upms-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--文件管理-->
|
<!--文件管理-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
<artifactId>common-oss</artifactId>
|
<artifactId>common-oss</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--feign 调用-->
|
<!--feign 调用-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
<artifactId>common-feign</artifactId>
|
<artifactId>common-feign</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--安全模块-->
|
<!--安全模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
<artifactId>common-security</artifactId>
|
<artifactId>common-security</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--日志处理-->
|
<!--日志处理-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
<artifactId>common-log</artifactId>
|
<artifactId>common-log</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
<artifactId>daily-plan</artifactId>
|
<artifactId>daily-plan</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 接口文档UI -->
|
<!-- 接口文档UI -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--接口文档-->
|
<!--接口文档-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
<artifactId>common-swagger</artifactId>
|
<artifactId>common-swagger</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- orm 模块-->
|
<!-- orm 模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysql</groupId>
|
<groupId>com.mysql</groupId>
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 阿里云短信下发 -->
|
<!-- 阿里云短信下发 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springboot.sms</groupId>
|
<groupId>io.springboot.sms</groupId>
|
||||||
<artifactId>aliyun-sms-spring-boot-starter</artifactId>
|
<artifactId>aliyun-sms-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--xss 过滤-->
|
<!--xss 过滤-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
<artifactId>common-xss</artifactId>
|
<artifactId>common-xss</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--undertow容器-->
|
<!--undertow容器-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||||
|
@ -105,44 +105,54 @@
|
||||||
<artifactId>druid-spring-boot-starter</artifactId>
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
<version>1.2.21</version>
|
<version>1.2.21</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- 加密模块-->
|
||||||
<!-- 加密模块-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bouncycastle</groupId>
|
<groupId>org.bouncycastle</groupId>
|
||||||
<artifactId>bcprov-jdk15on</artifactId>
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
<version>1.68</version>
|
<version>1.68</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<!-- 阿里云短信-->
|
||||||
|
<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>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>io.fabric8</groupId>
|
<groupId>io.fabric8</groupId>
|
||||||
<artifactId>docker-maven-plugin</artifactId>
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/*.xlsx</exclude>
|
<exclude>**/*.xlsx</exclude>
|
||||||
<exclude>**/*.xls</exclude>
|
<exclude>**/*.xls</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</resource>
|
</resource>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<filtering>false</filtering>
|
<filtering>false</filtering>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*.xlsx</include>
|
<include>**/*.xlsx</include>
|
||||||
<include>**/*.xls</include>
|
<include>**/*.xls</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -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
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean saveLog(SysLog sysLog) {
|
public Boolean saveLog(SysLog sysLog) {
|
||||||
|
System.out.println("sysLog = " + sysLog);
|
||||||
SysUser sysUser = userService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, sysLog.getCreateBy()));
|
SysUser sysUser = userService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, sysLog.getCreateBy()));
|
||||||
sysLog.setHospitalId(sysUser.getHospitalId());
|
sysLog.setHospitalId(sysUser.getHospitalId());
|
||||||
baseMapper.insert(sysLog);
|
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.exception.ErrorCodes;
|
||||||
import com.rax.common.core.util.MsgUtils;
|
import com.rax.common.core.util.MsgUtils;
|
||||||
import com.rax.common.core.util.R;
|
import com.rax.common.core.util.R;
|
||||||
|
import io.springboot.sms.core.SmsClient;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -34,6 +36,9 @@ public class SysMobileServiceImpl implements SysMobileService {
|
||||||
|
|
||||||
private final SysUserMapper userMapper;
|
private final SysUserMapper userMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SmsClient smsClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送手机验证码 TODO: 调用短信网关发送验证码,测试返回前端
|
* 发送手机验证码 TODO: 调用短信网关发送验证码,测试返回前端
|
||||||
* @param mobile mobile
|
* @param mobile mobile
|
||||||
|
@ -58,6 +63,7 @@ public class SysMobileServiceImpl implements SysMobileService {
|
||||||
|
|
||||||
String code = RandomUtil.randomNumbers(Integer.parseInt(SecurityConstants.CODE_SIZE));
|
String code = RandomUtil.randomNumbers(Integer.parseInt(SecurityConstants.CODE_SIZE));
|
||||||
log.debug("手机号生成验证码成功:{},{}", mobile, code);
|
log.debug("手机号生成验证码成功:{},{}", mobile, code);
|
||||||
|
smsClient.sendCode(code, mobile);
|
||||||
redisTemplate.opsForValue()
|
redisTemplate.opsForValue()
|
||||||
.set(CacheConstants.DEFAULT_CODE_KEY + mobile, code, SecurityConstants.CODE_TIME, TimeUnit.SECONDS);
|
.set(CacheConstants.DEFAULT_CODE_KEY + mobile, code, SecurityConstants.CODE_TIME, TimeUnit.SECONDS);
|
||||||
return R.ok(Boolean.TRUE, code);
|
return R.ok(Boolean.TRUE, code);
|
||||||
|
|
|
@ -197,7 +197,7 @@ public class AIMedicineServiceImpl implements AIMedicineService {
|
||||||
@Override
|
@Override
|
||||||
public Map getAiMedicine(MongoTemplate template) {
|
public Map getAiMedicine(MongoTemplate template) {
|
||||||
Query query = new Query();
|
Query query = new Query();
|
||||||
query.limit(2);
|
query.limit(1);
|
||||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
query.with(Sort.by(Sort.Order.desc("Time")));
|
||||||
List<Map> aimedicinetable = template.find(query, Map.class, "aimedicinetable");
|
List<Map> aimedicinetable = template.find(query, Map.class, "aimedicinetable");
|
||||||
return aimedicinetable.get(0);
|
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
|
- /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 配置
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user