Commit 848c5ade authored by tangwei's avatar tangwei

自动填充

parent cbb9f187
//package com.yeejoin.amos.boot.biz.config;
//
//import org.apache.commons.lang3.StringUtils;
//import org.apache.ibatis.reflection.MetaObject;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.util.ObjectUtils;
//import java.util.Date;
//import java.util.Map;
//import javax.servlet.http.HttpServletRequest;
//import com.alibaba.fastjson.JSONObject;
//import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
//import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
//import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
//import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
//
//
//@Component
//public class MetaHandler implements MetaObjectHandler {
//
// @Autowired
// protected HttpServletRequest request;
// @Autowired
// private RedisUtils redisUtils;
//
// protected String getToken() {
// String authToken = request.getHeader("token");
// if (authToken == null) {
// authToken = request.getHeader("X-Access-Token");
// }
// return authToken;
// }
// protected String buildKey(String token) {
// //由于用户id 不是接口携带参数,为了避免,公共字段填充时频繁访问平台,缓存用户信息时,
// return "region_" + token;
//
// }
// /**
// * 新增数据拦截
// *
// * @param metaObject
// */
// @Override
// public void insertFill(MetaObject metaObject) {
// autoFillUser(metaObject);
// }
//
// private void autoFillUser(MetaObject metaObject) {
// //获取用户信息 以及当前用户登录公司部门,角色
// ReginParams reginParams=JSONObject.parseObject(redisUtils.get(buildKey( getToken())).toString(), ReginParams.class);
// AgencyUserModel agencyUserModel=JSONObject.parseObject(redisUtils.get( getToken()).toString(), AgencyUserModel.class);
//
// if(ObjectUtils.isEmpty(reginParams)||ObjectUtils.isEmpty(agencyUserModel)){
// return;
// }
// Object entity = metaObject.getOriginalObject();
// if (isExistField("recUserId", entity)) {
// this.setFieldValByName("recUserId", Long.valueOf(agencyUserModel.getUserId()), metaObject);
// }
//
// if (isExistField("recUserName", entity)) {
// this.setFieldValByName("recUserName", agencyUserModel.getUserName(), metaObject);
// }
// if (isExistField("recDate", entity)) {
// Date currentDate = new Date();
// this.setFieldValByName("recDate", currentDate, metaObject);
// }
//// if (isExistField("companyCode", entity)) {
//// this.setFieldValByName("companyCode", reginParams.getDepartment().getOrgCode(), metaObject);
//// }
//// if (isExistField("companyName", entity)) {
//// this.setFieldValByName("companyName", reginParams.getDepartment().getDepartmentName(), metaObject);
//// }
//
//
// }
//
// private Boolean isExistField(String field, Object obj) {
// if (obj == null || StringUtils.isEmpty(field)) {
// return null;
// }
// Object o = JSONObject.toJSON(obj);
// JSONObject jsonObj = new JSONObject();
// if (o instanceof JSONObject) {
// jsonObj = (JSONObject) o;
// }
// return jsonObj.containsKey(field);
// }
//
// /**
// * 更新拦截
// *
// * @param metaObject
// */
// @Override
// public void updateFill(MetaObject metaObject) {
// Date currentDate = new Date();
// this.setFieldValByName("updateTime", currentDate, metaObject);
// }
//}
\ No newline at end of file
//package com.yeejoin.amos.boot.biz.config;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
//import com.baomidou.mybatisplus.core.MybatisConfiguration;
//import com.baomidou.mybatisplus.core.config.GlobalConfig;
//import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
///**
// *
// *
// **/
//@Configuration
//public class MyBatisPlusConfig {
// /**
// * 自动填充功能
// * @return
// */
// @Bean
// public GlobalConfig globalConfig() {
// GlobalConfig globalConfig = new GlobalConfig();
// globalConfig.setMetaObjectHandler(new MetaHandler());
// return globalConfig;
// }
//}
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