AppRegister&Login todo
This commit is contained in:
@ -31,6 +31,8 @@ public interface CacheKey {
|
|||||||
* 数据
|
* 数据
|
||||||
*/
|
*/
|
||||||
String DATA_USER = "data::user:";
|
String DATA_USER = "data::user:";
|
||||||
|
String DATA_APP_USER = "data::appUser:";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单
|
* 菜单
|
||||||
|
@ -21,8 +21,8 @@ import cn.hutool.jwt.JWTUtil;
|
|||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONArray;
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.fuyuanshen.utils.enums.DataScopeEnum;
|
import com.fuyuanshen.utils.enums.DataScopeEnum;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
|
@ -36,5 +36,6 @@ public class LoginProperties {
|
|||||||
private boolean singleLogin = false;
|
private boolean singleLogin = false;
|
||||||
|
|
||||||
public static final String cacheKey = "user_login_cache:";
|
public static final String cacheKey = "user_login_cache:";
|
||||||
|
public static final String cacheKey_app = "app_user_login_cache:";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ import com.fuyuanshen.modules.security.service.dto.JwtUserDto;
|
|||||||
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
||||||
import com.fuyuanshen.modules.system.domain.query.APPUserQuery;
|
import com.fuyuanshen.modules.system.domain.query.APPUserQuery;
|
||||||
import com.fuyuanshen.modules.system.mapper.app.APPUserMapper;
|
import com.fuyuanshen.modules.system.mapper.app.APPUserMapper;
|
||||||
|
import com.fuyuanshen.modules.system.service.app.APPUserService;
|
||||||
import com.fuyuanshen.modules.utils.ResponseVO;
|
import com.fuyuanshen.modules.utils.ResponseVO;
|
||||||
import com.fuyuanshen.utils.RedisUtils;
|
import com.fuyuanshen.utils.RedisUtils;
|
||||||
import com.fuyuanshen.utils.SecurityUtils;
|
import com.fuyuanshen.utils.SecurityUtils;
|
||||||
@ -87,6 +88,7 @@ public class AuthController {
|
|||||||
private final LoginProperties loginProperties;
|
private final LoginProperties loginProperties;
|
||||||
private final UserDetailsServiceImpl userDetailsService;
|
private final UserDetailsServiceImpl userDetailsService;
|
||||||
private final APPUserMapper appUserMapper;
|
private final APPUserMapper appUserMapper;
|
||||||
|
private final APPUserService appUserService;
|
||||||
|
|
||||||
@Log("用户登录")
|
@Log("用户登录")
|
||||||
@ApiOperation("登录授权")
|
@ApiOperation("登录授权")
|
||||||
@ -172,7 +174,7 @@ public class AuthController {
|
|||||||
|
|
||||||
|
|
||||||
// 4. 加载用户详情
|
// 4. 加载用户详情
|
||||||
JwtUserDto jwtUser = userDetailsService.apploadUserByUsername(appUser.getUsername());
|
JwtUserDto jwtUser = userDetailsService.loadUserByUsername(appUser.getUsername(),appUser.getUserType());
|
||||||
|
|
||||||
// 5. 创建认证信息
|
// 5. 创建认证信息
|
||||||
Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities());
|
Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities());
|
||||||
@ -182,7 +184,7 @@ public class AuthController {
|
|||||||
String token = appTokenProvider.createToken(jwtUser);
|
String token = appTokenProvider.createToken(jwtUser);
|
||||||
|
|
||||||
// 7. 获取角色权限
|
// 7. 获取角色权限
|
||||||
AppRoleDto appRoleDto = appUserMapper.selectRoleByUserLevel(appUser.getUserLevel());
|
//Integer optLevel = appUserService.selectRoleByUserLevel(appUser.getRoles());
|
||||||
|
|
||||||
// 8. 构建响应数据
|
// 8. 构建响应数据
|
||||||
Map<String, Object> authInfo = new HashMap<>(2) {{
|
Map<String, Object> authInfo = new HashMap<>(2) {{
|
||||||
|
@ -20,7 +20,6 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import com.fuyuanshen.modules.security.config.SecurityProperties;
|
import com.fuyuanshen.modules.security.config.SecurityProperties;
|
||||||
import com.fuyuanshen.modules.security.service.dto.JwtUserDto;
|
import com.fuyuanshen.modules.security.service.dto.JwtUserDto;
|
||||||
import com.fuyuanshen.modules.security.service.dto.app.AppJwtUserDto;
|
|
||||||
import com.fuyuanshen.utils.RedisUtils;
|
import com.fuyuanshen.utils.RedisUtils;
|
||||||
import io.jsonwebtoken.*;
|
import io.jsonwebtoken.*;
|
||||||
import io.jsonwebtoken.io.Decoders;
|
import io.jsonwebtoken.io.Decoders;
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.fuyuanshen.modules.security.service;
|
package com.fuyuanshen.modules.security.service;
|
||||||
|
|
||||||
import com.fuyuanshen.modules.security.service.dto.app.AppJwtUserDto;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import com.fuyuanshen.modules.security.security.TokenProvider;
|
import com.fuyuanshen.modules.security.security.TokenProvider;
|
||||||
@ -45,6 +44,9 @@ public class OnlineUserService {
|
|||||||
private final TokenProvider tokenProvider;
|
private final TokenProvider tokenProvider;
|
||||||
private final RedisUtils redisUtils;
|
private final RedisUtils redisUtils;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存在线用户信息
|
* 保存在线用户信息
|
||||||
* @param jwtUserDto /
|
* @param jwtUserDto /
|
||||||
@ -57,10 +59,8 @@ public class OnlineUserService {
|
|||||||
|
|
||||||
if (jwtUserDto.getUser() != null) {
|
if (jwtUserDto.getUser() != null) {
|
||||||
dept = jwtUserDto.getUser().getDept() == null ? null : jwtUserDto.getUser().getDept().getName();
|
dept = jwtUserDto.getUser().getDept() == null ? null : jwtUserDto.getUser().getDept().getName();
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
dept="";
|
dept= jwtUserDto.getAppUser().getDept() == null ? null : jwtUserDto.getAppUser().getDept().getName();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String ip = StringUtils.getIp(request);
|
String ip = StringUtils.getIp(request);
|
||||||
@ -69,7 +69,7 @@ public class OnlineUserService {
|
|||||||
String address = StringUtils.getCityInfo(ip);
|
String address = StringUtils.getCityInfo(ip);
|
||||||
OnlineUserDto onlineUserDto = null;
|
OnlineUserDto onlineUserDto = null;
|
||||||
try {
|
try {
|
||||||
onlineUserDto = new OnlineUserDto(id, jwtUserDto.getUsername(), jwtUserDto.getUser().getNickName(), dept, browser , ip, address, EncryptUtils.desEncrypt(token), new Date());
|
onlineUserDto = new OnlineUserDto(id, jwtUserDto.getUsername(), jwtUserDto.getAppUser().getNickName(), dept, browser , ip, address, EncryptUtils.desEncrypt(token), new Date());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(),e);
|
log.error(e.getMessage(),e);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,6 @@ public class UserCacheManager {
|
|||||||
if (StringUtils.isNotEmpty(userName)) {
|
if (StringUtils.isNotEmpty(userName)) {
|
||||||
// 获取数据
|
// 获取数据
|
||||||
try {
|
try {
|
||||||
|
|
||||||
JwtUserDto jwtUserDto = redisUtils.get(LoginProperties.cacheKey + userName, JwtUserDto.class);
|
JwtUserDto jwtUserDto = redisUtils.get(LoginProperties.cacheKey + userName, JwtUserDto.class);
|
||||||
if (jwtUserDto != null){
|
if (jwtUserDto != null){
|
||||||
jwtUserDto.getUsername();
|
jwtUserDto.getUsername();
|
||||||
@ -94,4 +93,62 @@ public class UserCacheManager {
|
|||||||
redisUtils.del(LoginProperties.cacheKey + userName);
|
redisUtils.del(LoginProperties.cacheKey + userName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回用户缓存
|
||||||
|
* @param userName 用户名
|
||||||
|
* @return JwtUserDto
|
||||||
|
*/
|
||||||
|
public JwtUserDto getUserCache(String userName, Integer userType) {
|
||||||
|
// 转小写
|
||||||
|
userName = StringUtils.lowerCase(userName);
|
||||||
|
if (StringUtils.isNotEmpty(userName)) {
|
||||||
|
// 获取数据
|
||||||
|
try {
|
||||||
|
JwtUserDto jwtUserDto = redisUtils.get(LoginProperties.cacheKey_app + userName, JwtUserDto.class);
|
||||||
|
if (jwtUserDto != null){
|
||||||
|
jwtUserDto.getUsername();
|
||||||
|
}
|
||||||
|
return jwtUserDto;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// redisUtils.del(LoginProperties.cacheKey + userName);
|
||||||
|
cleanUserCache(userName);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加缓存到Redis
|
||||||
|
* @param userName 用户名
|
||||||
|
*/
|
||||||
|
@Async
|
||||||
|
public void addUserCache(String userName, JwtUserDto user,Integer userType) {
|
||||||
|
// 转小写
|
||||||
|
userName = StringUtils.lowerCase(userName);
|
||||||
|
if (StringUtils.isNotEmpty(userName)) {
|
||||||
|
// 添加数据, 避免数据同时过期
|
||||||
|
long time = idleTime + RandomUtil.randomInt(900, 1800);
|
||||||
|
redisUtils.set(LoginProperties.cacheKey_app + userName, user, time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理用户缓存信息
|
||||||
|
* 用户信息变更时
|
||||||
|
* @param userName 用户名
|
||||||
|
*/
|
||||||
|
@Async
|
||||||
|
public void cleanUserCache(String userName,Integer userType) {
|
||||||
|
// 转小写
|
||||||
|
userName = StringUtils.lowerCase(userName);
|
||||||
|
if (StringUtils.isNotEmpty(userName)) {
|
||||||
|
// 清除数据
|
||||||
|
redisUtils.del(LoginProperties.cacheKey_app + userName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -68,9 +68,8 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public JwtUserDto loadUserByUsername(String username, Integer userType) {
|
||||||
public JwtUserDto apploadUserByUsername(String username) {
|
JwtUserDto jwtUserDto = userCacheManager.getUserCache(username , userType);
|
||||||
JwtUserDto jwtUserDto = userCacheManager.getUserCache(username);
|
|
||||||
if (jwtUserDto == null) {
|
if (jwtUserDto == null) {
|
||||||
|
|
||||||
APPUser user = userService.appGetLoginData(username);
|
APPUser user = userService.appGetLoginData(username);
|
||||||
@ -85,7 +84,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
|||||||
// 初始化JwtUserDto
|
// 初始化JwtUserDto
|
||||||
jwtUserDto = new JwtUserDto(null,user, dataService.getDeptIds(user), authorities);
|
jwtUserDto = new JwtUserDto(null,user, dataService.getDeptIds(user), authorities);
|
||||||
// 添加缓存数据
|
// 添加缓存数据
|
||||||
userCacheManager.addUserCache(username, jwtUserDto);
|
userCacheManager.addUserCache(username, jwtUserDto, userType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return jwtUserDto;
|
return jwtUserDto;
|
||||||
|
@ -43,7 +43,7 @@ public class JwtUserDto implements UserDetails, java.io.Serializable {
|
|||||||
@ApiModelProperty(value = "用户")
|
@ApiModelProperty(value = "用户")
|
||||||
private final User user;
|
private final User user;
|
||||||
|
|
||||||
@ApiModelProperty(value = "用户")
|
@ApiModelProperty(value = "App用户")
|
||||||
private final APPUser appUser;
|
private final APPUser appUser;
|
||||||
|
|
||||||
@ApiModelProperty(value = "数据权限")
|
@ApiModelProperty(value = "数据权限")
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.fuyuanshen.modules.security.service.dto.app;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class AppSecurityQuery {
|
||||||
|
private String username;
|
||||||
|
private String usertype;
|
||||||
|
}
|
@ -44,12 +44,12 @@ public class AppUserCacheManager {
|
|||||||
* @param userName 用户名
|
* @param userName 用户名
|
||||||
* @return JwtUserDto
|
* @return JwtUserDto
|
||||||
*/
|
*/
|
||||||
public AppJwtUserDto getUserCache(String userName) {
|
public JwtUserDto getUserCache(String userName) {
|
||||||
// 转小写
|
// 转小写
|
||||||
userName = StringUtils.lowerCase(userName);
|
userName = StringUtils.lowerCase(userName);
|
||||||
if (StringUtils.isNotEmpty(userName)) {
|
if (StringUtils.isNotEmpty(userName)) {
|
||||||
// 获取数据
|
// 获取数据
|
||||||
return redisUtils.get(LoginProperties.cacheKey + userName, AppJwtUserDto.class);
|
return redisUtils.get(LoginProperties.cacheKey_app + userName, JwtUserDto.class);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -59,13 +59,13 @@ public class AppUserCacheManager {
|
|||||||
* @param userName 用户名
|
* @param userName 用户名
|
||||||
*/
|
*/
|
||||||
@Async
|
@Async
|
||||||
public void addUserCache(String userName, AppJwtUserDto user) {
|
public void addUserCache(String userName, JwtUserDto user) {
|
||||||
// 转小写
|
// 转小写
|
||||||
userName = StringUtils.lowerCase(userName);
|
userName = StringUtils.lowerCase(userName);
|
||||||
if (StringUtils.isNotEmpty(userName)) {
|
if (StringUtils.isNotEmpty(userName)) {
|
||||||
// 添加数据, 避免数据同时过期
|
// 添加数据, 避免数据同时过期
|
||||||
long time = idleTime + RandomUtil.randomInt(900, 1800);
|
long time = idleTime + RandomUtil.randomInt(900, 1800);
|
||||||
redisUtils.set(LoginProperties.cacheKey + "a" + userName, user, time);
|
redisUtils.set(LoginProperties.cacheKey_app + userName, user, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ public class AppUserCacheManager {
|
|||||||
userName = StringUtils.lowerCase(userName);
|
userName = StringUtils.lowerCase(userName);
|
||||||
if (StringUtils.isNotEmpty(userName)) {
|
if (StringUtils.isNotEmpty(userName)) {
|
||||||
// 清除数据
|
// 清除数据
|
||||||
redisUtils.del(LoginProperties.cacheKey + userName);
|
redisUtils.del(LoginProperties.cacheKey_app + userName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,6 +18,7 @@ package com.fuyuanshen.modules.system.rest.app;
|
|||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.fuyuanshen.annotation.Log;
|
import com.fuyuanshen.annotation.Log;
|
||||||
|
import com.fuyuanshen.annotation.rest.AnonymousPostMapping;
|
||||||
import com.fuyuanshen.exception.BadRequestException;
|
import com.fuyuanshen.exception.BadRequestException;
|
||||||
import com.fuyuanshen.modules.security.service.UserCacheManager;
|
import com.fuyuanshen.modules.security.service.UserCacheManager;
|
||||||
import com.fuyuanshen.modules.security.service.dto.JwtUserDto;
|
import com.fuyuanshen.modules.security.service.dto.JwtUserDto;
|
||||||
@ -28,6 +29,8 @@ import com.fuyuanshen.modules.system.domain.User;
|
|||||||
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.UserPassVo;
|
import com.fuyuanshen.modules.system.domain.dto.UserPassVo;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.UserQueryCriteria;
|
import com.fuyuanshen.modules.system.domain.dto.UserQueryCriteria;
|
||||||
|
import com.fuyuanshen.modules.system.domain.dto.app.APPUserDTO;
|
||||||
|
import com.fuyuanshen.modules.system.domain.query.APPUserQuery;
|
||||||
import com.fuyuanshen.modules.system.domain.vo.ConsumerVo;
|
import com.fuyuanshen.modules.system.domain.vo.ConsumerVo;
|
||||||
import com.fuyuanshen.modules.system.enums.UserType;
|
import com.fuyuanshen.modules.system.enums.UserType;
|
||||||
import com.fuyuanshen.modules.system.mapper.UserMapper;
|
import com.fuyuanshen.modules.system.mapper.UserMapper;
|
||||||
@ -38,10 +41,12 @@ import com.fuyuanshen.utils.PageResult;
|
|||||||
import com.fuyuanshen.utils.SecurityUtils;
|
import com.fuyuanshen.utils.SecurityUtils;
|
||||||
import com.fuyuanshen.utils.StringUtils;
|
import com.fuyuanshen.utils.StringUtils;
|
||||||
import com.fuyuanshen.utils.enums.CodeEnum;
|
import com.fuyuanshen.utils.enums.CodeEnum;
|
||||||
|
import io.netty.util.internal.StringUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
@ -50,6 +55,7 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -81,6 +87,18 @@ public class APPUserController {
|
|||||||
return ResponseVO.success(appUserService.queryAPPUser(criteria, page));
|
return ResponseVO.success(appUserService.queryAPPUser(criteria, page));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log("app用户注册")
|
||||||
|
@ApiOperation("app用户注册")
|
||||||
|
@AnonymousPostMapping(value = "/app/register")
|
||||||
|
public ResponseVO<String> APPRegister(@Validated @RequestBody APPUserDTO user) throws Exception {
|
||||||
|
|
||||||
|
//暫定0000
|
||||||
|
if (user.getVerificationCode() == null || !"0000".equals(user.getVerificationCode())) {
|
||||||
|
throw new BadRequestException("验证码错误");
|
||||||
|
}
|
||||||
|
appUserService.addUser(user);
|
||||||
|
return ResponseVO.success("success!!!");
|
||||||
|
}
|
||||||
|
|
||||||
@Log("修改APP用户")
|
@Log("修改APP用户")
|
||||||
@ApiOperation("修改APP用户")
|
@ApiOperation("修改APP用户")
|
||||||
|
@ -17,12 +17,16 @@ package com.fuyuanshen.modules.system.service.app;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.fuyuanshen.modules.security.service.dto.app.AppRoleDto;
|
||||||
|
import com.fuyuanshen.modules.system.domain.Role;
|
||||||
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.UserQueryCriteria;
|
import com.fuyuanshen.modules.system.domain.dto.UserQueryCriteria;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.app.APPUserDTO;
|
import com.fuyuanshen.modules.system.domain.dto.app.APPUserDTO;
|
||||||
import com.fuyuanshen.modules.utils.ResponseVO;
|
import com.fuyuanshen.modules.utils.ResponseVO;
|
||||||
import com.fuyuanshen.utils.PageResult;
|
import com.fuyuanshen.utils.PageResult;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Zheng Jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
@ -48,4 +52,6 @@ public interface APPUserService extends IService<APPUser> {
|
|||||||
|
|
||||||
|
|
||||||
ResponseVO<Object> addUser(APPUserDTO user);
|
ResponseVO<Object> addUser(APPUserDTO user);
|
||||||
|
|
||||||
|
Integer selectRoleByUserLevel(Set<Role> roles);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ public class DataServiceImpl implements DataService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Long> getDeptIds(APPUser user) {
|
public List<Long> getDeptIds(APPUser user) {
|
||||||
String key = CacheKey.DATA_USER + user.getId();
|
String key = CacheKey.DATA_APP_USER + user.getId();
|
||||||
List<Long> ids = redisUtils.getList(key, Long.class);
|
List<Long> ids = redisUtils.getList(key, Long.class);
|
||||||
if (CollUtil.isEmpty(ids)) {
|
if (CollUtil.isEmpty(ids)) {
|
||||||
Set<Long> deptIds = new HashSet<>();
|
Set<Long> deptIds = new HashSet<>();
|
||||||
|
@ -18,6 +18,7 @@ package com.fuyuanshen.modules.system.service.impl.app;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fuyuanshen.exception.BadRequestException;
|
import com.fuyuanshen.exception.BadRequestException;
|
||||||
|
import com.fuyuanshen.modules.system.domain.Role;
|
||||||
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.UserQueryCriteria;
|
import com.fuyuanshen.modules.system.domain.dto.UserQueryCriteria;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.app.APPUserDTO;
|
import com.fuyuanshen.modules.system.domain.dto.app.APPUserDTO;
|
||||||
@ -28,6 +29,8 @@ import com.fuyuanshen.utils.*;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Zheng Jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
@ -68,10 +71,10 @@ public class APPUserServiceImpl extends ServiceImpl<APPUserMapper, APPUser> impl
|
|||||||
if (appUserMapper.getByUsername(username) != null) {
|
if (appUserMapper.getByUsername(username) != null) {
|
||||||
throw new BadRequestException("该手机号已被注册");
|
throw new BadRequestException("该手机号已被注册");
|
||||||
}
|
}
|
||||||
|
|
||||||
APPUser appUser = new APPUser();
|
APPUser appUser = new APPUser();
|
||||||
appUser.setUsername(user.getPhoneNumber().toString());
|
appUser.setUsername(user.getPhoneNumber().toString());
|
||||||
appUser.setPassword(user.getPassword());
|
appUser.setPassword(user.getPassword());
|
||||||
|
appUser.setNickName(user.getPhoneNumber());
|
||||||
appUser.setUserLevel((byte) 1);
|
appUser.setUserLevel((byte) 1);
|
||||||
appUser.setPhone(Long.valueOf(user.getPhoneNumber()));
|
appUser.setPhone(Long.valueOf(user.getPhoneNumber()));
|
||||||
appUser.setAdmin((byte) 1);
|
appUser.setAdmin((byte) 1);
|
||||||
@ -85,4 +88,9 @@ public class APPUserServiceImpl extends ServiceImpl<APPUserMapper, APPUser> impl
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer selectRoleByUserLevel(Set<Role> roles) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,7 @@
|
|||||||
<result property="admin" column="is_admin"/>
|
<result property="admin" column="is_admin"/>
|
||||||
<result property="createTime" column="create_time"/>
|
<result property="createTime" column="create_time"/>
|
||||||
<result property="updateTime" column="update_time"/>
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<result property="userType" column="user_type"/>
|
||||||
|
|
||||||
<!-- 角色字段 -->
|
<!-- 角色字段 -->
|
||||||
<collection property="roles" ofType="com.fuyuanshen.modules.system.domain.Role">
|
<collection property="roles" ofType="com.fuyuanshen.modules.system.domain.Role">
|
||||||
@ -131,6 +132,7 @@
|
|||||||
u1.is_admin,
|
u1.is_admin,
|
||||||
u1.create_time,
|
u1.create_time,
|
||||||
u1.update_time,
|
u1.update_time,
|
||||||
|
u1.user_type,
|
||||||
|
|
||||||
r.name AS role_name,
|
r.name AS role_name,
|
||||||
r.level AS role_level,
|
r.level AS role_level,
|
||||||
|
Reference in New Issue
Block a user