feat: app功能基本实现
This commit is contained in:
+84
@@ -0,0 +1,84 @@
|
||||
package com.agileboot.admin.controller.app;
|
||||
|
||||
import com.agileboot.admin.customize.service.login.LoginService;
|
||||
import com.agileboot.admin.customize.service.login.command.LoginCommand;
|
||||
import com.agileboot.admin.customize.service.login.dto.CaptchaDTO;
|
||||
import com.agileboot.admin.customize.service.login.dto.ConfigDTO;
|
||||
import com.agileboot.common.core.dto.ResponseDTO;
|
||||
import com.agileboot.domain.common.dto.CurrentLoginUserDTO;
|
||||
import com.agileboot.domain.common.dto.TokenDTO;
|
||||
import com.agileboot.domain.system.user.UserApplicationService;
|
||||
import com.agileboot.domain.system.user.command.RegisterUserCommand;
|
||||
import com.agileboot.infrastructure.user.AuthenticationUtils;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author codex
|
||||
*/
|
||||
@Tag(name = "小程序登录API", description = "小程序登录注册相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/app")
|
||||
@RequiredArgsConstructor
|
||||
public class AppAuthController {
|
||||
|
||||
private final LoginService loginService;
|
||||
private final UserApplicationService userApplicationService;
|
||||
|
||||
@Operation(summary = "小程序配置")
|
||||
@GetMapping("/getConfig")
|
||||
public ResponseDTO<ConfigDTO> getConfig() {
|
||||
return ResponseDTO.ok(loginService.getConfig());
|
||||
}
|
||||
|
||||
@Operation(summary = "小程序验证码")
|
||||
@GetMapping("/captchaImage")
|
||||
public ResponseDTO<CaptchaDTO> getCaptchaImg() {
|
||||
return ResponseDTO.ok(loginService.generateCaptchaImg());
|
||||
}
|
||||
|
||||
@Operation(summary = "小程序登录")
|
||||
@PostMapping("/login")
|
||||
public ResponseDTO<TokenDTO> login(@RequestBody LoginCommand command) {
|
||||
String token = loginService.login(command);
|
||||
return ResponseDTO.ok(buildTokenDTO(token));
|
||||
}
|
||||
|
||||
@Operation(summary = "小程序注册")
|
||||
@PostMapping("/register")
|
||||
public ResponseDTO<TokenDTO> register(@Validated @RequestBody RegisterUserCommand command) {
|
||||
decryptRegisterPassword(command);
|
||||
loginService.validateCaptchaIfEnabled(command.getUsername(), command.getCaptchaCode(),
|
||||
command.getCaptchaCodeKey());
|
||||
userApplicationService.registerUser(command);
|
||||
loginService.recordRegisterInfo(command.getUsername());
|
||||
return ResponseDTO.ok(buildTokenDTO(loginService.createTokenForRegisteredUser(command.getUsername())));
|
||||
}
|
||||
|
||||
@Operation(summary = "小程序当前登录用户")
|
||||
@GetMapping("/getLoginUserInfo")
|
||||
public ResponseDTO<CurrentLoginUserDTO> getLoginUserInfo() {
|
||||
SystemLoginUser loginUser = AuthenticationUtils.getSystemLoginUser();
|
||||
return ResponseDTO.ok(userApplicationService.getLoginUserInfo(loginUser));
|
||||
}
|
||||
|
||||
private TokenDTO buildTokenDTO(String token) {
|
||||
SystemLoginUser loginUser = AuthenticationUtils.getSystemLoginUser();
|
||||
CurrentLoginUserDTO currentUser = userApplicationService.getLoginUserInfo(loginUser);
|
||||
return new TokenDTO(token, currentUser);
|
||||
}
|
||||
|
||||
private void decryptRegisterPassword(RegisterUserCommand command) {
|
||||
command.setPassword(loginService.decryptPassword(command.getPassword()));
|
||||
command.setConfirmPassword(loginService.decryptPassword(command.getConfirmPassword()));
|
||||
}
|
||||
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package com.agileboot.admin.controller.app;
|
||||
|
||||
import com.agileboot.common.core.dto.ResponseDTO;
|
||||
import com.agileboot.common.core.page.PageDTO;
|
||||
import com.agileboot.domain.collaboration.record.CollaborationRecordApplicationService;
|
||||
import com.agileboot.domain.collaboration.record.command.AddCollaborationRecordCommand;
|
||||
import com.agileboot.domain.collaboration.record.command.UpdateCollaborationRecordCommand;
|
||||
import com.agileboot.domain.collaboration.record.dto.CollaborationMonthlyStatisticsDTO;
|
||||
import com.agileboot.domain.collaboration.record.dto.CollaborationOptionDTO;
|
||||
import com.agileboot.domain.collaboration.record.dto.CollaborationRecordDTO;
|
||||
import com.agileboot.domain.collaboration.record.dto.CollaborationRecordDetailDTO;
|
||||
import com.agileboot.domain.collaboration.record.query.CollaborationRecordQuery;
|
||||
import com.agileboot.domain.common.command.BulkOperationCommand;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Positive;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author codex
|
||||
*/
|
||||
@Tag(name = "小程序合作记录API", description = "小程序合作记录相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/app/collaboration/record")
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
public class AppCollaborationRecordController {
|
||||
|
||||
private final CollaborationRecordApplicationService recordApplicationService;
|
||||
|
||||
@Operation(summary = "小程序合作记录列表")
|
||||
@GetMapping("/list")
|
||||
public ResponseDTO<PageDTO<CollaborationRecordDTO>> list(CollaborationRecordQuery query) {
|
||||
return ResponseDTO.ok(recordApplicationService.getRecordList(query));
|
||||
}
|
||||
|
||||
@Operation(summary = "小程序合作记录详情")
|
||||
@GetMapping("/{recordId}")
|
||||
public ResponseDTO<CollaborationRecordDetailDTO> getInfo(@PathVariable @Positive Long recordId) {
|
||||
return ResponseDTO.ok(recordApplicationService.getRecordInfo(recordId));
|
||||
}
|
||||
|
||||
@Operation(summary = "小程序合作记录选项")
|
||||
@GetMapping("/options")
|
||||
public ResponseDTO<List<CollaborationOptionDTO>> options() {
|
||||
return ResponseDTO.ok(recordApplicationService.getOptions());
|
||||
}
|
||||
|
||||
@Operation(summary = "小程序合作记录月度统计")
|
||||
@GetMapping("/monthly-statistics")
|
||||
public ResponseDTO<List<CollaborationMonthlyStatisticsDTO>> monthlyStatistics(@RequestParam Integer year) {
|
||||
return ResponseDTO.ok(recordApplicationService.getMonthlyStatistics(year));
|
||||
}
|
||||
|
||||
@Operation(summary = "小程序新增合作记录")
|
||||
@PostMapping
|
||||
public ResponseDTO<Void> add(@Valid @RequestBody AddCollaborationRecordCommand command) {
|
||||
recordApplicationService.addRecord(command);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "小程序修改合作记录")
|
||||
@PutMapping
|
||||
public ResponseDTO<Void> edit(@Valid @RequestBody UpdateCollaborationRecordCommand command) {
|
||||
recordApplicationService.updateRecord(command);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "小程序删除合作记录")
|
||||
@DeleteMapping
|
||||
public ResponseDTO<Void> remove(@RequestParam @NotNull @NotEmpty List<Long> ids) {
|
||||
recordApplicationService.deleteRecord(new BulkOperationCommand<>(ids));
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.agileboot.admin.controller.app;
|
||||
|
||||
import com.agileboot.common.core.dto.ResponseDTO;
|
||||
import com.agileboot.domain.system.user.UserApplicationService;
|
||||
import com.agileboot.domain.system.user.command.UpdateProfileCommand;
|
||||
import com.agileboot.domain.system.user.command.UpdateUserPasswordCommand;
|
||||
import com.agileboot.domain.system.user.dto.UserProfileDTO;
|
||||
import com.agileboot.infrastructure.user.AuthenticationUtils;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author codex
|
||||
*/
|
||||
@Tag(name = "小程序个人信息API", description = "小程序个人信息相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/app/user/profile")
|
||||
@RequiredArgsConstructor
|
||||
public class AppProfileController {
|
||||
|
||||
private final UserApplicationService userApplicationService;
|
||||
|
||||
@Operation(summary = "小程序获取个人信息")
|
||||
@GetMapping
|
||||
public ResponseDTO<UserProfileDTO> profile() {
|
||||
SystemLoginUser user = AuthenticationUtils.getSystemLoginUser();
|
||||
return ResponseDTO.ok(userApplicationService.getUserProfile(user.getUserId()));
|
||||
}
|
||||
|
||||
@Operation(summary = "小程序修改个人信息")
|
||||
@PutMapping
|
||||
public ResponseDTO<Void> updateProfile(@RequestBody UpdateProfileCommand command) {
|
||||
SystemLoginUser loginUser = AuthenticationUtils.getSystemLoginUser();
|
||||
command.setUserId(loginUser.getUserId());
|
||||
userApplicationService.updateUserProfile(command);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "小程序修改个人密码")
|
||||
@PutMapping("/password")
|
||||
public ResponseDTO<Void> updatePassword(@Validated @RequestBody UpdateUserPasswordCommand command) {
|
||||
SystemLoginUser loginUser = AuthenticationUtils.getSystemLoginUser();
|
||||
command.setUserId(loginUser.getUserId());
|
||||
userApplicationService.updatePasswordBySelf(loginUser, command);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
}
|
||||
+3
-2
@@ -24,6 +24,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -73,7 +74,7 @@ public class FileController {
|
||||
*/
|
||||
@Operation(summary = "单个上传文件")
|
||||
@PostMapping("/upload")
|
||||
public ResponseDTO<UploadDTO> uploadFile(MultipartFile file) {
|
||||
public ResponseDTO<UploadDTO> uploadFile(@RequestParam("file") MultipartFile file) {
|
||||
if (file == null) {
|
||||
throw new ApiException(ErrorCode.Business.UPLOAD_FILE_IS_EMPTY);
|
||||
}
|
||||
@@ -101,7 +102,7 @@ public class FileController {
|
||||
*/
|
||||
@Operation(summary = "多个上传文件")
|
||||
@PostMapping("/uploads")
|
||||
public ResponseDTO<List<UploadDTO>> uploadFiles(List<MultipartFile> files) {
|
||||
public ResponseDTO<List<UploadDTO>> uploadFiles(@RequestParam("files") List<MultipartFile> files) {
|
||||
if (CollUtil.isEmpty(files)) {
|
||||
throw new ApiException(ErrorCode.Business.UPLOAD_FILE_IS_EMPTY);
|
||||
}
|
||||
|
||||
+19
-6
@@ -3,14 +3,12 @@ package com.agileboot.admin.controller.common;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.common.config.AgileBootConfig;
|
||||
import com.agileboot.common.core.dto.ResponseDTO;
|
||||
import com.agileboot.common.exception.ApiException;
|
||||
import com.agileboot.common.exception.error.ErrorCode.Business;
|
||||
import com.agileboot.domain.common.dto.CurrentLoginUserDTO;
|
||||
import com.agileboot.domain.common.dto.TokenDTO;
|
||||
import com.agileboot.domain.system.menu.MenuApplicationService;
|
||||
import com.agileboot.domain.system.menu.dto.RouterDTO;
|
||||
import com.agileboot.domain.system.user.UserApplicationService;
|
||||
import com.agileboot.domain.system.user.command.AddUserCommand;
|
||||
import com.agileboot.domain.system.user.command.RegisterUserCommand;
|
||||
import com.agileboot.infrastructure.annotations.ratelimit.RateLimit;
|
||||
import com.agileboot.infrastructure.annotations.ratelimit.RateLimit.CacheType;
|
||||
import com.agileboot.infrastructure.annotations.ratelimit.RateLimit.LimitType;
|
||||
@@ -25,6 +23,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -130,10 +129,24 @@ public class LoginController {
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "注册接口", description = "暂未实现")
|
||||
@Operation(summary = "注册接口")
|
||||
@PostMapping("/register")
|
||||
public ResponseDTO<Void> register(@RequestBody AddUserCommand command) {
|
||||
return ResponseDTO.fail(new ApiException(Business.COMMON_UNSUPPORTED_OPERATION));
|
||||
public ResponseDTO<TokenDTO> register(@Validated @RequestBody RegisterUserCommand command) {
|
||||
decryptRegisterPassword(command);
|
||||
loginService.validateCaptchaIfEnabled(command.getUsername(), command.getCaptchaCode(), command.getCaptchaCodeKey());
|
||||
userApplicationService.registerUser(command);
|
||||
loginService.recordRegisterInfo(command.getUsername());
|
||||
|
||||
String token = loginService.createTokenForRegisteredUser(command.getUsername());
|
||||
SystemLoginUser loginUser = AuthenticationUtils.getSystemLoginUser();
|
||||
CurrentLoginUserDTO currentUserDTO = userApplicationService.getLoginUserInfo(loginUser);
|
||||
|
||||
return ResponseDTO.ok(new TokenDTO(token, currentUserDTO));
|
||||
}
|
||||
|
||||
private void decryptRegisterPassword(RegisterUserCommand command) {
|
||||
command.setPassword(loginService.decryptPassword(command.getPassword()));
|
||||
command.setConfirmPassword(loginService.decryptPassword(command.getConfirmPassword()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-111
@@ -1,111 +0,0 @@
|
||||
package com.agileboot.admin.controller.system;
|
||||
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.agileboot.common.core.base.BaseController;
|
||||
import com.agileboot.common.core.dto.ResponseDTO;
|
||||
import com.agileboot.domain.system.dept.DeptApplicationService;
|
||||
import com.agileboot.domain.system.dept.command.AddDeptCommand;
|
||||
import com.agileboot.domain.system.dept.command.UpdateDeptCommand;
|
||||
import com.agileboot.domain.system.dept.dto.DeptDTO;
|
||||
import com.agileboot.domain.system.dept.query.DeptQuery;
|
||||
import com.agileboot.admin.customize.aop.accessLog.AccessLog;
|
||||
import com.agileboot.common.enums.common.BusinessTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 部门信息
|
||||
*
|
||||
* @author valarchie
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system")
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "部门API", description = "部门相关的增删查改")
|
||||
public class SysDeptController extends BaseController {
|
||||
|
||||
private final DeptApplicationService deptApplicationService;
|
||||
|
||||
/**
|
||||
* 获取部门列表
|
||||
*/
|
||||
@Operation(summary = "部门列表")
|
||||
@PreAuthorize("@permission.has('system:dept:list')")
|
||||
@GetMapping("/depts")
|
||||
public ResponseDTO<List<DeptDTO>> list(DeptQuery query) {
|
||||
List<DeptDTO> deptList = deptApplicationService.getDeptList(query);
|
||||
return ResponseDTO.ok(deptList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门编号获取详细信息
|
||||
*/
|
||||
@Operation(summary = "部门详情")
|
||||
@PreAuthorize("@permission.has('system:dept:query')")
|
||||
@GetMapping(value = "/dept/{deptId}")
|
||||
public ResponseDTO<DeptDTO> getInfo(@PathVariable Long deptId) {
|
||||
DeptDTO dept = deptApplicationService.getDeptInfo(deptId);
|
||||
return ResponseDTO.ok(dept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门下拉树列表
|
||||
*/
|
||||
@Operation(summary = "获取部门树级结构")
|
||||
@GetMapping("/depts/dropdown")
|
||||
public ResponseDTO<List<Tree<Long>>> dropdownList() {
|
||||
List<Tree<Long>> deptTree = deptApplicationService.getDeptTree();
|
||||
return ResponseDTO.ok(deptTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
*/
|
||||
@Operation(summary = "新增部门")
|
||||
@PreAuthorize("@permission.has('system:dept:add')")
|
||||
@AccessLog(title = "部门管理", businessType = BusinessTypeEnum.ADD)
|
||||
@PostMapping("/dept")
|
||||
public ResponseDTO<Void> add(@RequestBody AddDeptCommand addCommand) {
|
||||
deptApplicationService.addDept(addCommand);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改部门
|
||||
*/
|
||||
@Operation(summary = "修改部门")
|
||||
@PreAuthorize("@permission.has('system:dept:edit') AND @dataScope.checkDeptId(#updateCommand.deptId)")
|
||||
@AccessLog(title = "部门管理", businessType = BusinessTypeEnum.MODIFY)
|
||||
@PutMapping("/dept/{deptId}")
|
||||
public ResponseDTO<Void> edit(@PathVariable("deptId")Long deptId, @RequestBody UpdateDeptCommand updateCommand) {
|
||||
updateCommand.setDeptId(deptId);
|
||||
deptApplicationService.updateDept(updateCommand);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
*/
|
||||
@Operation(summary = "删除部门")
|
||||
@PreAuthorize("@permission.has('system:dept:remove') AND @dataScope.checkDeptId(#deptId)")
|
||||
@AccessLog(title = "部门管理", businessType = BusinessTypeEnum.DELETE)
|
||||
@DeleteMapping("/dept/{deptId}")
|
||||
public ResponseDTO<Void> remove(@PathVariable @NotNull Long deptId) {
|
||||
deptApplicationService.removeDept(deptId);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
}
|
||||
-122
@@ -1,122 +0,0 @@
|
||||
package com.agileboot.admin.controller.system;
|
||||
|
||||
import com.agileboot.admin.customize.aop.accessLog.AccessLog;
|
||||
import com.agileboot.common.core.base.BaseController;
|
||||
import com.agileboot.common.core.dto.ResponseDTO;
|
||||
import com.agileboot.common.core.page.PageDTO;
|
||||
import com.agileboot.common.enums.common.BusinessTypeEnum;
|
||||
import com.agileboot.common.utils.poi.CustomExcelUtil;
|
||||
import com.agileboot.domain.common.command.BulkOperationCommand;
|
||||
import com.agileboot.domain.system.post.PostApplicationService;
|
||||
import com.agileboot.domain.system.post.command.AddPostCommand;
|
||||
import com.agileboot.domain.system.post.command.UpdatePostCommand;
|
||||
import com.agileboot.domain.system.post.dto.PostDTO;
|
||||
import com.agileboot.domain.system.post.query.PostQuery;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 岗位信息操作处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Tag(name = "职位API", description = "职位相关的增删查改")
|
||||
@RestController
|
||||
@RequestMapping("/system/post")
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
public class SysPostController extends BaseController {
|
||||
|
||||
private final PostApplicationService postApplicationService;
|
||||
|
||||
/**
|
||||
* 获取岗位列表
|
||||
*/
|
||||
@Operation(summary = "职位列表")
|
||||
@PreAuthorize("@permission.has('system:post:list')")
|
||||
@GetMapping("/list")
|
||||
public ResponseDTO<PageDTO<PostDTO>> list(PostQuery query) {
|
||||
PageDTO<PostDTO> pageDTO = postApplicationService.getPostList(query);
|
||||
return ResponseDTO.ok(pageDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出查询到的所有岗位信息到excel文件
|
||||
* @param response http响应
|
||||
* @param query 查询参数
|
||||
* @author Kevin Zhang
|
||||
* @date 2023-10-02
|
||||
*/
|
||||
@Operation(summary = "职位列表导出")
|
||||
@AccessLog(title = "岗位管理", businessType = BusinessTypeEnum.EXPORT)
|
||||
@PreAuthorize("@permission.has('system:post:export')")
|
||||
@GetMapping("/excel")
|
||||
public void export(HttpServletResponse response, PostQuery query) {
|
||||
List<PostDTO> all = postApplicationService.getPostListAll(query);
|
||||
CustomExcelUtil.writeToResponse(all, PostDTO.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据岗位编号获取详细信息
|
||||
*/
|
||||
@Operation(summary = "职位详情")
|
||||
@PreAuthorize("@permission.has('system:post:query')")
|
||||
@GetMapping(value = "/{postId}")
|
||||
public ResponseDTO<PostDTO> getInfo(@PathVariable Long postId) {
|
||||
PostDTO post = postApplicationService.getPostInfo(postId);
|
||||
return ResponseDTO.ok(post);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增岗位
|
||||
*/
|
||||
@Operation(summary = "添加职位")
|
||||
@PreAuthorize("@permission.has('system:post:add')")
|
||||
@AccessLog(title = "岗位管理", businessType = BusinessTypeEnum.ADD)
|
||||
@PostMapping
|
||||
public ResponseDTO<Void> add(@RequestBody AddPostCommand addCommand) {
|
||||
postApplicationService.addPost(addCommand);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改岗位
|
||||
*/
|
||||
@Operation(summary = "修改职位")
|
||||
@PreAuthorize("@permission.has('system:post:edit')")
|
||||
@AccessLog(title = "岗位管理", businessType = BusinessTypeEnum.MODIFY)
|
||||
@PutMapping
|
||||
public ResponseDTO<Void> edit(@RequestBody UpdatePostCommand updateCommand) {
|
||||
postApplicationService.updatePost(updateCommand);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除岗位
|
||||
*/
|
||||
@Operation(summary = "删除职位")
|
||||
@PreAuthorize("@permission.has('system:post:remove')")
|
||||
@AccessLog(title = "岗位管理", businessType = BusinessTypeEnum.DELETE)
|
||||
@DeleteMapping
|
||||
public ResponseDTO<Void> remove(@RequestParam @NotNull @NotEmpty List<Long> ids) {
|
||||
postApplicationService.deletePost(new BulkOperationCommand<>(ids));
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -19,6 +19,7 @@ import com.agileboot.common.enums.common.BusinessTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
@@ -71,7 +72,7 @@ public class SysProfileController extends BaseController {
|
||||
@Operation(summary = "重置个人密码")
|
||||
@AccessLog(title = "个人信息", businessType = BusinessTypeEnum.MODIFY)
|
||||
@PutMapping("/password")
|
||||
public ResponseDTO<Void> updatePassword(@RequestBody UpdateUserPasswordCommand command) {
|
||||
public ResponseDTO<Void> updatePassword(@Validated @RequestBody UpdateUserPasswordCommand command) {
|
||||
SystemLoginUser loginUser = AuthenticationUtils.getSystemLoginUser();
|
||||
command.setUserId(loginUser.getUserId());
|
||||
userApplicationService.updatePasswordBySelf(loginUser, command);
|
||||
|
||||
-16
@@ -6,7 +6,6 @@ import com.agileboot.common.core.page.PageDTO;
|
||||
import com.agileboot.common.utils.poi.CustomExcelUtil;
|
||||
import com.agileboot.domain.system.role.RoleApplicationService;
|
||||
import com.agileboot.domain.system.role.command.AddRoleCommand;
|
||||
import com.agileboot.domain.system.role.command.UpdateDataScopeCommand;
|
||||
import com.agileboot.domain.system.role.command.UpdateRoleCommand;
|
||||
import com.agileboot.domain.system.role.command.UpdateStatusCommand;
|
||||
import com.agileboot.domain.system.role.dto.RoleDTO;
|
||||
@@ -111,21 +110,6 @@ public class SysRoleController extends BaseController {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存数据权限
|
||||
*/
|
||||
@Operation(summary = "修改角色数据权限")
|
||||
@PreAuthorize("@permission.has('system:role:edit')")
|
||||
@AccessLog(title = "角色管理", businessType = BusinessTypeEnum.MODIFY)
|
||||
@PutMapping("/{roleId}/dataScope")
|
||||
public ResponseDTO<Void> dataScope(@PathVariable("roleId") Long roleId,
|
||||
@RequestBody UpdateDataScopeCommand command) {
|
||||
command.setRoleId(roleId);
|
||||
|
||||
roleApplicationService.updateDataScope(command);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色状态修改
|
||||
*/
|
||||
|
||||
+2
-2
@@ -52,7 +52,7 @@ public class SysUserController extends BaseController {
|
||||
* 获取用户列表
|
||||
*/
|
||||
@Operation(summary = "用户列表")
|
||||
@PreAuthorize("@permission.has('system:user:list') AND @dataScope.checkDeptId(#query.deptId)")
|
||||
@PreAuthorize("@permission.has('system:user:list')")
|
||||
@GetMapping
|
||||
public ResponseDTO<PageDTO<UserDTO>> userList(SearchUserQuery<SearchUserDO> query) {
|
||||
PageDTO<UserDTO> page = userApplicationService.getUserList(query);
|
||||
@@ -105,7 +105,7 @@ public class SysUserController extends BaseController {
|
||||
* 新增用户
|
||||
*/
|
||||
@Operation(summary = "新增用户")
|
||||
@PreAuthorize("@permission.has('system:user:add') AND @dataScope.checkDeptId(#command.deptId)")
|
||||
@PreAuthorize("@permission.has('system:user:add')")
|
||||
@AccessLog(title = "用户管理", businessType = BusinessTypeEnum.ADD)
|
||||
@PostMapping
|
||||
public ResponseDTO<Void> add(@Validated @RequestBody AddUserCommand command) {
|
||||
|
||||
+1
@@ -135,6 +135,7 @@ public class SecurityConfig {
|
||||
// 对于登录login 注册register 验证码captchaImage 以及公共Api的请求允许匿名访问
|
||||
// 注意: 当携带token请求以下这几个接口时 会返回403的错误
|
||||
.antMatchers("/login", "/register", "/getConfig", "/captchaImage", "/api/**").anonymous()
|
||||
.antMatchers("/app/login", "/app/register", "/app/getConfig", "/app/captchaImage").anonymous()
|
||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js",
|
||||
"/profile/**").permitAll()
|
||||
// TODO this is danger.
|
||||
|
||||
+34
@@ -40,6 +40,7 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.FastByteArrayOutputStream;
|
||||
|
||||
@@ -61,6 +62,8 @@ public class LoginService {
|
||||
|
||||
private final AuthenticationManager authenticationManager;
|
||||
|
||||
private final UserDetailsService userDetailsService;
|
||||
|
||||
@Resource(name = "captchaProducer")
|
||||
private Producer captchaProducer;
|
||||
|
||||
@@ -115,6 +118,7 @@ public class LoginService {
|
||||
|
||||
boolean isCaptchaOn = isCaptchaOn();
|
||||
configDTO.setIsCaptchaOn(isCaptchaOn);
|
||||
configDTO.setIsRegisterUserOn(isRegisterUserOn());
|
||||
configDTO.setDictionary(MapCache.dictionaryCache());
|
||||
return configDTO;
|
||||
}
|
||||
@@ -179,6 +183,9 @@ public class LoginService {
|
||||
* @param captchaCodeKey 验证码对应的缓存key
|
||||
*/
|
||||
public void validateCaptcha(String username, String captchaCode, String captchaCodeKey) {
|
||||
if (StrUtil.isBlank(captchaCode) || StrUtil.isBlank(captchaCodeKey)) {
|
||||
throw new ApiException(ErrorCode.Business.LOGIN_CAPTCHA_CODE_NULL);
|
||||
}
|
||||
String captcha = redisCache.captchaCache.getObjectById(captchaCodeKey);
|
||||
redisCache.captchaCache.delete(captchaCodeKey);
|
||||
if (captcha == null) {
|
||||
@@ -193,6 +200,26 @@ public class LoginService {
|
||||
}
|
||||
}
|
||||
|
||||
public void validateCaptchaIfEnabled(String username, String captchaCode, String captchaCodeKey) {
|
||||
if (isCaptchaOn()) {
|
||||
validateCaptcha(username, captchaCode, captchaCodeKey);
|
||||
}
|
||||
}
|
||||
|
||||
public String createTokenForRegisteredUser(String username) {
|
||||
SystemLoginUser loginUser = (SystemLoginUser) userDetailsService.loadUserByUsername(username);
|
||||
Authentication authentication = new UsernamePasswordAuthenticationToken(loginUser, null,
|
||||
loginUser.getAuthorities());
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
updateLoginInfo(loginUser);
|
||||
return tokenService.createTokenAndPutUserInCache(loginUser);
|
||||
}
|
||||
|
||||
public void recordRegisterInfo(String username) {
|
||||
ThreadPoolManager.execute(AsyncTaskFactory.loginInfoTask(username, LoginStatusEnum.REGISTER,
|
||||
LoginStatusEnum.REGISTER.description()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
* @param loginUser 登录用户
|
||||
@@ -200,7 +227,10 @@ public class LoginService {
|
||||
public void recordLoginInfo(SystemLoginUser loginUser) {
|
||||
ThreadPoolManager.execute(AsyncTaskFactory.loginInfoTask(loginUser.getUsername(), LoginStatusEnum.LOGIN_SUCCESS,
|
||||
LoginStatusEnum.LOGIN_SUCCESS.description()));
|
||||
updateLoginInfo(loginUser);
|
||||
}
|
||||
|
||||
private void updateLoginInfo(SystemLoginUser loginUser) {
|
||||
SysUserEntity entity = redisCache.userCache.getObjectById(loginUser.getUserId());
|
||||
|
||||
entity.setLoginIp(ServletUtil.getClientIP(ServletHolderUtil.getRequest()));
|
||||
@@ -219,4 +249,8 @@ public class LoginService {
|
||||
return Convert.toBool(guavaCache.configCache.get(ConfigKeyEnum.CAPTCHA.getValue()));
|
||||
}
|
||||
|
||||
private boolean isRegisterUserOn() {
|
||||
return Convert.toBool(guavaCache.configCache.get(ConfigKeyEnum.REGISTER.getValue()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-12
@@ -1,7 +1,5 @@
|
||||
package com.agileboot.admin.customize.service.login;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.common.exception.ApiException;
|
||||
import com.agileboot.common.exception.error.ErrorCode;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
@@ -24,7 +22,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.SetUtils;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
@@ -67,7 +64,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
RoleInfo roleInfo = getRoleInfo(userEntity.getRoleId(), userEntity.getIsAdmin());
|
||||
|
||||
SystemLoginUser loginUser = new SystemLoginUser(userEntity.getUserId(), userEntity.getIsAdmin(), userEntity.getUsername(),
|
||||
userEntity.getPassword(), roleInfo, userEntity.getDeptId());
|
||||
userEntity.getPassword(), roleInfo);
|
||||
loginUser.fillLoginInfo();
|
||||
loginUser.setAutoRefreshCacheTime(loginUser.getLoginInfo().getLoginTime()
|
||||
+ TimeUnit.MINUTES.toMillis(tokenService.getAutoRefreshTime()));
|
||||
@@ -86,7 +83,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
Set<Long> allMenuIds = allMenus.stream().map(SysMenuEntity::getMenuId).collect(Collectors.toSet());
|
||||
|
||||
return new RoleInfo(RoleInfo.ADMIN_ROLE_ID, RoleInfo.ADMIN_ROLE_KEY, DataScopeEnum.ALL, SetUtils.emptySet(),
|
||||
return new RoleInfo(RoleInfo.ADMIN_ROLE_ID, RoleInfo.ADMIN_ROLE_KEY, DataScopeEnum.ALL,
|
||||
RoleInfo.ADMIN_PERMISSIONS, allMenuIds);
|
||||
|
||||
}
|
||||
@@ -104,13 +101,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
DataScopeEnum dataScopeEnum = BasicEnumUtil.fromValue(DataScopeEnum.class, roleEntity.getDataScope());
|
||||
|
||||
Set<Long> deptIdSet = SetUtils.emptySet();
|
||||
if (StrUtil.isNotEmpty(roleEntity.getDeptIdSet())) {
|
||||
deptIdSet = StrUtil.split(roleEntity.getDeptIdSet(), ",").stream()
|
||||
.map(Convert::toLong).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
return new RoleInfo(roleId, roleEntity.getRoleKey(), dataScopeEnum, deptIdSet, permissions, menuIds);
|
||||
return new RoleInfo(roleId, roleEntity.getRoleKey(), dataScopeEnum, permissions, menuIds);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
@@ -13,6 +13,8 @@ public class ConfigDTO {
|
||||
|
||||
private Boolean isCaptchaOn;
|
||||
|
||||
private Boolean isRegisterUserOn;
|
||||
|
||||
private Map<String, List<DictionaryData>> dictionary;
|
||||
|
||||
}
|
||||
|
||||
+6
-21
@@ -1,16 +1,11 @@
|
||||
package com.agileboot.admin.customize.service.permission;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.agileboot.admin.customize.service.permission.model.AbstractDataPermissionChecker;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.AllDataPermissionChecker;
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.CustomDataPermissionChecker;
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.DefaultDataPermissionChecker;
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.DeptTreeDataPermissionChecker;
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.OnlySelfDataPermissionChecker;
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.SingleDeptDataPermissionChecker;
|
||||
import com.agileboot.infrastructure.user.web.DataScopeEnum;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import javax.annotation.PostConstruct;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -21,41 +16,31 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class DataPermissionCheckerFactory {
|
||||
private static AbstractDataPermissionChecker allChecker;
|
||||
private static AbstractDataPermissionChecker customChecker;
|
||||
private static AbstractDataPermissionChecker singleDeptChecker;
|
||||
private static AbstractDataPermissionChecker deptTreeChecker;
|
||||
private static AbstractDataPermissionChecker onlySelfChecker;
|
||||
private static AbstractDataPermissionChecker defaultSelfChecker;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void initAllChecker() {
|
||||
SysDeptService deptService = SpringUtil.getBean(SysDeptService.class);
|
||||
|
||||
allChecker = new AllDataPermissionChecker();
|
||||
customChecker = new CustomDataPermissionChecker(deptService);
|
||||
singleDeptChecker = new SingleDeptDataPermissionChecker(deptService);
|
||||
deptTreeChecker = new DeptTreeDataPermissionChecker(deptService);
|
||||
onlySelfChecker = new OnlySelfDataPermissionChecker(deptService);
|
||||
onlySelfChecker = new OnlySelfDataPermissionChecker();
|
||||
defaultSelfChecker = new DefaultDataPermissionChecker();
|
||||
}
|
||||
|
||||
|
||||
public static AbstractDataPermissionChecker getChecker(SystemLoginUser loginUser) {
|
||||
if (loginUser == null) {
|
||||
return deptTreeChecker;
|
||||
return defaultSelfChecker;
|
||||
}
|
||||
|
||||
if (loginUser.getRoleInfo() == null || loginUser.getRoleInfo().getDataScope() == null) {
|
||||
return defaultSelfChecker;
|
||||
}
|
||||
|
||||
DataScopeEnum dataScope = loginUser.getRoleInfo().getDataScope();
|
||||
switch (dataScope) {
|
||||
case ALL:
|
||||
return allChecker;
|
||||
case CUSTOM_DEFINE:
|
||||
return customChecker;
|
||||
case SINGLE_DEPT:
|
||||
return singleDeptChecker;
|
||||
case DEPT_TREE:
|
||||
return deptTreeChecker;
|
||||
case ONLY_SELF:
|
||||
return onlySelfChecker;
|
||||
default:
|
||||
|
||||
+3
-9
@@ -33,7 +33,7 @@ public class DataPermissionService {
|
||||
if (targetUser == null) {
|
||||
return true;
|
||||
}
|
||||
return checkDataScope(loginUser, targetUser.getDeptId(), userId);
|
||||
return checkDataScope(loginUser, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,14 +53,8 @@ public class DataPermissionService {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkDeptId(Long deptId) {
|
||||
SystemLoginUser loginUser = AuthenticationUtils.getSystemLoginUser();
|
||||
return checkDataScope(loginUser, deptId, null);
|
||||
}
|
||||
|
||||
|
||||
public boolean checkDataScope(SystemLoginUser loginUser, Long targetDeptId, Long targetUserId) {
|
||||
DataCondition dataCondition = DataCondition.builder().targetDeptId(targetDeptId).targetUserId(targetUserId).build();
|
||||
public boolean checkDataScope(SystemLoginUser loginUser, Long targetUserId) {
|
||||
DataCondition dataCondition = DataCondition.builder().targetUserId(targetUserId).build();
|
||||
AbstractDataPermissionChecker checker = DataPermissionCheckerFactory.getChecker(loginUser);
|
||||
return checker.check(loginUser, dataCondition);
|
||||
}
|
||||
|
||||
-3
@@ -1,7 +1,6 @@
|
||||
package com.agileboot.admin.customize.service.permission.model;
|
||||
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -11,8 +10,6 @@ import lombok.Data;
|
||||
@Data
|
||||
public abstract class AbstractDataPermissionChecker {
|
||||
|
||||
private SysDeptService deptService;
|
||||
|
||||
/**
|
||||
* 检测当前用户对于 给定条件的数据 是否有权限
|
||||
*
|
||||
|
||||
-1
@@ -15,7 +15,6 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public class DataCondition {
|
||||
|
||||
private Long targetDeptId;
|
||||
private Long targetUserId;
|
||||
|
||||
}
|
||||
|
||||
-4
@@ -3,7 +3,6 @@ package com.agileboot.admin.customize.service.permission.model.checker;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.admin.customize.service.permission.model.AbstractDataPermissionChecker;
|
||||
import com.agileboot.admin.customize.service.permission.model.DataCondition;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -15,9 +14,6 @@ import lombok.EqualsAndHashCode;
|
||||
@Data
|
||||
public class AllDataPermissionChecker extends AbstractDataPermissionChecker {
|
||||
|
||||
private SysDeptService deptService;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(SystemLoginUser loginUser, DataCondition condition) {
|
||||
return true;
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
package com.agileboot.admin.customize.service.permission.model.checker;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.admin.customize.service.permission.model.AbstractDataPermissionChecker;
|
||||
import com.agileboot.admin.customize.service.permission.model.DataCondition;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import java.util.Set;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据权限测试接口
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CustomDataPermissionChecker extends AbstractDataPermissionChecker {
|
||||
|
||||
private SysDeptService deptService;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(SystemLoginUser loginUser, DataCondition condition) {
|
||||
if (condition == null || loginUser == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (loginUser.getRoleInfo() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Set<Long> deptIdSet = loginUser.getRoleInfo().getDeptIdSet();
|
||||
Long targetDeptId = condition.getTargetDeptId();
|
||||
|
||||
return condition.getTargetDeptId() != null && CollUtil.safeContains(deptIdSet, targetDeptId);
|
||||
}
|
||||
}
|
||||
-3
@@ -3,7 +3,6 @@ package com.agileboot.admin.customize.service.permission.model.checker;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.admin.customize.service.permission.model.AbstractDataPermissionChecker;
|
||||
import com.agileboot.admin.customize.service.permission.model.DataCondition;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -15,8 +14,6 @@ import lombok.EqualsAndHashCode;
|
||||
@Data
|
||||
public class DefaultDataPermissionChecker extends AbstractDataPermissionChecker {
|
||||
|
||||
private SysDeptService deptService;
|
||||
|
||||
@Override
|
||||
public boolean check(SystemLoginUser loginUser, DataCondition condition) {
|
||||
return false;
|
||||
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package com.agileboot.admin.customize.service.permission.model.checker;
|
||||
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.admin.customize.service.permission.model.AbstractDataPermissionChecker;
|
||||
import com.agileboot.admin.customize.service.permission.model.DataCondition;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import java.util.Objects;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据权限测试接口
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DeptTreeDataPermissionChecker extends AbstractDataPermissionChecker {
|
||||
|
||||
private SysDeptService deptService;
|
||||
|
||||
@Override
|
||||
public boolean check(SystemLoginUser loginUser, DataCondition condition) {
|
||||
if (condition == null || loginUser == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (loginUser.getDeptId() == null || condition.getTargetDeptId() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Long currentDeptId = loginUser.getDeptId();
|
||||
Long targetDeptId = condition.getTargetDeptId();
|
||||
|
||||
boolean isContainsTargetDept = deptService.isChildOfTheDept(loginUser.getDeptId(), targetDeptId);
|
||||
boolean isSameDept = Objects.equals(currentDeptId, targetDeptId);
|
||||
|
||||
return isContainsTargetDept || isSameDept;
|
||||
}
|
||||
|
||||
}
|
||||
-5
@@ -3,9 +3,7 @@ package com.agileboot.admin.customize.service.permission.model.checker;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.admin.customize.service.permission.model.AbstractDataPermissionChecker;
|
||||
import com.agileboot.admin.customize.service.permission.model.DataCondition;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import java.util.Objects;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -16,12 +14,9 @@ import lombok.NoArgsConstructor;
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class OnlySelfDataPermissionChecker extends AbstractDataPermissionChecker {
|
||||
|
||||
private SysDeptService deptService;
|
||||
|
||||
@Override
|
||||
public boolean check(SystemLoginUser loginUser, DataCondition condition) {
|
||||
if (condition == null || loginUser == null) {
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
package com.agileboot.admin.customize.service.permission.model.checker;
|
||||
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.admin.customize.service.permission.model.AbstractDataPermissionChecker;
|
||||
import com.agileboot.admin.customize.service.permission.model.DataCondition;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import java.util.Objects;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据权限测试接口
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SingleDeptDataPermissionChecker extends AbstractDataPermissionChecker {
|
||||
|
||||
private SysDeptService deptService;
|
||||
|
||||
@Override
|
||||
public boolean check(SystemLoginUser loginUser, DataCondition condition) {
|
||||
if (condition == null || loginUser == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (loginUser.getDeptId() == null || condition.getTargetDeptId() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Long currentDeptId = loginUser.getDeptId();
|
||||
Long targetDeptId = condition.getTargetDeptId();
|
||||
|
||||
return Objects.equals(currentDeptId, targetDeptId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -50,7 +50,7 @@ spring:
|
||||
datasource:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:mysql://localhost:33061/todo_agileboot_pure?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
url: jdbc:mysql://localhost:3306/todo_agileboot_pure?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: root123
|
||||
# 从库数据源
|
||||
@@ -64,7 +64,7 @@ spring:
|
||||
# 地址
|
||||
host: localhost
|
||||
# 端口,默认为6379
|
||||
port: 63791
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
database: 0
|
||||
# 密码
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
# 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
druid:
|
||||
webStatFilter:
|
||||
enabled: true
|
||||
statViewServlet:
|
||||
enabled: false
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
log-slow-sql: true
|
||||
slow-sql-millis: 1000
|
||||
merge-sql: true
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
dynamic:
|
||||
primary: master
|
||||
strict: false
|
||||
druid:
|
||||
initialSize: 5
|
||||
minIdle: 10
|
||||
maxActive: 20
|
||||
maxWait: 60000
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
maxEvictableIdleTimeMillis: 900000
|
||||
validationQuery: SELECT 1 FROM DUAL
|
||||
testWhileIdle: true
|
||||
testOnBorrow: false
|
||||
testOnReturn: false
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/${MYSQL_DATABASE:todo_agileboot_pure}?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
|
||||
username: ${MYSQL_USERNAME:todo_app}
|
||||
password: ${MYSQL_PASSWORD:todo_app123}
|
||||
|
||||
redis:
|
||||
host: ${REDIS_HOST:redis}
|
||||
port: ${REDIS_PORT:6379}
|
||||
database: 0
|
||||
password: ${REDIS_PASSWORD:redis123}
|
||||
timeout: 10s
|
||||
lettuce:
|
||||
pool:
|
||||
min-idle: 0
|
||||
max-idle: 8
|
||||
max-active: 8
|
||||
max-wait: -1ms
|
||||
|
||||
logging:
|
||||
file:
|
||||
path: /home/agileboot/logs/agileboot-prod
|
||||
|
||||
springdoc:
|
||||
swagger-ui:
|
||||
enabled: false
|
||||
|
||||
agileboot:
|
||||
file-base-dir: /home/agileboot
|
||||
api-prefix: /dev-api
|
||||
demo-enabled: false
|
||||
-83
@@ -1,83 +0,0 @@
|
||||
package com.agileboot.admin.customize.service.permission;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.CustomDataPermissionChecker;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.infrastructure.user.web.RoleInfo;
|
||||
import com.agileboot.admin.customize.service.permission.model.DataCondition;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import org.apache.commons.collections4.SetUtils;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class CustomDataPermissionCheckerTest {
|
||||
|
||||
private final SysDeptService deptService = mock(SysDeptService.class);
|
||||
public SystemLoginUser loginUser = mock(SystemLoginUser.class);
|
||||
|
||||
@BeforeEach
|
||||
public void mockBefore() {
|
||||
when(loginUser.getRoleInfo()).thenReturn(RoleInfo.EMPTY_ROLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckWhenParameterNull() {
|
||||
CustomDataPermissionChecker customChecker = new CustomDataPermissionChecker(deptService);
|
||||
|
||||
boolean check1 = customChecker.check(null, null);
|
||||
boolean check2 = customChecker.check(loginUser, null);
|
||||
boolean check3 = customChecker.check(null, new DataCondition());
|
||||
|
||||
assertFalse(check1);
|
||||
assertFalse(check2);
|
||||
assertFalse(check3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckWhenTargetDeptIdNull() {
|
||||
CustomDataPermissionChecker customChecker = new CustomDataPermissionChecker(deptService);
|
||||
|
||||
boolean check = customChecker.check(loginUser, new DataCondition(null, 1L));
|
||||
|
||||
assertFalse(check);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenRoleIsNull() {
|
||||
CustomDataPermissionChecker customChecker = new CustomDataPermissionChecker(deptService);
|
||||
|
||||
when(loginUser.getRoleInfo()).thenReturn(null);
|
||||
boolean check = customChecker.check(loginUser, new DataCondition(1L, 1L));
|
||||
|
||||
assertFalse(check);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenNotContainTargetDeptId() {
|
||||
CustomDataPermissionChecker customChecker = new CustomDataPermissionChecker(deptService);
|
||||
|
||||
loginUser.getRoleInfo().setDeptIdSet(SetUtils.hashSet(2L));
|
||||
boolean check = customChecker.check(loginUser, new DataCondition(1L, 1L));
|
||||
|
||||
assertFalse(check);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenContainTargetDeptId() {
|
||||
CustomDataPermissionChecker customChecker = new CustomDataPermissionChecker(deptService);
|
||||
|
||||
loginUser.getRoleInfo().setDeptIdSet(SetUtils.hashSet(1L));
|
||||
boolean check = customChecker.check(loginUser, new DataCondition(1L, 1L));
|
||||
|
||||
assertTrue(check);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
package com.agileboot.admin.customize.service.permission;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.DeptTreeDataPermissionChecker;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.infrastructure.user.web.RoleInfo;
|
||||
import com.agileboot.admin.customize.service.permission.model.DataCondition;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class DeptTreeDataPermissionCheckerTest {
|
||||
|
||||
private final SysDeptService deptService = mock(SysDeptService.class);
|
||||
|
||||
public SystemLoginUser loginUser = mock(SystemLoginUser.class);
|
||||
|
||||
@BeforeEach
|
||||
public void mockBefore() {
|
||||
when(loginUser.getRoleInfo()).thenReturn(RoleInfo.EMPTY_ROLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckWhenParameterNull() {
|
||||
DeptTreeDataPermissionChecker checker = new DeptTreeDataPermissionChecker(deptService);
|
||||
|
||||
boolean check1 = checker.check(null, null);
|
||||
boolean check2 = checker.check(new SystemLoginUser(), null);
|
||||
boolean check3 = checker.check(null, new DataCondition());
|
||||
boolean check4 = checker.check(loginUser, new DataCondition());
|
||||
|
||||
assertFalse(check1);
|
||||
assertFalse(check2);
|
||||
assertFalse(check3);
|
||||
assertFalse(check4);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenIsChildOfDept() {
|
||||
DeptTreeDataPermissionChecker checker = new DeptTreeDataPermissionChecker(deptService);
|
||||
|
||||
when(deptService.isChildOfTheDept(any(), any())).thenReturn(true);
|
||||
when(loginUser.getDeptId()).thenReturn(1L);
|
||||
|
||||
DataCondition dataCondition = new DataCondition();
|
||||
dataCondition.setTargetDeptId(2L);
|
||||
|
||||
boolean check = checker.check(loginUser, dataCondition);
|
||||
|
||||
assertTrue(check);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenIsSameDept() {
|
||||
DeptTreeDataPermissionChecker checker = new DeptTreeDataPermissionChecker(deptService);
|
||||
|
||||
when(deptService.isChildOfTheDept(any(), any())).thenReturn(false);
|
||||
when(loginUser.getDeptId()).thenReturn(1L);
|
||||
DataCondition dataCondition = new DataCondition();
|
||||
dataCondition.setTargetDeptId(1L);
|
||||
|
||||
boolean check = checker.check(loginUser, dataCondition);
|
||||
|
||||
assertTrue(check);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenFailed() {
|
||||
DeptTreeDataPermissionChecker checker = new DeptTreeDataPermissionChecker(deptService);
|
||||
|
||||
when(deptService.isChildOfTheDept(any(), any())).thenReturn(false);
|
||||
when(loginUser.getDeptId()).thenReturn(1L);
|
||||
DataCondition dataCondition = new DataCondition();
|
||||
dataCondition.setTargetDeptId(2L);
|
||||
|
||||
boolean check = checker.check(loginUser, dataCondition);
|
||||
|
||||
assertFalse(check);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+4
-8
@@ -2,21 +2,17 @@ package com.agileboot.admin.customize.service.permission;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.OnlySelfDataPermissionChecker;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.admin.customize.service.permission.model.DataCondition;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class OnlySelfDataPermissionCheckerTest {
|
||||
|
||||
private final SysDeptService deptService = mock(SysDeptService.class);
|
||||
|
||||
@Test
|
||||
void testCheckWhenParameterNull() {
|
||||
OnlySelfDataPermissionChecker checker = new OnlySelfDataPermissionChecker(deptService);
|
||||
OnlySelfDataPermissionChecker checker = new OnlySelfDataPermissionChecker();
|
||||
|
||||
boolean check1 = checker.check(null, null);
|
||||
boolean check2 = checker.check(new SystemLoginUser(), null);
|
||||
@@ -31,7 +27,7 @@ class OnlySelfDataPermissionCheckerTest {
|
||||
|
||||
@Test
|
||||
void testCheckWhenSameUserId() {
|
||||
OnlySelfDataPermissionChecker checker = new OnlySelfDataPermissionChecker(deptService);
|
||||
OnlySelfDataPermissionChecker checker = new OnlySelfDataPermissionChecker();
|
||||
SystemLoginUser loginUser = new SystemLoginUser();
|
||||
loginUser.setUserId(1L);
|
||||
DataCondition dataCondition = new DataCondition();
|
||||
@@ -45,11 +41,11 @@ class OnlySelfDataPermissionCheckerTest {
|
||||
|
||||
@Test
|
||||
void testCheckWhenDifferentUserId() {
|
||||
OnlySelfDataPermissionChecker checker = new OnlySelfDataPermissionChecker(deptService);
|
||||
OnlySelfDataPermissionChecker checker = new OnlySelfDataPermissionChecker();
|
||||
SystemLoginUser loginUser = new SystemLoginUser();
|
||||
loginUser.setUserId(1L);
|
||||
DataCondition dataCondition = new DataCondition();
|
||||
dataCondition.setTargetDeptId(2L);
|
||||
dataCondition.setTargetUserId(2L);
|
||||
|
||||
boolean check = checker.check(loginUser, dataCondition);
|
||||
|
||||
|
||||
-72
@@ -1,72 +0,0 @@
|
||||
package com.agileboot.admin.customize.service.permission;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.SingleDeptDataPermissionChecker;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.infrastructure.user.web.RoleInfo;
|
||||
import com.agileboot.admin.customize.service.permission.model.DataCondition;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class SingleDeptDataPermissionCheckerTest {
|
||||
|
||||
private final SysDeptService deptService = mock(SysDeptService.class);
|
||||
|
||||
public SystemLoginUser loginUser = mock(SystemLoginUser.class);
|
||||
|
||||
@BeforeEach
|
||||
public void mockBefore() {
|
||||
when(loginUser.getRoleInfo()).thenReturn(RoleInfo.EMPTY_ROLE);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenParameterNull() {
|
||||
SingleDeptDataPermissionChecker checker = new SingleDeptDataPermissionChecker(deptService);
|
||||
|
||||
boolean check1 = checker.check(null, null);
|
||||
boolean check2 = checker.check(new SystemLoginUser(), null);
|
||||
boolean check3 = checker.check(null, new DataCondition());
|
||||
boolean check4 = checker.check(loginUser, new DataCondition());
|
||||
|
||||
assertFalse(check1);
|
||||
assertFalse(check2);
|
||||
assertFalse(check3);
|
||||
assertFalse(check4);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckWhenSameDeptId() {
|
||||
SingleDeptDataPermissionChecker checker = new SingleDeptDataPermissionChecker(deptService);
|
||||
when(loginUser.getDeptId()).thenReturn(1L);
|
||||
DataCondition dataCondition = new DataCondition();
|
||||
dataCondition.setTargetDeptId(1L);
|
||||
|
||||
boolean check = checker.check(loginUser, dataCondition);
|
||||
|
||||
assertTrue(check);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenDifferentDeptId() {
|
||||
SingleDeptDataPermissionChecker checker = new SingleDeptDataPermissionChecker(deptService);
|
||||
when(loginUser.getDeptId()).thenReturn(1L);
|
||||
DataCondition dataCondition = new DataCondition();
|
||||
dataCondition.setTargetUserId(2L);
|
||||
|
||||
boolean check = checker.check(loginUser, dataCondition);
|
||||
|
||||
assertFalse(check);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user