fix: 模块补丁

This commit is contained in:
筱锋xiao_lfeng 2024-01-20 17:13:30 +08:00
parent 32cfac1525
commit 1d78d147ac
No known key found for this signature in database
GPG Key ID: F693AA12AABBFA87
4 changed files with 49 additions and 41 deletions

View File

@ -6,6 +6,7 @@ import com.jsl.oa.services.UserService;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -25,13 +26,7 @@ public class ShiroConfiguration {
shiroFilterFactoryBean.setSecurityManager(securityManager);
// 配置过滤器规则
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
filterChainDefinitionMap.put("/auth/**/**", "anon"); // 登录接口允许匿名访问
filterChainDefinitionMap.put("/unauthorized", "anon"); // 未授权接口允许匿名访问
filterChainDefinitionMap.put("/", "anon"); // 首页允许匿名访问
filterChainDefinitionMap.put("/info/header-image/get", "anon"); // 信息接口允许匿名访问
filterChainDefinitionMap.put("/info/header-user/get", "anon"); // 信息接口允许匿名访问
filterChainDefinitionMap.put("/**/**", "authc"); // 其他接口一律拦截(需要Token)
Map<String, String> filterChainDefinitionMap = setFilterChain();
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
@ -57,4 +52,18 @@ public class ShiroConfiguration {
public MyRealm myRealm() {
return new MyRealm();
}
@NotNull
private static Map<String, String> setFilterChain() {
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
filterChainDefinitionMap.put("/auth/**/**", "anon"); // 登录接口允许匿名访问
filterChainDefinitionMap.put("/unauthorized", "anon"); // 未授权接口允许匿名访问
filterChainDefinitionMap.put("/", "anon"); // 首页允许匿名访问
filterChainDefinitionMap.put("/info/header-image/get", "anon"); // 信息接口允许匿名访问
filterChainDefinitionMap.put("/info/header-user/get", "anon"); // 信息接口允许匿名访问
filterChainDefinitionMap.put("/project/header/get", "anon"); // 信息接口允许匿名访问
filterChainDefinitionMap.put("/project/get", "anon"); // 信息接口允许匿名访问
filterChainDefinitionMap.put("/**/**", "authc"); // 其他接口一律拦截(需要Token)
return filterChainDefinitionMap;
}
}

View File

@ -1,8 +1,6 @@
package com.jsl.oa.controllers;
import com.jsl.oa.model.doData.info.ProjectShowDO;
import com.jsl.oa.model.voData.ProjectInfoVO;
import com.jsl.oa.model.voData.business.info.CarouselVO;
import com.jsl.oa.model.voData.business.info.ProjectShowVO;
import com.jsl.oa.services.ProjectService;
import com.jsl.oa.utils.BaseResponse;
@ -32,7 +30,7 @@ public class ProjectController {
}
@GetMapping("/project/get")
public BaseResponse projectGet(){
public BaseResponse projectGet() {
return projectService.get();
}
@ -54,7 +52,7 @@ public class ProjectController {
}
@PutMapping("/project/header/edit")
public BaseResponse projectEditHeader(@RequestBody @Validated ProjectShowVO projectShowVO,@RequestParam Integer id,HttpServletRequest request,@NotNull BindingResult bindingResult) {
public BaseResponse projectEditHeader(@RequestBody @Validated ProjectShowVO projectShowVO, @RequestParam Integer id, HttpServletRequest request, @NotNull BindingResult bindingResult) {
log.info("请求接口[PUT]: /project/header/del");
// 参数校验
if (bindingResult.hasErrors()) {
@ -70,13 +68,14 @@ public class ProjectController {
@DeleteMapping("/project/header/del")
public BaseResponse projectDelHeader(@RequestParam Integer id,HttpServletRequest request) {
public BaseResponse projectDelHeader(@RequestParam Integer id, HttpServletRequest request) {
log.info("请求接口[Delete]: /project/header/del");
return projectService.delHeader(id,request);
return projectService.delHeader(id, request);
}
@PostMapping("/project/add")
public BaseResponse projectAdd(@RequestBody @Validated ProjectInfoVO projectAdd, BindingResult bindingResult){
public BaseResponse projectAdd(@RequestBody @Validated ProjectInfoVO projectAdd, @NotNull BindingResult bindingResult) {
log.info("请求接口[PUT]: /project/header/del");
// 判断是否有参数错误
if (bindingResult.hasErrors()) {
return ResultUtil.error(ErrorCode.REQUEST_BODY_ERROR, Processing.getValidatedErrorList(bindingResult));
@ -85,7 +84,8 @@ public class ProjectController {
}
@PutMapping("/project/edit")
public BaseResponse projectEdit(@RequestBody @Validated ProjectInfoVO projectEdit, BindingResult bindingResult){
public BaseResponse projectEdit(@RequestBody @Validated ProjectInfoVO projectEdit, @NotNull BindingResult bindingResult) {
log.info("请求接口[PUT]: /project/header/del");
// 判断是否有参数错误
if (bindingResult.hasErrors()) {
return ResultUtil.error(ErrorCode.REQUEST_BODY_ERROR, Processing.getValidatedErrorList(bindingResult));
@ -94,7 +94,8 @@ public class ProjectController {
}
@GetMapping("/project/cut/user")
public BaseResponse projectGetUserInCutting(@RequestParam Long uid){
public BaseResponse projectGetUserInCutting(@RequestParam Long uid) {
log.info("请求接口[PUT]: /project/header/del");
// 判断是否有参数错误
if (uid == null) {
return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
@ -103,11 +104,12 @@ public class ProjectController {
}
@PostMapping("/project/cut/user/add")
public BaseResponse projectAddUserForCutting(@RequestParam Long uid,@RequestParam Long pid){
public BaseResponse projectAddUserForCutting(@RequestParam Long uid, @RequestParam Long pid) {
log.info("请求接口[PUT]: /project/header/del");
// 判断是否有参数错误
if (uid == null || pid == null) {
return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
}
return projectService.projectAddUserForCutting(uid,pid);
return projectService.projectAddUserForCutting(uid, pid);
}
}

View File

@ -35,7 +35,7 @@ public class InfoDAO {
public CarouselDO getCarousel() {
String getCarouselSql = infoMapper.getCarousel();
CarouselDO getCarousel = null;
if (!getCarouselSql.equals("{}")) {
if (getCarouselSql != null && !getCarouselSql.equals("{}")) {
getCarousel = gson.fromJson(getCarouselSql, CarouselDO.class);
}
if (getCarousel == null) {

View File

@ -4,7 +4,6 @@ import com.google.gson.Gson;
import com.jsl.oa.mapper.ProjectMapper;
import com.jsl.oa.model.doData.ProjectCuttingDO;
import com.jsl.oa.model.doData.ProjectDO;
import com.jsl.oa.model.doData.info.CarouselDO;
import com.jsl.oa.model.doData.info.ProjectShowDO;
import com.jsl.oa.model.voData.ProjectInfoVO;
import com.jsl.oa.utils.BaseResponse;
@ -33,9 +32,7 @@ public class ProjectDAO {
}
public boolean isExistProject(Long id) {
if(projectMapper.getProjectById(id)==null) {
return false;
}else return true;
return projectMapper.getProjectById(id) != null;
}
public List<ProjectCuttingDO> projectGetUserInCutting(Long uid) {
@ -43,28 +40,28 @@ public class ProjectDAO {
}
public void projectAddUserForCutting(Long uid, Long pid) {
projectMapper.projectAddUserInCutting(uid,pid);
projectMapper.projectAddUserInCutting(uid, pid);
}
public ProjectShowDO getHeader() {
String getProjectShowSql = projectMapper.getHeader();
ProjectShowDO getProjectShow = null;
if (!getProjectShowSql.equals("{}")) {
getProjectShow = gson.fromJson(getProjectShowSql, ProjectShowDO.class);
String getProjectShowSql = projectMapper.getHeader();
ProjectShowDO getProjectShow = null;
if (getProjectShowSql != null && !getProjectShowSql.equals("{}")) {
getProjectShow = gson.fromJson(getProjectShowSql, ProjectShowDO.class);
}
if (getProjectShow == null) {
// 初始化
getProjectShow = new ProjectShowDO();
getProjectShow.setOrder("desc");
getProjectShow.setData(new ArrayList<>());
try {
projectMapper.insertProjectShow();
} catch (DuplicateKeyException ignored) {
}
if (getProjectShow == null) {
// 初始化
getProjectShow = new ProjectShowDO();
getProjectShow.setOrder("desc");
getProjectShow.setData(new ArrayList<>());
try {
projectMapper.insertProjectShow();
} catch (DuplicateKeyException ignored) {
}
}
// 获取排序
sortProject(getProjectShow);
return getProjectShow;
}
// 获取排序
sortProject(getProjectShow);
return getProjectShow;
}
private void sortProject(ProjectShowDO projectShowDO) {