mirror of
https://gitee.com/republicline/rax-remote-v2.git
synced 2025-08-24 04:04:57 +08:00
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;
|
||||
|
|
|
@ -1,93 +1,93 @@
|
|||
<?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"
|
||||
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>
|
||||
<parent>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>upms</artifactId>
|
||||
<version>3.7.3</version>
|
||||
</parent>
|
||||
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>
|
||||
<parent>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>upms</artifactId>
|
||||
<version>3.7.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>upms-biz</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>upms-biz</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>通用用户权限管理系统业务处理模块</description>
|
||||
<description>通用用户权限管理系统业务处理模块</description>
|
||||
|
||||
<dependencies>
|
||||
<!--upms api、model 模块-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>auth</artifactId>
|
||||
</dependency>
|
||||
<!-- 引入quartz依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
</dependency>
|
||||
<!--upms api、model 模块-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>upms-api</artifactId>
|
||||
</dependency>
|
||||
<!--文件管理-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
</dependency>
|
||||
<!--feign 调用-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>common-feign</artifactId>
|
||||
</dependency>
|
||||
<!--安全模块-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>common-security</artifactId>
|
||||
</dependency>
|
||||
<!--日志处理-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>common-log</artifactId>
|
||||
</dependency>
|
||||
<dependencies>
|
||||
<!--upms api、model 模块-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>auth</artifactId>
|
||||
</dependency>
|
||||
<!-- 引入quartz依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
</dependency>
|
||||
<!--upms api、model 模块-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>upms-api</artifactId>
|
||||
</dependency>
|
||||
<!--文件管理-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
</dependency>
|
||||
<!--feign 调用-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>common-feign</artifactId>
|
||||
</dependency>
|
||||
<!--安全模块-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>common-security</artifactId>
|
||||
</dependency>
|
||||
<!--日志处理-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>common-log</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>daily-plan</artifactId>
|
||||
</dependency>
|
||||
<!-- 接口文档UI -->
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
</dependency>
|
||||
<!--接口文档-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>common-swagger</artifactId>
|
||||
</dependency>
|
||||
<!-- orm 模块-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
<!-- 阿里云短信下发 -->
|
||||
<dependency>
|
||||
<groupId>io.springboot.sms</groupId>
|
||||
<artifactId>aliyun-sms-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!--xss 过滤-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>common-xss</artifactId>
|
||||
</dependency>
|
||||
<!--undertow容器-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||
</dependency>
|
||||
<!-- 接口文档UI -->
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
</dependency>
|
||||
<!--接口文档-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>common-swagger</artifactId>
|
||||
</dependency>
|
||||
<!-- orm 模块-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
<!-- 阿里云短信下发 -->
|
||||
<dependency>
|
||||
<groupId>io.springboot.sms</groupId>
|
||||
<artifactId>aliyun-sms-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!--xss 过滤-->
|
||||
<dependency>
|
||||
<groupId>com.rax</groupId>
|
||||
<artifactId>common-xss</artifactId>
|
||||
</dependency>
|
||||
<!--undertow容器-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
|
@ -105,44 +105,54 @@
|
|||
<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>
|
||||
</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>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>**/*.xlsx</exclude>
|
||||
<exclude>**/*.xls</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
<includes>
|
||||
<include>**/*.xlsx</include>
|
||||
<include>**/*.xls</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>**/*.xlsx</exclude>
|
||||
<exclude>**/*.xls</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
<includes>
|
||||
<include>**/*.xlsx</include>
|
||||
<include>**/*.xls</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</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
|
||||
@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