diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/RolePermissionController.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/RolePermissionController.java index f869fd25..dda29a6e 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/RolePermissionController.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/RolePermissionController.java @@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; +import javax.validation.Valid; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -89,7 +90,7 @@ public class RolePermissionController { */ @Transactional @PostMapping("/saveRolePermission") - public ResponseResult saveRolePermission(@RequestBody RolePermissionRequest rolePermission) { + public ResponseResult saveRolePermission(@Valid @RequestBody RolePermissionRequest rolePermission) { Date date = new Date(); rolePermission.setCreateTime(date); rolePermission.setMotifyTime(date); @@ -122,7 +123,7 @@ public class RolePermissionController { */ @Transactional @PostMapping("/updateRolePermission") - public ResponseResult updateRolePermission(@RequestBody RolePermissionRequest rolePermission) { + public ResponseResult updateRolePermission(@Valid @RequestBody RolePermissionRequest rolePermission) { Date date = new Date(); rolePermission.setMotifyTime(date); //根据角色Id修改角色内容 diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java index 21bdab41..da6c2327 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java @@ -127,10 +127,12 @@ public class UserLoginController implements UserLoginControllerApi { if("STATE".equals(state)){ UserEntity user = userService.saveWeChatUser(code,response); if(user != null){ - long times = 86400; +/* long times = 86400; //生成jwt String token = JwtUtils.createJWT(user.getId()+"","token", times); - RedisUtil.setEx("dq:token:"+token,String.valueOf(user.getId()),times); + RedisUtil.setEx("dq:token:"+token,String.valueOf(user.getId()),times);*/ + + String token = user.getToken(); // state 当前用户的页面地址,需要拼接 http:// 这样才不会站内跳转 response.sendRedirect("http://www.huorantech.cn/dq/index.html#/Dashboard?token="+token); //response.sendRedirect(state+"?token="+token+"&head_img="+user.getHeadImg()+"&name="+URLEncoder.encode(user.getName(),"UTF-8")); diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/handle/AdminAuthenticationProvider.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/handle/AdminAuthenticationProvider.java index efc951ae..7842e8fe 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/handle/AdminAuthenticationProvider.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/handle/AdminAuthenticationProvider.java @@ -72,6 +72,10 @@ public class AdminAuthenticationProvider implements AuthenticationProvider { userMapper.updateById(user); userInfo.getCurrentUserInfo().setToken(token);*/ + //根据id查询员工信息 + Long id = userInfo.getCurrentUserInfo().getId(); + + userInfo.getCurrentUserInfo().setToken(data.getToken()); return new UsernamePasswordAuthenticationToken(userInfo, password, userInfo.getAuthorities()); } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java index 909a0e91..2305b20f 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java @@ -126,7 +126,8 @@ public class UserLoginServiceImpl extends ServiceImpl }else {//微信登录 if(userEntity == null){ - return ResponseResult.FAIL(CommonCode.USER_IS_NOT_EXIST.code(), CommonCode.USER_IS_NOT_EXIST.message()); + throw new UsernameNotFoundException("用户不存在或已禁用!"); + //return ResponseResult.FAIL(CommonCode.USER_IS_NOT_EXIST.code(), CommonCode.USER_IS_NOT_EXIST.message()); } } //登录成功,token生成 diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserServiceImpl.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserServiceImpl.java index 03e2e4fe..7629deb6 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserServiceImpl.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserServiceImpl.java @@ -74,10 +74,13 @@ public class UserServiceImpl extends ServiceImpl imple ResponseResult login = userLoginService.login(loginRequest); LoginResponse data = (LoginResponse) login.getData(); -// SecurityUser userInfo = (SecurityUser) userDetailsService.loadUserByUsername(dbUser.getPhoneAccount()); -// -// userInfo.getCurrentUserInfo().setToken(data.getToken()); -// new UsernamePasswordAuthenticationToken(userInfo, null, userInfo.getAuthorities()); + log.info("token========================"+data.getToken()); + dbUser.setToken(data.getToken()); + +/* SecurityUser userInfo = (SecurityUser) userDetailsService.loadUserByUsername(dbUser.getPhoneAccount()); + + userInfo.getCurrentUserInfo().setToken(data.getToken()); + new UsernamePasswordAuthenticationToken(userInfo, null, userInfo.getAuthorities());*/ return dbUser; } diff --git a/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/RolePermissionMapper.xml b/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/RolePermissionMapper.xml index 9be358d9..0ecf4749 100644 --- a/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/RolePermissionMapper.xml +++ b/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/RolePermissionMapper.xml @@ -59,15 +59,13 @@ UPDATE hrms_role - + `name`=#{name}, - - + description=#{description}, - - + motify_time=#{motifyTime}, - + WHERE id = #{roleId} diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/UserEntity.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/UserEntity.java index cb5b163b..dd65e7f7 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/UserEntity.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/UserEntity.java @@ -95,5 +95,9 @@ public class UserEntity implements Serializable { * 盐值 */ //private String salt; + /** + * 头像地址 + */ + //private String headPortaritUrl; } diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/RolePermissionRequest.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/RolePermissionRequest.java index c43e8dbf..49964b7f 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/RolePermissionRequest.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/RolePermissionRequest.java @@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Date; import java.util.List; @@ -48,6 +51,7 @@ public class RolePermissionRequest implements Serializable { /** * 权限ids */ + @NotEmpty(message = "权限至少选中一项!") private Long[] permissionIds; private Long permissionId;