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

添加站点授权

parent 6dab6629
...@@ -11,7 +11,7 @@ import javax.servlet.http.HttpServletResponse; ...@@ -11,7 +11,7 @@ import javax.servlet.http.HttpServletResponse;
* @date: 2022/6/6 15:05 * @date: 2022/6/6 15:05
* @description:添加跨域响应 * @description:添加跨域响应
**/ **/
@Component //@Component
public class CrossInterceptor extends HandlerInterceptorAdapter { public class CrossInterceptor extends HandlerInterceptorAdapter {
@Override @Override
......
...@@ -932,36 +932,5 @@ public class SmsSetQuery extends SmsSetEntity { ...@@ -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; 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.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/**
* @ClassName SpringUtils
* @Description TODO
* @Author finegirl
* @Date 2020/4/24 15:32
**/
@Component @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 { * 判断以给定名字注册的bean定义是一个singleton还是一个prototype。
SpringUtils.applicationContext = applicationContext; * 如果与给定名字相应的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 name
* @param <T>
* @return
* @throws BeansException
*/ */
@SuppressWarnings("unchecked") public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
public static <T> T getBean(String name) throws BeansException { return getBeanFactory().getAliases(name);
return (T) applicationContext.getBean(name);
} }
/** /**
* 在对应的注解内未使用别名时 使用 * 获取aop代理对象
*
* @param invoker
* @return
*/ */
public static <T> T getBean(Class<T> clazz) { @SuppressWarnings("unchecked")
return applicationContext.getBean(clazz); public static <T> T getAopProxy(T invoker) {
return (T) AopContext.currentProxy();
} }
} }
...@@ -111,6 +111,16 @@ ...@@ -111,6 +111,16 @@
<version>2.3.31</version> <version>2.3.31</version>
</dependency> </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生成与解析--> <!--Token生成与解析-->
<dependency> <dependency>
<groupId>io.jsonwebtoken</groupId> <groupId>io.jsonwebtoken</groupId>
......
...@@ -8,6 +8,7 @@ import com.mortals.framework.util.AESUtil; ...@@ -8,6 +8,7 @@ import com.mortals.framework.util.AESUtil;
import com.mortals.framework.utils.ServletUtils; import com.mortals.framework.utils.ServletUtils;
import com.mortals.framework.web.interceptor.BaseInterceptor; import com.mortals.framework.web.interceptor.BaseInterceptor;
import com.mortals.xhx.base.framework.config.InterceptorConfig; import com.mortals.xhx.base.framework.config.InterceptorConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -24,6 +25,7 @@ import java.lang.reflect.Method; ...@@ -24,6 +25,7 @@ import java.lang.reflect.Method;
* @date: 2022/4/24 11:04 * @date: 2022/4/24 11:04
*/ */
@Component @Component
@Slf4j
public class AuthUserInterceptor extends BaseInterceptor { public class AuthUserInterceptor extends BaseInterceptor {
@Autowired @Autowired
private InterceptorConfig config; private InterceptorConfig config;
...@@ -40,12 +42,14 @@ public class AuthUserInterceptor extends BaseInterceptor { ...@@ -40,12 +42,14 @@ public class AuthUserInterceptor extends BaseInterceptor {
throws Exception { throws Exception {
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
try { try {
HandlerMethod handlerMethod = (HandlerMethod) handler; if(handler instanceof HandlerMethod){
Method method = handlerMethod.getMethod(); HandlerMethod handlerMethod = (HandlerMethod) handler;
UnAuth annotation = method.getAnnotation(UnAuth.class); Method method = handlerMethod.getMethod();
if (annotation != null) { UnAuth annotation = method.getAnnotation(UnAuth.class);
//取消校验 if (annotation != null) {
return true; //取消校验
return true;
}
} }
String uri = request.getServletPath(); String uri = request.getServletPath();
//校验配置的请求路径是否需要检查权限 //校验配置的请求路径是否需要检查权限
...@@ -71,7 +75,7 @@ public class AuthUserInterceptor extends BaseInterceptor { ...@@ -71,7 +75,7 @@ public class AuthUserInterceptor extends BaseInterceptor {
} }
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("权限校验拦截请求处理异常-->" + e.getMessage()); log.error("权限校验拦截请求处理异常-->" + e.getMessage(),e);
writeJsonResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "用户权限校验异常"); writeJsonResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "用户权限校验异常");
return false; 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.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
...@@ -12,7 +13,7 @@ import javax.servlet.http.HttpServletResponse; ...@@ -12,7 +13,7 @@ import javax.servlet.http.HttpServletResponse;
* @description:添加跨域响应 * @description:添加跨域响应
**/ **/
@Component @Component
public class CrossInterceptor extends HandlerInterceptorAdapter { public class CrossInterceptor extends BaseInterceptor {
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
...@@ -23,4 +24,9 @@ public class CrossInterceptor extends HandlerInterceptorAdapter { ...@@ -23,4 +24,9 @@ public class CrossInterceptor extends HandlerInterceptorAdapter {
response.setHeader("Access-Control-Allow-Credentials", "true"); response.setHeader("Access-Control-Allow-Credentials", "true");
return 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 { ...@@ -67,7 +67,6 @@ public class UploadServiceImpl implements UploadService {
} }
String newName = new Date().getTime() + "." + extension; String newName = new Date().getTime() + "." + extension;
String filePathAll = filePath + newName; String filePathAll = filePath + newName;
File uploadFile = new File(filePathAll); File uploadFile = new File(filePathAll);
try { try {
log.info("文件正在储存,filepath:"+filePathAll); log.info("文件正在储存,filepath:"+filePathAll);
......
...@@ -28,6 +28,26 @@ import java.util.*; ...@@ -28,6 +28,26 @@ import java.util.*;
@Service("menuService") @Service("menuService")
public class MenuServiceImpl extends AbstractCRUDServiceImpl<MenuDao, MenuEntity, Long> implements 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 @Override
protected void findAfter(MenuEntity params, PageInfo pageInfo, Context context, List<MenuEntity> list) throws AppException { 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; ...@@ -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.RoleService;
import com.mortals.xhx.module.role.service.RoleUserService; import com.mortals.xhx.module.role.service.RoleUserService;
import com.mortals.xhx.module.user.model.UserEntityExt; 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.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -51,6 +53,8 @@ import static com.mortals.framework.ap.SysConstains.*; ...@@ -51,6 +53,8 @@ import static com.mortals.framework.ap.SysConstains.*;
* @author zxfei * @author zxfei
* @date 2022-05-25 * @date 2022-05-25
*/ */
@Api(value = "用户信息控制器", tags = {"用户信息管理"})
@RestController @RestController
@RequestMapping("user") @RequestMapping("user")
public class UserController extends BaseCRUDJsonBodyMappingController<UserService, UserEntity, Long> { public class UserController extends BaseCRUDJsonBodyMappingController<UserService, UserEntity, Long> {
...@@ -64,7 +68,6 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic ...@@ -64,7 +68,6 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
private RoleService roleService; private RoleService roleService;
public UserController() { public UserController() {
super.setFormClass(UserForm.class);
super.setModuleDesc("用户信息业务"); super.setModuleDesc("用户信息业务");
} }
......
...@@ -36,7 +36,6 @@ mybatis: ...@@ -36,7 +36,6 @@ mybatis:
application: application:
auth: 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/* 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/*,/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/*,/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 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