mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-04 22:41:24 +08:00
Added permission control for WorkController
This commit is contained in:
@@ -7,6 +7,7 @@ import com.cfive.pinnacle.entity.common.ResponseResult;
|
|||||||
import com.cfive.pinnacle.service.IWorkService;
|
import com.cfive.pinnacle.service.IWorkService;
|
||||||
import com.cfive.pinnacle.utils.WebUtil;
|
import com.cfive.pinnacle.utils.WebUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -26,60 +27,87 @@ import java.util.List;
|
|||||||
public class WorkController {
|
public class WorkController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IWorkService workService;
|
private IWorkService workService;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseResult getAll(String content) {
|
@PreAuthorize("hasAuthority('work:manage:get')")
|
||||||
|
public ResponseResult<List<Work>> getAll(String content) {
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
List<Work> workList = workService.getWorkByContent(content);
|
List<Work> workList = workService.getWorkByContent(content);
|
||||||
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success",workList);
|
return ResponseResult.databaseSelectSuccess(workList);
|
||||||
} else {
|
} else {
|
||||||
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getAll());
|
return ResponseResult.databaseSelectSuccess(workService.getAll());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/todo")
|
@GetMapping("/todo")
|
||||||
public ResponseResult getTodo() {
|
@PreAuthorize("hasAuthority('work:self:get')")
|
||||||
|
public ResponseResult<List<Work>> getTodo() {
|
||||||
Long userId = WebUtil.getLoginUser().getUser().getId();
|
Long userId = WebUtil.getLoginUser().getUser().getId();
|
||||||
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getTodo(userId));
|
return ResponseResult.databaseSelectSuccess(workService.getTodo(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/card")
|
@GetMapping("/card")
|
||||||
public ResponseResult getCard() {
|
public ResponseResult<List<Work>> getCard() {
|
||||||
Long userId = WebUtil.getLoginUser().getUser().getId();
|
if (WebUtil.hasAuthority("work:self:home")) {
|
||||||
// long userId = 1;
|
Long userId = WebUtil.getLoginUser().getUser().getId();
|
||||||
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getCard(userId));
|
return ResponseResult.databaseSelectSuccess(workService.getCard(userId));
|
||||||
|
}
|
||||||
|
return ResponseResult.databaseSelectSuccess(List.of());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/complete")
|
@GetMapping("/complete")
|
||||||
public ResponseResult getComplete() {
|
@PreAuthorize("hasAuthority('work:self:get')")
|
||||||
|
public ResponseResult<List<Work>> getComplete() {
|
||||||
Long userId = WebUtil.getLoginUser().getUser().getId();
|
Long userId = WebUtil.getLoginUser().getUser().getId();
|
||||||
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getComplete(userId));
|
return ResponseResult.databaseSelectSuccess(workService.getComplete(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{workId}")
|
@GetMapping("/{workId}")
|
||||||
public ResponseResult getOne(@PathVariable Long workId) {
|
@PreAuthorize("hasAuthority('work:self:detail') and hasAuthority('work:self:get')")
|
||||||
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success",workService.getOne(workId));
|
public ResponseResult<Work> getOne(@PathVariable Long workId) {
|
||||||
|
return ResponseResult.databaseSelectSuccess(workService.getOne(workId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public ResponseResult addWork(@RequestBody Work work) {
|
@PreAuthorize("hasAuthority('work:manage:add')")
|
||||||
|
public ResponseResult<Work> addWork(@RequestBody Work work) {
|
||||||
work.setPublisherId(WebUtil.getLoginUser().getUser().getId());
|
work.setPublisherId(WebUtil.getLoginUser().getUser().getId());
|
||||||
return ResponseResult.build(ResponseCode.DATABASE_SAVE_OK, "success", workService.addWork(work));
|
if (workService.addWork(work)) {
|
||||||
|
return ResponseResult.databaseSaveSuccess(work);
|
||||||
|
} else {
|
||||||
|
return ResponseResult.build(ResponseCode.DATABASE_SAVE_ERROR, "Add failed", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public ResponseResult deleteById(@PathVariable Long id) {
|
@PreAuthorize("hasAuthority('work:manage:delete')")
|
||||||
return ResponseResult.build(ResponseCode.DATABASE_DELETE_OK, "success", workService.deleteByWorkId(id));
|
public ResponseResult<?> deleteById(@PathVariable Long id) {
|
||||||
|
if (workService.deleteByWorkId(id)) {
|
||||||
|
return ResponseResult.databaseDeleteSuccess();
|
||||||
|
} else {
|
||||||
|
return ResponseResult.build(ResponseCode.DATABASE_DELETE_ERROR, "Delete failed", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/setStatus")
|
@PutMapping("/setStatus")
|
||||||
public ResponseResult updateStatus(@RequestBody UserWork userWork) {
|
@PreAuthorize("hasAuthority('work:self:status') and hasAuthority('work:self:get')")
|
||||||
|
public ResponseResult<UserWork> updateStatus(@RequestBody UserWork userWork) {
|
||||||
userWork.setUserId(WebUtil.getLoginUser().getUser().getId());
|
userWork.setUserId(WebUtil.getLoginUser().getUser().getId());
|
||||||
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_OK, "success", workService.updateStatus(userWork));
|
if (workService.updateStatus(userWork)) {
|
||||||
|
return ResponseResult.databaseUpdateSuccess(userWork);
|
||||||
|
} else {
|
||||||
|
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_ERROR, "Update failed", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public ResponseResult updateWork(@RequestBody Work work) {
|
@PreAuthorize("hasAuthority('work:manage:modify')")
|
||||||
|
public ResponseResult<Work> updateWork(@RequestBody Work work) {
|
||||||
work.setPublisherId(WebUtil.getLoginUser().getUser().getId());
|
work.setPublisherId(WebUtil.getLoginUser().getUser().getId());
|
||||||
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_OK, "success", workService.updateWork(work));
|
if (workService.updateWork(work)) {
|
||||||
|
return ResponseResult.databaseUpdateSuccess(work);
|
||||||
|
} else {
|
||||||
|
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_ERROR, "Update failed", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class WebUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String objectResponse(int resultCode, String msg, Object object) throws JsonProcessingException {
|
public static String objectResponse(int resultCode, String msg, Object object) throws JsonProcessingException {
|
||||||
ResponseResult result = ResponseResult.build(resultCode, msg, object);
|
ResponseResult<Object> result = ResponseResult.build(resultCode, msg, object);
|
||||||
return convert2json(result);
|
return convert2json(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,4 +32,17 @@ public class WebUtil {
|
|||||||
Object principal = authentication.getPrincipal();
|
Object principal = authentication.getPrincipal();
|
||||||
return (LoginUser) principal;
|
return (LoginUser) principal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasAuthority(String authority) {
|
||||||
|
return hasAnyAuthority(authority);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasAnyAuthority(String... authorities) {
|
||||||
|
for (String authority : authorities) {
|
||||||
|
if (getLoginUser().getAuthorities().stream().anyMatch(grantedAuthority -> grantedAuthority.getAuthority().equals(authority))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
354
sql/Insert.sql
354
sql/Insert.sql
@@ -16,245 +16,271 @@ values (1, 'menu'),
|
|||||||
(3, 'operation');
|
(3, 'operation');
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power (id, type_id)
|
||||||
values (1);
|
values (1010000, 1);
|
||||||
insert into t_menu (id, name, url, power_id, parent_id)
|
insert into t_menu (id, name, url, power_id, parent_id)
|
||||||
VALUES (1, '公用', '/', last_insert_id(), null);
|
VALUES (1010000, '公用', '/', id, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power (id,type_id)
|
||||||
values (2);
|
values (1010100, 2);
|
||||||
insert into t_element(id, name, power_id, menu_id)
|
insert into t_element(id, name, power_id, menu_id)
|
||||||
VALUES (1, '公用', last_insert_id(), 1);
|
VALUES (1010100, '公用', id, 1010000);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power(type_id)
|
insert into t_power(id,type_id)
|
||||||
values (3);
|
values (1010101, 3);
|
||||||
insert into t_operation(name, code, power_id, element_id, parent_id)
|
insert into t_operation(id,name, code, power_id, element_id, parent_id)
|
||||||
VALUES ('查询当前用户权限', 'common:power:self', last_insert_id(), 1, null);
|
VALUES (1010101, '查询当前用户信息', 'common:user:self', id, 1010100, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power(type_id)
|
insert into t_power (id, type_id)
|
||||||
values (3);
|
values (2010000, 1);
|
||||||
insert into t_operation(name, code, power_id, element_id, parent_id)
|
|
||||||
VALUES ('查询当前用户信息', 'common:info:self', last_insert_id(), 1, null);
|
|
||||||
commit;
|
|
||||||
|
|
||||||
begin;
|
|
||||||
insert into t_power (type_id)
|
|
||||||
values (1);
|
|
||||||
insert into t_menu (id, name, url, power_id, parent_id)
|
insert into t_menu (id, name, url, power_id, parent_id)
|
||||||
VALUES (2, '角色管理', '/power/role', last_insert_id(), null);
|
VALUES (2010000, '工作事项', '/work/task', id, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power(id, type_id)
|
||||||
values (2);
|
VALUES (2010100, 2);
|
||||||
insert into t_element (id, name, power_id, menu_id)
|
insert into t_element(id, name, power_id, menu_id)
|
||||||
VALUES (2, '角色列表', last_insert_id(), 2);
|
VALUES (2010100, '列表', id, 2010000);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power(id,type_id)
|
||||||
values (3);
|
values (2010101,3);
|
||||||
insert into t_operation (name, code, power_id, element_id, parent_id)
|
insert into t_operation(id,name, code, power_id, element_id, parent_id)
|
||||||
VALUES ('查询所有角色', 'system:role:all', last_insert_id(), 2, null);
|
VALUES (2010101, '获取首页待办工作', 'work:self:home', id, 2010100, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power(id,type_id)
|
||||||
values (3);
|
values (2010102,3);
|
||||||
insert into t_operation (name, code, power_id, element_id, parent_id)
|
insert into t_operation(id,name, code, power_id, element_id, parent_id)
|
||||||
VALUES ('添加角色', 'system:role:add', last_insert_id(), 2, null);
|
VALUES (2010102, '获取个人工作', 'work:self:get', id, 2010100, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power(id,type_id)
|
||||||
values (3);
|
values (2010103,3);
|
||||||
insert into t_operation (name, code, power_id, element_id, parent_id)
|
insert into t_operation(id,name, code, power_id, element_id, parent_id)
|
||||||
VALUES ('删除角色', 'system:role:delete', last_insert_id(), 2, null);
|
VALUES (2010103, '获取工作详细内容', 'work:self:detail', id, 2010100, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power(id,type_id)
|
||||||
values (3);
|
values (2010104,3);
|
||||||
insert into t_operation (name, code, power_id, element_id, parent_id)
|
insert into t_operation(id,name, code, power_id, element_id, parent_id)
|
||||||
VALUES ('修改角色', 'system:role:modify', last_insert_id(), 2, null);
|
VALUES (2010104, '更新工作状态', 'work:self:status', id, 2010100, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power (id, type_id)
|
||||||
values (1);
|
values (2020000, 1);
|
||||||
insert into t_menu (id, name, url, power_id, parent_id)
|
insert into t_menu (id, name, url, power_id, parent_id)
|
||||||
VALUES (3, '用户组管理', '/power/group', last_insert_id(), null);
|
VALUES (2020000, '工作管理', '/work/manage', id, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power(id, type_id)
|
||||||
values (2);
|
VALUES (2020100, 2);
|
||||||
insert into t_element (id, name, power_id, menu_id)
|
insert into t_element(id, name, power_id, menu_id)
|
||||||
VALUES (3, '用户组列表', last_insert_id(), 3);
|
VALUES (2020100, '列表', id, 2020000);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power(id, type_id)
|
||||||
values (3);
|
values (2020101, 3);
|
||||||
insert into t_operation (name, code, power_id, element_id, parent_id)
|
insert into t_operation(id, name, code, power_id, element_id, parent_id)
|
||||||
VALUES ('查询所有用户组', 'system:group:all', last_insert_id(), 3, null);
|
VALUES (2020101, '获取发布的工作事项', 'work:manage:get', id, 2020100, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power(id, type_id)
|
||||||
values (3);
|
values (2020102, 3);
|
||||||
insert into t_operation (name, code, power_id, element_id, parent_id)
|
insert into t_operation(id, name, code, power_id, element_id, parent_id)
|
||||||
VALUES ('添加用户组', 'system:group:add', last_insert_id(), 3, null);
|
VALUES (2020102, '发布工作事项', 'work:manage:add', id, 2020100, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power(id, type_id)
|
||||||
values (3);
|
values (2020103, 3);
|
||||||
insert into t_operation (name, code, power_id, element_id, parent_id)
|
insert into t_operation(id, name, code, power_id, element_id, parent_id)
|
||||||
VALUES ('删除用户组', 'system:group:delete', last_insert_id(), 3, null);
|
VALUES (2020103, '删除发布的工作事项', 'work:manage:delete', id, 2020100, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power(id, type_id)
|
||||||
values (3);
|
values (2020104, 3);
|
||||||
insert into t_operation (name, code, power_id, element_id, parent_id)
|
insert into t_operation(id, name, code, power_id, element_id, parent_id)
|
||||||
VALUES ('修改用户组', 'system:group:modify', last_insert_id(), 3, null);
|
VALUES (2020104, '修改发布的工作内容', 'work:manage:modify', id, 2020100, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power(id, type_id)
|
||||||
values (1);
|
values (2020105, 3);
|
||||||
|
insert into t_operation(id, name, code, power_id, element_id, parent_id)
|
||||||
|
VALUES (2020105, '获取所有工作事项(管理)', 'work:admin:get', id, 2020100, null);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power(id, type_id)
|
||||||
|
values (2020106, 3);
|
||||||
|
insert into t_operation(id, name, code, power_id, element_id, parent_id)
|
||||||
|
VALUES (2020106, '添加工作事项(管理)', 'work:admin:add', id, 2020100, null);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power(id, type_id)
|
||||||
|
values (2020107, 3);
|
||||||
|
insert into t_operation(id, name, code, power_id, element_id, parent_id)
|
||||||
|
VALUES (2020107, '删除工作事项(管理)', 'work:admin:delete', id, 2020100, null);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power(id, type_id)
|
||||||
|
values (2020108, 3);
|
||||||
|
insert into t_operation(id, name, code, power_id, element_id, parent_id)
|
||||||
|
VALUES (2020108, '修改工作事项(管理)', 'work:admin:modify', id, 2020100, null);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power (id, type_id)
|
||||||
|
values (101010000, 1);
|
||||||
insert into t_menu (id, name, url, power_id, parent_id)
|
insert into t_menu (id, name, url, power_id, parent_id)
|
||||||
VALUES (4, '用户管理', '/power/user', last_insert_id(), null);
|
VALUES (101010000, '角色管理(权限相关)', '/power/role', id, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power (id, type_id)
|
||||||
values (2);
|
values (101010100, 2);
|
||||||
insert into t_element (id, name, power_id, menu_id)
|
insert into t_element (id, name, power_id, menu_id)
|
||||||
VALUES (4, '用户列表', last_insert_id(), 4);
|
VALUES (101010100, '列表', id, 101010000);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power (id, type_id)
|
||||||
values (3);
|
values (101010101, 3);
|
||||||
insert into t_operation (name, code, power_id, element_id, parent_id)
|
insert into t_operation (id, name, code, power_id, element_id, parent_id)
|
||||||
VALUES ('查看所有用户', 'system:user:all', last_insert_id(), 4, null);
|
VALUES (101010101, '查询所有角色', 'system:role:all', id, 101010100, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power (id, type_id)
|
||||||
values (3);
|
values (101010102, 3);
|
||||||
insert into t_operation (name, code, power_id, element_id, parent_id)
|
insert into t_operation (id, name, code, power_id, element_id, parent_id)
|
||||||
VALUES ('查看单个用户', 'system:user:one', last_insert_id(), 4, null);
|
VALUES (101010102, '添加角色', 'system:role:add', id, 101010100, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power (id, type_id)
|
||||||
values (3);
|
values (101010103, 3);
|
||||||
insert into t_operation (name, code, power_id, element_id, parent_id)
|
insert into t_operation (id, name, code, power_id, element_id, parent_id)
|
||||||
VALUES ('添加用户', 'system:user:add', last_insert_id(), 4, null);
|
VALUES (101010103, '删除角色', 'system:role:delete', id, 101010100, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power (id, type_id)
|
||||||
values (3);
|
values (101010104, 3);
|
||||||
insert into t_operation (name, code, power_id, element_id, parent_id)
|
insert into t_operation (id, name, code, power_id, element_id, parent_id)
|
||||||
VALUES ('删除用户', 'system:user:delete', last_insert_id(), 4, null);
|
VALUES (101010104, '修改角色', 'system:role:modify', id, 101010100, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (type_id)
|
insert into t_power (id, type_id)
|
||||||
values (3);
|
values (102010000, 1);
|
||||||
insert into t_operation (name, code, power_id, element_id, parent_id)
|
insert into t_menu (id, name, url, power_id, parent_id)
|
||||||
VALUES ('修改用户', 'system:user:modify', last_insert_id(), 4, null);
|
VALUES (102010000, '用户组管理(权限相关)', '/power/group', id, null);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
begin;
|
||||||
|
insert into t_power (id, type_id)
|
||||||
|
values (102010100, 2);
|
||||||
|
insert into t_element (id, name, power_id, menu_id)
|
||||||
|
VALUES (102010100, '列表', id, 102010000);
|
||||||
|
commit;
|
||||||
|
|
||||||
select *
|
begin;
|
||||||
from t_role
|
insert into t_power (id, type_id)
|
||||||
left join t_power_role tpr on t_role.id = tpr.role_id
|
values (102010101, 3);
|
||||||
left join t_power tp on tp.id = tpr.power_id
|
insert into t_operation (id, name, code, power_id, element_id, parent_id)
|
||||||
left join t_menu tm on tp.id = tm.power_id
|
VALUES (102010101, '查询所有用户组', 'system:group:all', id, 102010100, null);
|
||||||
left join t_element te on tp.id = te.power_id
|
commit;
|
||||||
left join t_operation t on tp.id = t.power_id;
|
|
||||||
|
|
||||||
select *
|
begin;
|
||||||
from t_group
|
insert into t_power (id, type_id)
|
||||||
left join t_role_group trg on t_group.id = trg.group_id
|
values (102010102, 3);
|
||||||
left join t_role tr on tr.id = trg.role_id;
|
insert into t_operation (id, name, code, power_id, element_id, parent_id)
|
||||||
|
VALUES (102010102, '添加用户组', 'system:group:add', id, 102010100, null);
|
||||||
|
commit;
|
||||||
|
|
||||||
update t_user
|
begin;
|
||||||
set deleted = id
|
insert into t_power (id, type_id)
|
||||||
where id = 1658537970212278274;
|
values (102010103, 3);
|
||||||
|
insert into t_operation (id, name, code, power_id, element_id, parent_id)
|
||||||
|
VALUES (102010103, '删除用户组', 'system:group:delete', id, 102010100, null);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power (id, type_id)
|
||||||
|
values (102010104, 3);
|
||||||
|
insert into t_operation (id, name, code, power_id, element_id, parent_id)
|
||||||
|
VALUES (102010104, '修改用户组', 'system:group:modify', id, 102010100, null);
|
||||||
|
commit;
|
||||||
|
|
||||||
select *
|
begin;
|
||||||
from t_user
|
insert into t_power (id, type_id)
|
||||||
inner join t_user_role tur on t_user.id = tur.user_id
|
values (103010000, 1);
|
||||||
inner join t_role tr on tr.id = tur.role_id
|
insert into t_menu (id, name, url, power_id, parent_id)
|
||||||
inner join t_user_group tug on t_user.id = tug.user_id
|
VALUES (103010000, '用户管理(权限相关)', '/power/user', id, null);
|
||||||
inner join t_group tg on tg.id = tug.group_id;
|
commit;
|
||||||
|
|
||||||
select t_user.id as user_id,
|
begin;
|
||||||
t_user.username as user_username,
|
insert into t_power (id, type_id)
|
||||||
t_user.department_id as user_department,
|
values (103010100, 2);
|
||||||
t_user.enable as user_enable,
|
insert into t_element (id, name, power_id, menu_id)
|
||||||
t_user.deleted as user_deleted,
|
VALUES (103010100, '列表', id, 103010000);
|
||||||
t_user.version as user_version,
|
commit;
|
||||||
tr.id as role_id,
|
|
||||||
tr.name as role_name,
|
|
||||||
tr.deleted as role_deleted,
|
|
||||||
tr.version as role_version,
|
|
||||||
tg.id as group_id,
|
|
||||||
tg.name as group_name,
|
|
||||||
tg.deleted as group_deleted,
|
|
||||||
tg.version as group_version
|
|
||||||
from t_user
|
|
||||||
left join (select * from t_user_role where deleted = 0) as tur on t_user.id = tur.user_id
|
|
||||||
left join (select * from t_role where deleted = 0) as tr on tr.id = tur.role_id
|
|
||||||
left join (select * from t_user_group where deleted = 0) as tug on t_user.id = tug.user_id
|
|
||||||
left join (select * from t_group where deleted = 0) as tg on tg.id = tug.group_id
|
|
||||||
where t_user.deleted = 0;
|
|
||||||
|
|
||||||
select distinct t_user.id as user_id,
|
begin;
|
||||||
t_user.username as user_username,
|
insert into t_power (id, type_id)
|
||||||
t_user.passwd as user_passwd,
|
values (103010101, 3);
|
||||||
t_user.department_id as user_department,
|
insert into t_operation (id, name, code, power_id, element_id, parent_id)
|
||||||
t_user.enable as user_enable,
|
VALUES (103010101, '查看所有用户', 'system:user:all', id, 103010100, null);
|
||||||
t_user.deleted as user_deleted,
|
commit;
|
||||||
t_user.version as user_version,
|
|
||||||
tm.id as menu_id,
|
begin;
|
||||||
tm.name as menu_name,
|
insert into t_power (id, type_id)
|
||||||
tm.url as menu_url,
|
values (103010102, 3);
|
||||||
tm.power_id as menu_powerId,
|
insert into t_operation (id, name, code, power_id, element_id, parent_id)
|
||||||
tm.parent_id as menu_parentId,
|
VALUES (103010102, '查看单个用户', 'system:user:one', id, 103010100, null);
|
||||||
te.id as element_id,
|
commit;
|
||||||
te.name as element_name,
|
|
||||||
te.power_id as element_powerId,
|
begin;
|
||||||
te.menu_id as element_menuId,
|
insert into t_power (id, type_id)
|
||||||
t.id as operation_id,
|
values (103010103, 3);
|
||||||
t.name as operation_name,
|
insert into t_operation (id, name, code, power_id, element_id, parent_id)
|
||||||
t.code as operation_code,
|
VALUES (103010103, '添加用户', 'system:user:add', id, 103010100, null);
|
||||||
t.power_id as operation_powerId,
|
commit;
|
||||||
t.element_id as operation_elementId,
|
|
||||||
t.parent_id as operation_parentId
|
begin;
|
||||||
from t_user
|
insert into t_power (id, type_id)
|
||||||
left join (select * from t_user_group where deleted = 0) as tug on t_user.id = tug.user_id
|
values (103010104, 3);
|
||||||
left join (select * from t_group where deleted = 0) as tg on tg.id = tug.group_id
|
insert into t_operation (id, name, code, power_id, element_id, parent_id)
|
||||||
left join (select * from t_role_group where deleted = 0) as trg on tg.id = trg.group_id
|
VALUES (103010104, '删除用户', 'system:user:delete', id, 103010100, null);
|
||||||
left join (select * from t_user_role where deleted = 0) as tur on t_user.id = tur.user_id
|
commit;
|
||||||
left join (select * from t_role where deleted = 0) as tr on tr.id = trg.role_id or tr.id = tur.role_id
|
|
||||||
left join (select * from t_power_role where deleted = 0) as tpr on tpr.role_id = tr.id
|
begin;
|
||||||
left join t_power as tp on tp.id = tpr.power_id
|
insert into t_power (id, type_id)
|
||||||
left join t_menu tm on tp.id = tm.power_id
|
values (103010105, 3);
|
||||||
left join t_element te on tp.id = te.power_id
|
insert into t_operation (id, name, code, power_id, element_id, parent_id)
|
||||||
left join t_operation t on tp.id = t.power_id
|
VALUES (103010105, '修改用户', 'system:user:modify', id, 103010100, null);
|
||||||
where t_user.deleted = 0;
|
commit;
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
Reference in New Issue
Block a user