Commit 77d5b908 authored by tianbo's avatar tianbo

metahandler修改

parent 1b48627c
......@@ -70,12 +70,14 @@ public class PermissionInterceptor implements Interceptor {
}
// 接口地址为空返回空数据
if (ValidationUtil.isEmpty(dataAuth.interfacePath())) {
// method.getReturnType().isPrimitive() = true 是count语句
return method.getReturnType().isPrimitive() ? invocation.proceed() : null;
}
ReginParams reginParam = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId()
, RequestContext.getToken())).toString(), ReginParams.class);
if (ValidationUtil.isEmpty(reginParam) || ValidationUtil.isEmpty(reginParam.getUserModel())) {
// method.getReturnType().isPrimitive() = true 是count语句
return method.getReturnType().isPrimitive() ? invocation.proceed() : null;
}
// 用户数据权限配置信息
......@@ -88,6 +90,7 @@ public class PermissionInterceptor implements Interceptor {
BoundSql boundSql = (BoundSql) metaObject.getValue("delegate.boundSql");
String sql = boundSql.getSql();
// 将权限规则拼接到原始sql
sql = processSelectSql(sql, dataAuthorization, reginParam, boundSql);
metaObject.setValue("delegate.boundSql.sql", sql);
return invocation.proceed();
......
......@@ -15,7 +15,6 @@ import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.Date;
import java.util.Map;
/**
* @author Dell
......@@ -41,7 +40,6 @@ public class MetaHandler implements MetaObjectHandler {
*/
@Override
public void insertFill(MetaObject metaObject) {
// autoFillUser(metaObject, metaObject.getOriginalObject());
Date currentDate = new Date();
Class clazz = metaObject.getOriginalObject().getClass();
FillCommonUserField annotation = (FillCommonUserField) clazz.getAnnotation(FillCommonUserField.class);
......@@ -50,11 +48,10 @@ public class MetaHandler implements MetaObjectHandler {
}
//如果有上传创建时间,不需要修改
// if(metaObject.getValue("createDate")==null){
// this.setFieldValByName("createDate", currentDate, metaObject);
// }
this.setFieldValByName("createDate", currentDate, metaObject);
}
private void autoFillUser(MetaObject metaObject, Object entity) {
//获取用户信息 以及当前用户登录公司部门,角色
String userId = RequestContext.getExeUserId();
......@@ -69,16 +66,10 @@ public class MetaHandler implements MetaObjectHandler {
if (ObjectUtils.isEmpty(reginParams) || ObjectUtils.isEmpty(agencyUserModel)) {
return;
}
if (isExistField("recUserId", entity)) {
this.setFieldValByName("recUserId", agencyUserModel.getUserId(), metaObject);
}
if (isExistField("recUserName", entity)) {
this.setFieldValByName("recUserName", agencyUserModel.getRealName(), metaObject);
}
if (isExistField("recDate", entity)) {
Date currentDate = new Date();
this.setFieldValByName("recDate", currentDate, metaObject);
}
// 更新rec字段
recInfoUpdate(metaObject, agencyUserModel);
if (isExistField("allotmentTime", entity)) {
Date currentDate = new Date();
this.setFieldValByName("recDate", currentDate, metaObject);
......@@ -105,13 +96,14 @@ public class MetaHandler implements MetaObjectHandler {
if (isExistField("departmentOrgcode", entity)) {
this.setFieldValByName("departmentOrgcode", ObjectUtils.isEmpty(reginParams.getDepartment()) ? "" : reginParams.getDepartment().getOrgCode(), metaObject);
}
// if (isExistField("updateTime", entity)) {
// Date currentDate = new Date();
// this.setFieldValByName("updateTime", currentDate, metaObject);
// }
// if (isExistField("companyName", entity)) {
// this.setFieldValByName("companyName", reginParams.getDepartment().getDepartmentName(), metaObject);
// }
}
private void recInfoUpdate(MetaObject metaObject, AgencyUserModel agencyUserModel) {
this.setFieldValByName("recUserId", agencyUserModel.getUserId(), metaObject);
this.setFieldValByName("recUserName", agencyUserModel.getRealName(), metaObject);
Date currentDate = new Date();
this.setFieldValByName("recDate", currentDate, metaObject);
this.setFieldValByName("updateTime", currentDate, metaObject);
}
private Boolean isExistField(String field, Object obj) {
......@@ -133,15 +125,15 @@ public class MetaHandler implements MetaObjectHandler {
*/
@Override
public void updateFill(MetaObject metaObject) {
//todo tianbo 逻辑
Class clazz = metaObject.getOriginalObject().getClass();
FillCommonUserField annotation = (FillCommonUserField) clazz.getAnnotation(FillCommonUserField.class);
if (annotation == null || annotation.isAutoFill()) {
Object updateEntity = ((Map) metaObject.getOriginalObject()).get("et");
autoFillUser(metaObject, updateEntity);
String userId = RequestContext.getExeUserId();
ReginParams reginParams =
JSONObject.parseObject(null != redisUtils.get(RedisKey.buildReginKey(userId, getToken())) ?
redisUtils.get(RedisKey.buildReginKey(userId, getToken())).toString() : null, ReginParams.class);
if (ObjectUtils.isEmpty(reginParams)) {
return;
}
// 正常只需要更新如下
Date currentDate = new Date();
this.setFieldValByName("updateTime", currentDate, metaObject);
AgencyUserModel agencyUserModel = reginParams.getUserModel();
recInfoUpdate(metaObject, agencyUserModel);
}
}
\ No newline at end of file
/*
package com.yeejoin.amos.supervision.feign;
import feign.codec.Encoder;
......@@ -10,11 +11,13 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.RequestContextListener;
*/
/**
* @Author: xinglei
* @Description:
* @Date: 2020/3/30 16:26
*/
*//*
@Configuration
public class MultipartSupportConfig {
......@@ -26,12 +29,15 @@ public class MultipartSupportConfig {
return new SpringFormEncoder(new SpringEncoder(messageConverters));
}
/**
*/
/**
* 创建Feign请求拦截器,在发送请求前设置认证的token,各个微服务将token设置到环境变量中来达到通用
* @return
*/
*//*
@Bean
public RequestContextListener requestInterceptor() {
return new RequestContextListener();
}
}
*/
package com.yeejoin.amos.supervision.feign;
import com.yeejoin.amos.boot.biz.common.feign.MultipartSupportConfig;
import com.yeejoin.amos.supervision.business.param.PushMsgParam;
import com.yeejoin.amos.supervision.business.util.CommonResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.yeejoin.amos.supervision.business.param.PushMsgParam;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.cloud.openfeign.FeignClient;
......
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