Commit 18144407 authored by trumansdo's avatar trumansdo
Browse files

应用codestyle


千万千万要用vscode打开前端项目,或者关闭eslint,移除它
Signed-off-by: default avatartrumansdo <1012243881@qq.com>
parent 9b3d96a6
......@@ -3,17 +3,17 @@ package com.ibeetl.admin.console.web.query;
import com.ibeetl.admin.core.annotation.Query;
import com.ibeetl.admin.core.web.query.PageParam;
/**
*/
/** */
public class UserRoleQuery extends PageParam {
@Query(name="角色",display=true,type=Query.TYPE_CONTROL,control="role")
@Query(name = "角色", display = true, type = Query.TYPE_CONTROL, control = "role")
private Long roleId;
@Query(name="部门",display=true,type=Query.TYPE_CONTROL,control="org")
@Query(name = "部门", display = true, type = Query.TYPE_CONTROL, control = "org")
private Long orgId;
private Long userId;
public Long getUserId() {
return userId;
}
......
......@@ -5,40 +5,39 @@ import java.util.Date;
import com.ibeetl.admin.core.annotation.Query;
import com.ibeetl.admin.core.web.query.PageParam;
/**
* 字典表单查询条件
*/
/** 字典表单查询条件 */
public class WorkflowQuery extends PageParam {
@Query(name = "用户列表", display = true,fuzzy=true)
@Query(name = "用户列表", display = true, fuzzy = true)
private String userIds;
@Query(name = "角色列表", display = true,fuzzy=true)
@Query(name = "角色列表", display = true, fuzzy = true)
private String roleIds;
@Query(name = "机构列表", display = true,fuzzy=true)
@Query(name = "机构列表", display = true, fuzzy = true)
private String orgIds;
public String getUserIds() {
return userIds;
}
public void setUserIds(String userIds) {
this.userIds = userIds;
}
public String getRoleIds() {
return roleIds;
}
public void setRoleIds(String roleIds) {
this.roleIds = roleIds;
}
public String getOrgIds() {
return orgIds;
}
public void setOrgIds(String orgIds) {
this.orgIds = orgIds;
}
}
......@@ -10,7 +10,6 @@ import com.ibeetl.admin.core.util.enums.CoreDictType;
/**
* 描述: 用来标注词典字段
*
*
* @author : lijiazhi
*/
@Retention(RetentionPolicy.RUNTIME)
......
......@@ -5,6 +5,7 @@ import java.lang.annotation.RetentionPolicy;
/**
* 用来标注功能id
*
* <pre>
* &#064;Function("user.add")
* public String addUser(){
......@@ -12,11 +13,12 @@ import java.lang.annotation.RetentionPolicy;
* </pre>
*
* 只有拥有此项功能的角色才能操作,否则,权限不足
* @author lijiazhi
*
* @author lijiazhi
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface Function {
public String value();
public String name() default "";
}
......@@ -5,47 +5,51 @@ import java.lang.annotation.RetentionPolicy;
/**
* 用来标准一个查询类
* @author lijiazhi
*
* @author lijiazhi
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface Query {
public static final int TYPE_GENERAL = 1;
public static final int TYPE_DATE_BETWEEN = 2;
//未实现
// 未实现
public static final int TYPE_DATETIME_BETWEEN = 3;
public static final int TYPE_VALUE_BETWEEN = 4;
public static final int TYPE_DICT = 5;
//用户自己定义
// 用户自己定义
public static final int TYPE_CONTROL = 6;
/**
* 中文名字
*
* @return
*/
public String name();
/**
* 查询类型,常规,范围,字典,前端自定义
*
* @return
*/
public int type() default TYPE_GENERAL;
/**
* 是否显示在查询界面上
*
* @return
*/
public boolean display() default false;
/**
* 模糊查询,仅仅针对TYPE_GENERAL
*
* @return
*/
public boolean fuzzy() default false;
/**
* 字典的主键,比如,"user_state"
*
* @return
*/
public String dict() default "";
......@@ -55,12 +59,14 @@ public @interface Query {
/**
* 控件名字,如组织机构面板
*
* @return
*/
public String control() default "";
/**
* 顺序,值越小,排在前面
*
* @return
*/
public int order() default 0;
......
......@@ -40,44 +40,29 @@ import com.ibeetl.starter.ObjectMapperJsonUtil;
@Configuration
@AutoConfigureAfter(JasonConfig.class)
public class BeetlConf {
@Autowired
Environment env;
@Autowired
CorePlatformService platFormService;
@Autowired Environment env;
@Autowired CorePlatformService platFormService;
@Autowired
OrgFunction orgFunction;
@Autowired OrgFunction orgFunction;
@Autowired
SysFunctionTreeFunction sysFunctionTreeFunction;
@Autowired SysFunctionTreeFunction sysFunctionTreeFunction;
@Autowired
DictQueryFunction dictDownQueryFunction;
@Autowired DictQueryFunction dictDownQueryFunction;
@Autowired RoleFunction roleFunction;
@Autowired FileFunction fileFunction;
@Autowired SearchCondtionFunction searchCondtionFunction;
@Autowired
RoleFunction roleFunction;
@Autowired
FileFunction fileFunction;
@Autowired DataAccessFactory dataAccessFactory;
@Autowired
SearchCondtionFunction searchCondtionFunction;
@Autowired ApplicationContext applicationContext;
@Autowired
DataAccessFactory dataAccessFactory;
@Autowired FunFunction funFunction;
@Autowired
ApplicationContext applicationContext;
@Autowired FunAccessUrlFunction funAccessUrlFunction;
@Autowired
FunFunction funFunction;
@Autowired
FunAccessUrlFunction funAccessUrlFunction;
@Autowired
MenuFunction menuFunction;
@Autowired MenuFunction menuFunction;
@Bean
public WebSimulate getWebSimulate(GroupTemplate gt, ObjectMapper objectMapper) {
......@@ -106,7 +91,9 @@ public class BeetlConf {
groupTemplate.registerFunction("uuid", new UUIDFunction());
groupTemplate.registerFunctionPackage("dict", dictDownQueryFunction);
// 模板页面判断是否有按钮权限,比如canAccess
groupTemplate.registerFunction("canAccess", new Function() {
groupTemplate.registerFunction(
"canAccess",
new Function() {
@Override
public Boolean call(Object[] paras, Context ctx) {
......@@ -115,52 +102,53 @@ public class BeetlConf {
String functionCode = (String) paras[0];
return platFormService.canAcessFunction(userId, orgId, functionCode);
}
});
groupTemplate.registerFunction("abcd", new Function() {
groupTemplate.registerFunction(
"abcd",
new Function() {
@Override
public Boolean call(Object[] paras, Context ctx) {
return true;
}
});
groupTemplate.registerFunction("env", new Function() {
groupTemplate.registerFunction(
"env",
new Function() {
@Override
public String call(Object[] paras, Context ctx) {
String key = (String)paras[0];
String key = (String) paras[0];
String value = env.getProperty(key);
if(value!=null) {
if (value != null) {
return getStr(value);
}
if(paras.length==2) {
return (String)paras[1];
if (paras.length == 2) {
return (String) paras[1];
}
return null;
}
protected String getStr(String str) {
try {
return new String(str.getBytes("iso8859-1"),"UTF-8");
return new String(str.getBytes("iso8859-1"), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
});
groupTemplate.registerFunction("dataAccessList", new Function() {
groupTemplate.registerFunction(
"dataAccessList",
new Function() {
@Override
public List<DataAccess> call(Object[] paras, Context ctx) {
return dataAccessFactory.all();
}
});
}
};
}
......@@ -178,5 +166,4 @@ public class BeetlConf {
return;
}
}
}
......@@ -27,11 +27,10 @@ import org.springframework.data.redis.serializer.RedisSerializationContext.Seria
* 支持一二级缓存,使得性能逆天快.默认不开启
*
* @author xiandafu
*
*/
//@Configuration
//@ConditionalOnProperty(name="springext.cache.enabled", havingValue="true" ,matchIfMissing=false)
// @Configuration
// @ConditionalOnProperty(name="springext.cache.enabled", havingValue="true" ,matchIfMissing=false)
public class CacheConfig {
// 定义一个redis 的频道,默认叫cache,用于pub/sub
......@@ -41,10 +40,13 @@ public class CacheConfig {
@Bean
public TowLevelCacheManager cacheManager(RedisTemplate redisTemplate) {
RedisCacheWriter writer = RedisCacheWriter.lockingRedisCacheWriter(redisTemplate.getConnectionFactory());
SerializationPair pair = SerializationPair
.fromSerializer(new JdkSerializationRedisSerializer(this.getClass().getClassLoader()));
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(pair);
RedisCacheWriter writer =
RedisCacheWriter.lockingRedisCacheWriter(redisTemplate.getConnectionFactory());
SerializationPair pair =
SerializationPair.fromSerializer(
new JdkSerializationRedisSerializer(this.getClass().getClassLoader()));
RedisCacheConfiguration config =
RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(pair);
TowLevelCacheManager cacheManager = new TowLevelCacheManager(redisTemplate, writer, config);
......@@ -52,8 +54,8 @@ public class CacheConfig {
}
@Bean
RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory,
MessageListenerAdapter listenerAdapter) {
RedisMessageListenerContainer container(
RedisConnectionFactory connectionFactory, MessageListenerAdapter listenerAdapter) {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
......@@ -63,7 +65,8 @@ public class CacheConfig {
@Bean
MessageListenerAdapter listenerAdapter(final TowLevelCacheManager cacheManager) {
return new MessageListenerAdapter(new MessageListener() {
return new MessageListenerAdapter(
new MessageListener() {
public void onMessage(Message message, byte[] pattern) {
byte[] bs = message.getChannel();
......@@ -75,16 +78,16 @@ public class CacheConfig {
e.printStackTrace();
// 不可能出错,忽略
}
}
});
}
class TowLevelCacheManager extends RedisCacheManager {
RedisTemplate redisTemplate;
public TowLevelCacheManager(RedisTemplate redisTemplate, RedisCacheWriter cacheWriter,
public TowLevelCacheManager(
RedisTemplate redisTemplate,
RedisCacheWriter cacheWriter,
RedisCacheConfiguration defaultCacheConfiguration) {
super(cacheWriter, defaultCacheConfiguration);
this.redisTemplate = redisTemplate;
......@@ -108,7 +111,6 @@ public class CacheConfig {
cache.clearLocal();
}
}
}
class RedisAndLocalCache implements Cache {
......@@ -146,7 +148,6 @@ public class CacheConfig {
return wrapper;
}
}
@Override
......@@ -165,7 +166,6 @@ public class CacheConfig {
System.out.println(value.getClass().getClassLoader());
redisCache.put(key, value);
clearOtherJVM();
}
@Override
......@@ -173,20 +173,17 @@ public class CacheConfig {
ValueWrapper v = redisCache.putIfAbsent(key, value);
clearOtherJVM();
return v;
}
@Override
public void evict(Object key) {
redisCache.evict(key);
clearOtherJVM();
}
@Override
public void clear() {
redisCache.clear();
}
public void clearLocal() {
......@@ -196,7 +193,5 @@ public class CacheConfig {
protected void clearOtherJVM() {
cacheManager.publishMessage(redisCache.getName());
}
}
}
package com.ibeetl.admin.core.conf;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
......@@ -40,8 +38,7 @@ public class CustomErrorController extends AbstractErrorController {
private static final String ERROR_PATH = "/error";
Log log = LogFactory.getLog(ErrorController.class);
@Autowired
ObjectMapper objectMapper;
@Autowired ObjectMapper objectMapper;
public CustomErrorController() {
super(new DefaultErrorAttributes());
......@@ -49,27 +46,23 @@ public class CustomErrorController extends AbstractErrorController {
@RequestMapping(ERROR_PATH)
public ModelAndView getErrorPath(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> model = Collections.unmodifiableMap(getErrorAttributes(
request, false));
Throwable cause =getCause(request);
int status = (Integer)model.get("status");
//错误信息
String message = (String)model.get("message");
//友好提示
Map<String, Object> model = Collections.unmodifiableMap(getErrorAttributes(request, false));
Throwable cause = getCause(request);
int status = (Integer) model.get("status");
// 错误信息
String message = (String) model.get("message");
// 友好提示
String errorMessage = getErrorMessage(cause);
String requestPath = (String)model.get("path");
String requestPath = (String) model.get("path");
List<FieldError> filedErrors = this.getFieldError(model, cause);
//后台打印日志信息方方便查错
log.error(status+":"+message+filedErrors, cause);
log.error("requestPath"+":"+requestPath);
// 后台打印日志信息方方便查错
log.error(status + ":" + message + filedErrors, cause);
log.error("requestPath" + ":" + requestPath);
response.setStatus(status);
if(!isJsonRequest(request)){
if (!isJsonRequest(request)) {
ModelAndView view = new ModelAndView("/error.html");
view.addAllObjects(model);
view.addObject("errorMessage", errorMessage);
......@@ -79,44 +72,39 @@ public class CustomErrorController extends AbstractErrorController {
return view;
}else{
if(filedErrors==null){
if(status==404){
writeJson(response,JsonResult.http404(requestPath));
}else{
writeJson(response,JsonResult.failMessage(getErrorMessage(cause)));
} else {
if (filedErrors == null) {
if (status == 404) {
writeJson(response, JsonResult.http404(requestPath));
} else {
writeJson(response, JsonResult.failMessage(getErrorMessage(cause)));
}
}else{
} else {
writeJson(response,JsonResult.fail(this.wrapFieldErrors(filedErrors)));
writeJson(response, JsonResult.fail(this.wrapFieldErrors(filedErrors)));
}
return null;
}
}
protected List<FieldError> getFieldError(Map<String, Object> model,Throwable cause){
List<FieldError> filedErrors = (List<FieldError>)model.get("errors");
if(filedErrors!=null){
protected List<FieldError> getFieldError(Map<String, Object> model, Throwable cause) {
List<FieldError> filedErrors = (List<FieldError>) model.get("errors");
if (filedErrors != null) {
return filedErrors;
}
if(cause instanceof FormFieldException){
FormFieldException fe = (FormFieldException)cause;
if (cause instanceof FormFieldException) {
FormFieldException fe = (FormFieldException) cause;
return fe.getErrors();
}
return null;
}
protected List<Map<String,String>> wrapFieldErrors(List<FieldError> errors){
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
for(FieldError e:errors){
Map<String,String> error = new HashMap<String,String>();
protected List<Map<String, String>> wrapFieldErrors(List<FieldError> errors) {
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
for (FieldError e : errors) {
Map<String, String> error = new HashMap<String, String>();
error.put("field", e.getField());
error.put("message", e.getDefaultMessage());
list.add(error);
......@@ -124,19 +112,18 @@ public class CustomErrorController extends AbstractErrorController {
return list;
}
protected boolean isJsonRequest(HttpServletRequest request){
String requestUri = (String)request.getAttribute("javax.servlet.error.request_uri");
if(requestUri!=null&&requestUri.endsWith(".json")){
protected boolean isJsonRequest(HttpServletRequest request) {
String requestUri = (String) request.getAttribute("javax.servlet.error.request_uri");
if (requestUri != null && requestUri.endsWith(".json")) {
return true;
}else{
return (request.getHeader("Accept").contains("application/json") || (request.getHeader("X-Requested-With") != null
} else {
return (request.getHeader("Accept").contains("application/json")
|| (request.getHeader("X-Requested-With") != null
&& request.getHeader("X-Requested-With").contains("XMLHttpRequest")));
}
}
protected void writeJson(HttpServletResponse response,JsonResult error){
protected void writeJson(HttpServletResponse response, JsonResult error) {
response.setContentType("application/json;charset=utf-8");
try {
response.getWriter().write(objectMapper.writeValueAsString(error));
......@@ -146,16 +133,15 @@ public class CustomErrorController extends AbstractErrorController {
}
protected String getErrorMessage(Throwable ex) {
if(ex instanceof PlatformException){
if (ex instanceof PlatformException) {
return ex.getMessage();
}else{
} else {
return "服务器错误,请联系管理员";
}
}
protected Throwable getCause(HttpServletRequest request) {
Throwable error = (Throwable)request.getAttribute("javax.servlet.error.exception");
Throwable error = (Throwable) request.getAttribute("javax.servlet.error.exception");
if (error != null) {
while (error instanceof ServletException && error.getCause() != null) {
error = ((ServletException) error).getCause();
......@@ -164,12 +150,9 @@ public class CustomErrorController extends AbstractErrorController {
return error;
}
@Override
public String getErrorPath() {
// TODO Auto-generated method stub
return null;
}
}
......@@ -7,6 +7,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import com.zaxxer.hikari.HikariDataSource;
@Configuration
public class DataSourceConfig {
@Bean(name = "baseDataSource")
......@@ -19,6 +20,3 @@ public class DataSourceConfig {
return ds;
}
}
......@@ -16,19 +16,19 @@ import com.ibeetl.admin.core.file.LocalFileService;
@Configuration
@ConditionalOnMissingBean(FileService.class)
public class FileSystemConfig {
@Autowired
Environment env;
@Autowired Environment env;
@Bean
public FileService getFileService(ApplicationContext ctx) {
String root = env.getProperty("localFile.root");
if(StringUtils.isEmpty(root)) {
if (StringUtils.isEmpty(root)) {
String userDir = System.getProperty("user.dir");
root = userDir+File.separator+"filesystem";
root = userDir + File.separator + "filesystem";
}
File f = new File(root);
if(!f.exists()) {
if (!f.exists()) {
f.mkdirs();
}
return new LocalFileService(ctx,root);
return new LocalFileService(ctx, root);
}
}
......@@ -25,43 +25,40 @@ public class JasonConfig {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
SimpleModule simpleModule = new SimpleModule("SimpleModule",
Version.unknownVersion());
SimpleModule simpleModule = new SimpleModule("SimpleModule", Version.unknownVersion());
simpleModule.addSerializer(JsonResult.class, new CustomJsonResultSerializer());
objectMapper.registerModule(simpleModule);
return objectMapper;
}
/**
* layui 前端要求后台返回的数据格式
* @author xiandafu
*
* @author xiandafu
*/
public static class CustomJsonResultSerializer extends JsonSerializer<JsonResult> {
public CustomJsonResultSerializer() {
}
public CustomJsonResultSerializer() {}
@Override
public void serialize(JsonResult value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
public void serialize(JsonResult value, JsonGenerator gen, SerializerProvider serializers)
throws IOException {
gen.writeStartObject();
if(value.getCode().equals("200")) {
if (value.getCode().equals("200")) {
gen.writeObjectField("code", 0);
}else {
} else {
gen.writeObjectField("code", Integer.parseInt(value.getCode()));
}
gen.writeStringField("msg", value.getMsg());
Object data = value.getData();
if(data instanceof PageQuery ) {
PageQuery query = (PageQuery)(data);
if (data instanceof PageQuery) {
PageQuery query = (PageQuery) (data);
gen.writeObjectField("count", query.getTotalRow());
gen.writeObjectField("data", query.getList());
}else {
} else {
gen.writeObjectField("data", data);
}
gen.writeEndObject();
}
}
}
......@@ -47,12 +47,9 @@ public class MVCConf implements WebMvcConfigurer, InitializingBean {
public static final String DEFAULT_APP_NAME = "开发平台";
/**
* 系统名称,可以在application.properties中配置
* app.name=xxx
*/
// @Value("${app.name}")
// String appName;
/** 系统名称,可以在application.properties中配置 app.name=xxx */
// @Value("${app.name}")
// String appName;
// 开发用的模拟当前用户和机构
Long useId;
......@@ -61,20 +58,15 @@ public class MVCConf implements WebMvcConfigurer, InitializingBean {
String mvcTestPath;
@Autowired
Environment env;
@Autowired Environment env;
@Autowired
CoreUserService userService;
@Autowired CoreUserService userService;
@Autowired
BeetlGroupUtilConfiguration beetlGroupUtilConfiguration;
@Autowired BeetlGroupUtilConfiguration beetlGroupUtilConfiguration;
@Autowired
HttpRequestLocal httpRequestLocal;
@Autowired HttpRequestLocal httpRequestLocal;
@Autowired
GroupTemplate groupTemplate;
@Autowired GroupTemplate groupTemplate;
@Override
public void addInterceptors(InterceptorRegistry registry) {
......@@ -95,7 +87,6 @@ public class MVCConf implements WebMvcConfigurer, InitializingBean {
registry.addFormatter(new DateFormatter("yyyy-MM-dd"));
}
@Override
public void afterPropertiesSet() throws Exception {
this.useId = env.getProperty("user.id", Long.class);
......@@ -103,21 +94,14 @@ public class MVCConf implements WebMvcConfigurer, InitializingBean {
this.mvcTestPath = env.getProperty("mvc.test.path");
Map<String, Object> var = new HashMap<>(5);
String appName = env.getProperty("app.name");
if(appName==null) {
var.put("appName",DEFAULT_APP_NAME);
if (appName == null) {
var.put("appName", DEFAULT_APP_NAME);
}
var.put("jsVer", System.currentTimeMillis());
groupTemplate.setSharedVars(var);
}
}
class SessionInterceptor implements HandlerInterceptor {
......@@ -133,7 +117,8 @@ class SessionInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
if (conf.useId != null && conf.orgId != null
if (conf.useId != null
&& conf.orgId != null
&& request.getSession().getAttribute(CorePlatformService.ACCESS_CURRENT_USER) == null) {
// 模拟用户登录,用于快速开发,未来用rember么代替?
CoreUser user = conf.userService.getUserById(conf.useId);
......@@ -143,22 +128,25 @@ class SessionInterceptor implements HandlerInterceptor {
request.getSession().setAttribute(CorePlatformService.ACCESS_CURRENT_ORG, org);
request.getSession().setAttribute(CorePlatformService.ACCESS_USER_ORGS, orgs);
request.getSession().setAttribute("ip", request.getRemoteHost());
}
httpRequestLocal.set(request);
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
public void postHandle(
HttpServletRequest request,
HttpServletResponse response,
Object handler,
ModelAndView modelAndView)
throws Exception {
// do nothing
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
public void afterCompletion(
HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
throws Exception {
// do nothing
}
}
......@@ -16,12 +16,10 @@ import com.ibeetl.admin.core.conf.PasswordConfig.PasswordEncryptService;
@ConditionalOnMissingBean(PasswordEncryptService.class)
public class PasswordConfig {
public static interface PasswordEncryptService{
public static interface PasswordEncryptService {
public String password(String pwd);
}
public static class DefaultEncryptBean implements PasswordEncryptService {
@Override
......@@ -29,12 +27,10 @@ public class PasswordConfig {
// 采用明文,系统应该提供自己的EncryptBean实现以代替默认
return pwd;
}
}
@Bean
public PasswordEncryptService passwordEncryptBean(){
public PasswordEncryptService passwordEncryptBean() {
return new DefaultEncryptBean();
}
}
......@@ -27,21 +27,19 @@ import com.ibeetl.admin.core.util.PlatformException;
@Aspect
@Component
public class RbacAnnotationConfig {
@Autowired
CorePlatformService platformService;
@Autowired
CoreAuditService sysAuditService;
@Autowired
HttpRequestLocal httpRequestLocal;
@Autowired CorePlatformService platformService;
@Autowired CoreAuditService sysAuditService;
@Autowired HttpRequestLocal httpRequestLocal;
@Autowired
Environment env;
@Autowired Environment env;
ObjectMapper jsonMapper = new ObjectMapper();
private final Log log = LogFactory.getLog(this.getClass());
@org.aspectj.lang.annotation.Around("within(@org.springframework.stereotype.Controller *) && @annotation(function)")
public Object functionAccessCheck(final ProceedingJoinPoint pjp, Function function) throws Throwable {
@org.aspectj.lang.annotation.Around(
"within(@org.springframework.stereotype.Controller *) && @annotation(function)")
public Object functionAccessCheck(final ProceedingJoinPoint pjp, Function function)
throws Throwable {
// debug
String funCode = null;
CoreUser user = null;
......@@ -62,32 +60,37 @@ public class RbacAnnotationConfig {
Object o = pjp.proceed();
if (function != null) {
MethodSignature ms = (MethodSignature)pjp.getSignature();
MethodSignature ms = (MethodSignature) pjp.getSignature();
m = ms.getMethod();
createAudit(funCode,function.name(), user, true, "",m);
createAudit(funCode, function.name(), user, true, "", m);
}
return o;
} catch (Throwable e) {
if (function != null) {
createAudit(funCode, function.name(),user, false, e.getMessage(),m);
createAudit(funCode, function.name(), user, false, e.getMessage(), m);
}
throw e;
}
}
private void createAudit(String functionCode, String functionName,CoreUser user, boolean success, String msg, Method m) {
private void createAudit(
String functionCode,
String functionName,
CoreUser user,
boolean success,
String msg,
Method m) {
boolean enable = env.getProperty("audit.enable", Boolean.class, false);
if (!enable) {
return;
}
if(filter(m,functionCode)){
return ;
if (filter(m, functionCode)) {
return;
}
CoreAudit audit = new CoreAudit();
if(StringUtils.isEmpty(functionName)) {
if (StringUtils.isEmpty(functionName)) {
CoreFunction fun = this.platformService.getFunction(functionCode);
if (fun == null) {
......@@ -110,17 +113,16 @@ public class RbacAnnotationConfig {
sysAuditService.save(audit);
}
private boolean filter(Method m,String functionCode){
if(functionCode.startsWith("audit.")){
private boolean filter(Method m, String functionCode) {
if (functionCode.startsWith("audit.")) {
return true;
}
String uri = httpRequestLocal.getRequestURI();
if(uri!=null&&uri.endsWith("/index/condition.json")){
if (uri != null && uri.endsWith("/index/condition.json")) {
return true ;
}else{
return true;
} else {
return false;
}
}
}
......@@ -8,9 +8,7 @@ import org.springframework.context.annotation.Configuration;
import com.ibeetl.admin.core.rbac.DataAccessFactory;
import com.ibeetl.admin.core.rbac.da.DefaultDataAccessFactory;
/**
* 数据权限,可以自动装配
*/
/** 数据权限,可以自动装配 */
@Configuration
public class RbacDataAccessConfig {
@ConditionalOnMissingBean(DataAccessFactory.class)
......
......@@ -6,10 +6,8 @@ import org.beetl.sql.core.mapper.BaseMapper;
import com.ibeetl.admin.core.entity.CoreAudit;
/*
*
* gen by starter mapper 2017-08-01
*/
*
* gen by starter mapper 2017-08-01
*/
@SqlResource("core.coreAudit")
public interface CoreAuditDao extends BaseMapper<CoreAudit> {
}
\ No newline at end of file
public interface CoreAuditDao extends BaseMapper<CoreAudit> {}
......@@ -9,14 +9,13 @@ import org.beetl.sql.core.mapper.BaseMapper;
import com.ibeetl.admin.core.entity.CoreDict;
/**
* 字典DAO接口
*/
/** 字典DAO接口 */
@SqlResource("core.coreDict")
public interface CoreDictDao extends BaseMapper<CoreDict> {
/**
* 查询某个类型下的字典集合
*
* @param type 字典类型
* @return
*/
......@@ -24,16 +23,16 @@ public interface CoreDictDao extends BaseMapper<CoreDict> {
/**
* 查询字段类型列表
*
* @param delFlag 删除标记
* @return
*/
@SqlStatement(returnType = Map.class)
List<Map<String, String>> findTypeList(int delFlag);
/**
* 根据父节点Id查询子节点数据
*
* @param id 父节点id
* @return
*/
......
......@@ -7,5 +7,5 @@ import com.ibeetl.admin.core.entity.CoreFile;
public interface CoreFileDao extends BaseMapper<CoreFile> {
@Sql("update core_file set biz_type=?,biz_id=? where file_batch_id=?")
public void updateBatchIdInfo( String bizType, String bizId,String fileBatchId);
public void updateBatchIdInfo(String bizType, String bizId, String fileBatchId);
}
......@@ -15,9 +15,7 @@ public interface CoreMenuDao extends BaseMapper<CoreMenu> {
public void queryByCondtion(PageQuery query);
public void clearMenuFunction( List<Long> functionIds);
public void clearMenuFunction(List<Long> functionIds);
public List<CoreMenu> allMenuWithURL();
}
Supports Markdown
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