Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
4e608b8f3a | |||
3c2d97aaf2 | |||
6ed1241a6d | |||
1cf7c47ef9 | |||
bdee8c8383 | |||
6f4e18fb3f | |||
3ca6b69709 | |||
e13e3c57a6 | |||
56704f6014 | |||
4f00c69f91 | |||
fcd17634dc | |||
24f0caacd5 | |||
c73a700210 | |||
3ed2f97752 |
@ -4,14 +4,13 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fuyuanshen.app.model.AppSmsLoginBody;
|
||||
import com.fuyuanshen.app.service.AppLoginService;
|
||||
import com.fuyuanshen.common.core.constant.SystemConstants;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.domain.model.RegisterBody;
|
||||
import com.fuyuanshen.common.core.domain.model.SmsLoginBody;
|
||||
import com.fuyuanshen.common.core.domain.model.AppLoginBody;
|
||||
import com.fuyuanshen.common.core.domain.model.AppSmsRegisterBody;
|
||||
import com.fuyuanshen.common.core.domain.model.PasswordLoginBody;
|
||||
import com.fuyuanshen.common.core.utils.*;
|
||||
import com.fuyuanshen.common.encrypt.annotation.ApiEncrypt;
|
||||
import com.fuyuanshen.common.json.utils.JsonUtils;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.common.tenant.helper.TenantHelper;
|
||||
@ -24,8 +23,8 @@ import com.fuyuanshen.system.service.ISysTenantService;
|
||||
import com.fuyuanshen.web.domain.vo.LoginTenantVo;
|
||||
import com.fuyuanshen.web.domain.vo.LoginVo;
|
||||
import com.fuyuanshen.web.domain.vo.TenantListVo;
|
||||
import com.fuyuanshen.web.service.AppRegisterService;
|
||||
import com.fuyuanshen.web.service.IAuthStrategy;
|
||||
import com.fuyuanshen.web.service.SysRegisterService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -51,7 +50,7 @@ import java.util.List;
|
||||
public class AppAuthController {
|
||||
|
||||
private final AppLoginService loginService;
|
||||
private final SysRegisterService registerService;
|
||||
private final AppRegisterService registerService;
|
||||
private final ISysConfigService configService;
|
||||
private final ISysTenantService tenantService;
|
||||
private final ISysClientService clientService;
|
||||
@ -64,15 +63,15 @@ public class AppAuthController {
|
||||
*/
|
||||
// @ApiEncrypt
|
||||
@PostMapping("/login")
|
||||
public R<LoginVo> login(@RequestBody AppSmsLoginBody appSmsLoginBody) {
|
||||
public R<LoginVo> login(@RequestBody AppLoginBody appLoginBody) {
|
||||
// SmsLoginBody loginBody = JsonUtils.parseObject(body, SmsLoginBody.class);
|
||||
ValidatorUtils.validate(appSmsLoginBody);
|
||||
SmsLoginBody loginBody = new SmsLoginBody();
|
||||
loginBody.setPhonenumber(appSmsLoginBody.getPhonenumber());
|
||||
loginBody.setSmsCode(appSmsLoginBody.getSmsCode());
|
||||
loginBody.setTenantId(appSmsLoginBody.getTenantId());
|
||||
loginBody.setClientId("ca839698e245d60aa2f0e59bd52b34f8");
|
||||
loginBody.setGrantType("appSms");
|
||||
ValidatorUtils.validate(appLoginBody);
|
||||
PasswordLoginBody loginBody = new PasswordLoginBody();
|
||||
loginBody.setUsername(appLoginBody.getUserName());
|
||||
loginBody.setPassword(appLoginBody.getPassword());
|
||||
loginBody.setTenantId(appLoginBody.getTenantId());
|
||||
loginBody.setClientId("835b15335d389c9fcfdf99421fa8019b");
|
||||
loginBody.setGrantType("appPassword");
|
||||
// 授权类型和客户端id
|
||||
String clientId = loginBody.getClientId();
|
||||
String grantType = loginBody.getGrantType();
|
||||
@ -107,12 +106,8 @@ public class AppAuthController {
|
||||
/**
|
||||
* 用户注册
|
||||
*/
|
||||
@ApiEncrypt
|
||||
@PostMapping("/register")
|
||||
public R<Void> register(@Validated @RequestBody RegisterBody user) {
|
||||
if (!configService.selectRegisterEnabled(user.getTenantId())) {
|
||||
return R.fail("当前系统没有开启注册功能!");
|
||||
}
|
||||
public R<Void> register(@Validated @RequestBody AppSmsRegisterBody user) {
|
||||
registerService.register(user);
|
||||
return R.ok();
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
package com.fuyuanshen.app.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.fuyuanshen.app.domain.dto.APPForgotPasswordDTO;
|
||||
import com.fuyuanshen.app.domain.dto.APPForgotPasswordSmsDTO;
|
||||
import com.fuyuanshen.app.domain.dto.APPUpdateUserDTO;
|
||||
import com.fuyuanshen.app.domain.vo.APPUserInfoVo;
|
||||
import com.fuyuanshen.app.service.IAppUserService;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* APP 用户管理
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/app/user")
|
||||
public class AppUserController extends BaseController {
|
||||
|
||||
private final IAppUserService appUserService;
|
||||
|
||||
/**
|
||||
* 个人中心
|
||||
*/
|
||||
@GetMapping("/getUserInfo")
|
||||
public R<APPUserInfoVo> getUserInfo() {
|
||||
return R.ok(appUserService.getUserInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改个人信息
|
||||
*/
|
||||
@PostMapping("/updateUser")
|
||||
public R<Void> updateUser(@Validated @ModelAttribute APPUpdateUserDTO bo) {
|
||||
return toAjax(appUserService.updateUser(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 忘记密码
|
||||
*/
|
||||
@SaIgnore
|
||||
@PostMapping("/forgotPassword")
|
||||
public R<Void> forgotPassword(@RequestBody APPForgotPasswordDTO bo) {
|
||||
return toAjax(appUserService.forgotPassword(bo));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 发送忘记密码短信
|
||||
*/
|
||||
@SaIgnore
|
||||
@PostMapping("/sendForgotPasswordSms")
|
||||
public R<Void> sendForgotPasswordSms(@Validated @RequestBody APPForgotPasswordSmsDTO dto) throws Exception {
|
||||
return toAjax(appUserService.sendForgotPasswordSms(dto));
|
||||
}
|
||||
}
|
@ -2,14 +2,11 @@ package com.fuyuanshen.app.service;
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fuyuanshen.app.domain.vo.AppRoleVo;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.common.core.constant.Constants;
|
||||
import com.fuyuanshen.common.core.constant.SystemConstants;
|
||||
import com.fuyuanshen.common.core.constant.TenantConstants;
|
||||
import com.fuyuanshen.common.core.domain.dto.RoleDTO;
|
||||
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
|
||||
import com.fuyuanshen.common.core.enums.LoginType;
|
||||
import com.fuyuanshen.common.core.exception.user.UserException;
|
||||
@ -31,7 +28,10 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,129 @@
|
||||
package com.fuyuanshen.web.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.fuyuanshen.app.domain.AppUser;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.mapper.AppUserMapper;
|
||||
import com.fuyuanshen.common.core.constant.Constants;
|
||||
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||
import com.fuyuanshen.common.core.domain.model.AppSmsRegisterBody;
|
||||
import com.fuyuanshen.common.core.exception.BadRequestException;
|
||||
import com.fuyuanshen.common.core.exception.user.CaptchaException;
|
||||
import com.fuyuanshen.common.core.exception.user.CaptchaExpireException;
|
||||
import com.fuyuanshen.common.core.exception.user.UserException;
|
||||
import com.fuyuanshen.common.core.utils.MessageUtils;
|
||||
import com.fuyuanshen.common.core.utils.ServletUtils;
|
||||
import com.fuyuanshen.common.core.utils.SpringUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.log.event.LogininforEvent;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.common.tenant.helper.TenantHelper;
|
||||
import com.fuyuanshen.common.web.config.properties.CaptchaProperties;
|
||||
import com.fuyuanshen.system.mapper.SysUserMapper;
|
||||
import com.fuyuanshen.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 注册校验方法
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class AppRegisterService {
|
||||
|
||||
private final ISysUserService userService;
|
||||
private final SysUserMapper userMapper;
|
||||
private final CaptchaProperties captchaProperties;
|
||||
private final AppUserMapper appUserMapper;
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public void register(AppSmsRegisterBody registerBody) {
|
||||
String phoneNumber = registerBody.getPhoneNumber();
|
||||
LambdaQueryWrapper<AppUser> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(AppUser::getPhonenumber, phoneNumber);
|
||||
AppUserVo appUserVo = appUserMapper.selectVoOne(wrapper);
|
||||
if (appUserVo != null) {
|
||||
throw new BadRequestException("该手机号已被注册");
|
||||
}
|
||||
String verificationCode = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + phoneNumber);
|
||||
if (verificationCode == null) {
|
||||
throw new BadRequestException("验证码已过期");
|
||||
}
|
||||
if(!registerBody.getVerificationCode().equals(verificationCode)){
|
||||
throw new BadRequestException("验证码错误");
|
||||
}
|
||||
String tenantId = registerBody.getTenantId();
|
||||
String username = registerBody.getPhoneNumber();
|
||||
String password = registerBody.getPassword();
|
||||
|
||||
AppUser appUser = new AppUser();
|
||||
appUser.setUserName(username);
|
||||
appUser.setNickName(username);
|
||||
appUser.setPhonenumber(phoneNumber);
|
||||
appUser.setPassword(password);
|
||||
appUser.setUserType("app_user");
|
||||
appUser.setTenantId(tenantId);
|
||||
appUser.setLoginIp(ServletUtils.getClientIP());
|
||||
appUser.setStatus("0");
|
||||
appUser.setDelFlag("0");
|
||||
appUser.setCreateTime(new Date());
|
||||
|
||||
|
||||
boolean exist = TenantHelper.dynamic(tenantId, () -> {
|
||||
return appUserMapper.exists(new LambdaQueryWrapper<AppUser>()
|
||||
.eq(AppUser::getUserName, appUser.getUserName()));
|
||||
});
|
||||
if (exist) {
|
||||
throw new UserException("user.register.save.error", username);
|
||||
}
|
||||
appUserMapper.insert(appUser);
|
||||
recordLogininfor(tenantId, username, Constants.REGISTER, MessageUtils.message("user.register.success"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param code 验证码
|
||||
* @param uuid 唯一标识
|
||||
*/
|
||||
public void validateCaptcha(String tenantId, String username, String code, String uuid) {
|
||||
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.blankToDefault(uuid, "");
|
||||
String captcha = RedisUtils.getCacheObject(verifyKey);
|
||||
RedisUtils.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha)) {
|
||||
recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"));
|
||||
throw new CaptchaException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param username 用户名
|
||||
* @param status 状态
|
||||
* @param message 消息内容
|
||||
* @return
|
||||
*/
|
||||
private void recordLogininfor(String tenantId, String username, String status, String message) {
|
||||
LogininforEvent logininforEvent = new LogininforEvent();
|
||||
logininforEvent.setTenantId(tenantId);
|
||||
logininforEvent.setUsername(username);
|
||||
logininforEvent.setStatus(status);
|
||||
logininforEvent.setMessage(message);
|
||||
logininforEvent.setRequest(ServletUtils.getRequest());
|
||||
SpringUtils.context().publishEvent(logininforEvent);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package com.fuyuanshen.web.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.fuyuanshen.app.domain.AppUser;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.mapper.AppUserMapper;
|
||||
import com.fuyuanshen.app.service.AppLoginService;
|
||||
import com.fuyuanshen.common.core.constant.Constants;
|
||||
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||
import com.fuyuanshen.common.core.constant.SystemConstants;
|
||||
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
|
||||
import com.fuyuanshen.common.core.domain.model.PasswordLoginBody;
|
||||
import com.fuyuanshen.common.core.enums.LoginType;
|
||||
import com.fuyuanshen.common.core.exception.user.CaptchaException;
|
||||
import com.fuyuanshen.common.core.exception.user.CaptchaExpireException;
|
||||
import com.fuyuanshen.common.core.exception.user.UserException;
|
||||
import com.fuyuanshen.common.core.utils.MessageUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.core.utils.ValidatorUtils;
|
||||
import com.fuyuanshen.common.json.utils.JsonUtils;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.common.tenant.helper.TenantHelper;
|
||||
import com.fuyuanshen.common.web.config.properties.CaptchaProperties;
|
||||
import com.fuyuanshen.system.domain.vo.SysClientVo;
|
||||
import com.fuyuanshen.web.domain.vo.LoginVo;
|
||||
import com.fuyuanshen.web.service.IAuthStrategy;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 密码认证策略
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
*/
|
||||
@Slf4j
|
||||
@Service("appPassword" + IAuthStrategy.BASE_NAME)
|
||||
@RequiredArgsConstructor
|
||||
public class AppPasswordAuthStrategy implements IAuthStrategy {
|
||||
|
||||
private final CaptchaProperties captchaProperties;
|
||||
private final AppLoginService loginService;
|
||||
private final AppUserMapper appUserMapper;
|
||||
@Override
|
||||
public LoginVo login(String body, SysClientVo client) {
|
||||
PasswordLoginBody loginBody = JsonUtils.parseObject(body, PasswordLoginBody.class);
|
||||
ValidatorUtils.validate(loginBody);
|
||||
String tenantId = loginBody.getTenantId();
|
||||
String username = loginBody.getUsername();
|
||||
String password = loginBody.getPassword();
|
||||
String code = loginBody.getCode();
|
||||
String uuid = loginBody.getUuid();
|
||||
|
||||
// boolean captchaEnabled = captchaProperties.getEnable();
|
||||
// // 验证码开关
|
||||
// if (captchaEnabled) {
|
||||
// validateCaptcha(tenantId, username, code, uuid);
|
||||
// }
|
||||
AppLoginUser loginUser = TenantHelper.dynamic(tenantId, () -> {
|
||||
AppUserVo user = loadUserByUsername(username);
|
||||
loginService.checkLogin(LoginType.PASSWORD, tenantId, username, () -> !password.equals(user.getPassword()));
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser
|
||||
return loginService.buildLoginUser(user);
|
||||
});
|
||||
loginUser.setClientKey(client.getClientKey());
|
||||
loginUser.setDeviceType(client.getDeviceType());
|
||||
SaLoginParameter model = new SaLoginParameter();
|
||||
model.setDeviceType(client.getDeviceType());
|
||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
||||
// 例如: 后台用户30分钟过期 app用户1天过期
|
||||
model.setTimeout(client.getTimeout());
|
||||
model.setActiveTimeout(client.getActiveTimeout());
|
||||
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
|
||||
// 生成token
|
||||
AppLoginHelper.login(loginUser, model);
|
||||
|
||||
LoginVo loginVo = new LoginVo();
|
||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
||||
loginVo.setClientId(client.getClientId());
|
||||
return loginVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param code 验证码
|
||||
* @param uuid 唯一标识
|
||||
*/
|
||||
private void validateCaptcha(String tenantId, String username, String code, String uuid) {
|
||||
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.blankToDefault(uuid, "");
|
||||
String captcha = RedisUtils.getCacheObject(verifyKey);
|
||||
RedisUtils.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
loginService.recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha)) {
|
||||
loginService.recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"));
|
||||
throw new CaptchaException();
|
||||
}
|
||||
}
|
||||
|
||||
private AppUserVo loadUserByUsername(String username) {
|
||||
AppUserVo user = appUserMapper.selectVoOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getUserName, username));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new UserException("user.not.exists", username);
|
||||
} else if (SystemConstants.DISABLE.equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", username);
|
||||
throw new UserException("user.blocked", username);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
@ -49,9 +49,9 @@ spring:
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||
url: jdbc:mysql://47.120.79.150:3306/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
url: jdbc:mysql://120.79.224.186:3366/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: Jq_123456#
|
||||
password: 1fys@QWER..
|
||||
# # 从库数据源
|
||||
# slave:
|
||||
# lazy: true
|
||||
@ -98,13 +98,13 @@ spring:
|
||||
spring.data:
|
||||
redis:
|
||||
# 地址
|
||||
host: 47.120.79.150
|
||||
host: 120.79.224.186
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
port: 26379
|
||||
# 数据库索引
|
||||
database: 2
|
||||
# redis 密码必须配置
|
||||
password: xhYc_djkl382^#780!
|
||||
password: 1fys@QWER..
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
@ -300,8 +300,8 @@ file:
|
||||
# MQTT配置
|
||||
mqtt:
|
||||
username: admin
|
||||
password: #YtvpSfCNG
|
||||
url: tcp://47.120.79.150:2883
|
||||
password: fys123456
|
||||
url: tcp://47.107.152.87:1883
|
||||
subClientId: fys_subClient
|
||||
subTopic: worker/alert/#,worker/location/#
|
||||
pubTopic: worker/location
|
||||
|
@ -4,7 +4,7 @@ spring.servlet.multipart.location: /fys/server/temp
|
||||
--- # 监控中心配置
|
||||
spring.boot.admin.client:
|
||||
# 增加客户端开关
|
||||
enabled: true
|
||||
enabled: false
|
||||
url: http://localhost:9090/admin
|
||||
instance:
|
||||
service-host-type: IP
|
||||
@ -16,7 +16,7 @@ spring.boot.admin.client:
|
||||
|
||||
--- # snail-job 配置
|
||||
snail-job:
|
||||
enabled: true
|
||||
enabled: false
|
||||
# 需要在 SnailJob 后台组管理创建对应名称的组,然后创建任务的时候选择对应的组,才能正确分派任务
|
||||
group: "fys_group"
|
||||
# SnailJob 接入验证令牌 详见 script/sql/ry_job.sql `sj_group_config`表
|
||||
|
@ -1,7 +1,7 @@
|
||||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为8080
|
||||
port: 8000
|
||||
port: 8001
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
|
@ -17,6 +17,11 @@ public interface GlobalConstants {
|
||||
*/
|
||||
String CAPTCHA_CODE_KEY = GLOBAL_REDIS_KEY + "captcha_codes:";
|
||||
|
||||
/**
|
||||
* 验证码 redis key
|
||||
*/
|
||||
String APP_FORGOT_PASSWORD_SMS_KEY = GLOBAL_REDIS_KEY + "app_sms_forgotPassword:";
|
||||
|
||||
/**
|
||||
* 防重提交 redis key
|
||||
*/
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.fuyuanshen.common.core.domain.model;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AppLoginBody {
|
||||
|
||||
/**
|
||||
* 手机号不能为空
|
||||
*/
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 密码不能为空
|
||||
*/
|
||||
@NotBlank(message = "密码不能为空")
|
||||
private String password;
|
||||
|
||||
private String tenantId;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.fuyuanshen.common.core.domain.model;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AppSmsRegisterBody {
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
private String phoneNumber;
|
||||
|
||||
@NotBlank(message = "密码不能为空")
|
||||
private String password;
|
||||
|
||||
@NotBlank(message = "验证码不能为空")
|
||||
private String verificationCode;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
@ -18,14 +18,14 @@ public class PasswordLoginBody extends LoginBody {
|
||||
* 用户名
|
||||
*/
|
||||
@NotBlank(message = "{user.username.not.blank}")
|
||||
@Length(min = 2, max = 30, message = "{user.username.length.valid}")
|
||||
// @Length(min = 2, max = 30, message = "{user.username.length.valid}")
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
@NotBlank(message = "{user.password.not.blank}")
|
||||
@Length(min = 5, max = 30, message = "{user.password.length.valid}")
|
||||
// @Length(min = 5, max = 30, message = "{user.password.length.valid}")
|
||||
private String password;
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
package com.fuyuanshen.app.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* APP用户信息对象 app_user
|
||||
@ -95,5 +96,9 @@ public class AppUser extends TenantEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 地区
|
||||
*/
|
||||
private String region;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.fuyuanshen.app.domain.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class APPForgotPasswordDTO {
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
private String phoneNumber;
|
||||
|
||||
|
||||
@NotBlank(message = "密码不能为空")
|
||||
private String password;
|
||||
|
||||
@NotBlank(message = "验证码不能为空")
|
||||
private String verificationCode;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.fuyuanshen.app.domain.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class APPForgotPasswordSmsDTO {
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
private String phoneNumber;
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package com.fuyuanshen.app.domain.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.fuyuanshen.app.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @author: 默苍璃
|
||||
* @date: 2025-06-1818:36
|
||||
*/
|
||||
@Data
|
||||
public class APPUpdateUserDTO {
|
||||
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 用户地区
|
||||
*/
|
||||
private String region;
|
||||
|
||||
/**
|
||||
* 用户性别
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private MultipartFile file;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.fuyuanshen.app.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class APPUserInfoVo {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
private String avatarPath;
|
||||
|
||||
/**
|
||||
* 地区
|
||||
*/
|
||||
private String region;
|
||||
|
||||
}
|
@ -23,4 +23,8 @@ public class AppFileVo {
|
||||
* 文件url
|
||||
*/
|
||||
private String fileUrl;
|
||||
/**
|
||||
* 文件类型(1:操作说明,2:产品参数)
|
||||
*/
|
||||
private Long fileType;
|
||||
}
|
||||
|
@ -14,4 +14,5 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface AppUserMapper extends BaseMapperPlus<AppUser, AppUserVo> {
|
||||
|
||||
AppUser appFindByUsername(String phoneNumber);
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
package com.fuyuanshen.app.service;
|
||||
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.domain.bo.AppUserBo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.app.domain.dto.APPForgotPasswordDTO;
|
||||
import com.fuyuanshen.app.domain.dto.APPForgotPasswordSmsDTO;
|
||||
import com.fuyuanshen.app.domain.dto.APPUpdateUserDTO;
|
||||
import com.fuyuanshen.app.domain.vo.APPUserInfoVo;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -65,4 +69,12 @@ public interface IAppUserService {
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
APPUserInfoVo getUserInfo();
|
||||
|
||||
int updateUser(APPUpdateUserDTO bo);
|
||||
|
||||
int forgotPassword(APPForgotPasswordDTO bo);
|
||||
|
||||
int sendForgotPasswordSms(APPForgotPasswordSmsDTO dto);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -66,6 +67,8 @@ public class AppOperationVideoServiceImpl implements IAppOperationVideoService {
|
||||
*/
|
||||
@Override
|
||||
public List<AppOperationVideoVo> queryList(AppOperationVideoBo bo) {
|
||||
Long userId = AppLoginHelper.getUserId();
|
||||
bo.setCreateBy(userId);
|
||||
LambdaQueryWrapper<AppOperationVideo> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
@ -1,24 +1,37 @@
|
||||
package com.fuyuanshen.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.app.domain.AppUser;
|
||||
import com.fuyuanshen.app.domain.bo.AppUserBo;
|
||||
import com.fuyuanshen.app.domain.dto.APPForgotPasswordDTO;
|
||||
import com.fuyuanshen.app.domain.dto.APPForgotPasswordSmsDTO;
|
||||
import com.fuyuanshen.app.domain.dto.APPUpdateUserDTO;
|
||||
import com.fuyuanshen.app.domain.vo.APPUserInfoVo;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.mapper.AppUserMapper;
|
||||
import com.fuyuanshen.app.service.IAppUserService;
|
||||
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
|
||||
import com.fuyuanshen.common.core.exception.BadRequestException;
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||
import com.fuyuanshen.system.service.ISysOssService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fuyuanshen.app.domain.bo.AppUserBo;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.domain.AppUser;
|
||||
import com.fuyuanshen.app.mapper.AppUserMapper;
|
||||
import com.fuyuanshen.app.service.IAppUserService;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Service业务层处理
|
||||
@ -33,6 +46,8 @@ public class AppUserServiceImpl implements IAppUserService {
|
||||
|
||||
private final AppUserMapper baseMapper;
|
||||
|
||||
private final ISysOssService sysOssService;
|
||||
|
||||
/**
|
||||
* 查询APP用户信息
|
||||
*
|
||||
@ -139,4 +154,75 @@ public class AppUserServiceImpl implements IAppUserService {
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public APPUserInfoVo getUserInfo() {
|
||||
String username = AppLoginHelper.getUsername();
|
||||
QueryWrapper<AppUser> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_name", username);
|
||||
List<AppUser> appUsers = baseMapper.selectList(queryWrapper);
|
||||
if(appUsers.isEmpty()){
|
||||
throw new BadRequestException("用户不存在");
|
||||
}
|
||||
AppUser user = appUsers.get(0);
|
||||
// AppUserVo user = baseMapper.selectVoById(userId);
|
||||
|
||||
APPUserInfoVo appUserVo = new APPUserInfoVo();
|
||||
appUserVo.setId(user.getUserId());
|
||||
appUserVo.setNickName(user.getNickName());
|
||||
appUserVo.setGender(user.getSex());
|
||||
appUserVo.setPhone(user.getPhonenumber());
|
||||
appUserVo.setRegion(user.getRegion());
|
||||
if(user.getAvatar() != null){
|
||||
SysOssVo oss = sysOssService.getById(user.getAvatar());
|
||||
if(oss != null){
|
||||
appUserVo.setAvatarPath(oss.getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
return appUserVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateUser(APPUpdateUserDTO bo) {
|
||||
AppLoginUser appUser = AppLoginHelper.getLoginUser();
|
||||
AppUserVo appUserVo = baseMapper.selectVoById(appUser.getUserId());
|
||||
if(appUserVo == null){
|
||||
throw new BadRequestException("用户不存在");
|
||||
}
|
||||
AppUser updUser= new AppUser();
|
||||
updUser.setUserId(appUser.getUserId());
|
||||
updUser.setNickName(bo.getNickName());
|
||||
if(bo.getFile() != null){
|
||||
SysOssVo oss = sysOssService.upload(bo.getFile());
|
||||
updUser.setAvatar(oss.getOssId());
|
||||
}
|
||||
|
||||
updUser.setRegion(bo.getRegion());
|
||||
updUser.setSex(bo.getGender());
|
||||
return baseMapper.update(updUser, new LambdaQueryWrapper<AppUser>().eq(AppUser::getUserId, appUser.getUserId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int forgotPassword(APPForgotPasswordDTO bo) {
|
||||
AppUser appUser = baseMapper.appFindByUsername(bo.getPhoneNumber());
|
||||
if (appUser == null) {
|
||||
throw new BadRequestException("手机号不存在");
|
||||
}
|
||||
String verificationCode = RedisUtils.getCacheObject(GlobalConstants.APP_FORGOT_PASSWORD_SMS_KEY + bo.getPhoneNumber());
|
||||
if (verificationCode == null) {
|
||||
throw new BadRequestException("验证码已过期");
|
||||
}
|
||||
if(!bo.getVerificationCode().equals(verificationCode)){
|
||||
throw new BadRequestException("验证码错误");
|
||||
}
|
||||
appUser.setPassword(bo.getPassword());
|
||||
baseMapper.updateById(appUser);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendForgotPasswordSms(APPForgotPasswordSmsDTO dto) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="queryAppFileList" resultType="com.fuyuanshen.app.domain.vo.AppFileVo">
|
||||
select a.id,a.business_id,a.file_id,b.file_name,b.url fileUrl from app_business_file a left join sys_oss b on a.file_id = b.oss_id
|
||||
where 1=1
|
||||
<if test="createBy != null">
|
||||
a.create_by = #{createBy}
|
||||
</if>
|
||||
<if test="businessId != null">
|
||||
and a.business_id = #{businessId}
|
||||
</if>
|
||||
|
@ -4,4 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuyuanshen.app.mapper.AppUserMapper">
|
||||
|
||||
<select id="appFindByUsername" resultType="com.fuyuanshen.app.domain.AppUser">
|
||||
select * from app_user where user_name = #{phoneNumber}
|
||||
</select>
|
||||
</mapper>
|
||||
|
Reference in New Issue
Block a user