修改联系人查询条件为模糊查询,添加工具类service
This commit is contained in:
parent
bd4881839b
commit
f475227d5b
@ -22,7 +22,7 @@ public interface InspectOrgMapper extends BaseMapperX<InspectOrgDO> {
|
||||
.likeIfPresent(InspectOrgDO::getOrgName, reqVO.getOrgName())
|
||||
.eqIfPresent(InspectOrgDO::getAddress, reqVO.getAddress())
|
||||
.eqIfPresent(InspectOrgDO::getContactTel, reqVO.getContactTel())
|
||||
.eqIfPresent(InspectOrgDO::getContactPerson, reqVO.getContactPerson())
|
||||
.likeIfPresent(InspectOrgDO::getContactPerson, reqVO.getContactPerson())
|
||||
.likeIfPresent(InspectOrgDO::getReportName, reqVO.getReportName())
|
||||
.eqIfPresent(InspectOrgDO::getHighLevelOrgID, reqVO.getHighLevelOrgID())
|
||||
.likeIfPresent(InspectOrgDO::getHighLevelOrgName, reqVO.getHighLevelOrgName())
|
||||
|
@ -0,0 +1,10 @@
|
||||
package cn.iocoder.yudao.module.inspect.service.common;
|
||||
|
||||
public interface ObjectCommonService<T> {
|
||||
/**
|
||||
* 处理对象中所有string类型的属性,去除头尾空白字符
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
T trimAllStringFiledFormObj(T obj);
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cn.iocoder.yudao.module.inspect.service.common;
|
||||
|
||||
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectorg.InspectOrgDO;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
@Service
|
||||
public class ObjectCommonServiceImpl implements ObjectCommonService<InspectOrgDO>{
|
||||
@Override
|
||||
public InspectOrgDO trimAllStringFiledFormObj(InspectOrgDO obj) {
|
||||
if (obj == null) return null;
|
||||
|
||||
Class<?> clazz = obj.getClass();
|
||||
// 递归处理继承链上的所有类
|
||||
while (clazz != null && clazz != Object.class) {
|
||||
processFields(obj, clazz.getDeclaredFields());
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
private void processFields(Object obj, Field[] fields) {
|
||||
for (Field field : fields) {
|
||||
// 跳过静态/最终字段和非String类型
|
||||
if (Modifier.isStatic(field.getModifiers()) ||
|
||||
Modifier.isFinal(field.getModifiers()) ||
|
||||
field.getType() != String.class) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
String value = (String) ReflectionUtils.getField(field, obj);
|
||||
if (value != null) {
|
||||
ReflectionUtils.setField(field, obj, value.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user