Commit 77d5b908 authored by tianbo's avatar tianbo

metahandler修改

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