Compare commits
20 Commits
2.0.0.rc19
...
2.0.0.rc35
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3728291e73 | ||
|
|
6997dea968 | ||
|
|
7f601c8e60 | ||
|
|
7adc2a7c4b | ||
|
|
f4f082cc86 | ||
|
|
d21d84bc87 | ||
|
|
60f996137f | ||
|
|
11c8d234ff | ||
|
|
125c681669 | ||
|
|
b9347013f0 | ||
|
|
3415f0836f | ||
|
|
22672c8a9e | ||
|
|
a405aa7057 | ||
|
|
e39dd646f5 | ||
|
|
2ca224f7a5 | ||
|
|
d4e97babf4 | ||
|
|
a1c75d010b | ||
|
|
9b6b3af33e | ||
|
|
91833a44bb | ||
|
|
8dc8709499 |
22
pom.xml
22
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>springboot-parent</name>
|
<name>springboot-parent</name>
|
||||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||||
@@ -58,61 +58,61 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-database</artifactId>
|
<artifactId>springboot-database</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-web</artifactId>
|
<artifactId>springboot-web</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-util</artifactId>
|
<artifactId>springboot-util</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-platform</artifactId>
|
<artifactId>springboot-platform</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-message</artifactId>
|
<artifactId>springboot-message</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
<artifactId>springboot-encrypt</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-role</artifactId>
|
<artifactId>springboot-role</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-annotation</artifactId>
|
<artifactId>springboot-annotation</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-poi</artifactId>
|
<artifactId>springboot-poi</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-ademo</artifactId>
|
<artifactId>springboot-ademo</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ tiesheng:
|
|||||||
test-map:
|
test-map:
|
||||||
"1111":
|
"1111":
|
||||||
id: "1"
|
id: "1"
|
||||||
role-id: "super"
|
role-id: "1822829641023524865"
|
||||||
global:
|
global:
|
||||||
version: 2
|
version: 2
|
||||||
host: http://localhost:8100
|
host: http://localhost:8100
|
||||||
service: demo
|
service: yrx
|
||||||
aliyun:
|
aliyun:
|
||||||
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
|
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
|
||||||
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
|
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-annotation</artifactId>
|
<artifactId>springboot-annotation</artifactId>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public @interface RoleAuthority {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String platform() default "web";
|
String platform() default "";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,4 +30,12 @@ public @interface RoleAuthority {
|
|||||||
*/
|
*/
|
||||||
String[] group() default {};
|
String[] group() default {};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 依赖其他权限
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String[] deps() default {};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.tiesheng.annotation.role;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Target({ElementType.METHOD})
|
||||||
|
@Documented
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface RoleIgnore {
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-database</artifactId>
|
<artifactId>springboot-database</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
<artifactId>springboot-encrypt</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public class TokenWebMvcConfigurer implements WebMvcConfigurer {
|
|||||||
TokenBean tokenBean = tsTokenConfig.validToken(request, true);
|
TokenBean tokenBean = tsTokenConfig.validToken(request, true);
|
||||||
|
|
||||||
// 验证用户是否存在
|
// 验证用户是否存在
|
||||||
RequestUserInfo cachedUserInfo = tsLoginConfigurer.getCachedUserInfo(tokenBean);
|
RequestUserInfo cachedUserInfo = tsLoginConfigurer.getCachedUserInfo(tokenBean, false);
|
||||||
if (cachedUserInfo == null) {
|
if (cachedUserInfo == null) {
|
||||||
throw new ApiException("非法TOKEN,请重新登录");
|
throw new ApiException("非法TOKEN,请重新登录");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
|
|||||||
platformUnique.setUserId(tokenBean.getId());
|
platformUnique.setUserId(tokenBean.getId());
|
||||||
saveOrUpdate(platformUnique);
|
saveOrUpdate(platformUnique);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tokenBean;
|
return tokenBean;
|
||||||
@@ -102,7 +104,7 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
|
|||||||
login.setUserId(tokenBean.getId());
|
login.setUserId(tokenBean.getId());
|
||||||
login.setPlatform(platformUnique.getPlatform());
|
login.setPlatform(platformUnique.getPlatform());
|
||||||
|
|
||||||
RequestUserInfo requestUserInfo = tsLoginConfigurer.getCachedUserInfo(tokenBean);
|
RequestUserInfo requestUserInfo = tsLoginConfigurer.getCachedUserInfo(tokenBean, true);
|
||||||
login.setUserName(requestUserInfo.getName());
|
login.setUserName(requestUserInfo.getName());
|
||||||
|
|
||||||
login.setIp(ip);
|
login.setIp(ip);
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ public interface TsLoginConfigurer {
|
|||||||
* @param tokenBean
|
* @param tokenBean
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
default RequestUserInfo getCachedUserInfo(TokenBean tokenBean) {
|
default RequestUserInfo getCachedUserInfo(TokenBean tokenBean, boolean force) {
|
||||||
String key = StrUtil.format(TsTokenConfig.CACHE_REQUEST_LOGIN_KEY, tokenBean.getId());
|
String key = StrUtil.format(TsTokenConfig.CACHE_REQUEST_LOGIN_KEY, tokenBean.getId());
|
||||||
RequestUserInfo obj = TsCacheService.of().getObj(key, RequestUserInfo.class, -1);
|
RequestUserInfo obj = TsCacheService.of().getObj(key, RequestUserInfo.class, -1);
|
||||||
if (obj == null) {
|
if (obj == null || force) {
|
||||||
obj = getCurrentUserName(tokenBean);
|
obj = getCurrentUserName(tokenBean);
|
||||||
}
|
}
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-message</artifactId>
|
<artifactId>springboot-message</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-platform</artifactId>
|
<artifactId>springboot-platform</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-poi</artifactId>
|
<artifactId>springboot-poi</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-role</artifactId>
|
<artifactId>springboot-role</artifactId>
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package com.tiesheng.role.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
|
||||||
|
import com.tiesheng.role.pojos.dao.CoreRoleServer;
|
||||||
|
import com.tiesheng.role.pojos.dto.OwnerMenuDTO;
|
||||||
|
import com.tiesheng.role.pojos.dto.OwnerPointDTO;
|
||||||
|
import com.tiesheng.role.pojos.vo.ServiceMenuVO;
|
||||||
|
import com.tiesheng.role.service.CoreRoleService;
|
||||||
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
|
import com.tiesheng.util.pojos.TokenBean;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/comm/role")
|
||||||
|
public class CommRoleController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
CoreRoleService coreRoleService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取自己拥有的服务
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/owner/server")
|
||||||
|
public ApiResp<List<CoreRoleServer>> ownerServer(TokenBean tokenBean) {
|
||||||
|
List<CoreRoleAuthority> allOwnerMenus = coreRoleService.getOwnerAuthorityLeafList(tokenBean.getId(), tokenBean.getRoleId());
|
||||||
|
List<String> list = allOwnerMenus.stream().map(CoreRoleAuthority::getService).collect(Collectors.toList());
|
||||||
|
|
||||||
|
List<CoreRoleServer> roleServerList = new ArrayList<>();
|
||||||
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
|
roleServerList = coreRoleService.getServerMapper().selectList(new QueryWrapper<CoreRoleServer>()
|
||||||
|
.in("id", list)
|
||||||
|
.eq(CoreRoleServer.IS_DELETED, 0)
|
||||||
|
.eq("is_open", 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ApiResp.respOK(roleServerList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取自己拥有的菜单
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/owner/menu")
|
||||||
|
public ApiResp<List<ServiceMenuVO>> ownerMenu(@Valid OwnerMenuDTO dto, TokenBean tokenBean) {
|
||||||
|
List<ServiceMenuVO> ownerMenus = coreRoleService.getOwnerMenus(tokenBean.getId(), tokenBean.getRoleId(), dto);
|
||||||
|
return ApiResp.respOK(ownerMenus);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取自己拥有的功能点
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/owner/point")
|
||||||
|
public ApiResp<List<CoreRoleAuthority>> ownerPoint(@Valid OwnerPointDTO dto, TokenBean tokenBean) {
|
||||||
|
|
||||||
|
List<CoreRoleAuthority> allOwnerMenus = coreRoleService.getOwnerAuthorityLeafList(tokenBean.getId(), tokenBean.getRoleId());
|
||||||
|
|
||||||
|
String parentId;
|
||||||
|
if (StrUtil.isNotEmpty(dto.getParentNo())) {
|
||||||
|
CoreRoleAuthority selected = coreRoleService.getAuthorityMapper().selectOne(new QueryWrapper<CoreRoleAuthority>()
|
||||||
|
.eq("no", dto.getParentNo())
|
||||||
|
.eq("is_deleted", 0)
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
parentId = selected == null ? "" : selected.getId();
|
||||||
|
} else {
|
||||||
|
parentId = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
List<CoreRoleAuthority> collect = allOwnerMenus.stream()
|
||||||
|
.filter(it -> Objects.equals(it.getType(), "point"))
|
||||||
|
.filter(it -> it.getService().equals(dto.getService()))
|
||||||
|
.filter(it -> it.getPlatform().equals(dto.getPlatform()))
|
||||||
|
.filter(it -> {
|
||||||
|
if (StrUtil.isNotEmpty(parentId)) {
|
||||||
|
return parentId.equals(it.getParent());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
return ApiResp.respOK(collect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,322 +0,0 @@
|
|||||||
package com.tiesheng.role.controller;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
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.annotation.role.RoleAuthority;
|
|
||||||
import com.tiesheng.role.pojos.dao.*;
|
|
||||||
import com.tiesheng.role.pojos.dto.GroupRxUpdateDTO;
|
|
||||||
import com.tiesheng.role.pojos.dto.MenuListDTO;
|
|
||||||
import com.tiesheng.role.pojos.dto.OwnerMenuDTO;
|
|
||||||
import com.tiesheng.role.pojos.dto.OwnerPointDTO;
|
|
||||||
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.util.exception.ApiException;
|
|
||||||
import com.tiesheng.util.pojos.ApiResp;
|
|
||||||
import com.tiesheng.util.pojos.IdDTO;
|
|
||||||
import com.tiesheng.util.pojos.PageDTO;
|
|
||||||
import com.tiesheng.util.pojos.TokenBean;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/role")
|
|
||||||
@RoleAuthority(value = "role", group = "role")
|
|
||||||
public class RoleController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
CoreRoleService coreRoleService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色列表
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/group/list")
|
|
||||||
@RoleAuthority(value = "groupList")
|
|
||||||
public ApiResp<List<CoreRoleGroup>> groupList(@Valid GroupTypeDTO dto) {
|
|
||||||
return ApiResp.respOK(coreRoleService.list(
|
|
||||||
new QueryWrapper<CoreRoleGroup>()
|
|
||||||
.eq("is_deleted", 0)
|
|
||||||
.eq("type", dto.getType())
|
|
||||||
.orderByAsc("sort")
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色编辑
|
|
||||||
*
|
|
||||||
* @param roleGroup
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/group/update")
|
|
||||||
@RoleAuthority(value = "groupUpdate")
|
|
||||||
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")
|
|
||||||
@RoleAuthority(value = "groupDeleted")
|
|
||||||
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("/group/rx/list")
|
|
||||||
public ApiResp<List<CoreRoleGroupRx>> groupRxList(@Valid IdDTO dto) {
|
|
||||||
List<CoreRoleGroupRx> list = coreRoleService.getGroupRxMapper().selectList(new QueryWrapper<CoreRoleGroupRx>()
|
|
||||||
.eq(CoreRoleGroupRx.IS_DELETED, 0)
|
|
||||||
.eq("group_id", dto.getId())
|
|
||||||
);
|
|
||||||
return ApiResp.respOK(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色的权限编辑
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/group/rx/update")
|
|
||||||
@RoleAuthority(value = "groupRxUpdate")
|
|
||||||
public ApiResp<String> groupRxUpdate(@RequestBody @Valid GroupRxUpdateDTO dto) {
|
|
||||||
coreRoleService.updateGroupRx(dto);
|
|
||||||
return ApiResp.respOK("");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 授权列表
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/user/page")
|
|
||||||
@RoleAuthority(value = "userPage")
|
|
||||||
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")
|
|
||||||
@RoleAuthority(value = "userUpdate")
|
|
||||||
public ApiResp<String> userUpdate(@RequestBody CoreRoleUser roleUser) {
|
|
||||||
coreRoleService.roleUserUpdate(roleUser);
|
|
||||||
return ApiResp.respOK("");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 授权-删除
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/user/deleted")
|
|
||||||
@RoleAuthority(value = "userDeleted")
|
|
||||||
public ApiResp<String> userDeleted(@RequestBody @Valid IdDTO dto) {
|
|
||||||
coreRoleService.roleUserDeleted(dto.getId());
|
|
||||||
return ApiResp.respOK("");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取服务列表
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/server/list")
|
|
||||||
@RoleAuthority(value = "serverList")
|
|
||||||
public ApiResp<List<CoreRoleServer>> list() {
|
|
||||||
return ApiResp.respOK(coreRoleService.getServerMapper().selectList(new QueryWrapper<CoreRoleServer>()
|
|
||||||
.eq(CoreRoleServer.IS_DELETED, 0)
|
|
||||||
.eq("is_open", 1)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改服务
|
|
||||||
*
|
|
||||||
* @param coreService
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/server/update")
|
|
||||||
@RoleAuthority(value = "serverUpdate")
|
|
||||||
public ApiResp<String> update(@RequestBody CoreRoleServer coreService) {
|
|
||||||
if (StrUtil.isNotEmpty(coreService.getId())) {
|
|
||||||
coreRoleService.getServerMapper().updateById(coreService);
|
|
||||||
} else {
|
|
||||||
coreRoleService.getServerMapper().insert(coreService);
|
|
||||||
}
|
|
||||||
return ApiResp.respOK("");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限-列出
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/authority/list")
|
|
||||||
public ApiResp<List<ServiceMenuVO>> menuList(@Valid MenuListDTO dto) {
|
|
||||||
|
|
||||||
List<CoreRoleAuthority> list = coreRoleService.getAuthorityMapper().selectList(new QueryWrapper<CoreRoleAuthority>()
|
|
||||||
.eq(CoreRoleAuthority.IS_DELETED, 0)
|
|
||||||
.eq("service", dto.getService())
|
|
||||||
.eq(StrUtil.isNotEmpty(dto.getPlatform()), "platform", dto.getPlatform())
|
|
||||||
.orderByAsc("sort")
|
|
||||||
);
|
|
||||||
|
|
||||||
List<ServiceMenuVO> collect = coreRoleService.menuChildrenWrap(list, null);
|
|
||||||
|
|
||||||
return ApiResp.respOK(collect);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限-编辑
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/authority/update")
|
|
||||||
@RoleAuthority(value = "authorityUpdate")
|
|
||||||
public ApiResp<String> menuUpdate(@RequestBody CoreRoleAuthority serviceMenu) {
|
|
||||||
serviceMenu.setParent(StrUtil.emptyToDefault(serviceMenu.getParent(), null));
|
|
||||||
if (StrUtil.isEmpty(serviceMenu.getId())) {
|
|
||||||
coreRoleService.getAuthorityMapper().insert(serviceMenu);
|
|
||||||
} else {
|
|
||||||
serviceMenu.setNo(null);
|
|
||||||
coreRoleService.getAuthorityMapper().updateById(serviceMenu);
|
|
||||||
}
|
|
||||||
return ApiResp.respOK("");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取自己拥有的服务
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/owner/server")
|
|
||||||
public ApiResp<List<CoreRoleServer>> ownerServer(TokenBean tokenBean) {
|
|
||||||
List<CoreRoleAuthority> allOwnerMenus = coreRoleService.getOwnerAuthorityLeafList(tokenBean.getId(), tokenBean.getRoleId());
|
|
||||||
List<String> list = allOwnerMenus.stream().map(CoreRoleAuthority::getService).collect(Collectors.toList());
|
|
||||||
|
|
||||||
List<CoreRoleServer> roleServerList = new ArrayList<>();
|
|
||||||
if (CollUtil.isNotEmpty(list)) {
|
|
||||||
roleServerList = coreRoleService.getServerMapper().selectList(new QueryWrapper<CoreRoleServer>()
|
|
||||||
.in("id", list)
|
|
||||||
.eq(CoreRoleServer.IS_DELETED, 0)
|
|
||||||
.eq("is_open", 1)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ApiResp.respOK(roleServerList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取自己拥有的菜单
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/owner/menu")
|
|
||||||
public ApiResp<List<ServiceMenuVO>> ownerMenu(TokenBean tokenBean, @Valid OwnerMenuDTO dto) {
|
|
||||||
List<ServiceMenuVO> ownerMenus = coreRoleService.getOwnerMenus(tokenBean.getId(), tokenBean.getRoleId(), dto);
|
|
||||||
return ApiResp.respOK(ownerMenus);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取自己拥有的功能点
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/owner/point")
|
|
||||||
public ApiResp<List<CoreRoleAuthority>> ownerPoint(TokenBean tokenBean, @Valid OwnerPointDTO dto) {
|
|
||||||
|
|
||||||
List<CoreRoleAuthority> allOwnerMenus = coreRoleService.getOwnerAuthorityLeafList(tokenBean.getId(), tokenBean.getRoleId());
|
|
||||||
|
|
||||||
String parentId;
|
|
||||||
if (StrUtil.isNotEmpty(dto.getParentNo())) {
|
|
||||||
CoreRoleAuthority selected = coreRoleService.getAuthorityMapper().selectOne(new QueryWrapper<CoreRoleAuthority>()
|
|
||||||
.eq("no", dto.getParentNo())
|
|
||||||
.eq("is_deleted", 0)
|
|
||||||
.last("limit 1")
|
|
||||||
);
|
|
||||||
parentId = selected == null ? "" : selected.getId();
|
|
||||||
} else {
|
|
||||||
parentId = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
List<CoreRoleAuthority> collect = allOwnerMenus.stream()
|
|
||||||
.filter(it -> Objects.equals(it.getType(), "point"))
|
|
||||||
.filter(it -> it.getService().equals(dto.getService()))
|
|
||||||
.filter(it -> it.getPlatform().equals(dto.getPlatform()))
|
|
||||||
.filter(it -> {
|
|
||||||
if (StrUtil.isNotEmpty(parentId)) {
|
|
||||||
return parentId.equals(it.getParent());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
|
|
||||||
return ApiResp.respOK(collect);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
package com.tiesheng.role.controller.role;
|
||||||
|
|
||||||
|
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.annotation.role.RoleAuthority;
|
||||||
|
import com.tiesheng.role.pojos.dao.CoreRoleGroup;
|
||||||
|
import com.tiesheng.role.pojos.dao.CoreRoleGroupRx;
|
||||||
|
import com.tiesheng.role.pojos.dto.GroupRxUpdateDTO;
|
||||||
|
import com.tiesheng.role.pojos.vo.GroupTypeDTO;
|
||||||
|
import com.tiesheng.role.service.CoreRoleService;
|
||||||
|
import com.tiesheng.util.exception.ApiException;
|
||||||
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
|
import com.tiesheng.util.pojos.IdDTO;
|
||||||
|
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/group")
|
||||||
|
@RoleAuthority(value = "group", group = "role")
|
||||||
|
public class RoleGroupController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
CoreRoleService coreRoleService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/page")
|
||||||
|
public ApiResp<List<CoreRoleGroup>> groupPage(@Valid GroupTypeDTO dto) {
|
||||||
|
|
||||||
|
QueryWrapper<CoreRoleGroup> queryWrapper = new QueryWrapper<CoreRoleGroup>()
|
||||||
|
.eq("is_deleted", 0)
|
||||||
|
.eq(StrUtil.isNotEmpty(dto.getType()), "type", dto.getType())
|
||||||
|
.orderByAsc("sort");
|
||||||
|
dto.likeColumns(queryWrapper, "name");
|
||||||
|
|
||||||
|
Page<CoreRoleGroup> page = dto.pageObj();
|
||||||
|
coreRoleService.page(page, queryWrapper);
|
||||||
|
|
||||||
|
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色编辑
|
||||||
|
*
|
||||||
|
* @param roleGroup
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/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("/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("/rx/list")
|
||||||
|
public ApiResp<List<CoreRoleGroupRx>> groupRxList(@Valid IdDTO dto) {
|
||||||
|
List<CoreRoleGroupRx> list = coreRoleService.getGroupRxMapper().selectList(new QueryWrapper<CoreRoleGroupRx>()
|
||||||
|
.eq(CoreRoleGroupRx.IS_DELETED, 0)
|
||||||
|
.eq("group_id", dto.getId())
|
||||||
|
.eq("type", "bind")
|
||||||
|
);
|
||||||
|
return ApiResp.respOK(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色的权限编辑
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/rx/update")
|
||||||
|
public ApiResp<String> groupRxUpdate(@RequestBody @Valid GroupRxUpdateDTO dto) {
|
||||||
|
coreRoleService.updateGroupRx(dto);
|
||||||
|
return ApiResp.respOK("");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package com.tiesheng.role.controller.role;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
|
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
|
||||||
|
import com.tiesheng.role.pojos.dao.CoreRoleServer;
|
||||||
|
import com.tiesheng.role.pojos.dto.MenuListDTO;
|
||||||
|
import com.tiesheng.role.pojos.vo.ServiceMenuVO;
|
||||||
|
import com.tiesheng.role.service.CoreRoleService;
|
||||||
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/role")
|
||||||
|
@RoleAuthority(value = "server", group = "role")
|
||||||
|
public class RoleServerController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
CoreRoleService coreRoleService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取服务列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/server/list")
|
||||||
|
public ApiResp<List<CoreRoleServer>> list() {
|
||||||
|
return ApiResp.respOK(coreRoleService.getServerMapper().selectList(new QueryWrapper<CoreRoleServer>()
|
||||||
|
.eq(CoreRoleServer.IS_DELETED, 0)
|
||||||
|
.eq("is_open", 1)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改服务
|
||||||
|
*
|
||||||
|
* @param coreService
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/server/update")
|
||||||
|
public ApiResp<String> update(@RequestBody CoreRoleServer coreService) {
|
||||||
|
if (StrUtil.isNotEmpty(coreService.getId())) {
|
||||||
|
coreRoleService.getServerMapper().updateById(coreService);
|
||||||
|
} else {
|
||||||
|
coreRoleService.getServerMapper().insert(coreService);
|
||||||
|
}
|
||||||
|
return ApiResp.respOK("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限-列出
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/authority/list")
|
||||||
|
public ApiResp<List<ServiceMenuVO>> menuList(@Valid MenuListDTO dto) {
|
||||||
|
|
||||||
|
List<CoreRoleAuthority> list = coreRoleService.getAuthorityMapper().selectList(new QueryWrapper<CoreRoleAuthority>()
|
||||||
|
.eq(CoreRoleAuthority.IS_DELETED, 0)
|
||||||
|
.eq("service", dto.getService())
|
||||||
|
.eq(StrUtil.isNotEmpty(dto.getPlatform()), "platform", dto.getPlatform())
|
||||||
|
.orderByAsc("sort")
|
||||||
|
);
|
||||||
|
|
||||||
|
List<ServiceMenuVO> collect = coreRoleService.menuChildrenWrap(list, null);
|
||||||
|
|
||||||
|
return ApiResp.respOK(collect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限-编辑
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/authority/update")
|
||||||
|
public ApiResp<String> menuUpdate(@RequestBody CoreRoleAuthority serviceMenu) {
|
||||||
|
serviceMenu.setParent(StrUtil.emptyToDefault(serviceMenu.getParent(), null));
|
||||||
|
if (StrUtil.isEmpty(serviceMenu.getId())) {
|
||||||
|
coreRoleService.getAuthorityMapper().insert(serviceMenu);
|
||||||
|
} else {
|
||||||
|
serviceMenu.setNo(null);
|
||||||
|
coreRoleService.getAuthorityMapper().updateById(serviceMenu);
|
||||||
|
}
|
||||||
|
return ApiResp.respOK("");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package com.tiesheng.role.controller.role;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
|
import com.tiesheng.role.pojos.dao.CoreRoleUser;
|
||||||
|
import com.tiesheng.role.pojos.vo.RoleUserPageVO;
|
||||||
|
import com.tiesheng.role.service.CoreRoleService;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/role/user")
|
||||||
|
@RoleAuthority(value = "user", group = "role")
|
||||||
|
public class RoleUserController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
CoreRoleService coreRoleService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授权列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/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("/update")
|
||||||
|
public ApiResp<String> userUpdate(@RequestBody CoreRoleUser roleUser) {
|
||||||
|
coreRoleService.roleUserUpdate(roleUser);
|
||||||
|
return ApiResp.respOK("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授权-删除
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/deleted")
|
||||||
|
public ApiResp<String> userDeleted(@RequestBody @Valid IdDTO dto) {
|
||||||
|
coreRoleService.roleUserDeleted(dto.getId());
|
||||||
|
return ApiResp.respOK("");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,13 +6,10 @@ import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface CoreRoleAuthorityMapper extends BaseMapper<CoreRoleAuthority> {
|
public interface CoreRoleAuthorityMapper extends BaseMapper<CoreRoleAuthority> {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量插入数据
|
* 批量插入数据
|
||||||
*
|
*
|
||||||
* @param coreRoleAuthorities
|
* @param coreRoleAuthorities
|
||||||
*/
|
*/
|
||||||
void batchInsert(List<CoreRoleAuthority> coreRoleAuthorities);
|
void batchInsert(List<CoreRoleAuthority> coreRoleAuthorities);
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -14,4 +14,4 @@ public interface CoreRoleGroupRxMapper extends BaseMapper<CoreRoleGroupRx> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int batchInsert(@Param("list") List<CoreRoleGroupRx> coreRoleGroupRxs);
|
int batchInsert(@Param("list") List<CoreRoleGroupRx> coreRoleGroupRxs);
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ public interface CoreRoleUserMapper extends BaseMapper<CoreRoleUser> {
|
|||||||
* @param userId
|
* @param userId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<CoreRoleAuthority> getOwnerAuthorityLeafList(@Param("userId") String userId,
|
List<CoreRoleAuthority> getOwnerAuthorityLeafList(@Param("userId") String userId, @Param("roleId") String roleId,
|
||||||
@Param("roleId") String roleId);
|
@Param("type") String type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,24 @@ public class CoreRoleAuthority extends DaoBase {
|
|||||||
@TableField(value = "platform")
|
@TableField(value = "platform")
|
||||||
private String platform;
|
private String platform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 版本号
|
||||||
|
*/
|
||||||
|
@TableField(value = "version")
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限来源:auto-自动生成,input-添加
|
||||||
|
*/
|
||||||
|
@TableField(value = "`source`")
|
||||||
|
private String source;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 依赖权限
|
||||||
|
*/
|
||||||
|
@TableField(value = "deps")
|
||||||
|
private String deps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扩展1
|
* 扩展1
|
||||||
*/
|
*/
|
||||||
@@ -294,6 +312,60 @@ public class CoreRoleAuthority extends DaoBase {
|
|||||||
this.platform = platform;
|
this.platform = platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取版本号
|
||||||
|
*
|
||||||
|
* @return version - 版本号
|
||||||
|
*/
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置版本号
|
||||||
|
*
|
||||||
|
* @param version 版本号
|
||||||
|
*/
|
||||||
|
public void setVersion(String version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取权限来源:auto-自动生成,input-添加
|
||||||
|
*
|
||||||
|
* @return source - 权限来源:auto-自动生成,input-添加
|
||||||
|
*/
|
||||||
|
public String getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置权限来源:auto-自动生成,input-添加
|
||||||
|
*
|
||||||
|
* @param source 权限来源:auto-自动生成,input-添加
|
||||||
|
*/
|
||||||
|
public void setSource(String source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取依赖权限
|
||||||
|
*
|
||||||
|
* @return deps - 依赖权限
|
||||||
|
*/
|
||||||
|
public String getDeps() {
|
||||||
|
return deps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置依赖权限
|
||||||
|
*
|
||||||
|
* @param deps 依赖权限
|
||||||
|
*/
|
||||||
|
public void setDeps(String deps) {
|
||||||
|
this.deps = deps;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取扩展1
|
* 获取扩展1
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -24,6 +24,12 @@ public class CoreRoleGroupRx extends DaoBase {
|
|||||||
@TableField(value = "menu_id")
|
@TableField(value = "menu_id")
|
||||||
private String menuId;
|
private String menuId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联类型:dep-依赖,bind-绑定
|
||||||
|
*/
|
||||||
|
@TableField(value = "`type`")
|
||||||
|
private String type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取角色id
|
* 获取角色id
|
||||||
*
|
*
|
||||||
@@ -59,4 +65,22 @@ public class CoreRoleGroupRx extends DaoBase {
|
|||||||
public void setMenuId(String menuId) {
|
public void setMenuId(String menuId) {
|
||||||
this.menuId = menuId;
|
this.menuId = menuId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取关联类型:dep-依赖,bind-绑定
|
||||||
|
*
|
||||||
|
* @return type - 关联类型:dep-依赖,bind-绑定
|
||||||
|
*/
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置关联类型:dep-依赖,bind-绑定
|
||||||
|
*
|
||||||
|
* @param type 关联类型:dep-依赖,bind-绑定
|
||||||
|
*/
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
package com.tiesheng.role.pojos.vo;
|
package com.tiesheng.role.pojos.vo;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import com.tiesheng.util.pojos.PageDTO;
|
||||||
|
|
||||||
public class GroupTypeDTO {
|
public class GroupTypeDTO extends PageDTO {
|
||||||
|
|
||||||
@NotEmpty(message = "请选择一个类型")
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -2,12 +2,23 @@ package com.tiesheng.role.pojos.vo;
|
|||||||
|
|
||||||
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
|
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ServiceMenuVO extends CoreRoleAuthority {
|
public class ServiceMenuVO extends CoreRoleAuthority {
|
||||||
|
|
||||||
private List<ServiceMenuVO> children;
|
private List<ServiceMenuVO> children;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
public ServiceMenuVO sortChildren() {
|
||||||
|
children = children.stream().sorted(Comparator.comparingInt(ServiceMenuVO::getSort))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// setter\getter
|
// setter\getter
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -3,8 +3,11 @@ package com.tiesheng.role.service;
|
|||||||
import cn.hutool.core.annotation.AnnotationUtil;
|
import cn.hutool.core.annotation.AnnotationUtil;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.lang.Validator;
|
import cn.hutool.core.lang.Validator;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.tiesheng.annotation.role.RoleAuthority;
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
import com.tiesheng.role.mapper.*;
|
import com.tiesheng.role.mapper.*;
|
||||||
@@ -71,7 +74,18 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<ServiceMenuVO> menuChildrenWrap(List<CoreRoleAuthority> coreServiceMenuList, String parent) {
|
public List<ServiceMenuVO> menuChildrenWrap(List<CoreRoleAuthority> coreServiceMenuList, String parent) {
|
||||||
List<CoreRoleAuthority> distinctList = coreServiceMenuList.stream().distinct().collect(Collectors.toList());
|
|
||||||
|
HashMap<String, String> keyMaps = MapUtil.newHashMap();
|
||||||
|
|
||||||
|
List<CoreRoleAuthority> distinctList = coreServiceMenuList.stream()
|
||||||
|
.filter(it -> {
|
||||||
|
if (keyMaps.containsKey(it.getId())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
keyMaps.put(it.getId(), it.getId());
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
List<ServiceMenuVO> list = new ArrayList<>();
|
List<ServiceMenuVO> list = new ArrayList<>();
|
||||||
|
|
||||||
@@ -100,6 +114,10 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
|
|||||||
.eq("group_id", dto.getId())
|
.eq("group_id", dto.getId())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(dto.getMenuIds())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CoreRoleGroup roleGroup = getById(dto.getId());
|
CoreRoleGroup roleGroup = getById(dto.getId());
|
||||||
Validator.validateNotEmpty(roleGroup, "角色不存在");
|
Validator.validateNotEmpty(roleGroup, "角色不存在");
|
||||||
|
|
||||||
@@ -113,7 +131,17 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
|
|||||||
CoreRoleGroupRx coreRoleGroupRx = new CoreRoleGroupRx();
|
CoreRoleGroupRx coreRoleGroupRx = new CoreRoleGroupRx();
|
||||||
coreRoleGroupRx.setGroupId(roleGroup.getId());
|
coreRoleGroupRx.setGroupId(roleGroup.getId());
|
||||||
coreRoleGroupRx.setMenuId(authority.getId());
|
coreRoleGroupRx.setMenuId(authority.getId());
|
||||||
|
coreRoleGroupRx.setType("bind");
|
||||||
list.add(coreRoleGroupRx);
|
list.add(coreRoleGroupRx);
|
||||||
|
|
||||||
|
List<String> deps = JSONUtil.toList(authority.getDeps(), String.class);
|
||||||
|
for (String dep : deps) {
|
||||||
|
CoreRoleGroupRx depRx = new CoreRoleGroupRx();
|
||||||
|
depRx.setGroupId(roleGroup.getId());
|
||||||
|
depRx.setMenuId(StrUtil.format("{}_{}", authority.getService(), dep));
|
||||||
|
depRx.setType("dep");
|
||||||
|
list.add(depRx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(list)) {
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
@@ -172,7 +200,7 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<CoreRoleAuthority> getOwnerAuthorityLeafList(String userId, String roleId) {
|
public List<CoreRoleAuthority> getOwnerAuthorityLeafList(String userId, String roleId) {
|
||||||
return coreRoleUserMapper.getOwnerAuthorityLeafList(userId, roleId);
|
return coreRoleUserMapper.getOwnerAuthorityLeafList(userId, roleId, "bind");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -213,7 +241,11 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
|
|||||||
|
|
||||||
return menuChildrenWrap(ownerAuthorityList.stream()
|
return menuChildrenWrap(ownerAuthorityList.stream()
|
||||||
.filter(it -> Objects.equals(it.getType(), "group") || Objects.equals(it.getType(), "menu"))
|
.filter(it -> Objects.equals(it.getType(), "group") || Objects.equals(it.getType(), "menu"))
|
||||||
.collect(Collectors.toList()), null);
|
.filter(it -> Objects.equals(it.getService(), dto.getService()) && Objects.equals(it.getPlatform(), dto.getPlatform()))
|
||||||
|
.collect(Collectors.toList()), null)
|
||||||
|
.stream().sorted(Comparator.comparingInt(ServiceMenuVO::getSort))
|
||||||
|
.map(ServiceMenuVO::sortChildren)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -221,6 +253,9 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
|
|||||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||||
ApplicationContext applicationContext = event.getApplicationContext();
|
ApplicationContext applicationContext = event.getApplicationContext();
|
||||||
Map<String, Object> beansOfType = applicationContext.getBeansWithAnnotation(RoleAuthority.class);
|
Map<String, Object> beansOfType = applicationContext.getBeansWithAnnotation(RoleAuthority.class);
|
||||||
|
|
||||||
|
String version = DateUtil.format(new Date(), "yyyyMMddHHmmss");
|
||||||
|
|
||||||
for (Map.Entry<String, Object> entry : beansOfType.entrySet()) {
|
for (Map.Entry<String, Object> entry : beansOfType.entrySet()) {
|
||||||
|
|
||||||
Class<?> targetClass = AopUtils.getTargetClass(entry.getValue());
|
Class<?> targetClass = AopUtils.getTargetClass(entry.getValue());
|
||||||
@@ -235,8 +270,14 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tsAuthorityHandler.addRoleAuthority(menu, points);
|
tsAuthorityHandler.addRoleAuthority(version, menu, points);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
coreRoleAuthorityMapper.delete(new QueryWrapper<CoreRoleAuthority>()
|
||||||
|
.ne("version", version)
|
||||||
|
.eq("source", "auto")
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.tiesheng.role.service;
|
package com.tiesheng.role.service;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.tiesheng.annotation.role.RoleAuthority;
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
import com.tiesheng.role.mapper.CoreRoleAuthorityMapper;
|
import com.tiesheng.role.mapper.CoreRoleAuthorityMapper;
|
||||||
import com.tiesheng.role.mapper.CoreRoleUserMapper;
|
import com.tiesheng.role.mapper.CoreRoleUserMapper;
|
||||||
@@ -27,11 +28,13 @@ public class RoleAuthorityHandler implements TsAuthorityHandler {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addRoleAuthority(RoleAuthority menu, List<RoleAuthority> points) {
|
public void addRoleAuthority(String version, RoleAuthority menu, List<RoleAuthority> points) {
|
||||||
if (menu.group().length == 0) {
|
if (menu.group().length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String menuPlatform = StrUtil.emptyToDefault(menu.platform(), "web");
|
||||||
|
|
||||||
List<CoreRoleAuthority> list = new ArrayList<>();
|
List<CoreRoleAuthority> list = new ArrayList<>();
|
||||||
|
|
||||||
// 分组
|
// 分组
|
||||||
@@ -39,7 +42,7 @@ public class RoleAuthorityHandler implements TsAuthorityHandler {
|
|||||||
groupAuthority.setLevel(0);
|
groupAuthority.setLevel(0);
|
||||||
for (String group : menu.group()) {
|
for (String group : menu.group()) {
|
||||||
|
|
||||||
String parentId = groupAuthority.getParent();
|
String parentId = groupAuthority.getId();
|
||||||
int level = groupAuthority.getLevel() + 1;
|
int level = groupAuthority.getLevel() + 1;
|
||||||
String no = group;
|
String no = group;
|
||||||
if (StrUtil.isNotEmpty(groupAuthority.getNo())) {
|
if (StrUtil.isNotEmpty(groupAuthority.getNo())) {
|
||||||
@@ -52,8 +55,10 @@ public class RoleAuthorityHandler implements TsAuthorityHandler {
|
|||||||
groupAuthority.setService(globalConfig.getService());
|
groupAuthority.setService(globalConfig.getService());
|
||||||
groupAuthority.setType("group");
|
groupAuthority.setType("group");
|
||||||
groupAuthority.setLevel(level);
|
groupAuthority.setLevel(level);
|
||||||
groupAuthority.setPlatform(menu.platform());
|
groupAuthority.setPlatform(menuPlatform);
|
||||||
groupAuthority.setParent(parentId);
|
groupAuthority.setParent(parentId);
|
||||||
|
groupAuthority.setVersion(version);
|
||||||
|
groupAuthority.setSource("auto");
|
||||||
groupAuthority.setId(StrUtil.join("_", groupAuthority.getService(), groupAuthority.getNo()));
|
groupAuthority.setId(StrUtil.join("_", groupAuthority.getService(), groupAuthority.getNo()));
|
||||||
list.add(groupAuthority);
|
list.add(groupAuthority);
|
||||||
}
|
}
|
||||||
@@ -67,7 +72,10 @@ public class RoleAuthorityHandler implements TsAuthorityHandler {
|
|||||||
menuAuthority.setType("menu");
|
menuAuthority.setType("menu");
|
||||||
menuAuthority.setLevel(groupAuthority.getLevel() + 1);
|
menuAuthority.setLevel(groupAuthority.getLevel() + 1);
|
||||||
menuAuthority.setParent(groupAuthority.getId());
|
menuAuthority.setParent(groupAuthority.getId());
|
||||||
menuAuthority.setPlatform(menu.platform());
|
menuAuthority.setPlatform(menuPlatform);
|
||||||
|
menuAuthority.setVersion(version);
|
||||||
|
menuAuthority.setSource("auto");
|
||||||
|
menuAuthority.setDeps(JSONUtil.toJsonStr(menu.deps()));
|
||||||
menuAuthority.setId(StrUtil.join("_", menuAuthority.getService(), menuAuthority.getNo()));
|
menuAuthority.setId(StrUtil.join("_", menuAuthority.getService(), menuAuthority.getNo()));
|
||||||
list.add(menuAuthority);
|
list.add(menuAuthority);
|
||||||
|
|
||||||
@@ -80,7 +88,10 @@ public class RoleAuthorityHandler implements TsAuthorityHandler {
|
|||||||
point.setType("point");
|
point.setType("point");
|
||||||
point.setLevel(menuAuthority.getLevel() + 1);
|
point.setLevel(menuAuthority.getLevel() + 1);
|
||||||
point.setParent(menuAuthority.getId());
|
point.setParent(menuAuthority.getId());
|
||||||
point.setPlatform(StrUtil.emptyToDefault(authority.platform(), menu.platform()));
|
point.setVersion(version);
|
||||||
|
point.setSource("auto");
|
||||||
|
point.setDeps(JSONUtil.toJsonStr(authority.deps()));
|
||||||
|
point.setPlatform(StrUtil.emptyToDefault(authority.platform(), menuPlatform));
|
||||||
point.setId(StrUtil.join("_", point.getService(), point.getNo()));
|
point.setId(StrUtil.join("_", point.getService(), point.getNo()));
|
||||||
list.add(point);
|
list.add(point);
|
||||||
}
|
}
|
||||||
@@ -92,7 +103,7 @@ public class RoleAuthorityHandler implements TsAuthorityHandler {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getAuthorities(TokenBean tokenBean) {
|
public List<String> getAuthorities(TokenBean tokenBean) {
|
||||||
List<CoreRoleAuthority> list = coreRoleUserMapper.getOwnerAuthorityLeafList(tokenBean.getId(),
|
List<CoreRoleAuthority> list = coreRoleUserMapper.getOwnerAuthorityLeafList(tokenBean.getId(),
|
||||||
tokenBean.getRoleId());
|
tokenBean.getRoleId(), "");
|
||||||
return list.stream().map(CoreRoleAuthority::getNo).distinct().collect(Collectors.toList());
|
return list.stream().map(CoreRoleAuthority::getNo).distinct().collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
SET NAMES utf8mb4;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
create table core_role_authority
|
create table core_role_authority
|
||||||
(
|
(
|
||||||
id varchar(50) not null
|
id varchar(50) not null
|
||||||
@@ -93,3 +96,16 @@ create table core_role_user
|
|||||||
DEFAULT CHARSET = utf8mb4
|
DEFAULT CHARSET = utf8mb4
|
||||||
comment '角色-用户';
|
comment '角色-用户';
|
||||||
|
|
||||||
|
alter table core_role_authority
|
||||||
|
add version varchar(50) null comment '版本号' after platform;
|
||||||
|
|
||||||
|
alter table core_role_authority
|
||||||
|
add source varchar(10) null comment '权限来源:auto-自动生成,input-添加' after version;
|
||||||
|
|
||||||
|
alter table core_role_authority
|
||||||
|
add deps text null comment '依赖权限' after source;
|
||||||
|
|
||||||
|
alter table core_role_group_rx
|
||||||
|
add type varchar(10) null comment '关联类型:dep-依赖,bind-绑定';
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|||||||
@@ -19,6 +19,9 @@
|
|||||||
<result column="type" jdbcType="VARCHAR" property="type" />
|
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||||
<result column="link" jdbcType="LONGVARCHAR" property="link" />
|
<result column="link" jdbcType="LONGVARCHAR" property="link" />
|
||||||
<result column="platform" jdbcType="VARCHAR" property="platform" />
|
<result column="platform" jdbcType="VARCHAR" property="platform" />
|
||||||
|
<result column="version" jdbcType="VARCHAR" property="version" />
|
||||||
|
<result column="source" jdbcType="VARCHAR" property="source" />
|
||||||
|
<result column="deps" jdbcType="LONGVARCHAR" property="deps" />
|
||||||
<result column="ext1" jdbcType="VARCHAR" property="ext1" />
|
<result column="ext1" jdbcType="VARCHAR" property="ext1" />
|
||||||
<result column="ext2" jdbcType="VARCHAR" property="ext2" />
|
<result column="ext2" jdbcType="VARCHAR" property="ext2" />
|
||||||
<result column="ext3" jdbcType="VARCHAR" property="ext3" />
|
<result column="ext3" jdbcType="VARCHAR" property="ext3" />
|
||||||
@@ -26,14 +29,14 @@
|
|||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
id, create_time, update_time, is_deleted, service, `no`, `name`, sort, `level`, parent,
|
id, create_time, update_time, is_deleted, service, `no`, `name`, sort, `level`, parent,
|
||||||
remark, is_open, `type`, link, platform, ext1, ext2, ext3
|
remark, is_open, `type`, link, platform, version, `source`, deps, ext1, ext2, ext3
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<insert id="batchInsert">
|
<insert id="batchInsert">
|
||||||
insert into core_role_authority(id, create_time, update_time, is_deleted, service, no, name, level, parent,
|
insert into core_role_authority(id, create_time, update_time, is_deleted, service, no, name, level, parent,
|
||||||
type, platform, is_open)
|
type, platform, is_open, version, source, deps)
|
||||||
values
|
values
|
||||||
<foreach collection="list" separator="," item="item">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(#{item.id}, now(), now(), 0,
|
(#{item.id}, now(), now(), 0,
|
||||||
#{item.service},
|
#{item.service},
|
||||||
#{item.no},
|
#{item.no},
|
||||||
@@ -41,7 +44,7 @@
|
|||||||
#{item.level},
|
#{item.level},
|
||||||
#{item.parent},
|
#{item.parent},
|
||||||
#{item.type},
|
#{item.type},
|
||||||
#{item.platform}, 1)
|
#{item.platform}, 1, #{item.version}, #{item.source}, #{item.deps})
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
||||||
on duplicate key update update_time=now(),
|
on duplicate key update update_time=now(),
|
||||||
@@ -49,7 +52,10 @@
|
|||||||
level=values(level),
|
level=values(level),
|
||||||
parent=values(parent),
|
parent=values(parent),
|
||||||
type=values(type),
|
type=values(type),
|
||||||
platform=values(platform)
|
platform=values(platform),
|
||||||
|
source=values(source),
|
||||||
|
deps=values(deps),
|
||||||
|
version=values(version)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -10,19 +10,20 @@
|
|||||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
|
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
|
||||||
<result column="group_id" jdbcType="VARCHAR" property="groupId" />
|
<result column="group_id" jdbcType="VARCHAR" property="groupId" />
|
||||||
<result column="menu_id" jdbcType="VARCHAR" property="menuId" />
|
<result column="menu_id" jdbcType="VARCHAR" property="menuId" />
|
||||||
|
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
id, create_time, update_time, is_deleted, group_id, menu_id
|
id, create_time, update_time, is_deleted, group_id, menu_id, `type`
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<insert id="batchInsert">
|
<insert id="batchInsert">
|
||||||
insert into core_role_group_rx(id, create_time, update_time, is_deleted, group_id, menu_id)
|
insert into core_role_group_rx(id, create_time, update_time, is_deleted, group_id, menu_id,type)
|
||||||
values
|
values
|
||||||
<foreach collection="list" separator="," item="item">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(uuid(), now(), now(), 0,
|
(uuid(), now(), now(), 0,
|
||||||
#{item.groupId},
|
#{item.groupId},
|
||||||
#{item.menuId})
|
#{item.menuId}, #{item.type})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -50,10 +50,13 @@
|
|||||||
select crgr.menu_id
|
select crgr.menu_id
|
||||||
from core_role_user cru
|
from core_role_user cru
|
||||||
left join core_role_group_rx crgr on crgr.group_id = cru.type_id
|
left join core_role_group_rx crgr on crgr.group_id = cru.type_id
|
||||||
where type = 'job'
|
where cru.type = 'job'
|
||||||
and user_id = #{userId}
|
and cru.user_id = #{userId}
|
||||||
and cru.is_deleted = 0
|
and cru.is_deleted = 0
|
||||||
and (cru.expire_time is null or cru.expire_time > now())
|
and (cru.expire_time is null or cru.expire_time > now())
|
||||||
|
<if test="type != null and type != ''">
|
||||||
|
and crgr.type=#{type}
|
||||||
|
</if>
|
||||||
|
|
||||||
<if test="roleId != null and roleId != ''">
|
<if test="roleId != null and roleId != ''">
|
||||||
union
|
union
|
||||||
@@ -61,6 +64,9 @@
|
|||||||
select menu_id
|
select menu_id
|
||||||
from core_role_group_rx
|
from core_role_group_rx
|
||||||
where group_id = #{roleId}
|
where group_id = #{roleId}
|
||||||
|
<if test="type != null and type != ''">
|
||||||
|
and type=#{type}
|
||||||
|
</if>
|
||||||
</if>
|
</if>
|
||||||
)
|
)
|
||||||
order by sort
|
order by sort
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-util</artifactId>
|
<artifactId>springboot-util</artifactId>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public interface TsAuthorityHandler {
|
|||||||
* @param pointAuthorityList
|
* @param pointAuthorityList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void addRoleAuthority(RoleAuthority groupAuthority, List<RoleAuthority> pointAuthorityList);
|
void addRoleAuthority(String version, RoleAuthority groupAuthority, List<RoleAuthority> pointAuthorityList);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc19</version>
|
<version>2.0.0.rc35</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-web</artifactId>
|
<artifactId>springboot-web</artifactId>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.tiesheng.web.config.role;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.tiesheng.annotation.role.RoleAuthority;
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
|
import com.tiesheng.annotation.role.RoleIgnore;
|
||||||
import com.tiesheng.annotation.token.TokenIgnore;
|
import com.tiesheng.annotation.token.TokenIgnore;
|
||||||
import com.tiesheng.util.ServletKit;
|
import com.tiesheng.util.ServletKit;
|
||||||
import com.tiesheng.util.config.TsTokenConfig;
|
import com.tiesheng.util.config.TsTokenConfig;
|
||||||
@@ -48,6 +49,10 @@ public class RoleAuthorityAspect {
|
|||||||
if (tokenIgnore != null) {
|
if (tokenIgnore != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
RoleIgnore roleIgnore = signature.getMethod().getAnnotation(RoleIgnore.class);
|
||||||
|
if (roleIgnore != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
HttpServletRequest request = ServletKit.getRequest();
|
HttpServletRequest request = ServletKit.getRequest();
|
||||||
TokenBean tokenBean = tsTokenConfig.validToken(request, true);
|
TokenBean tokenBean = tsTokenConfig.validToken(request, true);
|
||||||
@@ -61,17 +66,21 @@ public class RoleAuthorityAspect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isAuthorized;
|
||||||
String authority = StrUtil.join("_", classAnnotation.group(), classAnnotation.value());
|
String authority = StrUtil.join("_", classAnnotation.group(), classAnnotation.value());
|
||||||
RoleAuthority annotation = signature.getMethod().getAnnotation(RoleAuthority.class);
|
RoleAuthority annotation = signature.getMethod().getAnnotation(RoleAuthority.class);
|
||||||
if(annotation == null) {
|
if (annotation != null) {
|
||||||
return;
|
// 检查是否是功能点的权限
|
||||||
|
isAuthorized = CollUtil.contains(authorityList, StrUtil.join("_", authority, annotation.value()));
|
||||||
|
} else {
|
||||||
|
// 检查是否有menu的权限
|
||||||
|
isAuthorized = !authorityList.stream().filter(it -> StrUtil.startWith(it, authority))
|
||||||
|
.collect(Collectors.toList()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否是功能点的权限
|
if (isAuthorized) {
|
||||||
if (CollUtil.contains(authorityList, StrUtil.join("_", authority, annotation.value()))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ApiException(403, "您无权访问");
|
throw new ApiException(403, "您无权访问");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,130 +0,0 @@
|
|||||||
package com.tiesheng.web.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.annotation.role.RoleAuthority;
|
|
||||||
import com.tiesheng.login.pojos.dao.CoreLogLogin;
|
|
||||||
import com.tiesheng.util.pojos.ApiResp;
|
|
||||||
import com.tiesheng.util.pojos.PageDTO;
|
|
||||||
import com.tiesheng.web.pojos.dao.CoreLogApi;
|
|
||||||
import com.tiesheng.web.pojos.dao.CoreLogOperation;
|
|
||||||
import com.tiesheng.web.pojos.dao.CoreLogProcess;
|
|
||||||
import com.tiesheng.web.pojos.vo.ProcessDetailVo;
|
|
||||||
import com.tiesheng.web.service.CoreLogService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author hao
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/manager/log")
|
|
||||||
@RoleAuthority(value = "log", group = "system")
|
|
||||||
public class LogController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
CoreLogService coreLogService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作日志列表
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/operation/page")
|
|
||||||
@RoleAuthority(value = "operation")
|
|
||||||
public ApiResp<List<CoreLogOperation>> operationPage(@Valid PageDTO dto) {
|
|
||||||
|
|
||||||
QueryWrapper<CoreLogOperation> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("is_deleted", 0);
|
|
||||||
dto.likeColumns(queryWrapper, "user_name", "title", "subject");
|
|
||||||
queryWrapper.orderByDesc("create_time");
|
|
||||||
|
|
||||||
Page<CoreLogOperation> page = dto.pageObj();
|
|
||||||
coreLogService.getBaseMapper().page(page, queryWrapper);
|
|
||||||
|
|
||||||
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录日志列表
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/login/page")
|
|
||||||
@RoleAuthority(value = "login")
|
|
||||||
public ApiResp<List<CoreLogLogin>> loginPage(@Valid PageDTO dto) {
|
|
||||||
|
|
||||||
QueryWrapper<CoreLogLogin> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("is_deleted", 0);
|
|
||||||
dto.likeColumns(queryWrapper, "user_name", "ip", "address");
|
|
||||||
queryWrapper.orderByDesc("create_time");
|
|
||||||
|
|
||||||
Page<CoreLogLogin> page = dto.pageObj();
|
|
||||||
coreLogService.getLogLoginMapper().selectPage(page, queryWrapper);
|
|
||||||
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调用日志
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/api/page")
|
|
||||||
@RoleAuthority(value = "api")
|
|
||||||
public ApiResp<List<CoreLogApi>> apiPage(String result, @Valid PageDTO dto) {
|
|
||||||
|
|
||||||
QueryWrapper<CoreLogApi> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("is_deleted", 0);
|
|
||||||
if (!StrUtil.isEmpty(result)) {
|
|
||||||
queryWrapper.eq("result", result);
|
|
||||||
}
|
|
||||||
dto.likeColumns(queryWrapper, "type", "content");
|
|
||||||
queryWrapper.orderByDesc("create_time");
|
|
||||||
|
|
||||||
Page<CoreLogApi> page = dto.pageObj();
|
|
||||||
coreLogService.getLogApiMapper().selectPage(page, queryWrapper);
|
|
||||||
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 过程日志列表
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/process/page")
|
|
||||||
public ApiResp<List<CoreLogProcess>> processPage(String type, @Valid PageDTO dto) {
|
|
||||||
|
|
||||||
QueryWrapper<CoreLogProcess> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("is_deleted", 0);
|
|
||||||
if (!StrUtil.isEmpty(type)) {
|
|
||||||
queryWrapper.eq("type", type);
|
|
||||||
}
|
|
||||||
dto.likeColumns(queryWrapper, "title");
|
|
||||||
queryWrapper.orderByDesc("create_time");
|
|
||||||
|
|
||||||
Page<CoreLogProcess> page = dto.pageObj();
|
|
||||||
coreLogService.getCoreLogProcessMapper().selectPage(page, queryWrapper);
|
|
||||||
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 过程日志详情
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/process/detail")
|
|
||||||
public ApiResp<ProcessDetailVo> processPage(String id) {
|
|
||||||
ProcessDetailVo processDetail = coreLogService.getProcessDetail(id);
|
|
||||||
return ApiResp.respOK(processDetail);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package com.tiesheng.web.controller.comm;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Validator;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.tiesheng.annotation.token.TokenIgnore;
|
||||||
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
|
import com.tiesheng.util.pojos.IdDTO;
|
||||||
|
import com.tiesheng.web.pojos.dao.CoreConfigEnum;
|
||||||
|
import com.tiesheng.web.pojos.dao.CoreConfigSystem;
|
||||||
|
import com.tiesheng.web.pojos.dto.config.EnumTypeDTO;
|
||||||
|
import com.tiesheng.web.pojos.vo.ProcessDetailVo;
|
||||||
|
import com.tiesheng.web.service.CoreConfigService;
|
||||||
|
import com.tiesheng.web.service.CoreLogService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/comm/web")
|
||||||
|
public class CommWebController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CoreLogService coreLogService;
|
||||||
|
@Autowired
|
||||||
|
CoreConfigService coreConfigService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统配置列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/system/page")
|
||||||
|
@TokenIgnore
|
||||||
|
public ApiResp<List<CoreConfigSystem>> systemPage(String keyword) {
|
||||||
|
|
||||||
|
Validator.validateNotEmpty(keyword, "请上传关键字");
|
||||||
|
|
||||||
|
QueryWrapper<CoreConfigSystem> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("is_deleted", 0);
|
||||||
|
queryWrapper.likeRight("config_key", keyword);
|
||||||
|
queryWrapper.orderByAsc("config_key");
|
||||||
|
List<CoreConfigSystem> list = coreConfigService.list(queryWrapper);
|
||||||
|
|
||||||
|
return ApiResp.respOK(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取枚举列表
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/enum/list")
|
||||||
|
@TokenIgnore
|
||||||
|
public ApiResp<List<CoreConfigEnum>> enumList(EnumTypeDTO dto) {
|
||||||
|
QueryWrapper<CoreConfigEnum> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("is_deleted", 0);
|
||||||
|
queryWrapper.eq("type", dto.getType());
|
||||||
|
List<CoreConfigEnum> selectList = coreConfigService.getEnumMapper().selectList(queryWrapper);
|
||||||
|
|
||||||
|
return ApiResp.respOK(selectList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过程日志详情
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/process/detail")
|
||||||
|
@TokenIgnore
|
||||||
|
public ApiResp<ProcessDetailVo> processPage(@Valid IdDTO dto) {
|
||||||
|
ProcessDetailVo processDetail = coreLogService.getProcessDetail(dto.getId());
|
||||||
|
return ApiResp.respOK(processDetail);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tiesheng.web.controller;
|
package com.tiesheng.web.controller.comm;
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.captcha.LineCaptcha;
|
import cn.hutool.captcha.LineCaptcha;
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.tiesheng.web.controller.system;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
|
import com.tiesheng.web.pojos.dao.CoreConfigEnum;
|
||||||
|
import com.tiesheng.web.pojos.dto.config.EnumTypeDTO;
|
||||||
|
import com.tiesheng.web.service.CoreConfigService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/config")
|
||||||
|
@RoleAuthority(value = "enum", group = "system")
|
||||||
|
public class ConfigEnumController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CoreConfigService coreConfigService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取枚举列表
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/enum/list")
|
||||||
|
public ApiResp<List<CoreConfigEnum>> enumList(EnumTypeDTO dto) {
|
||||||
|
|
||||||
|
QueryWrapper<CoreConfigEnum> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("is_deleted", 0);
|
||||||
|
if (!StrUtil.isEmpty(dto.getType())) {
|
||||||
|
queryWrapper.eq("type", dto.getType());
|
||||||
|
}
|
||||||
|
List<CoreConfigEnum> selectList = coreConfigService.getEnumMapper().selectList(queryWrapper);
|
||||||
|
|
||||||
|
return ApiResp.respOK(selectList);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,18 +1,14 @@
|
|||||||
package com.tiesheng.web.controller;
|
package com.tiesheng.web.controller.system;
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.tiesheng.annotation.role.RoleAuthority;
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
import com.tiesheng.annotation.token.TokenIgnore;
|
|
||||||
import com.tiesheng.util.exception.ApiException;
|
import com.tiesheng.util.exception.ApiException;
|
||||||
import com.tiesheng.util.pojos.ApiResp;
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
import com.tiesheng.util.pojos.PageDTO;
|
import com.tiesheng.util.pojos.PageDTO;
|
||||||
import com.tiesheng.web.pojos.dao.CoreConfigEnum;
|
|
||||||
import com.tiesheng.web.pojos.dao.CoreConfigSystem;
|
import com.tiesheng.web.pojos.dao.CoreConfigSystem;
|
||||||
import com.tiesheng.web.pojos.dto.config.ConfigSystemDTO;
|
import com.tiesheng.web.pojos.dto.config.ConfigSystemDTO;
|
||||||
import com.tiesheng.web.pojos.dto.config.EnumTypeDTO;
|
|
||||||
import com.tiesheng.web.service.CoreConfigService;
|
import com.tiesheng.web.service.CoreConfigService;
|
||||||
import com.tiesheng.web.service.TieshengWebConfigurer;
|
import com.tiesheng.web.service.TieshengWebConfigurer;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -26,7 +22,7 @@ import java.util.List;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/config")
|
@RequestMapping("/config")
|
||||||
@RoleAuthority(value = "config", group = "system")
|
@RoleAuthority(value = "config", group = "system")
|
||||||
public class ConfigController {
|
public class ConfigSystemController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
CoreConfigService coreConfigService;
|
CoreConfigService coreConfigService;
|
||||||
@@ -40,7 +36,6 @@ public class ConfigController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/system/page")
|
@GetMapping("/system/page")
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<List<CoreConfigSystem>> systemPage(PageDTO dto) {
|
public ApiResp<List<CoreConfigSystem>> systemPage(PageDTO dto) {
|
||||||
|
|
||||||
QueryWrapper<CoreConfigSystem> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<CoreConfigSystem> queryWrapper = new QueryWrapper<>();
|
||||||
@@ -61,7 +56,6 @@ public class ConfigController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/system/update")
|
@PostMapping("/system/update")
|
||||||
@RoleAuthority(value = "systemUpdate")
|
|
||||||
public ApiResp<String> systemUpdate(@RequestBody ConfigSystemDTO dto) {
|
public ApiResp<String> systemUpdate(@RequestBody ConfigSystemDTO dto) {
|
||||||
|
|
||||||
CoreConfigSystem configKey = coreConfigService.getOneByColumn("config_key", dto.getConfigKey());
|
CoreConfigSystem configKey = coreConfigService.getOneByColumn("config_key", dto.getConfigKey());
|
||||||
@@ -81,25 +75,4 @@ public class ConfigController {
|
|||||||
return ApiResp.respOK("");
|
return ApiResp.respOK("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取枚举列表
|
|
||||||
*
|
|
||||||
* @param dto
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/enum/list")
|
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<List<CoreConfigEnum>> enumList(EnumTypeDTO dto) {
|
|
||||||
|
|
||||||
QueryWrapper<CoreConfigEnum> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("is_deleted", 0);
|
|
||||||
if (!StrUtil.isEmpty(dto.getType())) {
|
|
||||||
queryWrapper.eq("type", dto.getType());
|
|
||||||
}
|
|
||||||
List<CoreConfigEnum> selectList = coreConfigService.getEnumMapper().selectList(queryWrapper);
|
|
||||||
|
|
||||||
return ApiResp.respOK(selectList);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.tiesheng.web.controller.system;
|
||||||
|
|
||||||
|
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.annotation.role.RoleAuthority;
|
||||||
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
|
import com.tiesheng.util.pojos.PageDTO;
|
||||||
|
import com.tiesheng.web.pojos.dao.CoreLogApi;
|
||||||
|
import com.tiesheng.web.service.CoreLogService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/manager/log")
|
||||||
|
@RoleAuthority(value = "api", group = "system")
|
||||||
|
public class LogApiController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CoreLogService coreLogService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用日志
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/api/page")
|
||||||
|
public ApiResp<List<CoreLogApi>> apiPage(String result, @Valid PageDTO dto) {
|
||||||
|
|
||||||
|
QueryWrapper<CoreLogApi> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("is_deleted", 0);
|
||||||
|
if (!StrUtil.isEmpty(result)) {
|
||||||
|
queryWrapper.eq("result", result);
|
||||||
|
}
|
||||||
|
dto.likeColumns(queryWrapper, "type", "content");
|
||||||
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
|
||||||
|
Page<CoreLogApi> page = dto.pageObj();
|
||||||
|
coreLogService.getLogApiMapper().selectPage(page, queryWrapper);
|
||||||
|
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.tiesheng.web.controller.system;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
|
import com.tiesheng.login.pojos.dao.CoreLogLogin;
|
||||||
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
|
import com.tiesheng.util.pojos.PageDTO;
|
||||||
|
import com.tiesheng.web.service.CoreLogService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/manager/log")
|
||||||
|
@RoleAuthority(value = "login", group = "system")
|
||||||
|
public class LogLoginController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CoreLogService coreLogService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录日志列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/login/page")
|
||||||
|
public ApiResp<List<CoreLogLogin>> loginPage(@Valid PageDTO dto) {
|
||||||
|
|
||||||
|
QueryWrapper<CoreLogLogin> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("is_deleted", 0);
|
||||||
|
dto.likeColumns(queryWrapper, "user_name", "ip", "address");
|
||||||
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
|
||||||
|
Page<CoreLogLogin> page = dto.pageObj();
|
||||||
|
coreLogService.getLogLoginMapper().selectPage(page, queryWrapper);
|
||||||
|
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.tiesheng.web.controller.system;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
|
import com.tiesheng.util.pojos.PageDTO;
|
||||||
|
import com.tiesheng.web.pojos.dao.CoreLogOperation;
|
||||||
|
import com.tiesheng.web.service.CoreLogService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/manager/log")
|
||||||
|
@RoleAuthority(value = "operation", group = "system")
|
||||||
|
public class LogOperationController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CoreLogService coreLogService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作日志列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/operation/page")
|
||||||
|
public ApiResp<List<CoreLogOperation>> operationPage(@Valid PageDTO dto) {
|
||||||
|
|
||||||
|
QueryWrapper<CoreLogOperation> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("is_deleted", 0);
|
||||||
|
dto.likeColumns(queryWrapper, "user_name", "title", "subject");
|
||||||
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
|
||||||
|
Page<CoreLogOperation> page = dto.pageObj();
|
||||||
|
coreLogService.getBaseMapper().page(page, queryWrapper);
|
||||||
|
|
||||||
|
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.tiesheng.web.controller.system;
|
||||||
|
|
||||||
|
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.annotation.role.RoleAuthority;
|
||||||
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
|
import com.tiesheng.util.pojos.PageDTO;
|
||||||
|
import com.tiesheng.web.pojos.dao.CoreLogProcess;
|
||||||
|
import com.tiesheng.web.service.CoreLogService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/manager/log")
|
||||||
|
@RoleAuthority(value = "process", group = "system")
|
||||||
|
public class LogProcessController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CoreLogService coreLogService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过程日志列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/process/page")
|
||||||
|
public ApiResp<List<CoreLogProcess>> processPage(String type, @Valid PageDTO dto) {
|
||||||
|
|
||||||
|
QueryWrapper<CoreLogProcess> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("is_deleted", 0);
|
||||||
|
if (!StrUtil.isEmpty(type)) {
|
||||||
|
queryWrapper.eq("type", type);
|
||||||
|
}
|
||||||
|
dto.likeColumns(queryWrapper, "title");
|
||||||
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
|
||||||
|
Page<CoreLogProcess> page = dto.pageObj();
|
||||||
|
coreLogService.getCoreLogProcessMapper().selectPage(page, queryWrapper);
|
||||||
|
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -179,7 +179,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
|||||||
if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
|
if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RequestUserInfo requestUserInfo = tieshengWebConfigurer.configureLogin().getCachedUserInfo(tokenBean);
|
RequestUserInfo requestUserInfo = tieshengWebConfigurer.configureLogin().getCachedUserInfo(tokenBean, false);
|
||||||
if (requestUserInfo == null) {
|
if (requestUserInfo == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user