Merge branch 'dev' into test
This commit is contained in:
@@ -17,6 +17,7 @@ import com.intc.common.mail.utils.MailUtils;
|
||||
import com.intc.common.ratelimiter.annotation.RateLimiter;
|
||||
import com.intc.common.ratelimiter.enums.LimitType;
|
||||
import com.intc.common.redis.utils.RedisUtils;
|
||||
import com.intc.common.sms.config.properties.SmsProperties;
|
||||
import com.intc.common.web.config.properties.CaptchaProperties;
|
||||
import com.intc.common.web.enums.CaptchaType;
|
||||
import com.intc.web.domain.vo.CaptchaVo;
|
||||
@@ -50,6 +51,7 @@ public class CaptchaController {
|
||||
|
||||
private final CaptchaProperties captchaProperties;
|
||||
private final MailProperties mailProperties;
|
||||
private final SmsProperties smsProperties;
|
||||
|
||||
/**
|
||||
* 短信验证码
|
||||
@@ -60,17 +62,45 @@ public class CaptchaController {
|
||||
@GetMapping("/resource/sms/code")
|
||||
public R<Void> smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber) {
|
||||
String key = GlobalConstants.CAPTCHA_CODE_KEY + phonenumber;
|
||||
String code = RandomUtil.randomNumbers(4);
|
||||
String code = RandomUtil.randomNumbers(6);
|
||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
// 验证码模板id 自行处理 (查数据库或写死均可)
|
||||
String templateId = "";
|
||||
// 验证码模板id 从配置文件读取
|
||||
String templateId = smsProperties.getCodeTemplateId();
|
||||
if (StringUtils.isBlank(templateId)) {
|
||||
log.error("短信验证码模板ID未配置,请在配置文件中设置 sms.plus.code-template-id");
|
||||
return R.fail("短信服务配置错误,请联系管理员");
|
||||
}
|
||||
LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
|
||||
map.put("code", code);
|
||||
SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
|
||||
SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, templateId, map);
|
||||
if (!smsResponse.isSuccess()) {
|
||||
log.error("验证码短信发送异常 => {}", smsResponse);
|
||||
return R.fail(smsResponse.getData().toString());
|
||||
// 解析错误信息
|
||||
String errorMsg = "短信发送失败";
|
||||
if (smsResponse.getData() != null) {
|
||||
String data = smsResponse.getData().toString();
|
||||
if (data.contains("SMS_TEMPLATE_ILLEGAL")) {
|
||||
errorMsg = "短信模板不存在,请联系管理员配置正确的模板ID";
|
||||
} else if (data.contains("SMS_SIGNATURE_ILLEGAL")) {
|
||||
errorMsg = "短信签名不存在,请联系管理员配置正确的签名";
|
||||
} else if (data.contains("Message")) {
|
||||
// 尝试提取Message字段
|
||||
try {
|
||||
int msgStart = data.indexOf("Message\":\"") + 10;
|
||||
int msgEnd = data.indexOf("\"", msgStart);
|
||||
if (msgStart > 10 && msgEnd > msgStart) {
|
||||
String message = data.substring(msgStart, msgEnd);
|
||||
errorMsg = "短信发送失败:" + message;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("解析短信错误信息失败", e);
|
||||
}
|
||||
} else if (data.contains("isv.")) {
|
||||
errorMsg = "短信服务配置错误,请联系管理员";
|
||||
}
|
||||
}
|
||||
return R.fail(errorMsg);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ spring:
|
||||
# username: root
|
||||
# password: root
|
||||
driverClassName: org.postgresql.Driver
|
||||
url: jdbc:postgresql://154.8.147.51:15432/fishery_dev?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
||||
url: jdbc:postgresql://81.70.89.108:15432/fishery_dev?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
||||
username: postgres
|
||||
password: intc@123987
|
||||
# 从库数据源 - TDengine
|
||||
@@ -60,7 +60,7 @@ spring:
|
||||
type: ${spring.datasource.type}
|
||||
driverClassName: com.taosdata.jdbc.rs.RestfulDriver
|
||||
# 不指定数据库名,在 SQL 中使用完整路径 fishery.table_name
|
||||
url: jdbc:TAOS-RS://154.8.147.51:6041?timezone=Shanghai&charset=UTF-8&locale=en_US.UTF-8
|
||||
url: jdbc:TAOS-RS://81.70.89.108:6041?timezone=Shanghai&charset=UTF-8&locale=en_US.UTF-8
|
||||
username: root
|
||||
password: intc@123456
|
||||
hikari:
|
||||
@@ -106,13 +106,13 @@ spring:
|
||||
spring.data:
|
||||
redis:
|
||||
# 地址
|
||||
host: 154.8.147.51
|
||||
host: 81.70.89.108
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
port: 26379
|
||||
# 数据库索引
|
||||
database: 9
|
||||
# redis 密码必须配置
|
||||
password: intc@123987
|
||||
password: bbd4b56e5d3f
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
@@ -185,7 +185,9 @@ sms:
|
||||
access-key-id: LTAI5tRnPowmTLjH181nSbsR
|
||||
# 称为accessSecret有些称之为apiSecret
|
||||
access-key-secret: Vh2LoAM1t3XuMUVy2wTWSACJ97kOUW
|
||||
signature: 【鱼测云】
|
||||
# 短信签名:需要在阿里云控制台创建并审核通过,格式如:鱼测云(不带【】符号)
|
||||
# 请在阿里云短信服务控制台 -> 国内消息 -> 签名管理 中查看您的签名
|
||||
signature: 鱼测云 # TODO: 请填写您的阿里云短信签名(不带【】符号)
|
||||
sdk-app-id: 您的sdkAppId
|
||||
config2:
|
||||
# 厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
|
||||
@@ -194,6 +196,12 @@ sms:
|
||||
access-key-secret: 您的accessKeySecret
|
||||
signature: 您的短信签名
|
||||
sdk-app-id: 您的sdkAppId
|
||||
# plus扩展配置
|
||||
plus:
|
||||
# 短信验证码模板ID(请根据实际短信服务商的模板ID配置)
|
||||
# 请在阿里云短信服务控制台获取真实的模板CODE,格式如:SMS_460655548
|
||||
# 模板内容需包含 ${code} 参数
|
||||
code-template-id: 'SMS_465720430' # TODO: 请填写您的阿里云短信模板CODE
|
||||
|
||||
|
||||
--- # 三方授权
|
||||
|
||||
@@ -187,6 +187,10 @@ sms:
|
||||
access-key-secret: 您的accessKeySecret
|
||||
signature: 您的短信签名
|
||||
sdk-app-id: 您的sdkAppId
|
||||
# plus扩展配置
|
||||
plus:
|
||||
# 短信验证码模板ID(请根据实际短信服务商的模板ID配置)
|
||||
code-template-id: SMS_123456789
|
||||
|
||||
--- # 三方授权
|
||||
justauth:
|
||||
|
||||
@@ -171,7 +171,7 @@ mybatis-encryptor:
|
||||
# api接口加密
|
||||
api-decrypt:
|
||||
# 是否开启全局接口加密
|
||||
enabled: true
|
||||
enabled: false
|
||||
# AES 加密头标识
|
||||
headerFlag: encrypt-key
|
||||
# 响应加密公钥 非对称算法的公私钥 如:SM2,RSA 使用者请自行更换
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.intc.common.sms.config;
|
||||
|
||||
import com.intc.common.sms.config.properties.SmsProperties;
|
||||
import com.intc.common.sms.core.dao.PlusSmsDao;
|
||||
import com.intc.common.sms.handler.SmsExceptionHandler;
|
||||
import org.dromara.sms4j.api.dao.SmsDao;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
@@ -14,6 +16,7 @@ import org.springframework.context.annotation.Primary;
|
||||
* @author Feng
|
||||
*/
|
||||
@AutoConfiguration(after = {RedisAutoConfiguration.class})
|
||||
@EnableConfigurationProperties(SmsProperties.class)
|
||||
public class SmsAutoConfiguration {
|
||||
|
||||
@Primary
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.intc.common.sms.config.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* 短信配置属性
|
||||
*
|
||||
* @author Qoder
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "sms.plus")
|
||||
public class SmsProperties {
|
||||
|
||||
/**
|
||||
* 短信验证码模板ID
|
||||
*/
|
||||
private String codeTemplateId;
|
||||
|
||||
}
|
||||
@@ -102,6 +102,10 @@
|
||||
<groupId>com.intc</groupId>
|
||||
<artifactId>intc-common-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.intc</groupId>
|
||||
<artifactId>intc-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class FishController extends BaseController {
|
||||
/**
|
||||
* 查询鱼类管理列表
|
||||
*/
|
||||
@SaCheckPermission("fishery:fish:list")
|
||||
// @SaCheckPermission("fishery:fish:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<FishVo> list(FishBo bo, PageQuery pageQuery) {
|
||||
return fishService.queryPageList(bo, pageQuery);
|
||||
|
||||
@@ -21,6 +21,12 @@ import com.intc.fishery.domain.vo.PondVo;
|
||||
import com.intc.fishery.domain.bo.PondBo;
|
||||
import com.intc.fishery.service.IPondService;
|
||||
import com.intc.common.mybatis.core.page.TableDataInfo;
|
||||
import com.intc.common.satoken.utils.LoginHelper;
|
||||
import com.intc.fishery.service.IAquUserService;
|
||||
import com.intc.fishery.domain.vo.AquUserVo;
|
||||
import com.intc.fishery.domain.bo.AquUserBo;
|
||||
import com.intc.system.service.ISysUserService;
|
||||
import com.intc.system.domain.vo.SysUserVo;
|
||||
|
||||
/**
|
||||
* 塘口管理
|
||||
@@ -35,11 +41,13 @@ import com.intc.common.mybatis.core.page.TableDataInfo;
|
||||
public class PondController extends BaseController {
|
||||
|
||||
private final IPondService pondService;
|
||||
private final IAquUserService aquUserService;
|
||||
private final ISysUserService sysUserService;
|
||||
|
||||
/**
|
||||
* 查询塘口管理列表
|
||||
*/
|
||||
@SaCheckPermission("fishery:pond:list")
|
||||
// @SaCheckPermission("fishery:pond:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<PondVo> list(PondBo bo, PageQuery pageQuery) {
|
||||
return pondService.queryPageList(bo, pageQuery);
|
||||
@@ -71,11 +79,41 @@ public class PondController extends BaseController {
|
||||
/**
|
||||
* 新增塘口管理
|
||||
*/
|
||||
@SaCheckPermission("fishery:pond:add")
|
||||
// @SaCheckPermission("fishery:pond:add")
|
||||
@Log(title = "塘口管理", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody PondBo bo) {
|
||||
Long currentUserId = LoginHelper.getUserId();
|
||||
|
||||
// 如果userId为空,使用当前登录用户ID
|
||||
if (bo.getUserId() == null) {
|
||||
bo.setUserId(currentUserId);
|
||||
}
|
||||
|
||||
// 确保养殖用户存在,不存在则自动创建
|
||||
AquUserVo aquUser = aquUserService.queryById(bo.getUserId());
|
||||
if (aquUser == null) {
|
||||
// 获取系统用户信息
|
||||
SysUserVo sysUser = sysUserService.selectUserById(bo.getUserId());
|
||||
if (sysUser != null) {
|
||||
// 创建养殖用户记录
|
||||
AquUserBo aquUserBo = new AquUserBo();
|
||||
aquUserBo.setId(bo.getUserId());
|
||||
aquUserBo.setIsManager(0L);
|
||||
aquUserBo.setUserName(sysUser.getUserName());
|
||||
aquUserBo.setMobilePhone(sysUser.getPhonenumber() != null ? sysUser.getPhonenumber() : "未设置");
|
||||
aquUserBo.setWarnPhoneJson("[]"); // 默认空数组
|
||||
aquUserBo.setRemark("系统自动创建");
|
||||
aquUserService.insertByBo(aquUserBo);
|
||||
}
|
||||
}
|
||||
|
||||
// 默认关闭夜间防误关功能
|
||||
if (bo.getKeepNightOpen() == null) {
|
||||
bo.setKeepNightOpen(0);
|
||||
}
|
||||
|
||||
return toAjax(pondService.insertByBo(bo));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ public class PondBo extends BaseEntity {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
* 用户id(新增时由后端自动填充当前登录用户,前端无需传递)
|
||||
*/
|
||||
@NotNull(message = "用户id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
// @NotNull(message = "用户id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
@@ -63,9 +63,9 @@ public class PondBo extends BaseEntity {
|
||||
private Date placeTime;
|
||||
|
||||
/**
|
||||
* 夜间防止误关
|
||||
* 夜间防止误关(0-关闭 1-开启,默认关闭)
|
||||
*/
|
||||
@NotNull(message = "夜间防止误关不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
// @NotNull(message = "夜间防止误关不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Integer keepNightOpen;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user