@Repository
public interface StepMapper extends BaseMapper<Step> {
@Insert({"<script>",
"INSERT INTO step(id, recipe_id, description, img_url)",
"VALUES",
"<foreach collection =\"stepList\" item=\"step\" separator =\",\">",
"(#{step.id}, #{step.recipeId}, #{step.description}, #{step.imgUrl})",
"</foreach >",
"</script>"})
public int insertStepList(@Param("stepList") List<Step> stepList);
}

该代码示例展示了一个StepMapper接口,继承自BaseMapper,定义了一个方法insertStepList,使用注解@Insert来批量插入Step对象到数据库。方法参数为一个Step对象的列表,通过<foreach>标签遍历列表并构建SQL语句。
504

被折叠的 条评论
为什么被折叠?



