mybatis返回类型string,或者对象,均可用list<string>或者,list<对象>来接收

本文介绍使用MyBatis进行角色权限数据查询的方法,包括通过角色ID查找权限数据及通过ID查找角色对象的具体实现方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

--------------------------------------eg 1------------------------------------

 <!-- 通过角色id查找权限数据 -->
<select id="findSysRoleFunctionById" parameterType="string" resultType="string">
select sf_id from sys_role_function where sr_id = #{srId}
</select>



返回string类型,可以用List<String>  findSysRoleFunctionById(String srId);

list<String>来接收


----------------------------------------------eg 2------------------------------------

  <resultMap id="BaseResultMap" type="com.bdf.rolemanager.vo.SysRoleVO" >
    <id column="sr_id" property="srId" jdbcType="VARCHAR" />
    <result column="sr_name" property="srName" jdbcType="VARCHAR" />
    <result column="srTypeName" property="srTypeName" jdbcType="VARCHAR" />
<result column="roleUserCount" property="roleUserCount" jdbcType="VARCHAR" />
    <result column="sr_stats" property="srStats" jdbcType="VARCHAR" />
    <result column="umName" property="umName" jdbcType="VARCHAR" />
<result column="um_id" property="umId" jdbcType="VARCHAR" />
    <result column="sr_create_time" property="srCreateTime" jdbcType="VARCHAR" />
    <result column="sr_describe" property="srDescribe" jdbcType="VARCHAR" />
<result column="sr_type" property="srType" jdbcType="VARCHAR" />
  </resultMap>


<!-- 通过id查找对象 -->
<select id="findSysRoleById" parameterType="string" resultMap="BaseResultMap">
select * from sys_role where sr_id = #{srId}
</select>


SysRoleVO findSysRoleById(String srId);   用对象接收或者List<SysRoleVO>接收均可





评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值