forked from dyf/fys-Multi-tenant
@ -4,13 +4,14 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
|||||||
import cn.dev33.satoken.exception.NotLoginException;
|
import cn.dev33.satoken.exception.NotLoginException;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.fuyuanshen.app.model.AppSmsLoginBody;
|
||||||
import com.fuyuanshen.app.service.AppLoginService;
|
import com.fuyuanshen.app.service.AppLoginService;
|
||||||
import com.fuyuanshen.common.core.constant.SystemConstants;
|
import com.fuyuanshen.common.core.constant.SystemConstants;
|
||||||
import com.fuyuanshen.common.core.domain.R;
|
import com.fuyuanshen.common.core.domain.R;
|
||||||
import com.fuyuanshen.common.core.domain.model.AppLoginBody;
|
import com.fuyuanshen.common.core.domain.model.RegisterBody;
|
||||||
import com.fuyuanshen.common.core.domain.model.AppSmsRegisterBody;
|
import com.fuyuanshen.common.core.domain.model.SmsLoginBody;
|
||||||
import com.fuyuanshen.common.core.domain.model.PasswordLoginBody;
|
|
||||||
import com.fuyuanshen.common.core.utils.*;
|
import com.fuyuanshen.common.core.utils.*;
|
||||||
|
import com.fuyuanshen.common.encrypt.annotation.ApiEncrypt;
|
||||||
import com.fuyuanshen.common.json.utils.JsonUtils;
|
import com.fuyuanshen.common.json.utils.JsonUtils;
|
||||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||||
import com.fuyuanshen.common.tenant.helper.TenantHelper;
|
import com.fuyuanshen.common.tenant.helper.TenantHelper;
|
||||||
@ -23,7 +24,6 @@ import com.fuyuanshen.system.service.ISysTenantService;
|
|||||||
import com.fuyuanshen.web.domain.vo.LoginTenantVo;
|
import com.fuyuanshen.web.domain.vo.LoginTenantVo;
|
||||||
import com.fuyuanshen.web.domain.vo.LoginVo;
|
import com.fuyuanshen.web.domain.vo.LoginVo;
|
||||||
import com.fuyuanshen.web.domain.vo.TenantListVo;
|
import com.fuyuanshen.web.domain.vo.TenantListVo;
|
||||||
import com.fuyuanshen.web.service.AppRegisterService;
|
|
||||||
import com.fuyuanshen.web.service.IAuthStrategy;
|
import com.fuyuanshen.web.service.IAuthStrategy;
|
||||||
import com.fuyuanshen.web.service.SysRegisterService;
|
import com.fuyuanshen.web.service.SysRegisterService;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
@ -51,7 +51,7 @@ import java.util.List;
|
|||||||
public class AppAuthController {
|
public class AppAuthController {
|
||||||
|
|
||||||
private final AppLoginService loginService;
|
private final AppLoginService loginService;
|
||||||
private final AppRegisterService registerService;
|
private final SysRegisterService registerService;
|
||||||
private final ISysConfigService configService;
|
private final ISysConfigService configService;
|
||||||
private final ISysTenantService tenantService;
|
private final ISysTenantService tenantService;
|
||||||
private final ISysClientService clientService;
|
private final ISysClientService clientService;
|
||||||
@ -64,15 +64,15 @@ public class AppAuthController {
|
|||||||
*/
|
*/
|
||||||
// @ApiEncrypt
|
// @ApiEncrypt
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public R<LoginVo> login(@RequestBody AppLoginBody appLoginBody) {
|
public R<LoginVo> login(@RequestBody AppSmsLoginBody appSmsLoginBody) {
|
||||||
// SmsLoginBody loginBody = JsonUtils.parseObject(body, SmsLoginBody.class);
|
// SmsLoginBody loginBody = JsonUtils.parseObject(body, SmsLoginBody.class);
|
||||||
ValidatorUtils.validate(appLoginBody);
|
ValidatorUtils.validate(appSmsLoginBody);
|
||||||
PasswordLoginBody loginBody = new PasswordLoginBody();
|
SmsLoginBody loginBody = new SmsLoginBody();
|
||||||
loginBody.setUsername(appLoginBody.getUserName());
|
loginBody.setPhonenumber(appSmsLoginBody.getPhonenumber());
|
||||||
loginBody.setPassword(appLoginBody.getPassword());
|
loginBody.setSmsCode(appSmsLoginBody.getSmsCode());
|
||||||
loginBody.setTenantId(appLoginBody.getTenantId());
|
loginBody.setTenantId(appSmsLoginBody.getTenantId());
|
||||||
loginBody.setClientId("835b15335d389c9fcfdf99421fa8019b");
|
loginBody.setClientId("ca839698e245d60aa2f0e59bd52b34f8");
|
||||||
loginBody.setGrantType("appPassword");
|
loginBody.setGrantType("appSms");
|
||||||
// 授权类型和客户端id
|
// 授权类型和客户端id
|
||||||
String clientId = loginBody.getClientId();
|
String clientId = loginBody.getClientId();
|
||||||
String grantType = loginBody.getGrantType();
|
String grantType = loginBody.getGrantType();
|
||||||
@ -107,8 +107,12 @@ public class AppAuthController {
|
|||||||
/**
|
/**
|
||||||
* 用户注册
|
* 用户注册
|
||||||
*/
|
*/
|
||||||
|
@ApiEncrypt
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
public R<Void> register(@Validated @RequestBody AppSmsRegisterBody user) {
|
public R<Void> register(@Validated @RequestBody RegisterBody user) {
|
||||||
|
if (!configService.selectRegisterEnabled(user.getTenantId())) {
|
||||||
|
return R.fail("当前系统没有开启注册功能!");
|
||||||
|
}
|
||||||
registerService.register(user);
|
registerService.register(user);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
@ -64,8 +64,8 @@ public class AppOperationVideoController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 操作视频删除
|
* 操作视频删除
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/deleteOperationVideo/{id}")
|
@DeleteMapping("/deleteOperationVideo")
|
||||||
public R<Void> deleteOperationVideo(@PathVariable Long id) {
|
public R<Void> deleteOperationVideo(Long[] ids) {
|
||||||
return toAjax(appOperationVideoService.deleteWithValidByIds(List.of(id), true));
|
return toAjax(appOperationVideoService.deleteWithValidByIds(List.of(ids), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
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,11 +2,14 @@ package com.fuyuanshen.app.service;
|
|||||||
|
|
||||||
import cn.dev33.satoken.exception.NotLoginException;
|
import cn.dev33.satoken.exception.NotLoginException;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.fuyuanshen.app.domain.vo.AppRoleVo;
|
||||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||||
import com.fuyuanshen.common.core.constant.Constants;
|
import com.fuyuanshen.common.core.constant.Constants;
|
||||||
import com.fuyuanshen.common.core.constant.SystemConstants;
|
import com.fuyuanshen.common.core.constant.SystemConstants;
|
||||||
import com.fuyuanshen.common.core.constant.TenantConstants;
|
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.domain.model.AppLoginUser;
|
||||||
import com.fuyuanshen.common.core.enums.LoginType;
|
import com.fuyuanshen.common.core.enums.LoginType;
|
||||||
import com.fuyuanshen.common.core.exception.user.UserException;
|
import com.fuyuanshen.common.core.exception.user.UserException;
|
||||||
@ -28,10 +31,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,129 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -49,9 +49,9 @@ spring:
|
|||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
# rewriteBatchedStatements=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
|
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
|
||||||
username: root
|
username: root
|
||||||
password: 1fys@QWER..
|
password: Jq_123456#
|
||||||
# # 从库数据源
|
# # 从库数据源
|
||||||
# slave:
|
# slave:
|
||||||
# lazy: true
|
# lazy: true
|
||||||
@ -98,13 +98,13 @@ spring:
|
|||||||
spring.data:
|
spring.data:
|
||||||
redis:
|
redis:
|
||||||
# 地址
|
# 地址
|
||||||
host: 120.79.224.186
|
host: 47.120.79.150
|
||||||
# 端口,默认为6379
|
# 端口,默认为6379
|
||||||
port: 26379
|
port: 6379
|
||||||
# 数据库索引
|
# 数据库索引
|
||||||
database: 2
|
database: 2
|
||||||
# redis 密码必须配置
|
# redis 密码必须配置
|
||||||
password: 1fys@QWER..
|
password: xhYc_djkl382^#780!
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
# 是否开启ssl
|
# 是否开启ssl
|
||||||
@ -300,8 +300,8 @@ file:
|
|||||||
# MQTT配置
|
# MQTT配置
|
||||||
mqtt:
|
mqtt:
|
||||||
username: admin
|
username: admin
|
||||||
password: fys123456
|
password: #YtvpSfCNG
|
||||||
url: tcp://47.107.152.87:1883
|
url: tcp://47.120.79.150:2883
|
||||||
subClientId: fys_subClient
|
subClientId: fys_subClient
|
||||||
subTopic: worker/alert/#,worker/location/#
|
subTopic: worker/alert/#,worker/location/#
|
||||||
pubTopic: worker/location
|
pubTopic: worker/location
|
||||||
|
@ -17,11 +17,6 @@ public interface GlobalConstants {
|
|||||||
*/
|
*/
|
||||||
String CAPTCHA_CODE_KEY = GLOBAL_REDIS_KEY + "captcha_codes:";
|
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
|
* 防重提交 redis key
|
||||||
*/
|
*/
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
@ -1,14 +1,13 @@
|
|||||||
package com.fuyuanshen.app.domain;
|
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.fuyuanshen.common.tenant.core.TenantEntity;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import java.util.Date;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APP用户信息对象 app_user
|
* APP用户信息对象 app_user
|
||||||
@ -96,9 +95,5 @@ public class AppUser extends TenantEntity {
|
|||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/**
|
|
||||||
* 地区
|
|
||||||
*/
|
|
||||||
private String region;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
package com.fuyuanshen.app.domain.dto;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class APPForgotPasswordSmsDTO {
|
|
||||||
|
|
||||||
@NotBlank(message = "手机号不能为空")
|
|
||||||
private String phoneNumber;
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
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;
|
|
||||||
|
|
||||||
}
|
|
@ -14,5 +14,4 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface AppUserMapper extends BaseMapperPlus<AppUser, AppUserVo> {
|
public interface AppUserMapper extends BaseMapperPlus<AppUser, AppUserVo> {
|
||||||
|
|
||||||
AppUser appFindByUsername(String phoneNumber);
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
package com.fuyuanshen.app.service;
|
package com.fuyuanshen.app.service;
|
||||||
|
|
||||||
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.domain.vo.AppUserVo;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
import com.fuyuanshen.app.domain.bo.AppUserBo;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -69,12 +65,4 @@ public interface IAppUserService {
|
|||||||
* @return 是否删除成功
|
* @return 是否删除成功
|
||||||
*/
|
*/
|
||||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
|
||||||
APPUserInfoVo getUserInfo();
|
|
||||||
|
|
||||||
int updateUser(APPUpdateUserDTO bo);
|
|
||||||
|
|
||||||
int forgotPassword(APPForgotPasswordDTO bo);
|
|
||||||
|
|
||||||
int sendForgotPasswordSms(APPForgotPasswordSmsDTO dto);
|
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,24 @@
|
|||||||
package com.fuyuanshen.app.service.impl;
|
package com.fuyuanshen.app.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
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.MapstructUtils;
|
||||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
|
||||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.fuyuanshen.system.service.ISysOssService;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
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.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service业务层处理
|
* Service业务层处理
|
||||||
@ -44,8 +33,6 @@ public class AppUserServiceImpl implements IAppUserService {
|
|||||||
|
|
||||||
private final AppUserMapper baseMapper;
|
private final AppUserMapper baseMapper;
|
||||||
|
|
||||||
private final ISysOssService sysOssService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询APP用户信息
|
* 查询APP用户信息
|
||||||
*
|
*
|
||||||
@ -152,57 +139,4 @@ public class AppUserServiceImpl implements IAppUserService {
|
|||||||
}
|
}
|
||||||
return baseMapper.deleteByIds(ids) > 0;
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public APPUserInfoVo getUserInfo() {
|
|
||||||
Long userId = AppLoginHelper.getUserId();
|
|
||||||
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());
|
|
||||||
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());
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.fuyuanshen.app.mapper.AppUserMapper">
|
<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>
|
</mapper>
|
||||||
|
Reference in New Issue
Block a user