Commit 7b5813bb by guojuxing

角色菜单权限接口

parent 12fae90c
......@@ -219,8 +219,8 @@
a.user_name userName,
a.phone_number phoneNumber,
a.phone_area_code phoneAreaCode,
GROUP_CONCAT(b.role_id) userRoleIds,
GROUP_CONCAT(c.resource_id) userResourceIds
(select GROUP_CONCAT(role_name separator '/') from tab_sys_role where role_id in (GROUP_CONCAT(b.role_id))) userRoleNames,
(select GROUP_CONCAT(resource_name separator '/') from tab_sys_resource where resource_id in (GROUP_CONCAT(c.resource_id))) userResourceNames
from tab_sys_user a
left join tab_sys_user_role b on a.user_id = b.user_id
left join tab_sys_user_resource c on a.user_id = c.user_id
......
package com.gic.auth.web.controller;
import com.gic.enterprise.utils.UserDetailUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gic.auth.dto.RoleDTO;
import com.gic.auth.qo.RoleListQO;
import com.gic.auth.service.RoleApiService;
import com.gic.auth.web.vo.RoleDetailVO;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.utils.ResultControllerUtils;
@RestController
@RequestMapping("/role")
public class RoleController {
@Autowired
private RoleApiService roleApiService;
@RequestMapping("/get-detail")
public RestResponse getDetail(Integer id) {
return ResultControllerUtils.commonResultOne(roleApiService.getById(id), RoleDetailVO.class);
}
@RequestMapping("/save")
public RestResponse save(RoleDTO dto) {
dto.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
return ResultControllerUtils.commonResult(roleApiService.save(dto));
}
@RequestMapping("/update")
public RestResponse update(RoleDTO dto) {
dto.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
return ResultControllerUtils.commonResult(roleApiService.update(dto));
}
@RequestMapping("/list-role")
public RestResponse listRole(RoleListQO params) {
params.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
return ResultControllerUtils.commonResult(roleApiService.pageRole(params));
}
}
......@@ -30,8 +30,7 @@ public class UserController {
@RequestMapping("/save-or-update-user")
public RestResponse editUser(@Validated({ UserDTO.UserQoValid.class }) UserDTO userDTO) {
userDTO.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
String password = UserPasswordUtils.validPassword(userDTO.getPasswordType(), userDTO.getPassword(),
userDTO.getConfirmPassword());
String password = UserPasswordUtils.validPassword(userDTO.getPasswordType(), userDTO.getPassword());
userDTO.setPassword(UserPasswordUtils.getEncryptPassword(password));
ServiceResponse userResult;
//普通用户
......
......@@ -43,20 +43,18 @@ public class UserPasswordUtils {
* 获取密码
* @param passwordType
* @param password
* @param confirmPassword
* @return
*/
public static String validPassword(int passwordType, String password, String confirmPassword) {
public static String validPassword(int passwordType, String password) {
//加密
if (UserConstants.CREATE_AUTO == passwordType) {
//自动随机生成
return createPasswordAuto(8);
} else {
if (StringUtils.isNotBlank(password) && password.equals(confirmPassword)) {
//如果一致
if (StringUtils.isNotBlank(password)) {
return password;
} else {
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "密码不一致");
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "密码不能为空");
}
}
}
......
package com.gic.auth.web.vo;
import java.io.Serializable;
/**
* 角色详情
* @ClassName: RoleDetailVO

* @Description: 

* @author guojuxing

* @date 2019/9/3 2:54 PM

*/
public class RoleDetailVO implements Serializable{
private static final long serialVersionUID = 18646904997204432L;
/**
* id
*/
private Integer roleId;
/**
* 管理员角色名称
*/
private Integer roleName;
/**
* 菜单ID,多个时,用英文逗号隔开
*/
private String menuIds;
public Integer getRoleId() {
return roleId;
}
public void setRoleId(Integer roleId) {
this.roleId = roleId;
}
public Integer getRoleName() {
return roleName;
}
public void setRoleName(Integer roleName) {
this.roleName = roleName;
}
public String getMenuIds() {
return menuIds;
}
public void setMenuIds(String menuIds) {
this.menuIds = menuIds;
}
}
......@@ -50,6 +50,11 @@ public class UserDetailVO implements Serializable{
*/
private String userResourceIds;
/**
* 1:自动生成 2:自定义密码
*/
private Integer passwordType;
public Integer getUserId() {
return userId;
}
......@@ -113,4 +118,12 @@ public class UserDetailVO implements Serializable{
public void setUserResourceIds(String userResourceIds) {
this.userResourceIds = userResourceIds;
}
public Integer getPasswordType() {
return passwordType;
}
public void setPasswordType(Integer passwordType) {
this.passwordType = passwordType;
}
}
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