Commit 8d13ac95 authored by huyuchen's avatar huyuchen

Merge remote-tracking branch 'origin/master' into develop

# Conflicts:
#	yifu-auth/src/main/resources/application.yml
parents 7c3cc077 d8e32a0e
...@@ -29,6 +29,11 @@ import lombok.RequiredArgsConstructor; ...@@ -29,6 +29,11 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor @RequiredArgsConstructor
public enum MenuTypeEnum { public enum MenuTypeEnum {
/**
* 字典类型-系统内置(不可修改)
*/
SYSTEM("0", "系统内置"),
/** /**
* 左侧菜单 * 左侧菜单
*/ */
......
...@@ -63,6 +63,11 @@ public interface ErrorCodes { ...@@ -63,6 +63,11 @@ public interface ErrorCodes {
*/ */
String SYS_ROLE_NAMEORCODE_EXISTING = "sys.role.nameOrCode.existing"; String SYS_ROLE_NAMEORCODE_EXISTING = "sys.role.nameOrCode.existing";
/**
* 系统内置菜单不允许删除
*/
String SYS_MENU_DELETE_SYSTEM = "sys.menu.delete.system";
/** /**
* 菜单存在下级节点 删除失败 * 菜单存在下级节点 删除失败
*/ */
...@@ -88,4 +93,9 @@ public interface ErrorCodes { ...@@ -88,4 +93,9 @@ public interface ErrorCodes {
*/ */
String SYS_APP_PHONE_UNREGISTERED = "sys.app.phone.unregistered"; String SYS_APP_PHONE_UNREGISTERED = "sys.app.phone.unregistered";
/**
* 字典存在下级节点 删除失败
*/
String SYS_DICT_DELETE_EXISTING = "sys.dict.delete.existing";
} }
sys.user.update.passwordError=\u539f\u5bc6\u7801\u9519\u8bef\uff0c\u4fee\u6539\u5931\u8d25 sys.user.update.passwordError=\u539F\u5BC6\u7801\u9519\u8BEF\uFF0C\u4FEE\u6539\u5931\u8D25
sys.user.query.error=\u83b7\u53d6\u5f53\u524d\u7528\u6237\u4fe1\u606f\u5931\u8d25 sys.user.query.error=\u83B7\u53D6\u5F53\u524D\u7528\u6237\u4FE1\u606F\u5931\u8D25
sys.user.username.existing={0} \u7528\u6237\u540D\u5DF2\u5B58\u5728 sys.user.username.existing={0} \u7528\u6237\u540D\u5DF2\u5B58\u5728
sys.user.userInfo.empty={0} \u7528\u6237\u4fe1\u606f\u4e3a\u7a7a sys.user.userInfo.empty={0} \u7528\u6237\u4FE1\u606F\u4E3A\u7A7A
sys.dept.deptName.inexistence={0} \u90e8\u95e8\u540d\u79f0\u4e0d\u5b58\u5728 sys.dept.deptName.inexistence={0} \u90E8\u95E8\u540D\u79F0\u4E0D\u5B58\u5728
sys.post.postName.inexistence={0} \u5c97\u4f4d\u540d\u79f0\u4e0d\u5b58\u5728 sys.post.postName.inexistence={0} \u5C97\u4F4D\u540D\u79F0\u4E0D\u5B58\u5728
sys.post.nameOrCode.existing={0} {1} \u5c97\u4f4d\u540d\u6216\u5c97\u4f4d\u7f16\u7801\u5df2\u7ecf\u5b58\u5728 sys.post.nameOrCode.existing={0} {1} \u5C97\u4F4D\u540D\u6216\u5C97\u4F4D\u7F16\u7801\u5DF2\u7ECF\u5B58\u5728
sys.role.roleName.inexistence={0} \u89d2\u8272\u540d\u79f0\u4e0d\u5b58\u5728 sys.role.roleName.inexistence={0} \u89D2\u8272\u540D\u79F0\u4E0D\u5B58\u5728
sys.role.nameOrCode.existing={0} {1} \u89d2\u8272\u540d\u6216\u89d2\u8272\u7f16\u7801\u5df2\u7ecf\u5b58\u5728 sys.role.nameOrCode.existing={0} {1} \u89D2\u8272\u540D\u6216\u89D2\u8272\u7F16\u7801\u5DF2\u7ECF\u5B58\u5728
sys.param.delete.system=\u7cfb\u7edf\u5185\u7f6e\u53c2\u6570\u4e0d\u80fd\u5220\u9664 sys.param.delete.system=\u7CFB\u7EDF\u5185\u7F6E\u53C2\u6570\u4E0D\u80FD\u5220\u9664
sys.param.config.error={0} \u7CFB\u7EDF\u53C2\u6570\u914D\u7F6E\u9519\u8BEF sys.param.config.error={0} \u7CFB\u7EDF\u53C2\u6570\u914D\u7F6E\u9519\u8BEF
sys.menu.delete.existing=\u83dc\u5355\u542b\u6709\u4e0b\u7ea7\u4e0d\u80fd\u5220\u9664 sys.menu.delete.existing=\u83DC\u5355\u542B\u6709\u4E0B\u7EA7\u4E0D\u80FD\u5220\u9664
sys.menu.delete.system=\u7CFB\u7EDF\u5185\u7F6E\u83DC\u5355\u4E0D\u80FD\u5220\u9664
sys.app.sms.often=\u9a8c\u8bc1\u7801\u53d1\u9001\u8fc7\u9891\u7e41 sys.app.sms.often=\u9A8C\u8BC1\u7801\u53D1\u9001\u8FC7\u9891\u7E41
sys.app.phone.unregistered={0} \u624b\u673a\u53f7\u672a\u6ce8\u518c sys.app.phone.unregistered={0} \u624B\u673A\u53F7\u672A\u6CE8\u518C
sys.dict.delete.system=\u7cfb\u7edf\u5185\u7f6e\u5b57\u5178\u9879\u76ee\u4e0d\u80fd\u5220\u9664 sys.dict.delete.system=\u7CFB\u7EDF\u5185\u7F6E\u5B57\u5178\u9879\u76EE\u4E0D\u80FD\u5220\u9664
sys.dict.update.system=\u7cfb\u7edf\u5185\u7f6e\u5b57\u5178\u9879\u76ee\u4e0d\u80fd\u4fee\u6539 sys.dict.update.system=\u7CFB\u7EDF\u5185\u7F6E\u5B57\u5178\u9879\u76EE\u4E0D\u80FD\u4FEE\u6539
sys.dict.delete.existing=\u5B57\u5178\u5B58\u5728\u4E0B\u7EA7\u8282\u70B9\u4E0D\u80FD\u5931\u8D25
...@@ -37,11 +37,6 @@ public class UserDTO extends SysUser { ...@@ -37,11 +37,6 @@ public class UserDTO extends SysUser {
private Long deptId; private Long deptId;
/**
* 岗位ID
*/
private List<Long> post;
/** /**
* 新密码 * 新密码
*/ */
......
...@@ -23,6 +23,8 @@ import io.swagger.v3.oas.annotations.media.Schema; ...@@ -23,6 +23,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotNull;
/** /**
* 字典项 * 字典项
* *
...@@ -85,6 +87,13 @@ public class SysDictItem extends BaseEntity { ...@@ -85,6 +87,13 @@ public class SysDictItem extends BaseEntity {
@Schema(description = "备注信息") @Schema(description = "备注信息")
private String remark; private String remark;
/**
* 父节点ID
*/
@NotNull(message = "字典父节点ID不能为空")
@Schema(description = "字典父节点id")
private Long parentId;
/** /**
* 删除标记 * 删除标记
*/ */
......
...@@ -104,4 +104,15 @@ public class SysMenu extends BaseEntity { ...@@ -104,4 +104,15 @@ public class SysMenu extends BaseEntity {
@TableLogic @TableLogic
private String delFlag; private String delFlag;
/**
* 是否支持数据权限设置 (0是 1否)
*/
@Schema(description = "是否支持数据权限标识")
private String flag;
/**
* 是否是系统内置
*/
@Schema(description = "是否系统内置")
private String systemFlag;
} }
...@@ -25,6 +25,8 @@ import io.swagger.v3.oas.annotations.media.Schema; ...@@ -25,6 +25,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotNull;
/** /**
* <p> * <p>
* 用户表 * 用户表
...@@ -95,6 +97,26 @@ public class SysUser extends BaseEntity { ...@@ -95,6 +97,26 @@ public class SysUser extends BaseEntity {
@Schema(description = "用户所属部门id") @Schema(description = "用户所属部门id")
private Long deptId; private Long deptId;
/**
* 用户分组
*/
@NotNull(message = "用户分组不能为空")
@Schema(description = "用户分组")
private String userGroup;
/**
* 职务
*/
@Schema(description = "职务")
private String post;
/**
* 邮箱
*/
@NotNull(message = "邮箱不能为空")
@Schema(description = "邮箱")
private String email;
/** /**
* 0-正常,1-删除 * 0-正常,1-删除
*/ */
......
...@@ -108,4 +108,18 @@ public class UserVO implements Serializable { ...@@ -108,4 +108,18 @@ public class UserVO implements Serializable {
*/ */
private List<SysPost> postList; private List<SysPost> postList;
/**
* 用户分组
*/
private String userGroup;
/**
* 职务
*/
private String post;
/**
* 邮箱
*/
private String email;
} }
...@@ -104,6 +104,11 @@ ...@@ -104,6 +104,11 @@
<groupId>com.yifu.cloud.plus.v1</groupId> <groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-test</artifactId> <artifactId>yifu-common-test</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-models</artifactId>
<version>2.1.12</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.yifu.cloud.plus.v1.yifu.admin.controller; package com.yifu.cloud.plus.v1.yifu.admin.controller;
import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -191,4 +192,15 @@ public class DictController { ...@@ -191,4 +192,15 @@ public class DictController {
return R.ok(); return R.ok();
} }
/**
* 返回树形字典集合
* @param lazy 是否是懒加载
* @param parentId 父节点ID
* @return 树形菜单
*/
@GetMapping(value = "/tree")
public R<List<Tree<Long>>> getTree(boolean lazy, Long parentId) {
return R.ok(sysDictItemService.treeMenu(lazy, parentId));
}
} }
...@@ -15,9 +15,12 @@ ...@@ -15,9 +15,12 @@
*/ */
package com.yifu.cloud.plus.v1.yifu.admin.service; package com.yifu.cloud.plus.v1.yifu.admin.service;
import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem;
import java.util.List;
/** /**
* 字典项 * 字典项
* *
...@@ -40,4 +43,11 @@ public interface SysDictItemService extends IService<SysDictItem> { ...@@ -40,4 +43,11 @@ public interface SysDictItemService extends IService<SysDictItem> {
*/ */
void updateDictItem(SysDictItem item); void updateDictItem(SysDictItem item);
/**
* 构建树
* @param lazy 是否是懒加载
* @param parentId 父节点ID
* @return
*/
List<Tree<Long>> treeMenu(boolean lazy, Long parentId);
} }
...@@ -15,6 +15,11 @@ ...@@ -15,6 +15,11 @@
*/ */
package com.yifu.cloud.plus.v1.yifu.admin.service.impl; package com.yifu.cloud.plus.v1.yifu.admin.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDict; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDict;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem;
...@@ -22,6 +27,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDictItemMapper; ...@@ -22,6 +27,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDictItemMapper;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDictItemService; import com.yifu.cloud.plus.v1.yifu.admin.service.SysDictItemService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDictService; import com.yifu.cloud.plus.v1.yifu.admin.service.SysDictService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.enums.DictTypeEnum; import com.yifu.cloud.plus.v1.yifu.common.core.constant.enums.DictTypeEnum;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes; import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils; import com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils;
...@@ -30,6 +36,13 @@ import org.springframework.cache.annotation.CacheEvict; ...@@ -30,6 +36,13 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/** /**
* 字典项 * 字典项
* *
...@@ -50,6 +63,9 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi ...@@ -50,6 +63,9 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
@Override @Override
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true) @CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
public void removeDictItem(Long id) { public void removeDictItem(Long id) {
// 查询父节点为当前节点的节点
List<SysDictItem> dictList = this.list(Wrappers.<SysDictItem>query().lambda().eq(SysDictItem::getParentId, id));
Assert.isTrue(CollUtil.isEmpty(dictList), MsgUtils.getMessage(ErrorCodes.SYS_MENU_DELETE_EXISTING));
// 根据ID查询字典ID // 根据ID查询字典ID
SysDictItem dictItem = this.getById(id); SysDictItem dictItem = this.getById(id);
SysDict dict = dictService.getById(dictItem.getDictId()); SysDict dict = dictService.getById(dictItem.getDictId());
...@@ -75,4 +91,50 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi ...@@ -75,4 +91,50 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
this.updateById(item); this.updateById(item);
} }
/**
* 构建树查询 1. 不是懒加载情况,查询全部 2. 是懒加载,根据parentId 查询 2.1 父节点为空,则查询ID -1
* @param lazy 是否是懒加载
* @param parentId 父节点ID
* @return
*/
@Override
public List<Tree<Long>> treeMenu(boolean lazy, Long parentId) {
if (!lazy) {
List<TreeNode<Long>> collect = baseMapper
.selectList(Wrappers.<SysDictItem>lambdaQuery().orderByAsc(SysDictItem::getSortOrder)).stream()
.map(getNodeFunction()).collect(Collectors.toList());
return TreeUtil.build(collect, CommonConstants.MENU_TREE_ROOT_ID);
}
Long parent = parentId == null ? CommonConstants.MENU_TREE_ROOT_ID : parentId;
List<TreeNode<Long>> collect = baseMapper
.selectList(Wrappers.<SysDictItem>lambdaQuery().eq(SysDictItem::getParentId, parent)
.orderByAsc(SysDictItem::getSortOrder))
.stream().map(getNodeFunction()).collect(Collectors.toList());
return TreeUtil.build(collect, parent);
}
@NotNull
private Function<SysDictItem, TreeNode<Long>> getNodeFunction() {
return sysDictItem -> {
TreeNode<Long> node = new TreeNode<>();
node.setId(sysDictItem.getId());
node.setName(sysDictItem.getLabel());
node.setParentId(sysDictItem.getParentId());
node.setWeight(sysDictItem.getSortOrder());
// 扩展属性
Map<String, Object> extra = new HashMap<>();
extra.put("value", sysDictItem.getValue());
extra.put("dictId", sysDictItem.getDictId());
extra.put("type", sysDictItem.getType());
extra.put("label", sysDictItem.getLabel());
extra.put("sortOrder", sysDictItem.getSortOrder());
node.setExtra(extra);
return node;
};
}
} }
...@@ -79,6 +79,11 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl ...@@ -79,6 +79,11 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
Assert.isTrue(CollUtil.isEmpty(menuList), MsgUtils.getMessage(ErrorCodes.SYS_MENU_DELETE_EXISTING)); Assert.isTrue(CollUtil.isEmpty(menuList), MsgUtils.getMessage(ErrorCodes.SYS_MENU_DELETE_EXISTING));
SysMenu sysMenu = this.getById(id);
// 系统内置
Assert.state(!MenuTypeEnum.SYSTEM.getType().equals(sysMenu.getSystemFlag()),
MsgUtils.getMessage(ErrorCodes.SYS_MENU_DELETE_SYSTEM));
sysRoleMenuMapper.delete(Wrappers.<SysRoleMenu>query().lambda().eq(SysRoleMenu::getMenuId, id)); sysRoleMenuMapper.delete(Wrappers.<SysRoleMenu>query().lambda().eq(SysRoleMenu::getMenuId, id));
// 删除当前菜单及其子菜单 // 删除当前菜单及其子菜单
return this.removeById(id); return this.removeById(id);
......
...@@ -97,14 +97,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -97,14 +97,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return userRole; return userRole;
}).forEach(sysUserRoleMapper::insert); }).forEach(sysUserRoleMapper::insert);
// 保存用户岗位信息 // 保存用户岗位信息
Optional.ofNullable(userDto.getPost()).ifPresent(posts -> { // Optional.ofNullable(userDto.getPost()).ifPresent(posts -> {
posts.stream().map(postId -> { // posts.stream().map(postId -> {
SysUserPost userPost = new SysUserPost(); // SysUserPost userPost = new SysUserPost();
userPost.setUserId(sysUser.getUserId()); // userPost.setUserId(sysUser.getUserId());
userPost.setPostId(postId); // userPost.setPostId(postId);
return userPost; // return userPost;
}).forEach(sysUserPostMapper::insert); // }).forEach(sysUserPostMapper::insert);
}); // });
return Boolean.TRUE; return Boolean.TRUE;
} }
...@@ -215,13 +215,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -215,13 +215,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
userRole.setRoleId(roleId); userRole.setRoleId(roleId);
userRole.insert(); userRole.insert();
}); });
sysUserPostMapper.delete(Wrappers.<SysUserPost>lambdaQuery().eq(SysUserPost::getUserId, userDto.getUserId()));
userDto.getPost().forEach(postId -> {
SysUserPost userPost = new SysUserPost();
userPost.setUserId(sysUser.getUserId());
userPost.setPostId(postId);
userPost.insert();
});
return Boolean.TRUE; return Boolean.TRUE;
} }
...@@ -361,8 +354,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -361,8 +354,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// 根据角色名称查询角色ID // 根据角色名称查询角色ID
List<Long> roleIdList = roleCollList.stream().map(SysRole::getRoleId).collect(Collectors.toList()); List<Long> roleIdList = roleCollList.stream().map(SysRole::getRoleId).collect(Collectors.toList());
userDTO.setRole(roleIdList); userDTO.setRole(roleIdList);
List<Long> postIdList = postCollList.stream().map(SysPost::getPostId).collect(Collectors.toList()); // List<Long> postIdList = postCollList.stream().map(SysPost::getPostId).collect(Collectors.toList());
userDTO.setPost(postIdList); // userDTO.setPost(postIdList);
// 插入用户 // 插入用户
this.saveUser(userDTO); this.saveUser(userDTO);
} }
......
...@@ -26,6 +26,8 @@ import io.swagger.v3.oas.annotations.security.SecurityScheme; ...@@ -26,6 +26,8 @@ import io.swagger.v3.oas.annotations.security.SecurityScheme;
) )
) )
@SecurityScheme(type = SecuritySchemeType.HTTP, name = "JWT", scheme = "bearer", in = SecuritySchemeIn.HEADER) @SecurityScheme(type = SecuritySchemeType.HTTP, name = "JWT", scheme = "bearer", in = SecuritySchemeIn.HEADER)
//@SecurityScheme(type = SecuritySchemeType.OAUTH2,flows = @OAuthFlow( implicit = @OAuthFlow(authorizationUrl = "http://yifu-auth/oauth/check_token",
// scopes = @OAuthScope(name = "write:pets", description = "modify pets in your account"))))
public class Swagger3Config { public class Swagger3Config {
} }
...@@ -93,7 +93,8 @@ spring: ...@@ -93,7 +93,8 @@ spring:
activate: activate:
on-profile: test on-profile: test
redis: redis:
host: 127.0.0.1 host: 192.168.1.65
port: 22379
password: '@yf_2017' password: '@yf_2017'
datasource: datasource:
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
...@@ -112,8 +113,8 @@ spring: ...@@ -112,8 +113,8 @@ spring:
activate: activate:
on-profile: dev on-profile: dev
redis: redis:
host: 192.168.1.65 host: 127.0.0.1
port: 22379 port: 6379
password: '@yf_2017' password: '@yf_2017'
datasource: datasource:
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
<result column="update_by" property="updateBy"/> <result column="update_by" property="updateBy"/>
<result column="update_time" property="updateTime"/> <result column="update_time" property="updateTime"/>
<result column="del_flag" property="delFlag"/> <result column="del_flag" property="delFlag"/>
<result column="flag" property="flag"/>
<result column="system_flag" property="systemFlag"/>
</resultMap> </resultMap>
<!--通过角色查询菜单信息--> <!--通过角色查询菜单信息-->
...@@ -47,6 +49,8 @@ ...@@ -47,6 +49,8 @@
sys_menu.keep_alive, sys_menu.keep_alive,
sys_menu.type, sys_menu.type,
sys_menu.del_flag, sys_menu.del_flag,
sys_menu.flag,
sys_menu.system_flag,
sys_menu.create_by, sys_menu.create_by,
sys_menu.create_time, sys_menu.create_time,
sys_menu.update_by, sys_menu.update_by,
......
...@@ -32,12 +32,12 @@ ...@@ -32,12 +32,12 @@
<result column="deptId" property="deptId"/> <result column="deptId" property="deptId"/>
<result column="deptName" property="deptName"/> <result column="deptName" property="deptName"/>
<result column="nickname" property="nickname"/> <result column="nickname" property="nickname"/>
<result column="user_group" property="userGroup"/>
<result column="post" property="post"/>
<result column="email" property="email"/>
<collection property="roleList" ofType="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole" <collection property="roleList" ofType="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole"
select="com.yifu.cloud.plus.v1.yifu.admin.mapper.SysRoleMapper.listRolesByUserId" column="user_id"> select="com.yifu.cloud.plus.v1.yifu.admin.mapper.SysRoleMapper.listRolesByUserId" column="user_id">
</collection> </collection>
<collection property="postList" ofType="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysPost"
select="com.yifu.cloud.plus.v1.yifu.admin.mapper.SysPostMapper.listPostsByUserId" column="user_id">
</collection>
</resultMap> </resultMap>
<!-- userVo结果集 --> <!-- userVo结果集 -->
...@@ -55,6 +55,9 @@ ...@@ -55,6 +55,9 @@
<result column="deptId" property="deptId"/> <result column="deptId" property="deptId"/>
<result column="deptName" property="deptName"/> <result column="deptName" property="deptName"/>
<result column="nickname" property="nickname"/> <result column="nickname" property="nickname"/>
<result column="user_group" property="userGroup"/>
<result column="post" property="post"/>
<result column="email" property="email"/>
<collection property="roleList" ofType="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole"> <collection property="roleList" ofType="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole">
<id column="role_id" property="roleId"/> <id column="role_id" property="roleId"/>
<result column="role_name" property="roleName"/> <result column="role_name" property="roleName"/>
...@@ -79,6 +82,9 @@ ...@@ -79,6 +82,9 @@
sys_user.del_flag AS udel_flag, sys_user.del_flag AS udel_flag,
sys_user.lock_flag AS lock_flag, sys_user.lock_flag AS lock_flag,
sys_user.dept_id AS deptId, sys_user.dept_id AS deptId,
sys_user.user_group AS userGroup,
sys_user.post,
sys_user.email,
r.role_id, r.role_id,
r.role_name, r.role_name,
r.role_code, r.role_code,
...@@ -99,6 +105,9 @@ ...@@ -99,6 +105,9 @@
sys_user.update_time AS uupdate_time, sys_user.update_time AS uupdate_time,
sys_user.del_flag AS udel_flag, sys_user.del_flag AS udel_flag,
sys_user.lock_flag AS lock_flag, sys_user.lock_flag AS lock_flag,
sys_user.user_group AS userGroup,
sys_user.post,
sys_user.email,
r.role_id, r.role_id,
r.role_name, r.role_name,
r.role_code, r.role_code,
...@@ -141,6 +150,9 @@ ...@@ -141,6 +150,9 @@
sys_user.del_flag AS udel_flag, sys_user.del_flag AS udel_flag,
sys_user.lock_flag AS lock_flag, sys_user.lock_flag AS lock_flag,
sys_user.dept_id AS deptId, sys_user.dept_id AS deptId,
sys_user.user_group AS userGroup,
sys_user.post,
sys_user.email,
sys_dept.name AS deptName sys_dept.name AS deptName
FROM sys_user FROM sys_user
LEFT JOIN sys_dept ON sys_dept.dept_id = sys_user.dept_id LEFT JOIN sys_dept ON sys_dept.dept_id = sys_user.dept_id
...@@ -167,6 +179,9 @@ ...@@ -167,6 +179,9 @@
u.update_time uupdate_time, u.update_time uupdate_time,
u.del_flag, u.del_flag,
u.lock_flag, u.lock_flag,
u.group,
u.user_group userGroup,
u.email,
d.name AS deptName d.name AS deptName
FROM sys_user u FROM sys_user u
LEFT JOIN sys_dept d ON d.dept_id = u.dept_id LEFT JOIN sys_dept d ON d.dept_id = u.dept_id
......
...@@ -74,6 +74,16 @@ ...@@ -74,6 +74,16 @@
<artifactId>httpcore-nio</artifactId> <artifactId>httpcore-nio</artifactId>
<version>4.4.6</version> <version>4.4.6</version>
</dependency> </dependency>
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.3.5.RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -15,18 +15,30 @@ ...@@ -15,18 +15,30 @@
*/ */
package com.alibaba.csp.sentinel.dashboard.controller; package com.alibaba.csp.sentinel.dashboard.controller;
import cn.hutool.core.util.StrUtil;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService; import com.alibaba.csp.sentinel.dashboard.auth.AuthService;
import com.alibaba.csp.sentinel.dashboard.auth.SimpleWebAuthServiceImpl; import com.alibaba.csp.sentinel.dashboard.auth.SimpleWebAuthServiceImpl;
import com.alibaba.csp.sentinel.dashboard.config.DashboardConfig; import com.alibaba.csp.sentinel.dashboard.config.DashboardConfig;
import com.alibaba.csp.sentinel.dashboard.domain.Result; import com.alibaba.csp.sentinel.dashboard.domain.Result;
import com.google.common.net.HttpHeaders;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.util.SpringContextHolder;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.cache.CacheManager;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RestController; import org.springframework.security.authentication.event.LogoutSuccessEvent;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -34,10 +46,19 @@ import javax.servlet.http.HttpServletRequest; ...@@ -34,10 +46,19 @@ import javax.servlet.http.HttpServletRequest;
* @author cdfive * @author cdfive
* @since 1.6.0 * @since 1.6.0
*/ */
@RequiredArgsConstructor
@RestController @RestController
@RequestMapping("/auth") @RequestMapping("/auth")
public class AuthController { public class AuthController {
private final ClientDetailsService clientDetailsService;
private final TokenStore tokenStore;
private final RedisTemplate redisTemplate;
private final CacheManager cacheManager;
private static final Logger LOGGER = LoggerFactory.getLogger(AuthController.class); private static final Logger LOGGER = LoggerFactory.getLogger(AuthController.class);
@Value("${auth.username:sentinel}") @Value("${auth.username:sentinel}")
...@@ -91,4 +112,44 @@ public class AuthController { ...@@ -91,4 +112,44 @@ public class AuthController {
return Result.ofSuccess(authUser); return Result.ofSuccess(authUser);
} }
/* *//**
* 退出并删除token
* @param authHeader Authorization
*//*
@DeleteMapping("/logout")
public R<Boolean> logout(@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authHeader) {
if (StrUtil.isBlank(authHeader)) {
return R.ok();
}
String tokenValue = authHeader.replace(OAuth2AccessToken.BEARER_TYPE, StrUtil.EMPTY).trim();
return removeToken(tokenValue);
}
*//**
* 令牌管理调用
* @param token token
*//*
@DeleteMapping("/{token}")
public R<Boolean> removeToken(@PathVariable("token") String token) {
OAuth2AccessToken accessToken = tokenStore.readAccessToken(token);
if (accessToken == null || StrUtil.isBlank(accessToken.getValue())) {
return R.ok();
}
OAuth2Authentication auth2Authentication = tokenStore.readAuthentication(accessToken);
// 清空用户信息
cacheManager.getCache(CacheConstants.USER_DETAILS).evict(auth2Authentication.getName());
// 清空access token
tokenStore.removeAccessToken(accessToken);
// 清空 refresh token
OAuth2RefreshToken refreshToken = accessToken.getRefreshToken();
tokenStore.removeRefreshToken(refreshToken);
// 处理自定义退出事件,保存相关日志
SpringContextHolder.publishEvent(new LogoutSuccessEvent(auth2Authentication));
return R.ok();
}*/
} }
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