feat;增加角色模块
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.tiesheng.role;
|
||||
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@ComponentScan({
|
||||
"com.tiesheng.role.**.*",
|
||||
})
|
||||
@MapperScan("com.tiesheng.role.mapper")
|
||||
public class RoleAutoConfigurer {
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package com.tiesheng.role.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
|
||||
import com.tiesheng.role.pojos.dao.CoreRoleGroup;
|
||||
import com.tiesheng.role.pojos.dao.CoreRoleServer;
|
||||
import com.tiesheng.role.pojos.dao.CoreRoleUser;
|
||||
import com.tiesheng.role.pojos.dto.ServiceDTO;
|
||||
import com.tiesheng.role.pojos.vo.GroupTypeDTO;
|
||||
import com.tiesheng.role.pojos.vo.RoleUserPageVO;
|
||||
import com.tiesheng.role.pojos.vo.ServiceMenuVO;
|
||||
import com.tiesheng.role.service.CoreRoleService;
|
||||
import com.tiesheng.role.service.CoreServerService;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.util.pojos.IdDTO;
|
||||
import com.tiesheng.util.pojos.PageDTO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/role")
|
||||
public class RoleController {
|
||||
|
||||
@Resource
|
||||
CoreServerService coreServerService;
|
||||
@Resource
|
||||
CoreRoleService coreRoleService;
|
||||
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/group/list")
|
||||
public ApiResp<List<CoreRoleGroup>> groupList(@Valid GroupTypeDTO dto) {
|
||||
return ApiResp.respOK(coreRoleService.list(
|
||||
new QueryWrapper<CoreRoleGroup>()
|
||||
.eq("type", dto.getType())
|
||||
.orderByAsc("sort")
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 角色编辑
|
||||
*
|
||||
* @param roleGroup
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/group/update")
|
||||
public ApiResp<String> groupUpdate(@RequestBody CoreRoleGroup roleGroup) {
|
||||
|
||||
if (StrUtil.isNotEmpty(roleGroup.getId())) {
|
||||
roleGroup.setType(null);
|
||||
roleGroup.setIsSystem(null);
|
||||
}
|
||||
|
||||
coreRoleService.saveOrUpdate(roleGroup);
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 角色-删除
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/group/deleted")
|
||||
public ApiResp<String> groupDeleted(@RequestBody @Valid IdDTO dto) {
|
||||
|
||||
CoreRoleGroup byId = coreRoleService.getById(dto.getId());
|
||||
if (byId == null || byId.getIsDeleted() != 0) {
|
||||
throw new ApiException("角色不存在或已删除");
|
||||
}
|
||||
|
||||
if (byId.getIsSystem() == 1) {
|
||||
throw new ApiException(StrUtil.format("该{}无法删除",
|
||||
Objects.equals(byId.getType(), "role") ? "角色" : "职位"));
|
||||
}
|
||||
|
||||
CoreRoleGroup coreServiceMenu = new CoreRoleGroup();
|
||||
coreServiceMenu.setId(dto.getId());
|
||||
coreServiceMenu.setIsDeleted(1);
|
||||
coreRoleService.updateById(coreServiceMenu);
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 授权列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/user/page")
|
||||
public ApiResp<List<RoleUserPageVO>> userPage(PageDTO dto) {
|
||||
|
||||
QueryWrapper<CoreRoleUser> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("cru.is_deleted", 0);
|
||||
dto.likeColumns(queryWrapper, "cru.ext1", "cru.ext2", "cru.ext3");
|
||||
queryWrapper.orderByAsc("cru.user_id");
|
||||
|
||||
Page<RoleUserPageVO> page = dto.pageObj();
|
||||
coreRoleService.getUserMapper().page(page, queryWrapper);
|
||||
|
||||
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 授权调整
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/user/update")
|
||||
public ApiResp<String> userUpdate(@RequestBody CoreRoleUser roleUser) {
|
||||
if (StrUtil.isNotEmpty(roleUser.getId())) {
|
||||
coreRoleService.getUserMapper().updateById(roleUser);
|
||||
} else {
|
||||
coreRoleService.getUserMapper().insert(roleUser);
|
||||
}
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 授权-删除
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/user/deleted")
|
||||
public ApiResp<String> userDeleted(@RequestBody @Valid IdDTO dto) {
|
||||
CoreRoleUser coreRoleUser = new CoreRoleUser();
|
||||
coreRoleUser.setId(dto.getId());
|
||||
coreRoleUser.setIsDeleted(1);
|
||||
coreRoleService.getUserMapper().updateById(coreRoleUser);
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取服务列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/server/list")
|
||||
public ApiResp<List<CoreRoleServer>> list() {
|
||||
return ApiResp.respOK(coreServerService.list());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改服务
|
||||
*
|
||||
* @param coreService
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/server/update")
|
||||
public ApiResp<String> update(@RequestBody CoreRoleServer coreService) {
|
||||
coreServerService.saveOrUpdate(coreService);
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 权限-列出
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/authority/list")
|
||||
public ApiResp<List<ServiceMenuVO>> menuList(@Valid ServiceDTO dto) {
|
||||
|
||||
List<CoreRoleAuthority> list = coreServerService.getAuthorityMapper().selectList(new QueryWrapper<CoreRoleAuthority>()
|
||||
.eq(CoreRoleAuthority.IS_DELETED, 0)
|
||||
.eq("service", dto.getService())
|
||||
.orderByAsc("sort")
|
||||
);
|
||||
|
||||
List<ServiceMenuVO> collect = coreServerService.menuWrap(list, null);
|
||||
|
||||
return ApiResp.respOK(collect);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 权限-编辑
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/authority/update")
|
||||
public ApiResp<String> menuUpdate(@RequestBody CoreRoleAuthority serviceMenu) {
|
||||
if (StrUtil.isEmpty(serviceMenu.getId())) {
|
||||
coreServerService.getAuthorityMapper().insert(serviceMenu);
|
||||
} else {
|
||||
serviceMenu.setNo(null);
|
||||
coreServerService.getAuthorityMapper().updateById(serviceMenu);
|
||||
}
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tiesheng.role.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
|
||||
|
||||
public interface CoreRoleAuthorityMapper extends BaseMapper<CoreRoleAuthority> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tiesheng.role.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tiesheng.role.pojos.dao.CoreRoleGroup;
|
||||
|
||||
public interface CoreRoleGroupMapper extends BaseMapper<CoreRoleGroup> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tiesheng.role.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tiesheng.role.pojos.dao.CoreRoleServer;
|
||||
|
||||
public interface CoreRoleServerMapper extends BaseMapper<CoreRoleServer> {
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.tiesheng.role.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.tiesheng.role.pojos.dao.CoreRoleUser;
|
||||
import com.tiesheng.role.pojos.vo.RoleUserPageVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface CoreRoleUserMapper extends BaseMapper<CoreRoleUser> {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page
|
||||
* @param wrapper
|
||||
* @return
|
||||
*/
|
||||
Page<RoleUserPageVO> page(Page<RoleUserPageVO> page, @Param("ew") QueryWrapper<CoreRoleUser> wrapper);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,350 @@
|
||||
package com.tiesheng.role.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 角色-权限
|
||||
*/
|
||||
@TableName(value = "core_role_authority")
|
||||
public class CoreRoleAuthority extends DaoBase {
|
||||
/**
|
||||
* 服务
|
||||
*/
|
||||
@TableField(value = "service")
|
||||
private String service;
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableField(value = "`no`")
|
||||
private String no;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField(value = "`name`")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField(value = "sort")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 层级
|
||||
*/
|
||||
@TableField(value = "`level`")
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 父类ID
|
||||
*/
|
||||
@TableField(value = "parent")
|
||||
private String parent;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
@TableField(value = "remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@TableField(value = "is_open")
|
||||
private Integer isOpen;
|
||||
|
||||
/**
|
||||
* 类型:group-分组,menu-菜单项,point-点
|
||||
*/
|
||||
@TableField(value = "`type`")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 跳转地址
|
||||
*/
|
||||
@TableField(value = "link")
|
||||
private String link;
|
||||
|
||||
/**
|
||||
* 平台:ding、web、mobile等
|
||||
*/
|
||||
@TableField(value = "platform")
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* 扩展1
|
||||
*/
|
||||
@TableField(value = "ext1")
|
||||
private String ext1;
|
||||
|
||||
/**
|
||||
* 扩展2
|
||||
*/
|
||||
@TableField(value = "ext2")
|
||||
private String ext2;
|
||||
|
||||
/**
|
||||
* 扩展3
|
||||
*/
|
||||
@TableField(value = "ext3")
|
||||
private String ext3;
|
||||
|
||||
/**
|
||||
* 获取服务
|
||||
*
|
||||
* @return service - 服务
|
||||
*/
|
||||
public String getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置服务
|
||||
*
|
||||
* @param service 服务
|
||||
*/
|
||||
public void setService(String service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取编号
|
||||
*
|
||||
* @return no - 编号
|
||||
*/
|
||||
public String getNo() {
|
||||
return no;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置编号
|
||||
*
|
||||
* @param no 编号
|
||||
*/
|
||||
public void setNo(String no) {
|
||||
this.no = no;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取名称
|
||||
*
|
||||
* @return name - 名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置名称
|
||||
*
|
||||
* @param name 名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取排序
|
||||
*
|
||||
* @return sort - 排序
|
||||
*/
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置排序
|
||||
*
|
||||
* @param sort 排序
|
||||
*/
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取层级
|
||||
*
|
||||
* @return level - 层级
|
||||
*/
|
||||
public Integer getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置层级
|
||||
*
|
||||
* @param level 层级
|
||||
*/
|
||||
public void setLevel(Integer level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取父类ID
|
||||
*
|
||||
* @return parent - 父类ID
|
||||
*/
|
||||
public String getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置父类ID
|
||||
*
|
||||
* @param parent 父类ID
|
||||
*/
|
||||
public void setParent(String parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取说明
|
||||
*
|
||||
* @return remark - 说明
|
||||
*/
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置说明
|
||||
*
|
||||
* @param remark 说明
|
||||
*/
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否启用
|
||||
*
|
||||
* @return is_open - 是否启用
|
||||
*/
|
||||
public Integer getIsOpen() {
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否启用
|
||||
*
|
||||
* @param isOpen 是否启用
|
||||
*/
|
||||
public void setIsOpen(Integer isOpen) {
|
||||
this.isOpen = isOpen;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型:group-分组,menu-菜单项,point-点
|
||||
*
|
||||
* @return type - 类型:group-分组,menu-菜单项,point-点
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置类型:group-分组,menu-菜单项,point-点
|
||||
*
|
||||
* @param type 类型:group-分组,menu-菜单项,point-点
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取跳转地址
|
||||
*
|
||||
* @return link - 跳转地址
|
||||
*/
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置跳转地址
|
||||
*
|
||||
* @param link 跳转地址
|
||||
*/
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取平台:ding、web、mobile等
|
||||
*
|
||||
* @return platform - 平台:ding、web、mobile等
|
||||
*/
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置平台:ding、web、mobile等
|
||||
*
|
||||
* @param platform 平台:ding、web、mobile等
|
||||
*/
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展1
|
||||
*
|
||||
* @return ext1 - 扩展1
|
||||
*/
|
||||
public String getExt1() {
|
||||
return ext1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展1
|
||||
*
|
||||
* @param ext1 扩展1
|
||||
*/
|
||||
public void setExt1(String ext1) {
|
||||
this.ext1 = ext1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展2
|
||||
*
|
||||
* @return ext2 - 扩展2
|
||||
*/
|
||||
public String getExt2() {
|
||||
return ext2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展2
|
||||
*
|
||||
* @param ext2 扩展2
|
||||
*/
|
||||
public void setExt2(String ext2) {
|
||||
this.ext2 = ext2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展3
|
||||
*
|
||||
* @return ext3 - 扩展3
|
||||
*/
|
||||
public String getExt3() {
|
||||
return ext3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展3
|
||||
*
|
||||
* @param ext3 扩展3
|
||||
*/
|
||||
public void setExt3(String ext3) {
|
||||
this.ext3 = ext3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
package com.tiesheng.role.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 角色-分组
|
||||
*/
|
||||
@TableName(value = "core_role_group")
|
||||
public class CoreRoleGroup extends DaoBase {
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField(value = "`name`")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
@TableField(value = "remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 类型:role-角色,job-职位
|
||||
*/
|
||||
@TableField(value = "`type`")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 是否系统
|
||||
*/
|
||||
@TableField(value = "is_system")
|
||||
private Integer isSystem;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField(value = "sort")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 扩展1
|
||||
*/
|
||||
@TableField(value = "ext1")
|
||||
private String ext1;
|
||||
|
||||
/**
|
||||
* 扩展2
|
||||
*/
|
||||
@TableField(value = "ext2")
|
||||
private String ext2;
|
||||
|
||||
/**
|
||||
* 扩展3
|
||||
*/
|
||||
@TableField(value = "ext3")
|
||||
private String ext3;
|
||||
|
||||
/**
|
||||
* 获取名称
|
||||
*
|
||||
* @return name - 名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置名称
|
||||
*
|
||||
* @param name 名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取说明
|
||||
*
|
||||
* @return remark - 说明
|
||||
*/
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置说明
|
||||
*
|
||||
* @param remark 说明
|
||||
*/
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型:role-角色,job-职位
|
||||
*
|
||||
* @return type - 类型:role-角色,job-职位
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置类型:role-角色,job-职位
|
||||
*
|
||||
* @param type 类型:role-角色,job-职位
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 是否系统
|
||||
*
|
||||
* @return is_system - 是否系统
|
||||
*/
|
||||
public Integer getIsSystem() {
|
||||
return isSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 是否系统
|
||||
*
|
||||
* @param isSystem 是否系统
|
||||
*/
|
||||
public void setIsSystem(Integer isSystem) {
|
||||
this.isSystem = isSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取排序
|
||||
*
|
||||
* @return sort - 排序
|
||||
*/
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置排序
|
||||
*
|
||||
* @param sort 排序
|
||||
*/
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展1
|
||||
*
|
||||
* @return ext1 - 扩展1
|
||||
*/
|
||||
public String getExt1() {
|
||||
return ext1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展1
|
||||
*
|
||||
* @param ext1 扩展1
|
||||
*/
|
||||
public void setExt1(String ext1) {
|
||||
this.ext1 = ext1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展2
|
||||
*
|
||||
* @return ext2 - 扩展2
|
||||
*/
|
||||
public String getExt2() {
|
||||
return ext2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展2
|
||||
*
|
||||
* @param ext2 扩展2
|
||||
*/
|
||||
public void setExt2(String ext2) {
|
||||
this.ext2 = ext2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展3
|
||||
*
|
||||
* @return ext3 - 扩展3
|
||||
*/
|
||||
public String getExt3() {
|
||||
return ext3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展3
|
||||
*
|
||||
* @param ext3 扩展3
|
||||
*/
|
||||
public void setExt3(String ext3) {
|
||||
this.ext3 = ext3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
package com.tiesheng.role.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 角色-服务
|
||||
*/
|
||||
@TableName(value = "core_role_server")
|
||||
public class CoreRoleServer extends DaoBase {
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField(value = "`name`")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
@TableField(value = "remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* logo
|
||||
*/
|
||||
@TableField(value = "logo")
|
||||
private String logo;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField(value = "sort")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@TableField(value = "is_open")
|
||||
private Integer isOpen;
|
||||
|
||||
/**
|
||||
* 跳转地址
|
||||
*/
|
||||
@TableField(value = "link")
|
||||
private String link;
|
||||
|
||||
/**
|
||||
* 扩展1
|
||||
*/
|
||||
@TableField(value = "ext1")
|
||||
private String ext1;
|
||||
|
||||
/**
|
||||
* 扩展2
|
||||
*/
|
||||
@TableField(value = "ext2")
|
||||
private String ext2;
|
||||
|
||||
/**
|
||||
* 扩展3
|
||||
*/
|
||||
@TableField(value = "ext3")
|
||||
private String ext3;
|
||||
|
||||
/**
|
||||
* 获取名称
|
||||
*
|
||||
* @return name - 名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置名称
|
||||
*
|
||||
* @param name 名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取说明
|
||||
*
|
||||
* @return remark - 说明
|
||||
*/
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置说明
|
||||
*
|
||||
* @param remark 说明
|
||||
*/
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取logo
|
||||
*
|
||||
* @return logo - logo
|
||||
*/
|
||||
public String getLogo() {
|
||||
return logo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置logo
|
||||
*
|
||||
* @param logo logo
|
||||
*/
|
||||
public void setLogo(String logo) {
|
||||
this.logo = logo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取排序
|
||||
*
|
||||
* @return sort - 排序
|
||||
*/
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置排序
|
||||
*
|
||||
* @param sort 排序
|
||||
*/
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否启用
|
||||
*
|
||||
* @return is_open - 是否启用
|
||||
*/
|
||||
public Integer getIsOpen() {
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否启用
|
||||
*
|
||||
* @param isOpen 是否启用
|
||||
*/
|
||||
public void setIsOpen(Integer isOpen) {
|
||||
this.isOpen = isOpen;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取跳转地址
|
||||
*
|
||||
* @return link - 跳转地址
|
||||
*/
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置跳转地址
|
||||
*
|
||||
* @param link 跳转地址
|
||||
*/
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展1
|
||||
*
|
||||
* @return ext1 - 扩展1
|
||||
*/
|
||||
public String getExt1() {
|
||||
return ext1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展1
|
||||
*
|
||||
* @param ext1 扩展1
|
||||
*/
|
||||
public void setExt1(String ext1) {
|
||||
this.ext1 = ext1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展2
|
||||
*
|
||||
* @return ext2 - 扩展2
|
||||
*/
|
||||
public String getExt2() {
|
||||
return ext2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展2
|
||||
*
|
||||
* @param ext2 扩展2
|
||||
*/
|
||||
public void setExt2(String ext2) {
|
||||
this.ext2 = ext2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展3
|
||||
*
|
||||
* @return ext3 - 扩展3
|
||||
*/
|
||||
public String getExt3() {
|
||||
return ext3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展3
|
||||
*
|
||||
* @param ext3 扩展3
|
||||
*/
|
||||
public void setExt3(String ext3) {
|
||||
this.ext3 = ext3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
package com.tiesheng.role.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 角色-用户
|
||||
*/
|
||||
@TableName(value = "core_role_user")
|
||||
public class CoreRoleUser extends DaoBase {
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableField(value = "user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 类型:menu-菜单,group-分组
|
||||
*/
|
||||
@TableField(value = "`type`")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 类型关联的记录ID
|
||||
*/
|
||||
@TableField(value = "type_id")
|
||||
private String typeId;
|
||||
|
||||
/**
|
||||
* 过期时间,无则不过期
|
||||
*/
|
||||
@TableField(value = "expire_time")
|
||||
private Date expireTime;
|
||||
|
||||
/**
|
||||
* 扩展1
|
||||
*/
|
||||
@TableField(value = "ext1")
|
||||
private String ext1;
|
||||
|
||||
/**
|
||||
* 扩展2
|
||||
*/
|
||||
@TableField(value = "ext2")
|
||||
private String ext2;
|
||||
|
||||
/**
|
||||
* 扩展3
|
||||
*/
|
||||
@TableField(value = "ext3")
|
||||
private String ext3;
|
||||
|
||||
/**
|
||||
* 获取用户ID
|
||||
*
|
||||
* @return user_id - 用户ID
|
||||
*/
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户ID
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型:menu-菜单,group-分组
|
||||
*
|
||||
* @return type - 类型:menu-菜单,group-分组
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置类型:menu-菜单,group-分组
|
||||
*
|
||||
* @param type 类型:menu-菜单,group-分组
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型关联的记录ID
|
||||
*
|
||||
* @return type_id - 类型关联的记录ID
|
||||
*/
|
||||
public String getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置类型关联的记录ID
|
||||
*
|
||||
* @param typeId 类型关联的记录ID
|
||||
*/
|
||||
public void setTypeId(String typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取过期时间,无则不过期
|
||||
*
|
||||
* @return expire_time - 过期时间,无则不过期
|
||||
*/
|
||||
public Date getExpireTime() {
|
||||
return expireTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置过期时间,无则不过期
|
||||
*
|
||||
* @param expireTime 过期时间,无则不过期
|
||||
*/
|
||||
public void setExpireTime(Date expireTime) {
|
||||
this.expireTime = expireTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展1
|
||||
*
|
||||
* @return ext1 - 扩展1
|
||||
*/
|
||||
public String getExt1() {
|
||||
return ext1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展1
|
||||
*
|
||||
* @param ext1 扩展1
|
||||
*/
|
||||
public void setExt1(String ext1) {
|
||||
this.ext1 = ext1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展2
|
||||
*
|
||||
* @return ext2 - 扩展2
|
||||
*/
|
||||
public String getExt2() {
|
||||
return ext2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展2
|
||||
*
|
||||
* @param ext2 扩展2
|
||||
*/
|
||||
public void setExt2(String ext2) {
|
||||
this.ext2 = ext2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展3
|
||||
*
|
||||
* @return ext3 - 扩展3
|
||||
*/
|
||||
public String getExt3() {
|
||||
return ext3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展3
|
||||
*
|
||||
* @param ext3 扩展3
|
||||
*/
|
||||
public void setExt3(String ext3) {
|
||||
this.ext3 = ext3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.tiesheng.role.pojos.dto;
|
||||
|
||||
public class MenuListDTO extends ServiceDTO {
|
||||
|
||||
private String parent;
|
||||
private Integer childSize = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(String parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Integer getChildSize() {
|
||||
return childSize;
|
||||
}
|
||||
|
||||
public void setChildSize(Integer childSize) {
|
||||
this.childSize = childSize;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.tiesheng.role.pojos.dto;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
public class ServiceDTO {
|
||||
|
||||
@NotEmpty(message = "请选择一个服务")
|
||||
private String service;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public String getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
public void setService(String service) {
|
||||
this.service = service;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.tiesheng.role.pojos.vo;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
public class GroupTypeDTO {
|
||||
|
||||
@NotEmpty(message = "请选择一个类型")
|
||||
private String type;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.tiesheng.role.pojos.vo;
|
||||
|
||||
import com.tiesheng.role.pojos.dao.CoreRoleUser;
|
||||
|
||||
public class RoleUserPageVO extends CoreRoleUser {
|
||||
|
||||
private String typeName;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.tiesheng.role.pojos.vo;
|
||||
|
||||
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ServiceMenuVO extends CoreRoleAuthority {
|
||||
|
||||
private List<ServiceMenuVO> children;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public List<ServiceMenuVO> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<ServiceMenuVO> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.tiesheng.role.service;
|
||||
|
||||
import com.tiesheng.role.mapper.CoreRoleGroupMapper;
|
||||
import com.tiesheng.role.mapper.CoreRoleUserMapper;
|
||||
import com.tiesheng.role.pojos.dao.CoreRoleGroup;
|
||||
import com.tiesheng.util.service.TsServiceBase;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRoleGroup> {
|
||||
|
||||
|
||||
@Resource
|
||||
CoreRoleUserMapper coreRoleUserMapper;
|
||||
|
||||
public CoreRoleUserMapper getUserMapper() {
|
||||
return coreRoleUserMapper;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.tiesheng.role.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.tiesheng.role.mapper.CoreRoleAuthorityMapper;
|
||||
import com.tiesheng.role.mapper.CoreRoleServerMapper;
|
||||
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
|
||||
import com.tiesheng.role.pojos.dao.CoreRoleServer;
|
||||
import com.tiesheng.role.pojos.vo.ServiceMenuVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CoreServerService extends ServiceImpl<CoreRoleServerMapper, CoreRoleServer> {
|
||||
|
||||
@Resource
|
||||
CoreRoleAuthorityMapper coreRoleAuthorityMapper;
|
||||
|
||||
public CoreRoleAuthorityMapper getAuthorityMapper() {
|
||||
return coreRoleAuthorityMapper;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 菜单封装
|
||||
*
|
||||
* @param coreServiceMenuList
|
||||
* @param level
|
||||
* @return
|
||||
*/
|
||||
public List<ServiceMenuVO> menuWrap(List<CoreRoleAuthority> coreServiceMenuList, String parent) {
|
||||
List<ServiceMenuVO> list = new ArrayList<>();
|
||||
|
||||
for (CoreRoleAuthority coreServiceMenu : coreServiceMenuList) {
|
||||
if (!StrUtil.equals(parent, coreServiceMenu.getParent())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ServiceMenuVO menuVO = BeanUtil.copyProperties(coreServiceMenu, ServiceMenuVO.class);
|
||||
menuVO.setChildren(menuWrap(coreServiceMenuList, coreServiceMenu.getId()));
|
||||
list.add(menuVO);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user