1. 获取所有分区 2. 根据分区获得作品列表
增加了分区以及作品的swagger接口描述,并调整到正确的项目结构中
Change-Id: I36850cd93eeb93992cad7d342f2688dd8e50e6bc
diff --git a/src/main/resources/mapper/WorkMybatisMapper.xml b/src/main/resources/mapper/WorkMybatisMapper.xml
new file mode 100644
index 0000000..dd0d444
--- /dev/null
+++ b/src/main/resources/mapper/WorkMybatisMapper.xml
@@ -0,0 +1,37 @@
+<?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>
\ No newline at end of file