From 07a9a8273e72737c0418d2afdba7eb28c78cde3d Mon Sep 17 00:00:00 2001 From: "wangiegie@gmail.com" Date: Sun, 4 Feb 2018 22:32:21 +0800 Subject: [PATCH] =?UTF-8?q?add:=E8=A7=92=E8=89=B2=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=83=A8=E9=97=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pig/common/constant/MqQueueConstant.java | 5 +++ .../java/com/github/pig/common/vo/UserVo.java | 25 ++++++++++++ .../pig/admin/common/config/RabbitConfig.java | 6 +++ .../pig/admin/controller/RoleController.java | 9 ++--- .../pig/admin/controller/UserController.java | 4 +- .../pig/admin/mapper/SysRoleMapper.java | 8 ++++ .../pig/admin/mapper/SysUserMapper.java | 7 ++++ .../github/pig/admin/model/dto/UserDto.java | 3 ++ .../pig/admin/model/entity/SysUser.java | 28 +++++++++++--- .../pig/admin/service/SysRoleService.java | 9 +++++ .../pig/admin/service/SysUserService.java | 7 ++++ .../service/impl/SysRoleServiceImpl.java | 13 +++++++ .../service/impl/SysUserServiceImpl.java | 11 ++++++ .../main/resources/mapper/SysRoleMapper.xml | 12 ++++++ .../main/resources/mapper/SysUserMapper.xml | 38 ++++++++++++++++++- 15 files changed, 171 insertions(+), 14 deletions(-) diff --git a/pig-common/src/main/java/com/github/pig/common/constant/MqQueueConstant.java b/pig-common/src/main/java/com/github/pig/common/constant/MqQueueConstant.java index c6236a25..0aa71e47 100644 --- a/pig-common/src/main/java/com/github/pig/common/constant/MqQueueConstant.java +++ b/pig-common/src/main/java/com/github/pig/common/constant/MqQueueConstant.java @@ -20,4 +20,9 @@ public interface MqQueueConstant { * 服务状态队列 */ String SERVICE_STATUS_CHANGE = "service_status_change"; + + /** + * zipkin 队列 + */ + String ZIPLIN_NAME_QUEUE = "zipkin"; } diff --git a/pig-common/src/main/java/com/github/pig/common/vo/UserVo.java b/pig-common/src/main/java/com/github/pig/common/vo/UserVo.java index abfc342a..d639b539 100644 --- a/pig-common/src/main/java/com/github/pig/common/vo/UserVo.java +++ b/pig-common/src/main/java/com/github/pig/common/vo/UserVo.java @@ -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; + } } diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/common/config/RabbitConfig.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/common/config/RabbitConfig.java index b07858fc..53a57a46 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/common/config/RabbitConfig.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/common/config/RabbitConfig.java @@ -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); + } } diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/controller/RoleController.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/controller/RoleController.java index 10da99df..ac3a6da4 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/controller/RoleController.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/controller/RoleController.java @@ -71,13 +71,12 @@ public class RoleController extends BaseController { /** * 获取角色列表 * + * @param deptId 部门ID * @return 角色列表 */ - @GetMapping("/roleList") - public List roleList() { - SysRole condition = new SysRole(); - condition.setDelFlag(CommonConstant.STATUS_NORMAL); - return sysRoleService.selectList(new EntityWrapper<>(condition)); + @GetMapping("/roleList/{deptId}") + public List roleList(@PathVariable Integer deptId) { + return sysRoleService.selectListByDeptId(deptId); } diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/controller/UserController.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/controller/UserController.java index 667068cf..f4c62ae1 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/controller/UserController.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/controller/UserController.java @@ -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); } /** diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysRoleMapper.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysRoleMapper.java index 46d33a77..31afd4f1 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysRoleMapper.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysRoleMapper.java @@ -24,4 +24,12 @@ public interface SysRoleMapper extends BaseMapper { * @return List */ List selectRolePage(Query query, Map condition); + + /** + * 通过部门ID查询角色列表 + * + * @param deptId 部门ID + * @return 角色列表 + */ + List selectListByDeptId(Integer deptId); } \ No newline at end of file diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysUserMapper.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysUserMapper.java index a6448364..dbcfac77 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysUserMapper.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/mapper/SysUserMapper.java @@ -49,4 +49,11 @@ public interface SysUserMapper extends BaseMapper { * @return userVo */ UserVo selectUserVoByOpenId(String openId); + + /** + * 通过ID查询用户信息 + * @param id 用户ID + * @return userVo + */ + UserVo selectUserVoById(Integer id); } \ No newline at end of file diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/model/dto/UserDto.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/model/dto/UserDto.java index a1193f96..914ab30a 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/model/dto/UserDto.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/model/dto/UserDto.java @@ -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; } + } diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/model/entity/SysUser.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/model/entity/SysUser.java index 2bdb2145..7b838cbd 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/model/entity/SysUser.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/model/entity/SysUser.java @@ -62,6 +62,11 @@ public class SysUser extends Model { */ private String avatar; + /** + * 部门ID + */ + @TableField("dept_id") + private Integer deptId; public Integer getUserId() { @@ -141,16 +146,27 @@ public class SysUser extends Model { 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 + + '}'; } } diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/SysRoleService.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/SysRoleService.java index 6448386e..b176a657 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/SysRoleService.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/SysRoleService.java @@ -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; + /** *

* 服务类 @@ -40,4 +42,11 @@ public interface SysRoleService extends IService { * @return 成功、失败 */ Boolean updateRoleById(RoleDto roleDto); + + /** + * 通过部门ID查询角色列表 + * @param deptId 部门ID + * @return 角色列表 + */ + List selectListByDeptId(Integer deptId); } diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/SysUserService.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/SysUserService.java index 3a0c1882..55d0e407 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/SysUserService.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/SysUserService.java @@ -86,4 +86,11 @@ public interface SysUserService extends IService { * @return 用户信息 */ UserVo findUserByOpenId(String openId); + + /** + * 通过ID查询用户信息 + * @param id 用户ID + * @return 用户信息 + */ + UserVo selectUserVoById(Integer id); } diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysRoleServiceImpl.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysRoleServiceImpl.java index 688b217b..6647ad89 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysRoleServiceImpl.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysRoleServiceImpl.java @@ -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; + /** *

* 服务实现类 @@ -87,4 +89,15 @@ public class SysRoleServiceImpl extends ServiceImpl impl sysRoleDeptMapper.insert(roleDept); return true; } + + /** + * 通过部门ID查询角色列表 + * + * @param deptId 部门ID + * @return 角色列表 + */ + @Override + public List selectListByDeptId(Integer deptId) { + return sysRoleMapper.selectListByDeptId(deptId); + } } diff --git a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysUserServiceImpl.java b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysUserServiceImpl.java index 055420ea..e193ee9a 100644 --- a/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysUserServiceImpl.java +++ b/pig-modules/pig-upms-service/src/main/java/com/github/pig/admin/service/impl/SysUserServiceImpl.java @@ -113,6 +113,17 @@ public class SysUserServiceImpl extends ServiceImpl impl return query; } + /** + * 通过ID查询用户信息 + * + * @param id 用户ID + * @return 用户信息 + */ + @Override + public UserVo selectUserVoById(Integer id) { + return sysUserMapper.selectUserVoById(id); + } + /** * 保存用户验证码,和randomStr绑定 * diff --git a/pig-modules/pig-upms-service/src/main/resources/mapper/SysRoleMapper.xml b/pig-modules/pig-upms-service/src/main/resources/mapper/SysRoleMapper.xml index e4fbb26e..9bb23518 100644 --- a/pig-modules/pig-upms-service/src/main/resources/mapper/SysRoleMapper.xml +++ b/pig-modules/pig-upms-service/src/main/resources/mapper/SysRoleMapper.xml @@ -36,4 +36,16 @@ WHERE r.del_flag = 0 ORDER BY r.role_id ASC + diff --git a/pig-modules/pig-upms-service/src/main/resources/mapper/SysUserMapper.xml b/pig-modules/pig-upms-service/src/main/resources/mapper/SysUserMapper.xml index b5777d8a..d27a8a1d 100644 --- a/pig-modules/pig-upms-service/src/main/resources/mapper/SysUserMapper.xml +++ b/pig-modules/pig-upms-service/src/main/resources/mapper/SysUserMapper.xml @@ -9,6 +9,7 @@ + @@ -25,6 +26,8 @@ + + @@ -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} + +