blob: dd0d4442b02b74d8567ad68555ed4d3556721ebf [file] [log] [blame]
晓瑞223cae85b72025-05-30 01:09:40 +08001<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
4<mapper namespace="edu.bjtu.groupone.backend.mapper.WorkMybatisMapper">
5
6 <!-- 结果集映射 -->
7 <resultMap id="WorkResultMap" type="Work">
8 <id property="id" column="id"/>
9 <result property="title" column="title"/>
10 <result property="description" column="description"/>
11 <result property="categoryId" column="category_id"/>
12 <result property="createTime" column="create_time"/>
13 </resultMap>
14
15 <!-- 查询所有作品 -->
16 <select id="findAll" resultMap="WorkResultMap">
17 SELECT id, title, description, category_id, create_time
18 FROM works
19 </select>
20
21 <!-- 根据分类ID列表分页查询 -->
22 <select id="findByCategoryIdIn" resultMap="WorkResultMap">
23 SELECT * FROM works
24 <where>
25 <if test="categoryIds != null and categoryIds.size() > 0">
26 category_id IN
27 <foreach item="categoryId" collection="categoryIds"
28 open="(" separator="," close=")">
29 #{categoryId}
30 </foreach>
31 </if>
32 </where>
33 ORDER BY create_time DESC
34 LIMIT #{pageable.pageSize} OFFSET #{pageable.offset}
35 </select>
36
37</mapper>