|
|
|
@ -1,445 +0,0 @@
|
|
|
|
|
package com.docus.server.common;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
|
|
import com.baomidou.mybatisplus.annotation.TableId;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.enums.SqlMethod;
|
|
|
|
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.GlobalConfigUtils;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
|
|
|
|
import com.docus.infrastructure.core.db.Sort;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import org.apache.ibatis.binding.MapperMethod;
|
|
|
|
|
import org.apache.ibatis.logging.Log;
|
|
|
|
|
import org.apache.ibatis.logging.LogFactory;
|
|
|
|
|
import org.apache.ibatis.session.SqlSession;
|
|
|
|
|
import org.mybatis.spring.SqlSessionUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.function.BiConsumer;
|
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
public class BaseDaoImpl<M extends BaseMapper<T>, T> implements IDao<T> {
|
|
|
|
|
protected Log log = LogFactory.getLog(getClass());
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
protected M baseMapper;
|
|
|
|
|
|
|
|
|
|
public M getBaseMapper() {
|
|
|
|
|
return baseMapper;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Class<T> entityClass = currentModelClass();
|
|
|
|
|
|
|
|
|
|
public Class<T> getEntityClass() {
|
|
|
|
|
return entityClass;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Class<T> mapperClass = currentMapperClass();
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public T findById(Serializable id) {
|
|
|
|
|
if (id == null) {
|
|
|
|
|
throw new RuntimeException("param id is required");
|
|
|
|
|
}
|
|
|
|
|
return baseMapper.selectById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<T> findByIds(Collection<Serializable> ids) {
|
|
|
|
|
if (ids == null || ids.size() == 0) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
return baseMapper.selectBatchIds(ids);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 按字段查询,返回所有匹配的记录, eq
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<T> findBy(String propertyName, Object propertyValue) {
|
|
|
|
|
String columnName = getColumnName(propertyName);
|
|
|
|
|
return baseMapper.selectList(new QueryWrapper<T>().eq(columnName, propertyValue));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 按字段查询,返回所有匹配的记录, in
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<T> findByList(String propertyName, Collection<?> propertyValue) {
|
|
|
|
|
String columnName = getColumnName(propertyName);
|
|
|
|
|
return baseMapper.selectList(new QueryWrapper<T>().in(!Objects.isNull(propertyValue), columnName, propertyValue));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<T> findActiveBy(String propertyName, Object propertyValue) {
|
|
|
|
|
String columnName = getColumnName(propertyName);
|
|
|
|
|
QueryWrapper<T> queryWrapper = new QueryWrapper<T>().eq(columnName, propertyValue);
|
|
|
|
|
queryWrapper.ne("state", 1);
|
|
|
|
|
return baseMapper.selectList(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//返回所有匹配的记录并排序
|
|
|
|
|
@Override
|
|
|
|
|
public List<T> findBy(String propertyName, Object propertyValue, Sort sort) {
|
|
|
|
|
String columnName = getColumnName(propertyName);
|
|
|
|
|
QueryWrapper<T> query = new QueryWrapper<T>().eq(columnName, propertyValue);
|
|
|
|
|
buildSort(sort, query);
|
|
|
|
|
return baseMapper.selectList(query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 返回所有匹配的Active记录并排序
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<T> findActiveBy(String propertyName, Object propertyValue, Sort sort) {
|
|
|
|
|
String columnName = getColumnName(propertyName);
|
|
|
|
|
QueryWrapper<T> query = new QueryWrapper<T>().eq(columnName, propertyValue);
|
|
|
|
|
query.ne("state", 1);
|
|
|
|
|
buildSort(sort, query);
|
|
|
|
|
return baseMapper.selectList(query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public T findOneBy(String propertyName, Object propertyValue) {
|
|
|
|
|
String columnName = getColumnName(propertyName);
|
|
|
|
|
PageHelper.startPage(1, 1);
|
|
|
|
|
List<T> list = baseMapper.selectList(new QueryWrapper<T>().eq(columnName, propertyValue));
|
|
|
|
|
return (list == null || list.size() == 0) ? null : list.get(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public T findOneByList(String propertyName, Collection<?> propertyValue) {
|
|
|
|
|
String columnName = getColumnName(propertyName);
|
|
|
|
|
List<T> list = baseMapper.selectList(new QueryWrapper<T>().eq(!Objects.isNull(propertyValue), columnName, propertyValue));
|
|
|
|
|
return (list == null || list.size() == 0) ? null : list.get(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//按字段查询,返回第一条Active 记录
|
|
|
|
|
@Override
|
|
|
|
|
public T findActiveOneBy(String propertyName, Object propertyValue) {
|
|
|
|
|
String columnName = getColumnName(propertyName);
|
|
|
|
|
PageHelper.startPage(1, 1);
|
|
|
|
|
QueryWrapper<T> queryWrapper = new QueryWrapper<T>().eq(columnName, propertyValue);
|
|
|
|
|
queryWrapper.ne("state", 1);
|
|
|
|
|
List<T> list = baseMapper.selectList(queryWrapper);
|
|
|
|
|
return (list == null || list.size() == 0) ? null : list.get(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*Lambda方式自由组合查询条件*/
|
|
|
|
|
public List<T> find(LambdaQueryWrapper<T> queryWrapper) {
|
|
|
|
|
return baseMapper.selectList(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*Lambda方式自由组合查询条件,返回第一条记录*/
|
|
|
|
|
public T findOne(LambdaQueryWrapper<T> queryWrapper) {
|
|
|
|
|
PageHelper.startPage(1, 1);
|
|
|
|
|
List<T> list = baseMapper.selectList(queryWrapper);
|
|
|
|
|
return (list == null || list.size() == 0) ? null : list.get(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//返回表所有记录
|
|
|
|
|
@Override
|
|
|
|
|
public List<T> findAll() {
|
|
|
|
|
return baseMapper.selectList(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//返回表所有Active的记录
|
|
|
|
|
@Override
|
|
|
|
|
public List<T> findAllActive() {
|
|
|
|
|
return baseMapper.selectList(Wrappers.<T>query().ne("state", 1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//返回表所有记录并排序
|
|
|
|
|
@Override
|
|
|
|
|
public List<T> findAll(Sort sort) {
|
|
|
|
|
QueryWrapper<T> query = new QueryWrapper<T>();
|
|
|
|
|
buildSort(sort, query);
|
|
|
|
|
return baseMapper.selectList(query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//返回表所有Active记录并排序
|
|
|
|
|
@Override
|
|
|
|
|
public List<T> findAllActive(Sort sort) {
|
|
|
|
|
QueryWrapper<T> query = new QueryWrapper<T>();
|
|
|
|
|
query.ne("state", 1);
|
|
|
|
|
buildSort(sort, query);
|
|
|
|
|
return baseMapper.selectList(query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//组装排序语句
|
|
|
|
|
private void buildSort(Sort sort, QueryWrapper<T> query) {
|
|
|
|
|
if (sort != null) {
|
|
|
|
|
List<Sort.SortItem> sortList = sort.getSortList();
|
|
|
|
|
|
|
|
|
|
for (Sort.SortItem sortItem : sortList) {
|
|
|
|
|
if (sortItem.getDirection() == Sort.Direction.ASC) {
|
|
|
|
|
query.orderByAsc(getColumnName(sortItem.getProperty()));
|
|
|
|
|
} else {
|
|
|
|
|
query.orderByDesc(getColumnName(sortItem.getProperty()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteByIdList(List<Serializable> idList) {
|
|
|
|
|
if (idList == null || idList.size() == 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return baseMapper.deleteBatchIds(idList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断数据库操作是否成功
|
|
|
|
|
*
|
|
|
|
|
* @param result 数据库操作返回影响条数
|
|
|
|
|
* @return boolean
|
|
|
|
|
* @deprecated 3.3.1
|
|
|
|
|
*/
|
|
|
|
|
@Deprecated
|
|
|
|
|
protected boolean retBool(Integer result) {
|
|
|
|
|
return SqlHelper.retBool(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
protected Class<T> currentMapperClass() {
|
|
|
|
|
return (Class<T>) ReflectionKit.getSuperClassGenericType(getClass(), 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
protected Class<T> currentModelClass() {
|
|
|
|
|
return (Class<T>) ReflectionKit.getSuperClassGenericType(getClass(), 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量操作 SqlSession
|
|
|
|
|
*
|
|
|
|
|
* @deprecated 3.3.0
|
|
|
|
|
*/
|
|
|
|
|
@Deprecated
|
|
|
|
|
protected SqlSession sqlSessionBatch() {
|
|
|
|
|
return SqlHelper.sqlSessionBatch(entityClass);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 释放sqlSession
|
|
|
|
|
*
|
|
|
|
|
* @param sqlSession session
|
|
|
|
|
* @deprecated 3.3.0
|
|
|
|
|
*/
|
|
|
|
|
@Deprecated
|
|
|
|
|
protected void closeSqlSession(SqlSession sqlSession) {
|
|
|
|
|
SqlSessionUtils.closeSqlSession(sqlSession, GlobalConfigUtils.currentSessionFactory(entityClass));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取 SqlStatement
|
|
|
|
|
*
|
|
|
|
|
* @param sqlMethod ignore
|
|
|
|
|
* @return ignore
|
|
|
|
|
* @see #getSqlStatement(SqlMethod)
|
|
|
|
|
* @deprecated 3.4.0
|
|
|
|
|
*/
|
|
|
|
|
@Deprecated
|
|
|
|
|
protected String sqlStatement(SqlMethod sqlMethod) {
|
|
|
|
|
return SqlHelper.table(entityClass).getSqlStatement(sqlMethod.getMethod());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量插入
|
|
|
|
|
*
|
|
|
|
|
* @param entityList ignore
|
|
|
|
|
* @param batchSize ignore
|
|
|
|
|
* @return ignore
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public boolean saveBatch(Collection<T> entityList, int batchSize) {
|
|
|
|
|
String sqlStatement = getSqlStatement(SqlMethod.INSERT_ONE);
|
|
|
|
|
return executeBatch(entityList, batchSize, (sqlSession, entity) -> sqlSession.insert(sqlStatement, entity));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取mapperStatementId
|
|
|
|
|
*
|
|
|
|
|
* @param sqlMethod 方法名
|
|
|
|
|
* @return 命名id
|
|
|
|
|
* @since 3.4.0
|
|
|
|
|
*/
|
|
|
|
|
protected String getSqlStatement(SqlMethod sqlMethod) {
|
|
|
|
|
return SqlHelper.getSqlStatement(mapperClass, sqlMethod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TableId 注解存在更新记录,否插入一条记录
|
|
|
|
|
*
|
|
|
|
|
* @param entity 实体对象
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public boolean saveOrUpdate(T entity) {
|
|
|
|
|
if (null != entity) {
|
|
|
|
|
TableInfo tableInfo = TableInfoHelper.getTableInfo(this.entityClass);
|
|
|
|
|
Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!");
|
|
|
|
|
String keyProperty = tableInfo.getKeyProperty();
|
|
|
|
|
Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!");
|
|
|
|
|
Object idVal = ReflectionKit.getFieldValue(entity, tableInfo.getKeyProperty());
|
|
|
|
|
return StringUtils.checkValNull(idVal) || Objects.isNull(getById((Serializable) idVal)) ? save(entity) : updateById(entity);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据 ID 查询
|
|
|
|
|
*
|
|
|
|
|
* @param id 主键ID
|
|
|
|
|
*/
|
|
|
|
|
public T getById(Serializable id) {
|
|
|
|
|
return getBaseMapper().selectById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据 ID 选择修改
|
|
|
|
|
*
|
|
|
|
|
* @param entity 实体对象
|
|
|
|
|
*/
|
|
|
|
|
public boolean updateById(T entity) {
|
|
|
|
|
return SqlHelper.retBool(getBaseMapper().updateById(entity));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 插入一条记录(选择字段,策略插入)
|
|
|
|
|
*
|
|
|
|
|
* @param entity 实体对象
|
|
|
|
|
*/
|
|
|
|
|
public boolean save(T entity) {
|
|
|
|
|
return SqlHelper.retBool(getBaseMapper().insert(entity));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize) {
|
|
|
|
|
TableInfo tableInfo = TableInfoHelper.getTableInfo(entityClass);
|
|
|
|
|
Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!");
|
|
|
|
|
String keyProperty = tableInfo.getKeyProperty();
|
|
|
|
|
Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!");
|
|
|
|
|
return SqlHelper.saveOrUpdateBatch(this.entityClass, this.mapperClass, this.log, entityList, batchSize, (sqlSession, entity) -> {
|
|
|
|
|
Object idVal = ReflectionKit.getFieldValue(entity, keyProperty);
|
|
|
|
|
return StringUtils.checkValNull(idVal)
|
|
|
|
|
|| CollectionUtils.isEmpty(sqlSession.selectList(getSqlStatement(SqlMethod.SELECT_BY_ID), entity));
|
|
|
|
|
}, (sqlSession, entity) -> {
|
|
|
|
|
MapperMethod.ParamMap<T> param = new MapperMethod.ParamMap<>();
|
|
|
|
|
param.put(Constants.ENTITY, entity);
|
|
|
|
|
sqlSession.update(getSqlStatement(SqlMethod.UPDATE_BY_ID), param);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean updateBatchById(Collection<T> entityList, int batchSize) {
|
|
|
|
|
String sqlStatement = getSqlStatement(SqlMethod.UPDATE_BY_ID);
|
|
|
|
|
return executeBatch(entityList, batchSize, (sqlSession, entity) -> {
|
|
|
|
|
MapperMethod.ParamMap<T> param = new MapperMethod.ParamMap<>();
|
|
|
|
|
param.put(Constants.ENTITY, entity);
|
|
|
|
|
sqlSession.update(sqlStatement, param);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T getOne(Wrapper<T> queryWrapper, boolean throwEx) {
|
|
|
|
|
if (throwEx) {
|
|
|
|
|
return baseMapper.selectOne(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
return SqlHelper.getObject(log, baseMapper.selectList(queryWrapper));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, Object> getMap(Wrapper<T> queryWrapper) {
|
|
|
|
|
return SqlHelper.getObject(log, baseMapper.selectMaps(queryWrapper));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public <V> V getObj(Wrapper<T> queryWrapper, Function<? super Object, V> mapper) {
|
|
|
|
|
return SqlHelper.getObject(log, listObjs(queryWrapper, mapper));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private <V> List<V> listObjs(Wrapper<T> queryWrapper, Function<? super Object, V> mapper) {
|
|
|
|
|
return getBaseMapper().selectObjs(queryWrapper).stream().filter(Objects::nonNull).map(mapper).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 执行批量操作
|
|
|
|
|
*
|
|
|
|
|
* @param consumer consumer
|
|
|
|
|
* @since 3.3.0
|
|
|
|
|
* @deprecated 3.3.1 后面我打算移除掉 {@link #executeBatch(Collection, int, BiConsumer)} }.
|
|
|
|
|
*/
|
|
|
|
|
@Deprecated
|
|
|
|
|
protected boolean executeBatch(Consumer<SqlSession> consumer) {
|
|
|
|
|
return SqlHelper.executeBatch(this.entityClass, this.log, consumer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 执行批量操作
|
|
|
|
|
*
|
|
|
|
|
* @param list 数据集合
|
|
|
|
|
* @param batchSize 批量大小
|
|
|
|
|
* @param consumer 执行方法
|
|
|
|
|
* @param <E> 泛型
|
|
|
|
|
* @return 操作结果
|
|
|
|
|
* @since 3.3.1
|
|
|
|
|
*/
|
|
|
|
|
protected <E> boolean executeBatch(Collection<E> list, int batchSize, BiConsumer<SqlSession, E> consumer) {
|
|
|
|
|
return SqlHelper.executeBatch(this.entityClass, this.log, list, batchSize, consumer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 执行批量操作(默认批次提交数量{@link IService#DEFAULT_BATCH_SIZE})
|
|
|
|
|
*
|
|
|
|
|
* @param list 数据集合
|
|
|
|
|
* @param consumer 执行方法
|
|
|
|
|
* @param <E> 泛型
|
|
|
|
|
* @return 操作结果
|
|
|
|
|
* @since 3.3.1
|
|
|
|
|
*/
|
|
|
|
|
protected <E> boolean executeBatch(Collection<E> list, BiConsumer<SqlSession, E> consumer) {
|
|
|
|
|
return executeBatch(list, DEFAULT_BATCH_SIZE, consumer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//通过实体属性获取对应的数据库字段名
|
|
|
|
|
public String getColumnName(String propertyName) {
|
|
|
|
|
Map<String, Field> fieldMap = ReflectionKit.getFieldMap(getEntityClass());
|
|
|
|
|
if (fieldMap != null) {
|
|
|
|
|
Field field = fieldMap.get(propertyName);
|
|
|
|
|
|
|
|
|
|
if (field != null) {
|
|
|
|
|
TableField annotation = field.getAnnotation(TableField.class);
|
|
|
|
|
if (annotation != null) {
|
|
|
|
|
return annotation.value();
|
|
|
|
|
}
|
|
|
|
|
TableId idAnnotation = field.getAnnotation(TableId.class);
|
|
|
|
|
if (idAnnotation != null) {
|
|
|
|
|
return idAnnotation.value();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw new RuntimeException("获取不到属性" + propertyName + "的列名");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|