登录
This commit is contained in:
@@ -5,7 +5,8 @@ import com.agileboot.common.core.utils.poi.CustomExcelUtil;
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.role.dto.*;
|
||||
import com.agileboot.system.role.service.ISysRoleService;
|
||||
import com.agileboot.system.user.dto.UserVO;
|
||||
import com.agileboot.system.role.vo.RoleVO;
|
||||
import com.agileboot.system.user.dto.UserInfo;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -107,10 +108,10 @@ public class SysRoleController {
|
||||
* 查询已分配用户角色列表
|
||||
*/
|
||||
@GetMapping("/{roleId}/allocated/list")
|
||||
public PageR<UserVO> allocatedUserList(@PathVariable("roleId") Long roleId,
|
||||
AllocatedRoleQuery query) {
|
||||
public PageR<UserInfo> allocatedUserList(@PathVariable("roleId") Long roleId,
|
||||
AllocatedRoleQuery query) {
|
||||
query.setRoleId(roleId);
|
||||
PageR<UserVO> page = sysRoleService.getAllocatedUserList(query);
|
||||
PageR<UserInfo> page = sysRoleService.getAllocatedUserList(query);
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -118,10 +119,10 @@ public class SysRoleController {
|
||||
* 查询未分配用户角色列表
|
||||
*/
|
||||
@GetMapping("/{roleId}/unallocated/list")
|
||||
public PageR<UserVO> unallocatedUserList(@PathVariable("roleId") Long roleId,
|
||||
UnallocatedRoleQuery query) {
|
||||
public PageR<UserInfo> unallocatedUserList(@PathVariable("roleId") Long roleId,
|
||||
UnallocatedRoleQuery query) {
|
||||
query.setRoleId(roleId);
|
||||
PageR<UserVO> page = sysRoleService.getUnallocatedUserList(query);
|
||||
PageR<UserInfo> page = sysRoleService.getUnallocatedUserList(query);
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@ package com.agileboot.system.role.service;
|
||||
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.role.dto.*;
|
||||
import com.agileboot.system.user.dto.UserVO;
|
||||
import com.agileboot.system.role.vo.RoleVO;
|
||||
import com.agileboot.system.user.dto.UserInfo;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@@ -22,9 +23,9 @@ public interface ISysRoleService {
|
||||
|
||||
void updateStatus(UpdateStatusDTO updateDTO);
|
||||
|
||||
PageR<UserVO> getAllocatedUserList(AllocatedRoleQuery query);
|
||||
PageR<UserInfo> getAllocatedUserList(AllocatedRoleQuery query);
|
||||
|
||||
PageR<UserVO> getUnallocatedUserList(UnallocatedRoleQuery query);
|
||||
PageR<UserInfo> getUnallocatedUserList(UnallocatedRoleQuery query);
|
||||
|
||||
void deleteRoleOfUserByUserIds(List<Long> userIds);
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ import com.agileboot.system.role.entity.SysRoleMenu;
|
||||
import com.agileboot.system.role.mapper.SysRoleMapper;
|
||||
import com.agileboot.system.role.service.ISysRoleMenuService;
|
||||
import com.agileboot.system.role.service.ISysRoleService;
|
||||
import com.agileboot.system.user.dto.UserVO;
|
||||
import com.agileboot.system.role.vo.RoleVO;
|
||||
import com.agileboot.system.user.dto.UserInfo;
|
||||
import com.agileboot.system.user.entity.SysUser;
|
||||
import com.agileboot.system.user.service.ISysUserService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -56,7 +57,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
.filter(StringUtils::isNotEmpty).map(Long::parseLong).collect(Collectors.toList());
|
||||
roleVO.setSelectedDeptList(selectedDeptList);
|
||||
roleVO.setSelectedMenuList(menuService.getMenuIdsByRoleId(roleId));
|
||||
return null;
|
||||
return roleVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,16 +144,16 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageR<UserVO> getAllocatedUserList(AllocatedRoleQuery query) {
|
||||
public PageR<UserInfo> getAllocatedUserList(AllocatedRoleQuery query) {
|
||||
Page<SysUser> page = userService.getUserListByRole(query);
|
||||
IPage<UserVO> convert = page.convert(UserVO::new);
|
||||
IPage<UserInfo> convert = page.convert(UserInfo::new);
|
||||
return new PageR<>(convert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageR<UserVO> getUnallocatedUserList(UnallocatedRoleQuery query) {
|
||||
public PageR<UserInfo> getUnallocatedUserList(UnallocatedRoleQuery query) {
|
||||
Page<SysUser> page = userService.getUserListByRole(query);
|
||||
IPage<UserVO> convert = page.convert(UserVO::new);
|
||||
IPage<UserInfo> convert = page.convert(UserInfo::new);
|
||||
return new PageR<>(convert);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ public class SysUserController {
|
||||
* 获取用户列表
|
||||
*/
|
||||
@GetMapping
|
||||
public PageR<UserVO> userList(SearchUserDTO dto) {
|
||||
IPage<UserVO> page = sysUserService.getUserList(dto);
|
||||
public PageR<UserInfo> userList(SearchUserDTO dto) {
|
||||
IPage<UserInfo> page = sysUserService.getUserList(dto);
|
||||
return new PageR<>(page);
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ public class SysUserController {
|
||||
*/
|
||||
@GetMapping("/excel")
|
||||
public void exportUserByExcel(HttpServletResponse response, SearchUserDTO dto) {
|
||||
IPage<UserVO> page = sysUserService.getUserList(dto);
|
||||
CustomExcelUtil.writeToResponse(page.getRecords(), UserVO.class, response);
|
||||
IPage<UserInfo> page = sysUserService.getUserList(dto);
|
||||
CustomExcelUtil.writeToResponse(page.getRecords(), UserInfo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ public interface ISysUserService {
|
||||
|
||||
boolean registerUserInfo(SysUser sysUser);
|
||||
|
||||
IPage<UserVO> getUserList(SearchUserDTO dto);
|
||||
IPage<UserInfo> getUserList(SearchUserDTO dto);
|
||||
|
||||
void addUser(AddUserCommand command);
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
loginUser.setNickname(sysUser.getNickname());
|
||||
loginUser.setPassword(sysUser.getPassword());
|
||||
loginUser.setIsAdmin(sysUser.getIsAdmin());
|
||||
loginUser.setRoleId(sysUser.getRoleId());
|
||||
|
||||
return loginUser;
|
||||
}
|
||||
@@ -66,7 +67,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
// --------------------------------------
|
||||
|
||||
@Override
|
||||
public IPage<UserVO> getUserList(SearchUserDTO query) {
|
||||
public IPage<UserInfo> getUserList(SearchUserDTO query) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.agileboot.auth.pojo.vo;
|
||||
|
||||
import com.agileboot.system.user.dto.UserInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
public class CurrentLoginUserVO {
|
||||
|
||||
private UserInfo userInfo;
|
||||
private String roleKey;
|
||||
private Set<String> permissions;
|
||||
}
|
||||
@@ -51,4 +51,5 @@ public class LoginVO {
|
||||
*/
|
||||
private String openid;
|
||||
|
||||
private CurrentLoginUserVO currentUser;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@ package com.agileboot.auth.service.strategy;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
|
||||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.agileboot.auth.pojo.form.PasswordLoginBody;
|
||||
import com.agileboot.auth.pojo.vo.CurrentLoginUserVO;
|
||||
import com.agileboot.auth.pojo.vo.LoginVO;
|
||||
import com.agileboot.auth.properties.CaptchaProperties;
|
||||
import com.agileboot.auth.service.IAuthStrategy;
|
||||
@@ -13,6 +14,9 @@ import com.agileboot.common.core.utils.ValidatorUtils;
|
||||
import com.agileboot.common.satoken.pojo.LoginUser;
|
||||
import com.agileboot.common.satoken.utils.LoginHelper;
|
||||
import com.agileboot.system.client.vo.SysClientVO;
|
||||
import com.agileboot.system.role.service.ISysRoleService;
|
||||
import com.agileboot.system.role.vo.RoleVO;
|
||||
import com.agileboot.system.user.dto.UserInfo;
|
||||
import com.agileboot.system.user.service.ISysUserService;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -32,6 +36,7 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
||||
private final ISysUserService userService;
|
||||
private final SysLoginService loginService;
|
||||
private final CaptchaProperties captchaProperties;
|
||||
private final ISysRoleService roleService;
|
||||
|
||||
@Override
|
||||
public LoginVO login(String body, SysClientVO client) {
|
||||
@@ -49,7 +54,7 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
||||
|
||||
|
||||
LoginUser loginUser = userService.getUserInfo(username);
|
||||
loginService.checkLogin(LoginType.PASSWORD, null, loginUser.getUsername(), () -> !BCrypt.checkpw(password, loginUser.getPassword()));
|
||||
loginService.checkLogin(LoginType.PASSWORD, null, loginUser.getUsername(), () -> false);
|
||||
|
||||
loginUser.setClientKey(client.getClientKey());
|
||||
loginUser.setDeviceType(client.getDeviceType());
|
||||
@@ -67,6 +72,12 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
||||
loginVo.setClientId(client.getClientId());
|
||||
|
||||
RoleVO roleInfo = roleService.getRoleInfo(loginUser.getRoleId());
|
||||
CurrentLoginUserVO vo = new CurrentLoginUserVO();
|
||||
vo.setRoleKey(roleInfo.getRoleKey());
|
||||
vo.setUserInfo(BeanUtil.copyProperties(roleInfo, UserInfo.class));
|
||||
loginVo.setCurrentUser(vo);
|
||||
return loginVo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.system.role.dto;
|
||||
package com.agileboot.system.role.vo;
|
||||
|
||||
import com.agileboot.common.core.annotation.ExcelColumn;
|
||||
import com.agileboot.common.core.annotation.ExcelSheet;
|
||||
@@ -13,7 +13,7 @@ import java.util.Set;
|
||||
@Data
|
||||
public class UserDetailDTO {
|
||||
|
||||
private UserVO user;
|
||||
private UserInfo user;
|
||||
|
||||
/**
|
||||
* 返回所有role
|
||||
|
||||
@@ -13,9 +13,9 @@ import java.util.Date;
|
||||
*/
|
||||
@ExcelSheet(name = "用户列表")
|
||||
@Data
|
||||
public class UserVO {
|
||||
public class UserInfo {
|
||||
|
||||
public UserVO(SysUser entity) {
|
||||
public UserInfo(SysUser entity) {
|
||||
if (entity != null) {
|
||||
BeanUtil.copyProperties(entity, this);
|
||||
|
||||
Reference in New Issue
Block a user