浇水bug修改
This commit is contained in:
@@ -15,10 +15,7 @@ import me.zhyd.oauth.request.AuthRequest;
|
||||
import me.zhyd.oauth.utils.AuthStateUtils;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.domain.model.ForgotLoginBody;
|
||||
import org.dromara.common.core.domain.model.LoginBody;
|
||||
import org.dromara.common.core.domain.model.RegisterBody;
|
||||
import org.dromara.common.core.domain.model.SocialLoginBody;
|
||||
import org.dromara.common.core.domain.model.*;
|
||||
import org.dromara.common.core.exception.user.UserException;
|
||||
import org.dromara.common.core.utils.*;
|
||||
import org.dromara.common.encrypt.annotation.ApiEncrypt;
|
||||
@@ -42,10 +39,7 @@ import org.dromara.system.service.ISysTenantService;
|
||||
import org.dromara.web.domain.vo.LoginTenantVo;
|
||||
import org.dromara.web.domain.vo.LoginVo;
|
||||
import org.dromara.web.domain.vo.TenantListVo;
|
||||
import org.dromara.web.service.ForgotPasswordService;
|
||||
import org.dromara.web.service.IAuthStrategy;
|
||||
import org.dromara.web.service.SysLoginService;
|
||||
import org.dromara.web.service.SysRegisterService;
|
||||
import org.dromara.web.service.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -79,6 +73,7 @@ public class AuthController {
|
||||
private final ISysClientService clientService;
|
||||
private final ScheduledExecutorService scheduledExecutorService;
|
||||
private final ForgotPasswordService forgotPasswordService;
|
||||
private final AccountCancellationService accountCancellationService;
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
@@ -189,6 +184,17 @@ public class AuthController {
|
||||
return R.ok("退出成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销当前账号
|
||||
*/
|
||||
@DeleteMapping("/account")
|
||||
public R<Void> cancelAccount(@Validated @RequestBody AccountCancelBody body) {
|
||||
StpUtil.checkLogin();
|
||||
accountCancellationService.cancelCurrentAccount(body.getCode());
|
||||
StpUtil.logout();
|
||||
return R.ok("注销成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dromara.web.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.captcha.generator.CodeGenerator;
|
||||
import cn.hutool.captcha.generator.MathGenerator;
|
||||
import cn.hutool.captcha.generator.RandomGenerator;
|
||||
@@ -21,11 +22,14 @@ import org.dromara.common.mail.utils.MailUtils;
|
||||
import org.dromara.common.ratelimiter.annotation.RateLimiter;
|
||||
import org.dromara.common.ratelimiter.enums.LimitType;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.common.web.core.WaveAndCircleCaptcha;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.web.config.properties.CaptchaProperties;
|
||||
import org.dromara.common.web.core.WaveAndCircleCaptcha;
|
||||
import org.dromara.sms4j.api.SmsBlend;
|
||||
import org.dromara.sms4j.api.entity.SmsResponse;
|
||||
import org.dromara.sms4j.core.factory.SmsFactory;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.service.ISysUserService;
|
||||
import org.dromara.web.domain.vo.CaptchaVo;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
@@ -52,6 +56,7 @@ public class CaptchaController {
|
||||
|
||||
private final CaptchaProperties captchaProperties;
|
||||
private final MailProperties mailProperties;
|
||||
private final ISysUserService userService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -66,20 +71,20 @@ public class CaptchaController {
|
||||
String code = RandomUtil.randomNumbers(6);
|
||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
|
||||
// if (Validator.isMobile(username)){
|
||||
// // 验证码模板id 自行处理 (查数据库或写死均可)
|
||||
// String templateId = "SMS_333877107";
|
||||
// LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
|
||||
// map.put("code", code);
|
||||
// SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
|
||||
// SmsResponse smsResponse = smsBlend.sendMessage(username, templateId, map);
|
||||
// if (!smsResponse.isSuccess()) {
|
||||
// log.error("验证码短信发送异常 => {}", smsResponse);
|
||||
// return R.fail(smsResponse.getData().toString());
|
||||
// }
|
||||
// }else {
|
||||
// emailCodeImpl(username);
|
||||
// }
|
||||
if (Validator.isMobile(username)){
|
||||
// 验证码模板id 自行处理 (查数据库或写死均可)
|
||||
String templateId = "SMS_333877107";
|
||||
LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
|
||||
map.put("code", code);
|
||||
SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
|
||||
SmsResponse smsResponse = smsBlend.sendMessage(username, templateId, map);
|
||||
if (!smsResponse.isSuccess()) {
|
||||
log.error("验证码短信发送异常 => {}", smsResponse);
|
||||
return R.fail(smsResponse.getData().toString());
|
||||
}
|
||||
}else {
|
||||
emailCodeImpl(username);
|
||||
}
|
||||
|
||||
return R.ok(code);
|
||||
}
|
||||
@@ -95,7 +100,49 @@ public class CaptchaController {
|
||||
@RateLimiter(key = "#phonenumber", time = 60, count = 1)
|
||||
@GetMapping("/resource/sms/code")
|
||||
public R<Void> smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber) {
|
||||
String key = GlobalConstants.CAPTCHA_CODE_KEY + phonenumber;
|
||||
R<Void> result = sendSmsCode(phonenumber, phonenumber);
|
||||
if (R.isError(result)) {
|
||||
return result;
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销账号验证码
|
||||
*/
|
||||
@GetMapping("/resource/account/cancel/code")
|
||||
public R<Void> accountCancelCode() {
|
||||
StpUtil.checkLogin();
|
||||
Long userId = LoginHelper.getUserId();
|
||||
String username = LoginHelper.getUsername();
|
||||
if (userId == null || StringUtils.isBlank(username)) {
|
||||
return R.fail("用户未登录");
|
||||
}
|
||||
SysUserVo user = userService.selectUserById(userId);
|
||||
if (user == null) {
|
||||
return R.fail("用户不存在");
|
||||
}
|
||||
if (Validator.isMobile(user.getPhonenumber())) {
|
||||
return sendSmsCode(user.getPhonenumber(), username);
|
||||
}
|
||||
if (StringUtils.isNotBlank(user.getEmail())) {
|
||||
if (!mailProperties.getEnabled()) {
|
||||
return R.fail("当前系统没有开启邮箱功能!");
|
||||
}
|
||||
emailCodeImpl(user.getEmail(), username);
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
return R.fail("当前账号未绑定手机号或邮箱");
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信验证码
|
||||
*
|
||||
* @param phonenumber 接收手机号
|
||||
* @param cacheKey 验证码缓存标识
|
||||
*/
|
||||
public R<Void> sendSmsCode(String phonenumber, String cacheKey) {
|
||||
String key = GlobalConstants.CAPTCHA_CODE_KEY + cacheKey;
|
||||
String code = RandomUtil.randomNumbers(6);
|
||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
// 验证码模板id 自行处理 (查数据库或写死均可)
|
||||
@@ -131,7 +178,15 @@ public class CaptchaController {
|
||||
*/
|
||||
@RateLimiter(key = "#email", time = 60, count = 1)
|
||||
public void emailCodeImpl(String email) {
|
||||
String key = GlobalConstants.CAPTCHA_CODE_KEY + email;
|
||||
emailCodeImpl(email, email);
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮箱验证码
|
||||
*/
|
||||
@RateLimiter(key = "#email", time = 60, count = 1)
|
||||
public void emailCodeImpl(String email, String cacheKey) {
|
||||
String key = GlobalConstants.CAPTCHA_CODE_KEY + cacheKey;
|
||||
String code = RandomUtil.randomNumbers(6);
|
||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
try {
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.dromara.web.service;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
import org.dromara.common.core.constant.GlobalConstants;
|
||||
@@ -67,7 +66,7 @@ public class SysRegisterService {
|
||||
}
|
||||
|
||||
SysUserBo sysUser = new SysUserBo();
|
||||
// sysUser.setUserName(username);
|
||||
sysUser.setUserName(username);
|
||||
|
||||
|
||||
sysUser.setNickName("用户"+new Date().getTime());
|
||||
@@ -76,6 +75,7 @@ public class SysRegisterService {
|
||||
boolean exist;
|
||||
if(Validator.isEmail(username)){
|
||||
sysUser.setEmail(username);
|
||||
|
||||
exist = TenantHelper.dynamic(tenantId, () -> {
|
||||
return userMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getEmail, sysUser.getEmail()));
|
||||
|
||||
@@ -58,6 +58,7 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
||||
});
|
||||
loginUser.setClientKey(client.getClientKey());
|
||||
loginUser.setDeviceType(client.getDeviceType());
|
||||
//loginUser.setUsername(phonenumber);
|
||||
SaLoginParameter model = new SaLoginParameter();
|
||||
model.setDeviceType(client.getDeviceType());
|
||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
||||
|
||||
@@ -96,13 +96,13 @@ spring:
|
||||
spring.data:
|
||||
redis:
|
||||
# 地址
|
||||
host: localhost
|
||||
host: 47.97.217.123
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
database: 0
|
||||
# redis 密码必须配置
|
||||
#password:
|
||||
password: waterx123
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
|
||||
@@ -22,9 +22,10 @@ server:
|
||||
--- # mqtt配置信息
|
||||
mqtt:
|
||||
enabled: ${MQTT_ENABLED:true}
|
||||
broker-url: ssl://service.reinkun.com:8883
|
||||
#broker-url: ssl://www.mmipco.cn:8883
|
||||
broker-url: tcp://47.97.217.123
|
||||
username: admin
|
||||
password: yukun_mqtt
|
||||
password: 61e6062129e9
|
||||
client-id: water-server-${server.port}
|
||||
qos: 1
|
||||
keep-alive: 60
|
||||
@@ -46,7 +47,7 @@ mqtt:
|
||||
command-ack:
|
||||
enabled: true
|
||||
max-retry-count: 3
|
||||
retry-interval-ms: 5000
|
||||
retry-interval-ms: 30000
|
||||
scan-interval-ms: 5000
|
||||
pending-ttl-seconds: 86400
|
||||
ack-ttl-seconds: 86400
|
||||
@@ -66,6 +67,7 @@ mqtt:
|
||||
- /+/publish/register #设备注册
|
||||
- /+/publish/power #电量
|
||||
- /+/publish/ack #应答
|
||||
- /+/publish/start #开始浇水上报
|
||||
- /+/publish/finish/key #按键浇水完成
|
||||
- /+/publish/error #硬件故障
|
||||
# - /+/subscriber/cmd #下发命令 0关闭浇水 1开始浇水
|
||||
@@ -123,9 +125,9 @@ spring:
|
||||
servlet:
|
||||
multipart:
|
||||
# 单个文件大小
|
||||
max-file-size: 10MB
|
||||
max-file-size: 100MB
|
||||
# 设置总上传的文件大小
|
||||
max-request-size: 20MB
|
||||
max-request-size: 100MB
|
||||
mvc:
|
||||
# 设置静态资源路径 防止所有请求都去查静态资源
|
||||
static-path-pattern: /static/**
|
||||
|
||||
Reference in New Issue
Block a user