接口方法是这样的:
List> getBackupDbInfoByDbIds(@Param(“dbIds”) List dbIds);
mapper.xml如下:
<sql id="selectDbmBackupConfigLeftBackupInfoVo"> SELECT c.*, t.tsm_password, t.tsm_nodename, t.tsm_mgmtclass, t.keep_day, t.parallel FROM `dbm_backup_config` c LEFT JOIN dbm_backup_info t ON c.db_id = t.db_id </sql> <select id="getBackupDbInfoByDbIds" resultType="java.util.Map"> <include refid="selectDbmBackupConfigLeftBackupInfoVo"/> WHERE c.db_id in <foreach item="id" collection="dbIds" open="(" separator="," close=")"> #{id} </foreach> </select>
总结
1、resultType 定义为 “java.util.Map”
2、返回List> 的好处在于:不用再定义一个实体类对象了。
3、@Param(“dbIds”) List dbIds 表示给当前参数重新命名,方便foreach遍历