42 lines
1.6 KiB
XML
42 lines
1.6 KiB
XML
|
|
<?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="com.mingchen.mapper.CategoriesMapper">
|
||
|
|
|
||
|
|
<resultMap id="CategoryWithLawsResultMap" type="com.mingchen.model.dto.CategoryWithLaws">
|
||
|
|
<id property="categoryId" column="category_id"/>
|
||
|
|
<result property="name" column="name"/>
|
||
|
|
<result property="description" column="description"/>
|
||
|
|
|
||
|
|
<collection property="laws" ofType="com.mingchen.model.dto.CategoryWithLaws$Law">
|
||
|
|
<id property="lawId" column="law_id"/>
|
||
|
|
<result property="categoryId" column="law_category_id"/>
|
||
|
|
<result property="title" column="title"/>
|
||
|
|
<result property="summary" column="summary"/>
|
||
|
|
<result property="content" column="content"/>
|
||
|
|
<result property="effectiveDate" column="effective_date"/>
|
||
|
|
<result property="referenceUrl" column="reference_url"/>
|
||
|
|
</collection>
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<!-- 查询所有类别及其关联的法律法规 -->
|
||
|
|
<select id="getAllCategoriesWithLaws" resultMap="CategoryWithLawsResultMap">
|
||
|
|
SELECT
|
||
|
|
c.category_id,
|
||
|
|
c.name,
|
||
|
|
c.description,
|
||
|
|
l.law_id,
|
||
|
|
l.category_id AS law_category_id,
|
||
|
|
l.title,
|
||
|
|
l.summary,
|
||
|
|
l.content,
|
||
|
|
l.effective_date,
|
||
|
|
l.reference_url
|
||
|
|
FROM
|
||
|
|
categories c
|
||
|
|
LEFT JOIN
|
||
|
|
laws l ON c.category_id = l.category_id
|
||
|
|
ORDER BY
|
||
|
|
c.category_id, l.law_id
|
||
|
|
</select>
|
||
|
|
</mapper>
|