This commit is contained in:
commit
a10fbce2f8
|
@ -2,7 +2,22 @@
|
|||
<configuration default="false" name="oa [clean,spring-boot:run]" type="MavenRunConfiguration" factoryName="Maven" nameIsGenerated="true">
|
||||
<MavenSettings>
|
||||
<option name="myGeneralSettings" />
|
||||
<option name="myRunnerSettings" />
|
||||
<option name="myRunnerSettings">
|
||||
<MavenRunnerSettings>
|
||||
<option name="delegateBuildToMaven" value="false" />
|
||||
<option name="environmentProperties">
|
||||
<map />
|
||||
</option>
|
||||
<option name="jreName" value="corretto-17" />
|
||||
<option name="mavenProperties">
|
||||
<map />
|
||||
</option>
|
||||
<option name="passParentEnv" value="true" />
|
||||
<option name="runMavenInBackground" value="true" />
|
||||
<option name="skipTests" value="false" />
|
||||
<option name="vmOptions" value="-Dfile.encoding=GB2312" />
|
||||
</MavenRunnerSettings>
|
||||
</option>
|
||||
<option name="myRunnerParameters">
|
||||
<MavenRunnerParameters>
|
||||
<option name="cmdOptions" />
|
||||
|
|
|
@ -3,11 +3,14 @@ package com.jsl.oa.aspect;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.jsl.oa.annotations.NeedPermission;
|
||||
import com.jsl.oa.common.constant.BusinessConstants;
|
||||
import com.jsl.oa.dao.RoleDAO;
|
||||
import com.jsl.oa.exception.library.NotLoginException;
|
||||
import com.jsl.oa.exception.library.PermissionDeniedException;
|
||||
import com.jsl.oa.exception.library.TokenNotFoundedException;
|
||||
import com.jsl.oa.model.dodata.RoleDO;
|
||||
import com.jsl.oa.utils.Processing;
|
||||
import com.jsl.oa.utils.redis.TokenRedisUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
|
@ -37,6 +40,7 @@ public class CheckUserPermissionAspect {
|
|||
|
||||
private final RoleDAO roleDAO;
|
||||
private final Gson gson;
|
||||
private final TokenRedisUtil<String> tokenRedisUtil;
|
||||
|
||||
/**
|
||||
* 检查权限
|
||||
|
@ -58,6 +62,9 @@ public class CheckUserPermissionAspect {
|
|||
if (getUserId == null) {
|
||||
throw new NotLoginException("用户信息不存在");
|
||||
}
|
||||
if (tokenRedisUtil.getData(BusinessConstants.BUSINESS_LOGIN, getUserId.toString()) == null) {
|
||||
throw new TokenNotFoundedException("用户未登录");
|
||||
}
|
||||
// 获取方法签名
|
||||
MethodSignature signature = (MethodSignature) pjp.getSignature();
|
||||
NeedPermission checkAccountPermission = signature.getMethod().getAnnotation(NeedPermission.class);
|
||||
|
|
|
@ -19,19 +19,16 @@ public class PermissionList {
|
|||
|
||||
|
||||
public PermissionList() {
|
||||
permissionList.add(new PermissionVO("auth:logout", "账户登出"));
|
||||
permissionList.add(new PermissionVO("auth:change_password", "修改密码"));
|
||||
permissionList.add(new PermissionVO("info:get_header_image", "获取头部图片"));
|
||||
permissionList.add(new PermissionVO("info:edit_header_image", "编辑头部图片"));
|
||||
permissionList.add(new PermissionVO("info:delete_header_image", "删除头部图片"));
|
||||
|
||||
permissionPrincipal.add(new PermissionVO("auth:logout", "账户登出"));
|
||||
permissionPrincipal.add(new PermissionVO("auth:change_password", "修改密码"));
|
||||
permissionPrincipal.add(new PermissionVO("info:get_header_image", "获取头部图片"));
|
||||
permissionPrincipal.add(new PermissionVO("info:edit_header_image", "编辑头部图片"));
|
||||
permissionPrincipal.add(new PermissionVO("info:delete_header_image", "删除头部图片"));
|
||||
|
||||
permissionDeveloper.add(new PermissionVO("auth:logout", "账户登出"));
|
||||
permissionDeveloper.add(new PermissionVO("auth:change_password", "修改密码"));
|
||||
permissionDeveloper.add(new PermissionVO("info:get_header_image", "获取头部图片"));
|
||||
permissionDeveloper.add(new PermissionVO("info:edit_header_image", "编辑头部图片"));
|
||||
|
|
|
@ -147,7 +147,6 @@ public class AuthController {
|
|||
* @since v1.1.0
|
||||
*/
|
||||
@GetMapping("/auth/logout")
|
||||
@NeedPermission("auth:logout")
|
||||
public BaseResponse authLogout(HttpServletRequest request) {
|
||||
return authService.authLogout(request);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.jsl.oa.exception;
|
||||
|
||||
import com.jsl.oa.exception.library.PermissionDeniedException;
|
||||
import com.jsl.oa.exception.library.TokenNotFoundedException;
|
||||
import com.jsl.oa.utils.BaseResponse;
|
||||
import com.jsl.oa.utils.ErrorCode;
|
||||
import com.jsl.oa.utils.ResultUtil;
|
||||
|
@ -110,4 +111,10 @@ public class ProcessException {
|
|||
log.warn("[EXCEPTION] 无权限操作,需要权限: {}", e.getNeedPermission());
|
||||
return ResultUtil.error("需要权限: " + e.getNeedPermission(), ErrorCode.PERMISSION_NOT_EXIST);
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = TokenNotFoundedException.class)
|
||||
public BaseResponse businessTokenNotFoundedException(TokenNotFoundedException e) {
|
||||
log.warn("[EXCEPTION] {}", e.getMessage());
|
||||
return ResultUtil.error(e.getMessage(), ErrorCode.TOKEN_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package com.jsl.oa.exception.library;
|
||||
|
||||
public class TokenNotFoundedException extends RuntimeException {
|
||||
public TokenNotFoundedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
17
src/main/java/com/jsl/oa/model/vodata/PageBean.java
Normal file
17
src/main/java/com/jsl/oa/model/vodata/PageBean.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package com.jsl.oa.model.vodata;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PageBean<T> {
|
||||
private int totalCount; // 总记录数
|
||||
private int currentPage; // 当前页码
|
||||
private int pageSize; // 每页记录数
|
||||
private List<T> list; // 当前页的数据列表
|
||||
}
|
|
@ -213,7 +213,7 @@ public class AuthServiceImpl implements AuthService {
|
|||
if (tokenRedisUtil.delData(BusinessConstants.BUSINESS_LOGIN, userDO.getId().toString())) {
|
||||
return ResultUtil.success("登出成功");
|
||||
} else {
|
||||
return ResultUtil.error(ErrorCode.DATABASE_DELETE_ERROR);
|
||||
return ResultUtil.error(ErrorCode.TOKEN_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.jsl.oa.model.dodata.ProjectChildDO;
|
|||
import com.jsl.oa.model.dodata.ProjectModuleDO;
|
||||
import com.jsl.oa.model.vodata.MessageAddVO;
|
||||
import com.jsl.oa.model.vodata.MessageGetVO;
|
||||
import com.jsl.oa.model.vodata.PageBean;
|
||||
import com.jsl.oa.services.MessageService;
|
||||
import com.jsl.oa.utils.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
@ -86,12 +87,18 @@ public class MessageServiceImpl implements MessageService {
|
|||
}
|
||||
messageGetVOList.add(messageGetVO1);
|
||||
}
|
||||
|
||||
//分页返回
|
||||
int start = (page - 1) * pageSize;
|
||||
int end = start + pageSize;
|
||||
List<MessageGetVO> pageData = messageGetVOList.subList(start,
|
||||
Math.min(end, messageGetVOList.size()));
|
||||
return ResultUtil.success(pageData);
|
||||
PageBean<MessageGetVO> pageBean = new PageBean<>();
|
||||
pageBean.setTotalCount(messageGetVOList.size());
|
||||
pageBean.setCurrentPage(page);
|
||||
pageBean.setPageSize(pageSize);
|
||||
pageBean.setList(pageData);
|
||||
return ResultUtil.success(pageBean);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user