blob: dd0d4442b02b74d8567ad68555ed4d3556721ebf [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="edu.bjtu.groupone.backend.mapper.WorkMybatisMapper">
<!-- 结果集映射 -->
<resultMap id="WorkResultMap" type="Work">
<id property="id" column="id"/>
<result property="title" column="title"/>
<result property="description" column="description"/>
<result property="categoryId" column="category_id"/>
<result property="createTime" column="create_time"/>
</resultMap>
<!-- 查询所有作品 -->
<select id="findAll" resultMap="WorkResultMap">
SELECT id, title, description, category_id, create_time
FROM works
</select>
<!-- 根据分类ID列表分页查询 -->
<select id="findByCategoryIdIn" resultMap="WorkResultMap">
SELECT * FROM works
<where>
<if test="categoryIds != null and categoryIds.size() > 0">
category_id IN
<foreach item="categoryId" collection="categoryIds"
open="(" separator="," close=")">
#{categoryId}
</foreach>
</if>
</where>
ORDER BY create_time DESC
LIMIT #{pageable.pageSize} OFFSET #{pageable.offset}
</select>
</mapper>