两种方式

注解方式

动态查找:
@Select("select ${ew.SqlSelect} from ${tableName} ${ew.customSqlSegment}")
List<File> listFileByCondition(@Param("tableName") String tableName, @Param("ew") Wrapper wrapper);

ew.SqlSelect:所需要查找的字段

tableName:使用的是那张表

ew.customSqlSegment:条件
用法:allFileMapper.listFileByCondition(tableName,Wrappers.query().select("*").in("relation_uuid", uuids));
结果: select * from tablName where relation_uuid in ()


动态修改:
@Update("update ${tableName} set ${ew.sqlSet} ${ew.customSqlSegment}")
int updateByCondition(@Param("tableName") String tableName, @Param("ew") Wrapper wrapper);

ew.sqlSet:修改的字段

tableName:使用的是那张表

ew.customSqlSegment:条件

用法:
mapper.updateByCondition(tableName, Wrappers.update().set("state", "初始状态").in("id", ids));
结果: update tableName set state = '初始状态' where id in ()

xml方式

查找:
<select >
	SELECT ${ew.SqlSelect} FROM ${tableName} ${ew.customSqlSegment}
</select>


修改:
<update  >
	update ${tableName} ${ew.SqlSelect}  ${ew.customSqlSegment}
</update>

查找带分页

xml用法:
Page<File> selectPage(Page page, @Param("tableName") String tableName, @Param("ew") Wrapper wrapper);

<select >
        select * from ${tableName} ${ew.customSqlSegment}
</select>

注解分页:

相关文章:

  • 2021-12-06
  • 2023-01-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
  • 2020-07-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-02
  • 2021-06-11
  • 2021-12-08
  • 2023-03-05
相关资源
相似解决方案