| Constructor and Description |
|---|
BaseService(Mapper<T> mapper) |
| Modifier and Type | Method and Description |
|---|---|
int[] |
batchInsertTable(String tableName,
List<String> columns,
List<Object[]> datas,
boolean ignoreConflict)
保存单表多项数据
|
long |
count(T model) |
long |
countByCondition(tk.mybatis.mapper.entity.Condition condition) |
int |
deleteByCondition(tk.mybatis.mapper.entity.Condition condition) |
int |
deleteByIds(List<PK> ids) |
int |
deleteByPrimaryKey(PK id) |
void |
executeSql(String sql) |
boolean |
existsWithPrimaryKey(PK key) |
org.springframework.jdbc.core.JdbcTemplate |
getJdbcTemplate() |
int |
insert(T model) |
int |
insertList(List<T> models)
批量插入
|
int |
insertListIgnoreConflict(List<T> models)
批量插入忽略冲突
|
int |
insertSelective(T model) |
int |
insertSelectiveListIgnoreConflict(List<String> insertPropertis,
List<T> models)
按属性批量插入数据并忽略冲突
|
int |
insertTable(String tableName,
List<String> columns,
List<Object> datas,
boolean ignoreConflict)
保存单表多项数据
|
int |
insertTable(String tableName,
Map<String,Object> datas,
boolean ignoreConflict) |
List<Map<String,Object>> |
queryForList(String sql,
Object[] args)
根据sql语句查询
|
<T> List<T> |
queryForList(String sql,
Object[] args,
Class<T> elementType)
根据sql语句查询
|
Map<String,Object> |
queryForMap(String sql,
Object... args)
根据sql语句查询
|
<T> T |
queryForObject(String sql,
Class<T> requiredType,
Object... args)
根据sql语句查询
|
<T> T |
queryForSingleColumn(Class<T> returnClass,
String sql,
Object[] args)
根据sql语句查询单列单行数据,注意:多好请设置 limit 1;
|
List<T> |
select(T model) |
List<T> |
selectAll() |
List<T> |
selectByCondition(tk.mybatis.mapper.entity.Condition condition) |
List<T> |
selectByConditionForOffsetAndLimit(tk.mybatis.mapper.entity.Condition condition,
Integer offset,
Integer limit,
Boolean count) |
List<T> |
selectByConditionForStartPage(tk.mybatis.mapper.entity.Condition condition,
Integer pageNum,
Integer pageSize) |
List<T> |
selectByConditionForStartPage(tk.mybatis.mapper.entity.Condition condition,
Integer pageNum,
Integer pageSize,
Boolean count) |
List<T> |
selectByIds(List<PK> ids) |
T |
selectByPrimaryKey(PK id) |
T |
selectFirst(T model) |
T |
selectFirstByCondition(tk.mybatis.mapper.entity.Condition condition) |
List<T> |
selectForStartPage(T model,
Integer pageNum,
Integer pageSize) |
T |
selectOne(T model) |
int |
updateByCondition(T model,
tk.mybatis.mapper.entity.Condition condition) |
int |
updateByConditionSelective(T model,
tk.mybatis.mapper.entity.Condition condition) |
int |
updateByPrimaryKey(T model) |
int |
updateByPrimaryKeySelective(T model) |
int |
updateTable(String sql,
Object... args) |
protected tk.mybatis.mapper.entity.Condition |
wrapCondition(Class claz) |
protected <PKI> tk.mybatis.mapper.entity.Condition |
wrapCondition(Class claz,
PKI id)
删除时候用到的条件
|
protected <PKI,PKC> tk.mybatis.mapper.entity.Condition |
wrapCondition(Class claz,
PKI id,
PKC createdBy)
删除时候用到的条件
|
tk.mybatis.mapper.entity.Condition |
wrapCondition(Class claz,
String[] properties)
参见
|
tk.mybatis.mapper.entity.Condition |
wrapCondition(Class claz,
String[] properties,
boolean withEnabledFilter)
返回查询条件
|
static com.github.pagehelper.PageRowBounds |
wrapPageRowBounds(PageParams params) |
static com.github.pagehelper.PageRowBounds |
wrapPageRowBounds(PageParams params,
boolean count) |
public boolean existsWithPrimaryKey(PK key)
existsWithPrimaryKey in interface Service<T,PK>public long countByCondition(tk.mybatis.mapper.entity.Condition condition)
countByCondition in interface Service<T,PK>public int insertSelective(T model)
insertSelective in interface Service<T,PK>public int insertList(List<T> models)
ServiceinsertList in interface Service<T,PK>models - 插入的实体对象public int insertListIgnoreConflict(List<T> models)
ServiceinsertListIgnoreConflict in interface Service<T,PK>models - 插入的实体对象public int insertSelectiveListIgnoreConflict(List<String> insertPropertis, List<T> models)
ServiceinsertSelectiveListIgnoreConflict in interface Service<T,PK>insertPropertis - 需要插入的对象属性值models - 插入的实体对象public int deleteByPrimaryKey(PK id)
deleteByPrimaryKey in interface Service<T,PK>public int deleteByIds(List<PK> ids)
deleteByIds in interface Service<T,PK>public int deleteByCondition(tk.mybatis.mapper.entity.Condition condition)
deleteByCondition in interface Service<T,PK>public int updateByCondition(T model, tk.mybatis.mapper.entity.Condition condition)
updateByCondition in interface Service<T,PK>public int updateByConditionSelective(T model, tk.mybatis.mapper.entity.Condition condition)
updateByConditionSelective in interface Service<T,PK>public int updateByPrimaryKey(T model)
updateByPrimaryKey in interface Service<T,PK>public int updateByPrimaryKeySelective(T model)
updateByPrimaryKeySelective in interface Service<T,PK>public T selectByPrimaryKey(PK id)
selectByPrimaryKey in interface Service<T,PK>public T selectFirstByCondition(tk.mybatis.mapper.entity.Condition condition)
selectFirstByCondition in interface Service<T,PK>public List<T> selectForStartPage(T model, Integer pageNum, Integer pageSize)
selectForStartPage in interface Service<T,PK>public List<T> selectByIds(List<PK> ids)
selectByIds in interface Service<T,PK>public List<T> selectByCondition(tk.mybatis.mapper.entity.Condition condition)
selectByCondition in interface Service<T,PK>public List<T> selectByConditionForStartPage(tk.mybatis.mapper.entity.Condition condition, Integer pageNum, Integer pageSize)
selectByConditionForStartPage in interface Service<T,PK>public List<T> selectByConditionForStartPage(tk.mybatis.mapper.entity.Condition condition, Integer pageNum, Integer pageSize, Boolean count)
selectByConditionForStartPage in interface Service<T,PK>public List<T> selectByConditionForOffsetAndLimit(tk.mybatis.mapper.entity.Condition condition, Integer offset, Integer limit, Boolean count)
selectByConditionForOffsetAndLimit in interface Service<T,PK>public org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate()
getJdbcTemplate in interface Service<T,PK>public <T> T queryForObject(String sql, Class<T> requiredType, @Nullable Object... args)
queryForObject in interface Service<T,PK>public <T> T queryForSingleColumn(Class<T> returnClass, String sql, Object[] args)
queryForSingleColumn in interface Service<T,PK>public Map<String,Object> queryForMap(String sql, @Nullable Object... args)
queryForMap in interface Service<T,PK>public <T> List<T> queryForList(String sql, Object[] args, Class<T> elementType)
queryForList in interface Service<T,PK>public List<Map<String,Object>> queryForList(String sql, Object[] args)
queryForList in interface Service<T,PK>public int[] batchInsertTable(String tableName, List<String> columns, List<Object[]> datas, boolean ignoreConflict)
batchInsertTable in interface Service<T,PK>tableName - 表名称columns - 列名datas - 要插入的数据,每行数据不能少于列数,空值需要传ignoreConflict - 是否忽略冲突
使用该方法请打开jdbc的批量驱动参数:rewriteBatchedStatements=true 批量操作batchInsert/update/deletepublic int insertTable(String tableName, List<String> columns, List<Object> datas, boolean ignoreConflict)
insertTable in interface Service<T,PK>tableName - 表名称columns - 列名datas - 要插入的数据,每行数据不能少于列数,空值需要传ignoreConflict - 是否忽略冲突
使用该方法请打开jdbc的批量驱动参数:rewriteBatchedStatements=true 批量操作batchInsert/update/deletepublic int insertTable(String tableName, Map<String,Object> datas, boolean ignoreConflict)
insertTable in interface Service<T,PK>public int updateTable(String sql, Object... args)
updateTable in interface Service<T,PK>public void executeSql(String sql)
executeSql in interface Service<T,PK>protected tk.mybatis.mapper.entity.Condition wrapCondition(Class claz)
public tk.mybatis.mapper.entity.Condition wrapCondition(Class claz, String[] properties)
ServicewrapCondition in interface Service<T,PK>wrapCondition(claz, properties, withEnabledFilter=true)public tk.mybatis.mapper.entity.Condition wrapCondition(Class claz, String[] properties, boolean withEnabledFilter)
ServicewrapCondition in interface Service<T,PK>claz - 类必填properties - 若非空,则查询当前实体的参数列表,若为空,则查询当前实体除了(createdBy、createdByName、version、modifiedBy、modifiedTime)以外的所有属性withEnabledFilter - 是否包含enabled=true的查询条件protected <PKI> tk.mybatis.mapper.entity.Condition wrapCondition(Class claz, PKI id)
PKI - 主键类型claz - 需要删除的实体类id - 需要删除的实体idprotected <PKI,PKC> tk.mybatis.mapper.entity.Condition wrapCondition(Class claz, PKI id, PKC createdBy)
PKI - 主键类型PKC - 创建人主键类型claz - 需要删除的实体类id - 需要删除的实体idcreatedBy - 创建人实体idpublic static com.github.pagehelper.PageRowBounds wrapPageRowBounds(PageParams params)
public static com.github.pagehelper.PageRowBounds wrapPageRowBounds(PageParams params, boolean count)
Copyright © 2020. All rights reserved.