add:角色管理部门

This commit is contained in:
wangiegie@gmail.com 2018-02-04 22:32:21 +08:00
parent e995b47378
commit 07a9a8273e
15 changed files with 171 additions and 14 deletions

View File

@ -20,4 +20,9 @@ public interface MqQueueConstant {
* 服务状态队列
*/
String SERVICE_STATUS_CHANGE = "service_status_change";
/**
* zipkin 队列
*/
String ZIPLIN_NAME_QUEUE = "zipkin";
}

View File

@ -49,6 +49,15 @@ public class UserVo implements Serializable {
*/
private String avatar;
/**
* 部门ID
*/
private Integer deptId;
/**
* 部门名称
*/
private String deptName;
/**
* 角色列表
*/
@ -133,4 +142,20 @@ public class UserVo implements Serializable {
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public Integer getDeptId() {
return deptId;
}
public void setDeptId(Integer deptId) {
this.deptId = deptId;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
}

View File

@ -34,10 +34,16 @@ public class RabbitConfig {
/**
* 初始化服务状态改变队列
*
* @return
*/
@Bean
public Queue initServiceStatusChangeQueue() {
return new Queue(MqQueueConstant.SERVICE_STATUS_CHANGE);
}
@Bean
public Queue initZipkinQueue() {
return new Queue(MqQueueConstant.ZIPLIN_NAME_QUEUE);
}
}

View File

@ -71,13 +71,12 @@ public class RoleController extends BaseController {
/**
* 获取角色列表
*
* @param deptId 部门ID
* @return 角色列表
*/
@GetMapping("/roleList")
public List<SysRole> roleList() {
SysRole condition = new SysRole();
condition.setDelFlag(CommonConstant.STATUS_NORMAL);
return sysRoleService.selectList(new EntityWrapper<>(condition));
@GetMapping("/roleList/{deptId}")
public List<SysRole> roleList(@PathVariable Integer deptId) {
return sysRoleService.selectListByDeptId(deptId);
}

View File

@ -62,8 +62,8 @@ public class UserController extends BaseController {
* @return 用户信息
*/
@GetMapping("/{id}")
public SysUser user(@PathVariable Integer id) {
return userService.selectById(id);
public UserVo user(@PathVariable Integer id) {
return userService.selectUserVoById(id);
}
/**

View File

@ -24,4 +24,12 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
* @return List
*/
List<Object> selectRolePage(Query<Object> query, Map<String, Object> condition);
/**
* 通过部门ID查询角色列表
*
* @param deptId 部门ID
* @return 角色列表
*/
List<SysRole> selectListByDeptId(Integer deptId);
}

View File

@ -49,4 +49,11 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @return userVo
*/
UserVo selectUserVoByOpenId(String openId);
/**
* 通过ID查询用户信息
* @param id 用户ID
* @return userVo
*/
UserVo selectUserVoById(Integer id);
}

View File

@ -12,6 +12,8 @@ public class UserDto extends SysUser {
*/
private Integer role;
private Integer deptId;
/**
* 新密码
*/
@ -32,4 +34,5 @@ public class UserDto extends SysUser {
public void setNewpassword1(String newpassword1) {
this.newpassword1 = newpassword1;
}
}

View File

@ -62,6 +62,11 @@ public class SysUser extends Model<SysUser> {
*/
private String avatar;
/**
* 部门ID
*/
@TableField("dept_id")
private Integer deptId;
public Integer getUserId() {
@ -141,16 +146,27 @@ public class SysUser extends Model<SysUser> {
this.avatar = avatar;
}
public Integer getDeptId() {
return deptId;
}
public void setDeptId(Integer deptId) {
this.deptId = deptId;
}
@Override
public String toString() {
return "SysUser{" +
", userId=" + userId +
", username=" + username +
", password=" + password +
", salt=" + salt +
"userId=" + userId +
", username='" + username + '\'' +
", password='" + password + '\'' +
", salt='" + salt + '\'' +
", createTime=" + createTime +
", updateTime=" + updateTime +
", delFlag=" + delFlag +
"}";
", delFlag='" + delFlag + '\'' +
", introduction='" + introduction + '\'' +
", avatar='" + avatar + '\'' +
", deptId=" + deptId +
'}';
}
}

View File

@ -7,6 +7,8 @@ import com.github.pig.admin.model.dto.RoleDto;
import com.github.pig.admin.model.entity.SysRole;
import com.github.pig.common.util.Query;
import java.util.List;
/**
* <p>
* 服务类
@ -40,4 +42,11 @@ public interface SysRoleService extends IService<SysRole> {
* @return 成功失败
*/
Boolean updateRoleById(RoleDto roleDto);
/**
* 通过部门ID查询角色列表
* @param deptId 部门ID
* @return 角色列表
*/
List<SysRole> selectListByDeptId(Integer deptId);
}

View File

@ -86,4 +86,11 @@ public interface SysUserService extends IService<SysUser> {
* @return 用户信息
*/
UserVo findUserByOpenId(String openId);
/**
* 通过ID查询用户信息
* @param id 用户ID
* @return 用户信息
*/
UserVo selectUserVoById(Integer id);
}

View File

@ -15,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* <p>
* 服务实现类
@ -87,4 +89,15 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
sysRoleDeptMapper.insert(roleDept);
return true;
}
/**
* 通过部门ID查询角色列表
*
* @param deptId 部门ID
* @return 角色列表
*/
@Override
public List<SysRole> selectListByDeptId(Integer deptId) {
return sysRoleMapper.selectListByDeptId(deptId);
}
}

View File

@ -113,6 +113,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return query;
}
/**
* 通过ID查询用户信息
*
* @param id 用户ID
* @return 用户信息
*/
@Override
public UserVo selectUserVoById(Integer id) {
return sysUserMapper.selectUserVoById(id);
}
/**
* 保存用户验证码和randomStr绑定
*

View File

@ -36,4 +36,16 @@
WHERE r.del_flag = 0
ORDER BY r.role_id ASC
</select>
<select id="selectListByDeptId" resultMap="BaseResultMap">
SELECT
r.role_id,
r.role_name,
r.role_code,
r.role_desc,
r.create_time,
r.update_time,
r.del_flag
FROM sys_role r LEFT OUTER JOIN sys_role_dept rd ON rd.role_id = r.role_id
WHERE rd.dept_id = #{deptId}
</select>
</mapper>

View File

@ -9,6 +9,7 @@
<result column="introduction" property="introduction" />
<result column="avatar" property="avatar" />
<result column="salt" property="salt"/>
<result column="dept_id" property="deptId"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="del_flag" property="delFlag"/>
@ -25,6 +26,8 @@
<result column="ucreate_time" property="createTime"/>
<result column="uupdate_time" property="updateTime"/>
<result column="udel_flag" property="delFlag"/>
<result column="deptId" property="deptId"/>
<result column="deptName" property="deptName"/>
<collection property="roleList" ofType="com.github.pig.common.vo.SysRole">
<id column="role_id" property="roleId" />
<result column="role_name" property="roleName" />
@ -43,9 +46,11 @@
`user`.salt,
`user`.introduction,
`user`.avatar,
`user`.dept_id,
`user`.create_time AS ucreate_time,
`user`.update_time AS uupdate_time,
`user`.del_flag AS udel_flag,
`user`.dept_id AS deptId,
r.role_id,
r.role_name,
r.role_code,
@ -73,6 +78,34 @@
WHERE `user`.salt = #{openId}
</select>
<select id="selectUserVoById" resultMap="userVoResultMap">
SELECT
`user`.user_id,
`user`.username,
`user`.`password`,
`user`.salt,
`user`.introduction,
`user`.avatar,
`user`.create_time AS create_time,
`user`.update_time AS uupdate_time,
`user`.del_flag AS udel_flag,
r.role_id,
r.role_name,
r.role_code,
r.role_desc,
r.create_time AS rcreate_time,
r.update_time AS rupdate_time,
d.name AS deptName,
d.dept_id AS deptId
FROM
sys_user AS `user`
LEFT JOIN sys_user_role AS ur ON ur.user_id = `user`.user_id
LEFT JOIN sys_role AS r ON r.role_id = ur.role_id
LEFT JOIN sys_dept AS d ON d.dept_id = `user`.dept_id
WHERE
`user`.user_id = #{id}
</select>
<select id="selectUserVoPage" resultMap="userVoResultMap" >
SELECT
`user`.user_id,
@ -89,11 +122,14 @@
r.role_code,
r.role_desc,
r.create_time AS rcreate_time,
r.update_time AS rupdate_time
r.update_time AS rupdate_time,
d.name AS deptName,
d.dept_id AS deptId
FROM
sys_user AS `user`
LEFT JOIN sys_user_role AS ur ON ur.user_id = `user`.user_id
LEFT JOIN sys_role AS r ON r.role_id = ur.role_id
LEFT JOIN sys_dept AS d ON d.dept_id = `user`.dept_id
WHERE
r.del_flag = 0
<if test="username != null and username != ''">