Commit bba75c66 authored by hubin's avatar hubin

登陆接口开发

parent 10d7dfb7
...@@ -33,7 +33,7 @@ public class UserDetailsServiceImpl implements UserDetailsService { ...@@ -33,7 +33,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
} }
SystemUser systemUser = userRes.getData(); SystemUser systemUser = userRes.getData();
//根据用户id获取用户权限 //根据用户id获取用户权限
Result<List<Long>> roles = systemAdminFeignService.loadUserRolesByUserId(systemUser.getId()); Result<List<Long>> roles = systemAdminFeignService.loadUserRolesByUserId(systemUser.getUserId());
UserLoginInfoVO userLoginInfoVO = new UserLoginInfoVO(systemUser); UserLoginInfoVO userLoginInfoVO = new UserLoginInfoVO(systemUser);
userLoginInfoVO.setAuthorities(roles.getData()); userLoginInfoVO.setAuthorities(roles.getData());
......
...@@ -18,15 +18,13 @@ import java.util.List; ...@@ -18,15 +18,13 @@ import java.util.List;
public class SystemResource { public class SystemResource {
@TableId @TableId
@TableField("RESOURCE_ID") private Long resourceId;
private Long id;
private String resourceName; private String resourceName;
private String resourceUrl; private String resourceUrl;
private String method; private String method;
private String resourceType; private String resourceType;
private Long parentId; private Long parentId;
@TableField("RESOURCE_ICON") private String resourceIcon;
private String icon;
private Date createTime; private Date createTime;
@TableField(exist = false) @TableField(exist = false)
......
...@@ -17,10 +17,8 @@ import java.util.Date; ...@@ -17,10 +17,8 @@ import java.util.Date;
public class SystemRole { public class SystemRole {
@TableId @TableId
@TableField("ROLE_ID") private Long roleId;
private Long id; private String roleName;
@TableField("ROLE_NAME")
private String name;
private String status; private String status;
private Date createTime; private Date createTime;
private Date modifyTime; private Date modifyTime;
......
...@@ -17,14 +17,12 @@ import java.util.Date; ...@@ -17,14 +17,12 @@ import java.util.Date;
public class SystemUser { public class SystemUser {
@TableId @TableId
@TableField("USER_ID") private Long userId;
private Long id;
private String account; private String account;
private String password; private String password;
private String realName; private String realName;
private String avatar; private String avatar;
private String gender; private String gender;
private String marketerCode;
private Integer userStatus; private Integer userStatus;
private Date createdTime; private Date createdTime;
private Date updatedTime; private Date updatedTime;
......
...@@ -28,11 +28,11 @@ public class UserLoginInfoVO implements UserDetails { ...@@ -28,11 +28,11 @@ public class UserLoginInfoVO implements UserDetails {
this.username = user.getAccount(); this.username = user.getAccount();
this.password = user.getPassword(); this.password = user.getPassword();
this.name = user.getRealName(); this.name = user.getRealName();
this.userId = user.getId(); this.userId = user.getUserId();
this.enable = "1".equals(user.getUserStatus()) ; this.enable = user.getUserStatus() == 1;
} }
public void setAuthorities(List<Long> roles){ public void setAuthorities(List<Long> roles) {
if (CollectionUtil.isNotEmpty(roles)) { if (CollectionUtil.isNotEmpty(roles)) {
authorities = new ArrayList<>(); authorities = new ArrayList<>();
roles.forEach(roleId -> authorities.add(new SimpleGrantedAuthority(String.valueOf(roleId)))); roles.forEach(roleId -> authorities.add(new SimpleGrantedAuthority(String.valueOf(roleId))));
......
...@@ -42,9 +42,9 @@ public class ResourcesController { ...@@ -42,9 +42,9 @@ public class ResourcesController {
List<MainMenuVO> resourceList = resourceService.list(new LambdaQueryWrapper<SystemResource>().eq(SystemResource::getResourceType, "2")) List<MainMenuVO> resourceList = resourceService.list(new LambdaQueryWrapper<SystemResource>().eq(SystemResource::getResourceType, "2"))
.stream().map(item -> { .stream().map(item -> {
MainMenuVO mainMenuVO = new MainMenuVO(); MainMenuVO mainMenuVO = new MainMenuVO();
mainMenuVO.setIcon(item.getIcon()); mainMenuVO.setIcon(item.getResourceIcon());
mainMenuVO.setName(item.getResourceName()); mainMenuVO.setName(item.getResourceName());
mainMenuVO.setId(item.getId()); mainMenuVO.setId(item.getResourceId());
mainMenuVO.setParentId(item.getParentId()); mainMenuVO.setParentId(item.getParentId());
return mainMenuVO; return mainMenuVO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
...@@ -81,8 +81,8 @@ public class ResourcesController { ...@@ -81,8 +81,8 @@ public class ResourcesController {
systemResource.setResourceName(reqResource.getName()); systemResource.setResourceName(reqResource.getName());
systemResource.setResourceUrl(reqResource.getUrl()); systemResource.setResourceUrl(reqResource.getUrl());
systemResource.setResourceType(reqResource.getType()); systemResource.setResourceType(reqResource.getType());
systemResource.setIcon(reqResource.getIcon()); systemResource.setResourceId(reqResource.getId());
systemResource.setIcon(reqResource.getIcon()); systemResource.setResourceIcon(reqResource.getIcon());
systemResource.setParentId(reqResource.getParentId()); systemResource.setParentId(reqResource.getParentId());
systemResource.setCreateTime(new Date()); systemResource.setCreateTime(new Date());
resourceService.save(systemResource); resourceService.save(systemResource);
......
...@@ -53,14 +53,14 @@ public class RoleController { ...@@ -53,14 +53,14 @@ public class RoleController {
} }
SystemRole role = roleService.getOne(new LambdaQueryWrapper<SystemRole>() SystemRole role = roleService.getOne(new LambdaQueryWrapper<SystemRole>()
.eq(SystemRole::getName, reqRoleInfo.getName())); .eq(SystemRole::getRoleName, reqRoleInfo.getName()));
if (role != null) { if (role != null) {
return Result.failed("角色名称不能重复!"); return Result.failed("角色名称不能重复!");
} }
SystemRole systemRole = new SystemRole(); SystemRole systemRole = new SystemRole();
systemRole.setName(reqRoleInfo.getName()); systemRole.setRoleName(reqRoleInfo.getName());
systemRole.setStatus(reqRoleInfo.getStatus()); systemRole.setStatus(reqRoleInfo.getStatus());
systemRole.setCreateTime(new Date()); systemRole.setCreateTime(new Date());
roleService.save(systemRole); roleService.save(systemRole);
...@@ -89,7 +89,7 @@ public class RoleController { ...@@ -89,7 +89,7 @@ public class RoleController {
return Result.failed("名称不能为空!"); return Result.failed("名称不能为空!");
} }
SystemRole systemRole = roleService.getOne(new LambdaQueryWrapper<SystemRole>() SystemRole systemRole = roleService.getOne(new LambdaQueryWrapper<SystemRole>()
.eq(SystemRole::getName, roleName)); .eq(SystemRole::getRoleName, roleName));
if (systemRole != null) { if (systemRole != null) {
return Result.failed("名称已存在!"); return Result.failed("名称已存在!");
} }
...@@ -106,7 +106,7 @@ public class RoleController { ...@@ -106,7 +106,7 @@ public class RoleController {
QueryWrapper<SystemRole> systemRoleQueryWrapper = new QueryWrapper<>(); QueryWrapper<SystemRole> systemRoleQueryWrapper = new QueryWrapper<>();
if (!StrUtil.isBlankIfStr(reqRoleInfo.getName())) { if (!StrUtil.isBlankIfStr(reqRoleInfo.getName())) {
systemRoleQueryWrapper.and(wrapper -> wrapper.lambda().like(SystemRole::getName, reqRoleInfo.getName())); systemRoleQueryWrapper.and(wrapper -> wrapper.lambda().like(SystemRole::getRoleName, reqRoleInfo.getName()));
} }
if (!StrUtil.isBlankIfStr(reqRoleInfo.getStatus())) { if (!StrUtil.isBlankIfStr(reqRoleInfo.getStatus())) {
systemRoleQueryWrapper.and(wrapper -> wrapper.lambda().eq(SystemRole::getStatus, reqRoleInfo.getStatus())); systemRoleQueryWrapper.and(wrapper -> wrapper.lambda().eq(SystemRole::getStatus, reqRoleInfo.getStatus()));
...@@ -124,13 +124,13 @@ public class RoleController { ...@@ -124,13 +124,13 @@ public class RoleController {
if (reqRoleInfo.getId() == null || reqRoleInfo.getId() == 0) { if (reqRoleInfo.getId() == null || reqRoleInfo.getId() == 0) {
return Result.failed("角色ID无效!"); return Result.failed("角色ID无效!");
} }
SystemRole systemRole = roleService.getOne(new LambdaQueryWrapper<SystemRole>().eq(SystemRole::getId, reqRoleInfo.getId())); SystemRole systemRole = roleService.getOne(new LambdaQueryWrapper<SystemRole>().eq(SystemRole::getRoleId, reqRoleInfo.getId()));
if (systemRole == null) { if (systemRole == null) {
return Result.failed("角色ID无效!"); return Result.failed("角色ID无效!");
} }
boolean flag = false; boolean flag = false;
if (!reqRoleInfo.getName().equals(systemRole.getName())) { if (!reqRoleInfo.getName().equals(systemRole.getRoleName())) {
systemRole.setName(reqRoleInfo.getName()); systemRole.setRoleName(reqRoleInfo.getName());
flag = true; flag = true;
} }
if (!reqRoleInfo.getStatus().equals(systemRole.getStatus())) { if (!reqRoleInfo.getStatus().equals(systemRole.getStatus())) {
......
...@@ -95,16 +95,15 @@ public class UserController { ...@@ -95,16 +95,15 @@ public class UserController {
} }
SystemUser systemUser = userInfoService.getOne(new LambdaQueryWrapper<SystemUser>() SystemUser systemUser = userInfoService.getOne(new LambdaQueryWrapper<SystemUser>()
.eq(SystemUser::getAccount, reqUserInfo.getAccount()).or() .eq(SystemUser::getAccount, reqUserInfo.getAccount()).or()
.eq(SystemUser::getId, reqUserInfo.getId())); .eq(SystemUser::getUserId, reqUserInfo.getId()));
if (systemUser != null) { if (systemUser != null) {
return Result.failed("账号已存在!"); return Result.failed("账号已存在!");
} }
SystemUser user = new SystemUser(); SystemUser user = new SystemUser();
user.setId(reqUserInfo.getId()); user.setUserId(reqUserInfo.getId());
user.setAccount(reqUserInfo.getAccount()); user.setAccount(reqUserInfo.getAccount());
user.setPassword(new BCryptPasswordEncoder().encode(reqUserInfo.getPassword())); user.setPassword(new BCryptPasswordEncoder().encode(reqUserInfo.getPassword()));
user.setGender(reqUserInfo.getGender()); user.setGender(reqUserInfo.getGender());
user.setMarketerCode(reqUserInfo.getMarketerCode());
user.setRealName(reqUserInfo.getName()); user.setRealName(reqUserInfo.getName());
user.setUserStatus(reqUserInfo.getEnable()); user.setUserStatus(reqUserInfo.getEnable());
user.setCreatedTime(new Date()); user.setCreatedTime(new Date());
...@@ -114,7 +113,7 @@ public class UserController { ...@@ -114,7 +113,7 @@ public class UserController {
roles.add(1L); roles.add(1L);
List<SystemUserRole> roleList = roles.stream().map(roleId -> { List<SystemUserRole> roleList = roles.stream().map(roleId -> {
SystemUserRole systemUserRole = new SystemUserRole(); SystemUserRole systemUserRole = new SystemUserRole();
systemUserRole.setUserId(user.getId()); systemUserRole.setUserId(user.getUserId());
systemUserRole.setRoleId(roleId); systemUserRole.setRoleId(roleId);
return systemUserRole; return systemUserRole;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
...@@ -183,13 +182,12 @@ public class UserController { ...@@ -183,13 +182,12 @@ public class UserController {
List<SystemUser> users = userInfoService.list(systemUserQueryWrapper); List<SystemUser> users = userInfoService.list(systemUserQueryWrapper);
List<ReqUserInfo> resUsers = users.stream().map(user -> { List<ReqUserInfo> resUsers = users.stream().map(user -> {
ReqUserInfo userInfo = new ReqUserInfo(); ReqUserInfo userInfo = new ReqUserInfo();
userInfo.setId(user.getId()); userInfo.setId(user.getUserId());
userInfo.setName(user.getRealName()); userInfo.setName(user.getRealName());
userInfo.setAccount(user.getAccount()); userInfo.setAccount(user.getAccount());
userInfo.setEnable(user.getUserStatus()); userInfo.setEnable(user.getUserStatus());
userInfo.setAvatar(user.getAvatar()); userInfo.setAvatar(user.getAvatar());
userInfo.setGender(Gender.MAN.getCode().equals(user.getGender()) ? Gender.MAN.getDesc() : Gender.WOMAN.getDesc()); userInfo.setGender(Gender.MAN.getCode().equals(user.getGender()) ? Gender.MAN.getDesc() : Gender.WOMAN.getDesc());
userInfo.setMarketerCode(user.getMarketerCode());
return userInfo; return userInfo;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return Result.success(resUsers); return Result.success(resUsers);
......
...@@ -11,7 +11,7 @@ import java.util.List; ...@@ -11,7 +11,7 @@ import java.util.List;
/** /**
* @author hubin * @author hubin
*/ */
@FeignClient("ltc-SYSTEM-ADMIN-SERVICE") @FeignClient("LTC-SYSTEM-ADMIN-SERVICE")
public interface SystemAdminFeignService { public interface SystemAdminFeignService {
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment