Commit bca6d9e6 authored by 赵啸非's avatar 赵啸非

添加站点授权

parent 6dab6629
......@@ -11,7 +11,7 @@ import javax.servlet.http.HttpServletResponse;
* @date: 2022/6/6 15:05
* @description:添加跨域响应
**/
@Component
//@Component
public class CrossInterceptor extends HandlerInterceptorAdapter {
@Override
......
......@@ -932,36 +932,5 @@ public class SmsSetQuery extends SmsSetEntity {
}
/**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList
*/
public List<SmsSetQuery> getOrConditionList(){
return this.orConditionList;
}
/**
* 设置 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @param orConditionList
*/
public void setOrConditionList(List<SmsSetQuery> orConditionList){
this.orConditionList = orConditionList;
}
/**
* 获取 AND条件集合,列表项之间是AND,项内容之间是OR,如:(list[0].1 or list[0].2) and (list[1].3 or list[1].4)
* @return andConditionList
*/
public List<SmsSetQuery> getAndConditionList(){
return this.andConditionList;
}
/**
* 设置 AND条件集合,列表项之间是AND,项内容之间是OR,如:(list[0].1 or list[0].2) and (list[1].3 or list[1].4)
* @param andConditionList
*/
public void setAndConditionList(List<SmsSetQuery> andConditionList){
this.andConditionList = andConditionList;
}
}
\ No newline at end of file
package com.mortals.xhx.utils;
import cn.hutool.extra.spring.SpringUtil;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* @ClassName SpringUtils
* @Description TODO
* @Author finegirl
* @Date 2020/4/24 15:32
**/
@Component
public class SpringUtils implements ApplicationContextAware {
public final class SpringUtils extends SpringUtil {
private static ApplicationContext applicationContext;
/**
* 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true
*
* @param name
* @return boolean
*/
public static boolean containsBean(String name) {
return getBeanFactory().containsBean(name);
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
SpringUtils.applicationContext = applicationContext;
/**
* 判断以给定名字注册的bean定义是一个singleton还是一个prototype。
* 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException)
*
* @param name
* @return boolean
*/
public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
return getBeanFactory().isSingleton(name);
}
public static ApplicationContext getApplicationContext() {
return applicationContext;
/**
* @param name
* @return Class 注册对象的类型
*/
public static Class<?> getType(String name) throws NoSuchBeanDefinitionException {
return getBeanFactory().getType(name);
}
/**
* 对应的被管理类有别名时使用
* 如果给定的bean名字在bean定义中有别名,则返回这些别名
*
* @param name
* @param <T>
* @return
* @throws BeansException
*/
@SuppressWarnings("unchecked")
public static <T> T getBean(String name) throws BeansException {
return (T) applicationContext.getBean(name);
public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
return getBeanFactory().getAliases(name);
}
/**
* 在对应的注解内未使用别名时 使用
* 获取aop代理对象
*
* @param invoker
* @return
*/
public static <T> T getBean(Class<T> clazz) {
return applicationContext.getBean(clazz);
@SuppressWarnings("unchecked")
public static <T> T getAopProxy(T invoker) {
return (T) AopContext.currentProxy();
}
}
......@@ -111,6 +111,16 @@
<version>2.3.31</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
<!--Token生成与解析-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
......
......@@ -8,6 +8,7 @@ import com.mortals.framework.util.AESUtil;
import com.mortals.framework.utils.ServletUtils;
import com.mortals.framework.web.interceptor.BaseInterceptor;
import com.mortals.xhx.base.framework.config.InterceptorConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
......@@ -24,6 +25,7 @@ import java.lang.reflect.Method;
* @date: 2022/4/24 11:04
*/
@Component
@Slf4j
public class AuthUserInterceptor extends BaseInterceptor {
@Autowired
private InterceptorConfig config;
......@@ -40,12 +42,14 @@ public class AuthUserInterceptor extends BaseInterceptor {
throws Exception {
JSONObject ret = new JSONObject();
try {
HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod();
UnAuth annotation = method.getAnnotation(UnAuth.class);
if (annotation != null) {
//取消校验
return true;
if(handler instanceof HandlerMethod){
HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod();
UnAuth annotation = method.getAnnotation(UnAuth.class);
if (annotation != null) {
//取消校验
return true;
}
}
String uri = request.getServletPath();
//校验配置的请求路径是否需要检查权限
......@@ -71,7 +75,7 @@ public class AuthUserInterceptor extends BaseInterceptor {
}
}
} catch (Exception e) {
logger.error("权限校验拦截请求处理异常-->" + e.getMessage());
log.error("权限校验拦截请求处理异常-->" + e.getMessage(),e);
writeJsonResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "用户权限校验异常");
return false;
}
......
package com.mortals.xhx.base.framework.config;
package com.mortals.xhx.base.framework.interceptor;
import com.mortals.framework.web.interceptor.BaseInterceptor;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
......@@ -12,7 +13,7 @@ import javax.servlet.http.HttpServletResponse;
* @description:添加跨域响应
**/
@Component
public class CrossInterceptor extends HandlerInterceptorAdapter {
public class CrossInterceptor extends BaseInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
......@@ -23,4 +24,9 @@ public class CrossInterceptor extends HandlerInterceptorAdapter {
response.setHeader("Access-Control-Allow-Credentials", "true");
return true;
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
super.afterCompletion(request, response, handler, ex);
}
}
......@@ -67,7 +67,6 @@ public class UploadServiceImpl implements UploadService {
}
String newName = new Date().getTime() + "." + extension;
String filePathAll = filePath + newName;
File uploadFile = new File(filePathAll);
try {
log.info("文件正在储存,filepath:"+filePathAll);
......
......@@ -28,6 +28,26 @@ import java.util.*;
@Service("menuService")
public class MenuServiceImpl extends AbstractCRUDServiceImpl<MenuDao, MenuEntity, Long> implements MenuService {
@Override
public int remove(Long[] ids, Context context) throws AppException {
//删除后级联删除子节点
Arrays.asList(ids).stream().forEach(id->{
menudelete(context, id);
});
return super.remove(ids, context);
}
private void menudelete(Context context, Long id) {
List<MenuEntity> menuEntityList = this.find(new MenuQuery().parentId(id));
if(!ObjectUtils.isEmpty(menuEntityList)){
this.remove(menuEntityList, context);
menuEntityList.forEach(item->{
menudelete(context,item.getId());
});
}
}
@Override
protected void findAfter(MenuEntity params, PageInfo pageInfo, Context context, List<MenuEntity> list) throws AppException {
//查询当前目录等级
......
......@@ -14,6 +14,8 @@ import com.mortals.xhx.module.role.model.RoleUserQuery;
import com.mortals.xhx.module.role.service.RoleService;
import com.mortals.xhx.module.role.service.RoleUserService;
import com.mortals.xhx.module.user.model.UserEntityExt;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -51,6 +53,8 @@ import static com.mortals.framework.ap.SysConstains.*;
* @author zxfei
* @date 2022-05-25
*/
@Api(value = "用户信息控制器", tags = {"用户信息管理"})
@RestController
@RequestMapping("user")
public class UserController extends BaseCRUDJsonBodyMappingController<UserService, UserEntity, Long> {
......@@ -64,7 +68,6 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
private RoleService roleService;
public UserController() {
super.setFormClass(UserForm.class);
super.setModuleDesc("用户信息业务");
}
......
......@@ -36,7 +36,6 @@ mybatis:
application:
auth:
unloginUrl: /refresh,/error,/login/login,/login/index,/login/logout,/securitycode/createCode,/file/common/*,/test*,/padsign/*,/terminal/*,/resource/list,/api/asset/*,/api/*,/flow/*,/uploads/*,/project/file/*,/file/*,/assessment/*
uncheckUrl: /refresh,/error,/login/login,/login/index,/login/logout,/securitycode/createCode,/file/common/*,/test*,/padsign/*,/terminal/*,/resource/list,/api/asset/*,/api/*,/flow/*,/uploads/*,/project/file/*,/file/*,/assessment/*
unloginUrl: /refresh,/error,/login/login,/login/index,/login/logout,/securitycode/createCode,/file/common/*,/test*,/padsign/*,/terminal/*,/resource/list,/api/asset/*,/api/*,/flow/*,/uploads/*,/project/file/*,/file/*,/doc.html
uncheckUrl: /refresh,/error,/login/login,/login/index,/login/logout,/securitycode/createCode,/file/common/*,/test*,/padsign/*,/terminal/*,/resource/list,/api/asset/*,/api/*,/flow/*,/uploads/*,/project/file/*,/file/*,/doc.html
POST {{baseUrl}}/file/commonupload
Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="1.png"
< ./1.png
--WebAppBoundary--
###
###登录
POST {{baseUrl}}/login/login
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment