mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-04 22:41:24 +08:00
Added permission control for AffairManagement
This commit is contained in:
@@ -9,6 +9,7 @@ import com.cfive.pinnacle.entity.common.ResponseResult;
|
|||||||
import com.cfive.pinnacle.service.IAffairService;
|
import com.cfive.pinnacle.service.IAffairService;
|
||||||
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;
|
||||||
@@ -34,6 +35,7 @@ public class AffairController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
|
@PreAuthorize("hasAuthority('affair:self:add')")
|
||||||
public ResponseResult<Boolean> addAffair(@RequestBody Affair affair) {
|
public ResponseResult<Boolean> addAffair(@RequestBody Affair affair) {
|
||||||
return ResponseResult.build(ResponseCode.DATABASE_SAVE_OK, "success", affairService.save(affair));
|
return ResponseResult.build(ResponseCode.DATABASE_SAVE_OK, "success", affairService.save(affair));
|
||||||
}
|
}
|
||||||
@@ -50,6 +52,7 @@ public class AffairController {
|
|||||||
}//获取当前用户
|
}//获取当前用户
|
||||||
|
|
||||||
@GetMapping("/personal_affairs")
|
@GetMapping("/personal_affairs")
|
||||||
|
@PreAuthorize("hasAuthority('affair:self:get')")
|
||||||
public ResponseResult<List<Affair>> getPersonalAffairs() {
|
public ResponseResult<List<Affair>> getPersonalAffairs() {
|
||||||
LambdaQueryWrapper<Affair> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Affair> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(Affair::getApplicantId, WebUtil.getLoginUser().getUser().getId());
|
wrapper.eq(Affair::getApplicantId, WebUtil.getLoginUser().getUser().getId());
|
||||||
@@ -59,6 +62,7 @@ public class AffairController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping("/not_approved")
|
@GetMapping("/not_approved")
|
||||||
|
@PreAuthorize("hasAuthority('affair:manage:get')")
|
||||||
public ResponseResult<List<Affair>> selectNotApproved() {
|
public ResponseResult<List<Affair>> selectNotApproved() {
|
||||||
LambdaQueryWrapper<Affair> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Affair> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(Affair::getStatus, 0).eq(Affair::getInspectorId, WebUtil.getLoginUser().getUser().getId());
|
wrapper.eq(Affair::getStatus, 0).eq(Affair::getInspectorId, WebUtil.getLoginUser().getUser().getId());
|
||||||
@@ -68,6 +72,7 @@ public class AffairController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping("/approved")
|
@GetMapping("/approved")
|
||||||
|
@PreAuthorize("hasAuthority('affair:manage:get')")
|
||||||
public ResponseResult<List<Affair>> selectApproved() {
|
public ResponseResult<List<Affair>> selectApproved() {
|
||||||
LambdaQueryWrapper<Affair> wrapper2 = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Affair> wrapper2 = new LambdaQueryWrapper<>();
|
||||||
wrapper2.ne(Affair::getStatus, 0).eq(Affair::getInspectorId, WebUtil.getLoginUser().getUser().getId());
|
wrapper2.ne(Affair::getStatus, 0).eq(Affair::getInspectorId, WebUtil.getLoginUser().getUser().getId());
|
||||||
@@ -76,6 +81,7 @@ public class AffairController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/yes")
|
@PutMapping("/yes")
|
||||||
|
@PreAuthorize("hasAuthority('affair:manage:modify')")
|
||||||
public ResponseResult updateAffairYes(@RequestBody Affair affair) {
|
public ResponseResult updateAffairYes(@RequestBody Affair affair) {
|
||||||
System.out.println(affair);
|
System.out.println(affair);
|
||||||
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_OK, "success", affairService.updateAffairYes(affair));
|
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_OK, "success", affairService.updateAffairYes(affair));
|
||||||
@@ -83,6 +89,7 @@ public class AffairController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/no")
|
@PutMapping("/no")
|
||||||
|
@PreAuthorize("hasAuthority('affair:manage:modify')")
|
||||||
public ResponseResult updateAffairNo(@RequestBody Affair affair) {
|
public ResponseResult updateAffairNo(@RequestBody Affair affair) {
|
||||||
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_OK, "success", affairService.updateAffairNo(affair));
|
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_OK, "success", affairService.updateAffairNo(affair));
|
||||||
//审批驳回
|
//审批驳回
|
||||||
@@ -90,6 +97,7 @@ public class AffairController {
|
|||||||
|
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
|
@PreAuthorize("hasAuthority('affair:manage:delete')")
|
||||||
public ResponseResult deleteAffairApproved(@PathVariable Long id) {
|
public ResponseResult deleteAffairApproved(@PathVariable Long id) {
|
||||||
System.out.println("affair");
|
System.out.println("affair");
|
||||||
return ResponseResult.build(ResponseCode.DATABASE_DELETE_OK, "success", affairService.removeById(id));
|
return ResponseResult.build(ResponseCode.DATABASE_DELETE_OK, "success", affairService.removeById(id));
|
||||||
|
|||||||
@@ -39,6 +39,13 @@ public class UserController {
|
|||||||
return ResponseResult.databaseSelectSuccess(userService.getInfo());
|
return ResponseResult.databaseSelectSuccess(userService.getInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/affair")
|
||||||
|
@PreAuthorize("hasAuthority('affair:self:add')")
|
||||||
|
@Operation(summary = "获取拥有审批权限的用户")
|
||||||
|
public ResponseResult<List<User>> getAffairUser() {
|
||||||
|
return ResponseResult.databaseSelectSuccess(userService.getAffairUser());
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("hasAnyAuthority('system:user:all', 'system:user:add', 'system:user:modify')")
|
@PreAuthorize("hasAnyAuthority('system:user:all', 'system:user:add', 'system:user:modify')")
|
||||||
@Operation(summary = "获取所有用户(权限管理相关)")
|
@Operation(summary = "获取所有用户(权限管理相关)")
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import java.util.List;
|
|||||||
public interface UserMapper extends BaseMapper<User> {
|
public interface UserMapper extends BaseMapper<User> {
|
||||||
List<User> getAll();
|
List<User> getAll();
|
||||||
|
|
||||||
|
List<User> getAllAffairUser();
|
||||||
|
|
||||||
User getOneById(@Param("id") long id);
|
User getOneById(@Param("id") long id);
|
||||||
|
|
||||||
User getOneWithPowerByUsername(@Param("username") String username);
|
User getOneWithPowerByUsername(@Param("username") String username);
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ public interface IUserService extends IService<User> {
|
|||||||
|
|
||||||
User getInfo();
|
User getInfo();
|
||||||
|
|
||||||
|
List<User> getAffairUser();
|
||||||
|
|
||||||
List<User> getAllUser();
|
List<User> getAllUser();
|
||||||
|
|
||||||
User getUser(long id);
|
User getUser(long id);
|
||||||
|
|||||||
@@ -73,6 +73,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|||||||
return WebUtil.getLoginUser().getUser();
|
return WebUtil.getLoginUser().getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<User> getAffairUser() {
|
||||||
|
return userMapper.getAllAffairUser();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getAllUser() {
|
public List<User> getAllUser() {
|
||||||
List<User> users = userMapper.getAll();
|
List<User> users = userMapper.getAll();
|
||||||
|
|||||||
@@ -106,6 +106,41 @@
|
|||||||
where t_user.deleted = 0
|
where t_user.deleted = 0
|
||||||
and t_user.username = #{username};
|
and t_user.username = #{username};
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getAllAffairUser" resultMap="userMap">
|
||||||
|
select t_user.id as user_id,
|
||||||
|
t_user.username as user_username,
|
||||||
|
t_user.department_id as user_department_id,
|
||||||
|
t_user.enable as user_enable,
|
||||||
|
t_user.deleted as user_deleted,
|
||||||
|
t_user.version as user_version,
|
||||||
|
ts.id as staff_id,
|
||||||
|
ts.first_name as staff_first_name,
|
||||||
|
ts.last_name as staff_last_name,
|
||||||
|
ts.deleted as staff_deleted,
|
||||||
|
ts.version as staff_version,
|
||||||
|
tr.id as role_id,
|
||||||
|
tr.enable as role_enable,
|
||||||
|
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.enable as group_enable,
|
||||||
|
tg.deleted as group_deleted,
|
||||||
|
tg.version as group_version
|
||||||
|
from t_user
|
||||||
|
left join (select * from t_staff where deleted = 0) as ts on ts.user_id = t_user.id
|
||||||
|
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
|
||||||
|
left join (select * from t_power_role where deleted = 0) as tpr on tpr.role_id = tr.id
|
||||||
|
left join t_power as tp on tp.id = tpr.power_id
|
||||||
|
left join (select * from t_operation) as t on t.power_id = tp.id
|
||||||
|
where t_user.deleted = 0
|
||||||
|
and t_user.id != 1
|
||||||
|
and t.code = 'affair:manage:modify';
|
||||||
|
</select>
|
||||||
|
|
||||||
<resultMap id="userMap" type="user">
|
<resultMap id="userMap" type="user">
|
||||||
<id property="id" column="user_id"/>
|
<id property="id" column="user_id"/>
|
||||||
|
|||||||
@@ -150,6 +150,71 @@ commit;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power (id, type_id)
|
||||||
|
values (5010000, 1);
|
||||||
|
insert into t_menu (id, name, url, power_id, parent_id)
|
||||||
|
VALUES (5010000, '我的事务', '/affair/personalAffairs', id, null);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power(id, type_id)
|
||||||
|
VALUES (5010100, 2);
|
||||||
|
insert into t_element(id, name, power_id, menu_id)
|
||||||
|
VALUES (5010100, '列表', id, 5010000);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power(id, type_id)
|
||||||
|
values (5010101, 3);
|
||||||
|
insert into t_operation(id, name, code, power_id, element_id, parent_id)
|
||||||
|
VALUES (5010101, '获取个人事务', 'affair:self:get', id, 5010100, null);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power(id, type_id)
|
||||||
|
values (5010102, 3);
|
||||||
|
insert into t_operation(id, name, code, power_id, element_id, parent_id)
|
||||||
|
VALUES (5010102, '创建事务', 'affair:self:add', id, 5010100, null);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power (id, type_id)
|
||||||
|
values (5020000, 1);
|
||||||
|
insert into t_menu (id, name, url, power_id, parent_id)
|
||||||
|
VALUES (5020000, '事务管理', '/affair/manage', id, null);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power(id, type_id)
|
||||||
|
VALUES (5020100, 2);
|
||||||
|
insert into t_element(id, name, power_id, menu_id)
|
||||||
|
VALUES (5020100, '列表', id, 5020000);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power(id, type_id)
|
||||||
|
values (5020101, 3);
|
||||||
|
insert into t_operation(id, name, code, power_id, element_id, parent_id)
|
||||||
|
VALUES (5020101, '获取审批事务', 'affair:manage:get', id, 5020100, null);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power(id, type_id)
|
||||||
|
values (5020102, 3);
|
||||||
|
insert into t_operation(id, name, code, power_id, element_id, parent_id)
|
||||||
|
VALUES (5020102, '修改审批事务', 'affair:manage:modify', id, 5020100, null);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power(id, type_id)
|
||||||
|
values (5020103, 3);
|
||||||
|
insert into t_operation(id, name, code, power_id, element_id, parent_id)
|
||||||
|
VALUES (5020103, '删除审批事务', 'affair:manage:delete', id, 5020100, null);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
insert into t_power (id, type_id)
|
insert into t_power (id, type_id)
|
||||||
values (101010000, 1);
|
values (101010000, 1);
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ const affairRouter = {
|
|||||||
title: '我的事务',
|
title: '我的事务',
|
||||||
requiresMenu: true,
|
requiresMenu: true,
|
||||||
requiresScrollbar: true,
|
requiresScrollbar: true,
|
||||||
requiresPadding: true
|
requiresPadding: true,
|
||||||
|
requiresAuth: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -33,7 +34,8 @@ const affairRouter = {
|
|||||||
title: '事务审批',
|
title: '事务审批',
|
||||||
requiresMenu: true,
|
requiresMenu: true,
|
||||||
requiresScrollbar: true,
|
requiresScrollbar: true,
|
||||||
requiresPadding: true
|
requiresPadding: true,
|
||||||
|
requiresAuth: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user