Commit 367d5863 authored by tangwei's avatar tangwei

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

parents 9597e8c9 4cde68d2
package com.yeejoin.amos.boot.biz.config;
import java.util.Date;
import java.util.Map;
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 org.typroject.tyboot.core.foundation.context.RequestContext;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.yeejoin.amos.boot.biz.common.annotation.FillCommonUserField;
......@@ -17,6 +7,15 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
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 org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.Date;
import java.util.Map;
/**
* @author Dell
......@@ -46,15 +45,16 @@ public class MetaHandler implements MetaObjectHandler {
Date currentDate = new Date();
Class clazz = metaObject.getOriginalObject().getClass();
FillCommonUserField annotation = (FillCommonUserField) clazz.getAnnotation(FillCommonUserField.class);
if(annotation == null || annotation.isAutoFill()){
autoFillUser(metaObject,metaObject.getOriginalObject());
if (annotation == null || annotation.isAutoFill()) {
autoFillUser(metaObject, metaObject.getOriginalObject());
}
//如果有上传创建时间,不需要修改
if(metaObject.getValue("createDate")==null){
this.setFieldValByName("createDate", currentDate, metaObject);
}
// if(metaObject.getValue("createDate")==null){
// this.setFieldValByName("createDate", currentDate, metaObject);
// }
}
private void autoFillUser(MetaObject metaObject, Object entity) {
//获取用户信息 以及当前用户登录公司部门,角色
String userId = RequestContext.getExeUserId();
......@@ -100,10 +100,10 @@ public class MetaHandler implements MetaObjectHandler {
this.setFieldValByName("orgCode", reginParams.getCompany().getOrgCode(), metaObject);
}
if (isExistField("departmentName", entity)) {
this.setFieldValByName("departmentName", ObjectUtils.isEmpty(reginParams.getDepartment())?"":reginParams.getDepartment().getDepartmentName(), metaObject);
this.setFieldValByName("departmentName", ObjectUtils.isEmpty(reginParams.getDepartment()) ? "" : reginParams.getDepartment().getDepartmentName(), metaObject);
}
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();
......@@ -133,9 +133,17 @@ public class MetaHandler implements MetaObjectHandler {
*/
@Override
public void updateFill(MetaObject metaObject) {
// DOTO 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);
}
// 正常只需要更新如下
Date currentDate = new Date();
if (isExistField("updateTime", metaObject.getOriginalObject())) {
this.setFieldValByName("updateTime", currentDate, metaObject);
}
}
}
\ No newline at end of file
......@@ -14,6 +14,8 @@
where
rs.parent_mrid > 0
and rs.station_code = #{stationCode}
ORDER BY
rs.rpni DESC, rs.rpn DESC
<if test="top != null and top !=''">
limit ${top}
</if>
......
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