类 JdbcHelper

java.lang.Object
net.sohelp.boot.admin.core.db.JdbcHelper

@Component public class JdbcHelper extends Object
SQL数据操作
从以下版本开始:
2024/3/30 11:35
作者:
AaronFung
  • 构造器详细资料

    • JdbcHelper

      public JdbcHelper(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, org.mybatis.spring.SqlSessionTemplate sqlSessionTemplate)
      JdbcHelper构造函数,初始化数据库操作相关组件
      参数:
      jdbcTemplate - JDBC操作模板,用于执行SQL语句
      sqlSessionTemplate - MyBatis SQL会话模板,用于执行MyBatis映射语句

      初始化内容: 1. 从Spring容器获取动态数据源实例 2. 保存传入的JDBC模板和SQL会话模板

  • 方法详细资料

    • getCacheName

      @Comment("\u83b7\u53d6\u7f13\u5b58Key") public String getCacheName()
      获取缓存Key
      返回:
      缓存Key字符串
    • setCacheName

      public void setCacheName(@Comment(name="cacheName",value="\u7f13\u5b58\u540d") String cacheName)
      设置缓存名
      参数:
      cacheName - 缓存名
    • cache

      @Comment("\u4f7f\u7528\u7f13\u5b58") public JdbcHelper cache(@Comment(name="cacheName",value="\u7f13\u5b58\u540d") String cacheName, @Comment(name="ttl",value="\u8fc7\u671f\u65f6\u95f4") long ttl)
      使用缓存配置JDBC操作

      当缓存名为null时直接返回当前对象,否则设置缓存名称和过期时间。 如果未初始化sqlCache,则使用默认的LRU+TTL缓存实现(容量1000,TTL永不过期)。

      参数:
      cacheName - 缓存名称,用于标识缓存实例
      ttl - 缓存条目过期时间(毫秒),-1表示永不过期
      返回:
      返回当前JdbcHelper实例以支持链式调用
    • instance

      @Comment("\u83b7\u53d6JdbcHelper\u5b9e\u4f8b") public static JdbcHelper instance()
      获取JdbcHelper实例
      返回:
      JdbcHelper实例对象
    • setKey

      @Comment("\u8bbe\u7f6e\u6570\u636e\u6e90\u540d\u79f0") public void setKey(String key)
      设置数据源名称
      参数:
      key - 数据源名称
    • getKey

      @Comment("\u83b7\u53d6\u6570\u636e\u6e90\u540d\u79f0") public String getKey(String key)
      获取数据源名称
      参数:
      key - 参数说明(当前函数实现中未使用该参数,可能是设计遗留问题)
      返回:
      数据源名称
    • clearTableCache

      @Comment("\u6e05\u7a7a\u6570\u636e\u5e93\u8868\u5b57\u6bb5\u7f13\u5b58") public void clearTableCache() throws SQLException
      清空数据库表字段缓存
      抛出:
      SQLException
    • removeTableCache

      @Comment("\u6839\u636e\u6570\u636e\u6e90\u5237\u65b0\u7f13\u5b58") public void removeTableCache(@Comment("\u6570\u636e\u6e90\u540d\u79f0") String key) throws SQLException
      根据数据源刷新缓存
      参数:
      key - 数据源名称
      抛出:
      SQLException
    • getDatabaseName

      @Comment("\u83b7\u53d6\u9ed8\u8ba4\u6570\u636e\u5e93\u540d\u79f0") public String getDatabaseName() throws SQLException
      获取默认数据库名称
      返回:
      抛出:
      SQLException
    • getDatabaseType

      @Comment("\u83b7\u53d6\u9ed8\u8ba4\u6570\u636e\u5e93\u7c7b\u578b") public String getDatabaseType() throws SQLException
      获取默认数据库类型
      返回:
      数据库类型字符串
      抛出:
      SQLException - 如果获取数据库类型时发生SQL异常
    • transaction

      @Comment("\u5f00\u542f\u4e8b\u52a1\uff0c\u5e76\u5728\u56de\u8c03\u4e2d\u5904\u7406") public Object transaction(@Comment(name="function",value="\u56de\u8c03\u51fd\u6570\uff0c\u5982\uff1a()=>{....}") Function<?,?> function)
      开启事务,在一个回调中进行操作
      参数:
      function - 回调函数
    • transaction

      @Comment("\u5f00\u542f\u4e8b\u52a1\uff0c\u624b\u52a8\u63d0\u4ea4\u548c\u56de\u6eda") public org.ssssssss.magicapi.modules.db.Transaction transaction()
      开启事务,手动提交和回滚
    • getTableComment

      @Comment("\u6839\u636e\u6570\u636e\u540d\u83b7\u53d6\u8868\u6ce8\u91ca") public String getTableComment(@Comment("\u6570\u636e\u6e90\u540d\u79f0") String tableName) throws SQLException
      根据数据源获取表注释
      参数:
      tableName - 数据源
      返回:
      抛出:
      SQLException
    • getTableComment

      @Comment("\u83b7\u53d6\u5f53\u524d\u9ed8\u8ba4\u6570\u636e\u5e93\u8868\u6ce8\u91ca") public Map<String,String> getTableComment() throws SQLException
      获取默认数据源表备注
      返回:
      抛出:
      SQLException
    • getTableField

      @Comment("\u6839\u636e\u6570\u636e\u5e93\u540d\u548c\u8868\uff0c\u83b7\u53d6\u8868\u5b57\u6bb5\u6ce8\u91ca") public Map<String,Map<String,Object>> getTableField(@Comment("\u8868\u540d") String tableName) throws SQLException
      获取默认数据表字段
      返回:
      抛出:
      SQLException
    • getTableField

      @Comment("\u6839\u636e\u6570\u636e\u5e93\u540d\u548c\u8868\uff0c\u83b7\u53d6\u8868\u5b57\u6bb5\u6ce8\u91ca") public Map<String,Map<String,Map<String,Object>>> getTableField() throws SQLException
      获取默认数据表字段
      返回:
      抛出:
      SQLException
    • use

      @Comment("\u5207\u6362\u6570\u636e\u6e90") public JdbcHelper use(@Comment("\u6570\u636e\u6e90") String key) throws SQLException
      切换数据源进行SQL接口操作
      参数:
      key - 数据源
      返回:
      抛出:
      SQLException
    • table

      @Comment("\u4f7f\u7528\u8868") public JdbcHelper.Table table(@Comment("\u8868\u540d") String tableName) throws SQLException
      使用表
      参数:
      tableName - 表名
      返回:
      返回Table对象
      抛出:
      SQLException - 如果发生SQL异常
    • toPager

      @Comment("\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment("\u67e5\u8be2\u8bed\u53e5\uff1aselect * from table where id=? and name=?") String sql, @Comment("\u4f8b\u5982:[id,name]") List<Object> params, @Comment("\u4ece\u7b2c\u51e0\u884c\u8d77") int offset, @Comment("\u4e00\u9875\u663e\u793a\u51e0\u884c") int limit)
      分页查询
      参数:
      sql - 查询语句:select * from table where id=? and name=?
      params - 查询参数列表,例如:[id,name]
      offset - 从第几行起
      limit - 一页显示几行
      返回:
      分页查询结果
    • toPager

      @Comment("\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment("\u67e5\u8be2\u8bed\u53e5\uff1aselect * from table where id=? and name=?") String sql, @Comment("\u4f8b\u5982\uff1a[id,name]") Object[] params, @Comment("\u4ece\u7b2c\u51e0\u884c\u8d77") int offset, @Comment("\u4e00\u9875\u663e\u793a\u51e0\u884c") int limit)
      分页查询
      参数:
      sql - 查询语句:select * from table where id=? and name=?
      params - 查询参数,例如:[id,name]
      offset - 从第几行起
      limit - 一页显示几行
      返回:
      包含分页结果和总数的Pager对象
    • toPager

      @Comment("\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment("\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982:select * from table where field1=? and field2=?") String sql, @Comment("\u7edf\u8ba1\u884c\u6570\u8bed\u53e5,\u4f8b\u5982\uff1aselect count(*) from table where field1=? and field2=?") String countSQL, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params, @Comment("\u4ece\u7b2c\u51e0\u884c\u8d77") int offset, @Comment("\u4e00\u9875\u663e\u793a\u51e0\u884c") int limit)
      分页查询
      参数:
      sql - 查询语句,例如:select * from table where field1=? and field2=?
      countSQL - 统计行数语句,例如:select count(*) from table where field1=? and field2=?
      params - 查询参数列表,例如:[参数1,参数2]
      offset - 从第几行起
      limit - 一页显示几行
      返回:
      分页查询结果
    • toPager

      @Comment("\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment("\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982:select * from table where field1=? and field2=?") String sql, @Comment("\u7edf\u8ba1\u884c\u6570\u8bed\u53e5,\u4f8b\u5982\uff1aselect count(*) from table where field1=? and field2=?") String countSQL, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params, @Comment("\u4ece\u7b2c\u51e0\u884c\u8d77") jakarta.servlet.http.HttpServletRequest request)
      分页查询
      参数:
      sql - 查询语句,例如:select * from table where field1=? and field2=?
      countSQL - 统计行数语句,例如:select count(*) from table where field1=? and field2=?
      params - 查询参数列表,例如:[参数1,参数2]
      request - HttpServletRequest对象,用于获取分页参数(从第几行起)
      返回:
      分页结果对象,包含查询数据和分页信息
    • toPager

      @Comment("\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment("\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982:select * from table where field1=? and field2=?") String sql, @Comment("\u7edf\u8ba1\u884c\u6570\u8bed\u53e5,\u4f8b\u5982\uff1aselect count(*) from table where field1=? and field2=?") String countSQL, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params, @Comment("\u4ece\u7b2c\u51e0\u884c\u8d77") int offset, @Comment("\u4e00\u9875\u663e\u793a\u51e0\u884c") int limit)
      分页查询数据
      参数:
      sql - 查询语句,例如:select * from table where field1=? and field2=?
      countSQL - 统计行数语句,例如:select count(*) from table where field1=? and field2=?
      params - 查询参数数组,例如:[参数1,参数2]
      offset - 从第几行开始查询(起始行)
      limit - 每页显示的记录数
      返回:
      包含分页结果和总记录数的Pager对象,其中结果为Map列表,每个Map代表一条记录
    • toPager

      @Comment("\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment("\u67e5\u8be2\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params)
      分页查询
      参数:
      sql - 查询语句
      params - 例如:[参数1,参数2]
      返回:
      分页查询结果,包含Map类型的数据集合
    • toPager

      @Comment("\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment("\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982:select * from table where field1=? and field2=?") String sql, @Comment("\u7edf\u8ba1\u884c\u6570\u8bed\u53e5,\u4f8b\u5982\uff1aselect count(*) from table where field1=? and field2=?") String countSQL, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params, @Comment("HttpServletRequest") jakarta.servlet.http.HttpServletRequest request)
      分页查询
      参数:
      sql - 查询语句,例如:select * from table where field1=? and field2=?
      countSQL - 统计行数语句,例如:select count(*) from table where field1=? and field2=?
      params - 查询参数,例如:[参数1,参数2]
      request - HttpServletRequest对象,用于获取分页参数
      返回:
      分页结果对象,包含查询数据和分页信息
    • toPager

      @Comment("\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment("\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982:select * from table where field1=? and field2=?") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params, @Comment("HttpServletRequest") jakarta.servlet.http.HttpServletRequest request)
      分页查询
      参数:
      sql - 查询语句,例如:select * from table where field1=? and field2=?
      params - 查询参数数组,例如:[参数1,参数2]
      request - HttpServletRequest对象,用于获取分页参数
      返回:
      分页结果对象,包含当前页数据和分页信息
    • toList

      @Comment("\u5217\u8868\u67e5\u8be2,\u4f8b\u5982 select * from table where field1=#{field1} and field2=#{field2}") public List<Map<String,Object>> toList(@Comment("\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982:select * from table where field1=? and field2=?") String sql)
      列表查询,执行指定的SQL查询语句并返回结果列表

      示例:select * from table where field1=#{field1} and field2=#{field2}

      参数:
      sql - 查询语句,示例:select * from table where field1=? and field2=?
      返回:
      查询结果列表,每个元素是一个Map,包含列名和对应的值
    • toList

      @Comment("\u83b7\u53d6\u6570\u636e\u8868") public List<Map<String,Object>> toList(@Comment("\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982:select * from table where field1=? and field2=?") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params)
      获取数据表
      参数:
      sql - 查询语句,例如:select * from table where field1=? and field2=?
      params - 查询参数数组,例如:[参数1,参数2]
      返回:
      查询结果列表,每个元素是一个Map,包含列名和对应的值
    • deleteCache

      @Comment("\u5220\u9664`SQL`\u7f13\u5b58") public JdbcHelper deleteCache(@Comment("\u7f13\u5b58\u540d\u79f0") String name)
      删除SQL缓存
      参数:
      name - 缓存名称,非空时执行删除操作
      返回:
      返回当前JdbcHelper实例以支持链式调用
    • deleteCache

      @Comment("\u5220\u9664`SQL`\u7f13\u5b58") public JdbcHelper deleteCache()
      删除SQL缓存

      如果当前JdbcHelper实例中设置了缓存名称(cacheName),则删除对应的SQL缓存。

      返回:
      返回当前JdbcHelper实例,支持链式调用
    • toList

      @Comment("\u5217\u8868\u67e5\u8be2") public List<Map<String,Object>> toList(@Comment("\u67e5\u8be2\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params)
      列表查询
      参数:
      sql - 查询语句
      params - 例如:[参数1,参数2]
      返回:
      查询结果列表
    • getValues

      @Comment("\u83b7\u53d6\u6570\u636e\u5217") public List getValues(@Comment("\u5355\u5217\u67e5\u8be2\u8bed\u53e5,\u4f8b\u5982: select id from table where field=? and field1=?") String sql, @Comment("\u53c2\u6570:[\u53c2\u65701\uff0c\u53c2\u65702]") Object[] params)
      获取数据列
      参数:
      sql - 单列查询语句,例如: select id from table where field=? and field1=?
      params - 参数:[参数1,参数2]
      返回:
      包含查询结果值的列表
    • getValues

      @Comment("\u83b7\u53d6\u6570\u636e\u5217\uff0c\u4f8b\u5982\uff1a[1,3,4,5]") public List getValues(@Comment("\u5355\u5217\u67e5\u8be2\u8bed\u53e5\uff0c\u4f8b\u5982\uff1aselect id from table where field1=? and field2=?") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params)
      获取数据列,例如:[1,3,4,5]
      参数:
      sql - 单列查询语句,例如:select id from table where field1=? and field2=?
      params - 查询参数列表,例如:[参数1,参数2]
      返回:
      查询结果数据列
    • getValues

      @Comment("\u83b7\u53d6\u6570\u636e\u5217\uff0c\u4f8b\u5982\uff1a[1,3,4,5]") public List getValues(@Comment("\u5355\u5217\u67e5\u8be2\u8bed\u53e5\uff0c\u4f8b\u5982\uff1aselect id from table where name=?") String sql, @Comment("\u4f8b\u5982\uff1a{name:\'1\'}") Map params)
      获取数据列,例如:[1,3,4,5]
      参数:
      sql - 单列查询语句,例如:select id from table where name=?
      params - 查询参数,例如:{name:'1'}
      返回:
      包含查询结果单列值的列表
    • insert

      @Comment("\u63d2\u5165\u6570\u636e\uff0c\u9488\u5bf9 jdbcTemplate") public int insert(@Comment("\u63d2\u5165\u8bed\u53e5:insert table(field1,field2) values (?,?)") String sql, @Comment("\u53c2\u6570\uff1a[\u53c2\u65701\uff0c\u53c2\u65702]") Object[] params)
      插入数据,针对jdbcTemplate
      参数:
      sql - 插入语句:insert table(field1,field2) values (?,?)
      params - 参数:[参数1,参数2]
      返回:
      受影响的行数
    • insert

      @Comment("\u63d2\u5165\u6570\u636e\uff0c\u9488\u5bf9 jdbcTemplate") public int insert(@Comment("\u63d2\u5165\u8bed\u53e5:insert table(field1,field2) values (?,?)") String sql, @Comment("\u53c2\u6570\uff1a[\u53c2\u65701\uff0c\u53c2\u65702]") List<Object> params)
      插入数据,针对 jdbcTemplate
      参数:
      sql - 插入语句:insert table(field1,field2) values (?,?)
      params - 参数:[参数1,参数2]
      返回:
      插入操作影响的行数
    • query

      public void query(String sql, org.springframework.jdbc.core.RowCallbackHandler rch)
      执行查询回调
      参数:
      sql - SQL语句
      rch - 回调处理器
    • query

      public void query(String sql, Object[] args, org.springframework.jdbc.core.RowCallbackHandler rch)
      执行查询回调
      参数:
      sql - SQL语句
      args - 参数
      rch - 回调处理器
    • batchUpdateByMap

      @Comment("\u6279\u91cf\u64cd\u4f5c,\u9488\u5bf9jdbcTemplate") public int[] batchUpdateByMap(@Comment("\u66f4\u65b0\u8bed\u53e5\uff1aupdate table set name=? where id=?") String sql, @Comment("\u4f8b\u5982\uff1a[{id\uff1a3,name:\'a\'},{id:4,name:\'b\'}]") List<Map> params)
      批量执行JDBC更新操作,针对jdbcTemplate实现
      参数:
      sql - 更新SQL语句,使用占位符格式如:'update table set name=? where id=?'
      params - 参数列表,每个Map对应一条记录的参数,格式如:[{id:'1',name:'aaa'},{id:'2',name:'bbb'}]
      返回:
      包含每条记录更新结果的int数组,数组长度与params长度一致
    • update

      @Comment("\u66f4\u65b0\u6307\u5b9a\u8bb0\u5f55") public int update(@Comment("\u4f8b\u5982\uff1aupdate table set name=? where id=?") String sql, @Comment("\u4f8b\u5982\uff1a[name,id]") Object[] params)
      更新指定记录
      参数:
      sql - SQL更新语句,例如:update table set name=? where id=?
      params - SQL参数数组,例如:[name,id]
      返回:
      受影响的记录行数
    • update

      @Comment("\u66f4\u65b0\u6307\u5b9a\u8bb0\u5f55") public int update(@Comment("\u4f8b\u5982\uff1aupdate table set name=? where id=?") String sql, @Comment("\u4f8b\u5982\uff1a[name,id]") List<Object> params)
      更新指定记录
      参数:
      sql - SQL更新语句,格式例如:update table set name=? where id=?
      params - 参数列表,例如:[name,id]
      返回:
      受影响的行数
    • batchDeleteByMap

      @Comment("\u6279\u91cf\u5220\u9664\u591a\u6761\u8bb0\u5f55,\u9488\u5bf9sqlSessionTemplate") public int[] batchDeleteByMap(@Comment("\u4f8b\u5982\uff1adelete from table where id=#{id} and name=#{name}") String sql, @Comment("\u4f8b\u5982\uff1a[{id:\'1\',name:\'aa\'},{id:\'2\',name:\'b\'}]") List<Map> params)
      批量删除多条记录,针对sqlSessionTemplate执行批量删除操作
      参数:
      sql - SQL删除语句模板,例如:delete from table where id=#{id} and name=#{name}
      params - 参数列表,每个Map对应一条记录的删除参数,例如:[{id:'1',name:'aa'},{id:'2',name:'b'}]
      返回:
      包含每条记录删除操作结果的数组,数组长度与params大小相同,每个元素表示对应记录的删除结果
    • batchDelete

      @Comment("\u6279\u91cf\u5220\u9664\u591a\u6761\u8bb0\u5f55\uff0c\u9488\u5bf9JdbcTemplate") public int[] batchDelete(@Comment("\u4f8b\u5982\uff1adelete from table where id=?\' \u6216\u8005 delete from table where id=? and name=?") String sql, @Comment(" [[id,name],[id1,name1]]") List<Object[]> params)
      批量删除多条记录,针对JdbcTemplate
      参数:
      sql - SQL删除语句,例如:"delete from table where id=?" 或 "delete from table where id=? and name=?"
      params - 参数数组,可以是单个ID数组[id,id,id]或复合条件数组[[id,name],[id,name]]
      返回:
      批量删除操作影响的记录数数组,如果参数为null则返回null
    • batchInsert

      public int[] batchInsert(String sql, List<Object[]> params)
      批量插入多条记录,针对JdbcTemplate
      参数:
      sql - 插入语句
      params - List无效输入:'<'Object[]>
      返回:
    • delete

      @Comment("\u5220\u9664\u8bb0\u5f55") public int delete(@Comment("\u4f8b\u5982\uff1adelete from table=? where id =? and name=?") String sql, @Comment("\u53c2\u6570\uff1a[id,name]") Object[] params)
      删除记录
      参数:
      sql - SQL语句,例如:delete from table=? where id =? and name=?
      params - 参数列表,例如:[[id,name],[id,name]]
      返回:
      受影响的行数
    • execute

      @Comment("\u6267\u884c\u811a\u672c\u8bed\u53e5\uff0c\u6ca1\u6709\u8fd4\u56de\u503c") public void execute(@Comment("\u811a\u672c\u8bed\u53e5") String sql) throws SQLException
      执行脚本语句,没有返回值
      参数:
      sql - 脚本语句,支持用分号分隔的多条SQL语句
      抛出:
      SQLException - 当执行SQL语句发生错误时抛出
    • toMap

      @Comment("\u83b7\u53d6\u5355\u6761Map\u6570\u636e") public Map<String,Object> toMap(@Comment("\u5355\u6761\u6570\u636e\u67e5\u8be2\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params)
      获取单条Map数据
      参数:
      sql - 单条数据查询语句
      params - 查询参数数组,例如:[参数1,参数2]
      返回:
      查询结果的第一条记录的Map对象,如果查询结果为空则返回空的HashMap
    • toMap

      @Comment("\u83b7\u53d6\u5355\u6761Map\u6570\u636e") public Map<String,Object> toMap(@Comment("\u5355\u6761\u6570\u636e\u67e5\u8be2\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params)
      获取单条Map数据
      参数:
      sql - 单条数据查询语句
      params - 查询参数列表,例如:[参数1,参数2]
      返回:
      包含单条数据的Map对象
    • getObject

      @Comment("\u83b7\u53d6\u5355\u4e2aObject\u7c7b\u578b\u6570\u636e") public Object getObject(@Comment("\u5355\u6761\u6570\u636e\u67e5\u8be2\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params)
      获取单个Object类型数据
      参数:
      sql - 单条数据查询语句
      params - 例如:[参数1,参数2]
      返回:
      查询结果中的第一个值,如果查询结果为空则返回null
    • getString

      @Comment("\u83b7\u53d6\u5b57\u7b26\u4e32\u6570\u636e") public String getString(@Comment("sql\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params)
      获取字符串数据
      参数:
      sql - sql语句
      params - 例如:[参数1,参数2]
      返回:
      转换后的字符串数据,如果转换失败则返回空字符串
    • getString

      @Comment("\u83b7\u53d6\u5b57\u7b26\u4e32\u6570\u636e") public String getString(@Comment("sql\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params)
      获取字符串数据
      参数:
      sql - sql语句
      params - 参数列表,例如:[参数1,参数2]
      返回:
      查询结果字符串
    • getInt

      @Comment("\u83b7\u53d6Integer\u7c7b\u578b\u6570\u636e") public int getInt(@Comment("sql\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params)
      获取Integer类型数据
      参数:
      sql - sql语句
      params - 例如:[参数1,参数2]
      返回:
      转换后的Integer类型数据,如果转换失败则返回0
    • getInt

      @Comment("\u83b7\u53d6Integer\u7c7b\u578b\u6570\u636e") public int getInt(@Comment("sql\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Map<String,Object>> params)
      获取Integer类型数据
      参数:
      sql - sql语句
      params - 参数列表,例如:[参数1,参数2]
      返回:
      Integer类型的结果
    • getLong

      @Comment("\u83b7\u53d6Long\u7c7b\u578b\u6570\u636e") public long getLong(@Comment("sql\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params)
      获取Long类型数据
      参数:
      sql - sql语句
      params - 例如:[参数1,参数2]
      返回:
      转换后的Long类型数据,如果转换失败则返回0L
    • getLong

      @Comment("\u83b7\u53d6Long\u7c7b\u578b\u6570\u636e") public long getLong(@Comment("sql\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Map<String,Object> paramMap)
      获取Long类型数据
      参数:
      sql - sql语句
      paramMap - 参数映射,例如:[参数1,参数2]
      返回:
      转换后的Long类型数据,如果转换失败则返回0
    • getLong

      @Comment("\u83b7\u53d6Long\u7c7b\u578b\u6570\u636e") public long getLong(@Comment("sql\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params)
      获取Long类型数据
      参数:
      sql - sql语句
      params - 参数列表,例如:[参数1,参数2]
      返回:
      查询结果对应的Long类型值
    • getDouble

      @Comment("\u83b7\u53d6Double\u7c7b\u578b\u6570\u636e") public double getDouble(@Comment("sql\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Object[] params)
      获取Double类型数据
      参数:
      sql - sql语句
      params - 例如:[参数1,参数2]
      返回:
      转换后的Double类型数据,如果转换失败则返回0d
    • getDouble

      @Comment("\u83b7\u53d6Double\u7c7b\u578b\u6570\u636e") public double getDouble(@Comment("sql\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params)
      获取Double类型数据
      参数:
      sql - sql语句
      params - 参数列表,例如:[参数1,参数2]
      返回:
      Double类型结果
    • toPager

      @Comment("\u624b\u5de5\u5206\u9875") public Pager<Map<String,Object>> toPager(@Comment("sql\u8bed\u53e5") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Map<String,Object> paramMap, @Comment("\u4ece\u7b2c\u51e0\u884c\u8d77\u59cb") int offset, @Comment("\u4e00\u9875\u663e\u793a\u51e0\u884c") int limit)
      手工分页
      参数:
      sql - sql语句
      paramMap - 参数映射,例如:[参数1,参数2]
      offset - 从第几行起始
      limit - 一页显示几行
      返回:
      分页结果对象,包含当前页数据和分页信息
    • toPager

      @Comment("\u624b\u5de5\u5206\u9875") public Pager<Map<String,Object>> toPager(@Comment("sql\u8bed\u53e5") String sql, @Comment("\u7edf\u8ba1sql\u8bed\u53e5") String countSQL, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Map<String,Object> paramMap, @Comment("\u4ece\u7b2c\u51e0\u884c\u8d77\u59cb") int offset, @Comment("\u4e00\u9875\u663e\u793a\u51e0\u884c") int limit)
      手工分页查询方法
      参数:
      sql - 查询数据的SQL语句
      countSQL - 统计总数的SQL语句
      paramMap - 查询参数Map,例如:[参数1,参数2]
      offset - 从第几行开始查询(从0开始计数)
      limit - 每页显示的数据行数
      返回:
      包含分页数据和总数的Pager对象
    • toPager

      @Comment("\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment("\u4f8b\u5982\uff1aselect * from table") String sql)
      分页查询
      参数:
      sql - SQL查询语句,例如:select * from table
      返回:
      包含分页数据的Pager对象,其中每条记录以Map形式存储
    • toPager

      @Comment("\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment("\u4f8b\u5982\uff1aselect * from table") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") Map<String,Object> paramMap)
      分页查询
      参数:
      sql - SQL查询语句,例如:select * from table
      paramMap - 查询参数映射,例如:[参数1,参数2]
      返回:
      分页查询结果,包含数据列表和分页信息
    • toPager

      @Comment("\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment("\u4f8b\u5982\uff1aselect * from table") String sql, @Comment("\u4f8b\u5982\uff1a[\u53c2\u65701,\u53c2\u65702]") List<Object> params)
      分页查询
      参数:
      sql - SQL查询语句,例如:select * from table
      params - 查询参数列表,例如:[参数1,参数2]
      返回:
      分页查询结果,包含数据列表和分页信息
    • toPager

      @Comment("\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment("\u4f8b\u5982\uff1aselect * from table") String sql, @Comment("\u53c2\u6570") List<Object> params, @Comment("HttpServletRequest") jakarta.servlet.http.HttpServletRequest request)
      分页查询
      参数:
      sql - 例如:select * from table
      params - 参数列表
      request - HttpServletRequest对象
      返回:
      分页结果,包含Map类型的数据集合
    • toPager

      @Comment("\u5206\u9875\u67e5\u8be2") public Pager<Map<String,Object>> toPager(@Comment("\u4f8b\u5982\uff1aselect * from table") String sql, @Comment("\u4f8b\u5982\uff1a{name:\'a\'}") Map<String,Object> paramMap, @Comment("HttpServletRequest") jakarta.servlet.http.HttpServletRequest request)
      分页查询
      参数:
      sql - SQL查询语句,例如:select * from table
      paramMap - 查询参数Map,例如:{name:'a'}
      request - HttpServletRequest对象,用于获取分页参数
      返回:
      返回分页结果Pager对象,包含当前页数据和分页信息
    • toList

      @Comment("\u83b7\u53d6\u5217\u8868") public List<Map<String,Object>> toList(@Comment("\u4f8b\u5982\uff1aselect * from table") String sql, @Comment("\u4f8b\u5982\uff1a{name:\'a\'}") Map<String,Object> paramMap)
      获取列表数据
      参数:
      sql - SQL查询语句,例如:select * from table
      paramMap - 查询参数Map,例如:{name:'a'}
      返回:
      包含查询结果的List,每个元素是一个Map无效输入:'<'String, Object>
    • insert

      @Comment("\u63d2\u5165\u6570\u636e") public int insert(@Comment("\u4f8b\u5982\uff1ainsert into table(name) values(#{name})") String sql, @Comment("\u4f8b\u5982\uff1a{name:\'a\'}") Map<String,Object> paramMap)
      插入数据
      参数:
      sql - SQL插入语句,例如:insert into table(name) values(#{name})
      paramMap - 参数映射Map,例如:{name:'a'}
      返回:
      影响的行数
    • update

      @Comment("\u66f4\u65b0\u6570\u636e") public int update(@Comment("\u4f8b\u5982\uff1aupdate table set name=#{name} where id=#{id}") String sql, @Comment("\u4f8b\u5982\uff1a{id:1,name:\'a\'}") Map<String,Object> paramMap)
      更新数据
      参数:
      sql - SQL更新语句,例如:update table set name=#{name} where id=#{id}
      paramMap - 参数映射Map,例如:{id:1,name:'a'}
      返回:
      更新操作影响的行数
    • batchUpdate

      @Comment("\u6279\u91cf\u66f4\u65b0\u6570\u636e") public int[] batchUpdate(@Comment("\u4f8b\u5982\uff1aupdate table set name=1 where id=? \u6216\u8005 update table set name=? where id=?") String sql, @Comment("\u4f8b\u5982\uff1a[id,id,id,id] \u6216\u8005[[name,id],[name,id],[\'name\',\'id\']]") Object[] params)
      批量更新数据
      参数:
      sql - SQL更新语句,例如:update table set name=1 where id=? 或者 update table set name=? where id=?
      params - 参数数组,可以是单个值数组[id,id,id,id],也可以是二维数组[[name,id],[name,id],['name','id']]
      返回:
      批量更新操作的结果数组,如果参数为null则返回null
    • batchDelete

      public int[] batchDelete(@Comment("\u4f8b\u5982\uff1adelete from table where name=1 where id=? \u6216\u8005 delete from table where name=? where id=?") String sql, @Comment("\u4f8b\u5982\uff1a[id,id,id,id] \u6216\u8005[[name,id],[name,id],[\'name\',\'id\']]") Object[] params)
    • batchUpdate

      @Comment("\u6279\u91cf\u66f4\u65b0\u6570\u636e") public int[] batchUpdate(@Comment("\u4f8b\u5982\uff1aupdate table name=22 where id=? \u6216\u8005 update table name=? where id=?") String sql, @Comment("\u4f8b\u5982\uff1a[id,id,id,id] \u6216\u8005[[name,id],[name,id]]") List<Object> params)
      批量更新数据
      参数:
      sql - SQL更新语句,例如:update table name=22 where id=? 或者 update table name=? where id=?
      params - 参数列表,例如:[id,id,id,id] 或者 [[name,id],[name,id]]
      返回:
      更新结果数组,如果params为null则返回null
    • delete

      @Comment("\u5220\u9664\u6570\u636e") public int delete(@Comment("\u4f8b\u5982\uff1adelete from table where id=#{id}") String sql, @Comment("\u4f8b\u5982\uff1a{id:1}") Map<String,Object> paramMap)
      删除数据
      参数:
      sql - SQL删除语句,例如:delete from table where id=#{id}
      paramMap - 参数映射Map,例如:{id:1}
      返回:
      返回受影响的行数
    • toMap

      @Comment("\u83b7\u53d6Map") public Map<String,Object> toMap(@Comment("\u67e5\u8be2\u8bed\u53e5") String sql, @Comment("\u53c2\u6570") Map<String,Object> paramMap)
      根据SQL查询语句和参数获取Map结果
      参数:
      sql - 查询语句
      paramMap - 参数Map
      返回:
      查询结果的第一条记录Map,如果结果为空则返回null
    • toMap

      @Comment("\u83b7\u53d6Map") public Map<String,Object> toMap(@Comment("\u67e5\u8be2\u8bed\u53e5") String sql)
      获取Map

      根据传入的SQL查询语句执行查询,并返回第一条记录的Map表示 如果查询结果为空则返回null

      参数:
      sql - 查询语句
      返回:
      查询结果的第一条记录的Map表示,如果没有结果则返回null
    • getObject

      @Comment("\u83b7\u53d6Object") public Object getObject(@Comment("\u67e5\u8be2\u8bed\u53e5") String sql, @Comment("\u53c2\u6570") Map<String,Object> paramMap)
      获取Object对象
      参数:
      sql - 查询语句
      paramMap - 参数映射Map
      返回:
      查询结果中的第一个值对象,如果查询结果为空则返回null
    • getObject

      @Comment("\u83b7\u53d6Object") public Object getObject(@Comment("\u67e5\u8be2\u8bed\u53e5") String sql, @Comment("\u53c2\u6570") List<Object> params)
      获取Object对象
      参数:
      sql - 查询语句
      params - 参数列表
      返回:
      查询结果对象
    • getString

      @Comment("\u83b7\u53d6String") public String getString(@Comment("\u67e5\u8be2\u8bed\u53e5") String sql, @Comment("\u53c2\u6570") Map<String,Object> paramMap)
      获取String类型的数据
      参数:
      sql - 查询语句
      paramMap - 参数映射Map
      返回:
      转换后的字符串,如果转换失败则返回空字符串
    • getInt

      @Comment("\u83b7\u53d6int") public int getInt(@Comment("\u67e5\u8be2\u8bed\u53e5") String sql, @Comment("\u53c2\u6570") Map<String,Object> paramMap)
      根据SQL查询语句和参数Map获取int类型结果
      参数:
      sql - 查询语句
      paramMap - 参数Map,键为参数名,值为参数值
      返回:
      查询结果转换后的int类型值
    • getDouble

      @Comment("\u83b7\u53d6double") public double getDouble(@Comment("\u67e5\u8be2\u8bed\u53e5") String sql, @Comment("\u53c2\u6570") Map<String,Object> paramMap)
      获取double类型数据
      参数:
      sql - 查询语句
      paramMap - 参数映射Map
      返回:
      转换后的double类型数据