潘志宝
2024-11-13 a13dc8843bbf54dacca27254000865a539a87231
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?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.iailab.module.model.mpk.dao.ProjectDao">
 
    <resultMap id="projectModel" type="com.iailab.module.model.mpk.dto.ProjectDTO">
        <id property="id" column="id"/>
        <result property="projectName" column="project_name"/>
        <result property="projectCode" column="project_code"/>
        <result property="createTime" column="create_time"/>
        <collection property="models" ofType="com.iailab.module.model.mpk.dto.MpkFileDTO">
            <id property="id" column="model_id"/>
            <result property="pyName" column="py_name"/>
        </collection>
    </resultMap>
 
    <select id="getPageList" resultMap="projectModel" resultType="com.iailab.module.model.mpk.dto.ProjectDTO">
        SELECT
            t1.id,
            t1.project_name,
            t1.project_code,
            t1.create_time,
            t2.model_id,
            t3.py_name
        FROM
            t_mpk_project t1
                LEFT JOIN t_mpk_project_model t2 on t1.id = t2.project_id
                LEFT JOIN t_mpk_file t3 ON t2.model_id = t3.id
        <where>
            <if test="params.projectName != null and params.projectName != ''">
                and t1.project_name like CONCAT('%',#{params.projectName},'%')
            </if>
            <if test="params.projectCode != null and params.projectCode != ''">
                and t1.project_code like CONCAT('%',#{params.projectCode},'%')
            </if>
        </where>
        order by t1.create_time desc
    </select>
</mapper>