潘志宝
2024-09-12 27e7299964b861c079dbb2826edab00dfd6dc27d
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?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.MpkFileDao">
 
    <resultMap id="mpkFile" type="com.iailab.module.model.mpk.dto.MpkFileDTO">
        <id property="id" column="id"/>
        <result property="pyName" column="py_name"/>
        <result property="filePath" column="file_path"/>
        <result property="pkgName" column="pkg_name"/>
        <result property="className" column="class_name"/>
        <result property="pyModule" column="py_module"/>
        <result property="remark" column="remark"/>
        <result property="creator" column="creator"/>
        <result property="createDate" column="create_date"/>
        <result property="updater" column="updater"/>
        <result property="updateDate" column="update_date"/>
        <collection property="modelMethods" ofType="com.iailab.module.model.mpk.entity.ModelMethodEntity">
            <id property="id" column="method_id"/>
            <result property="methodName" column="method_name"/>
            <result property="dataLength" column="data_length"/>
            <result property="model" column="model"/>
        </collection>
    </resultMap>
 
    <select id="get" resultMap="mpkFile">
        SELECT
            a.*,
            b.id method_id,
            b.method_name,
            b.data_length,
            b.model
        FROM
            t_mpk_file a
            LEFT JOIN t_mpk_model_method b ON a.id = b.mpk_file_id
        WHERE a.id = #{id}
    </select>
    <select id="selectByIds" resultMap="mpkFile">
        SELECT
            a.*,
            b.id method_id,
            b.method_name,
            b.data_length,
            b.model
        FROM
            t_mpk_file a
                LEFT JOIN t_mpk_model_method b ON a.id = b.mpk_file_id
        WHERE a.id in
        <foreach collection="ids" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
    </select>
    <select id="getProjectModelCount" resultType="java.lang.Integer" parameterType="java.lang.String">
        SELECT
            count(*)
        FROM
            t_mpk_project_model
        WHERE
            project_id = #{projectId}
    </select>
    <select id="getProjectModel" resultMap="mpkFile">
        SELECT
            t3.*,t4.method_name,t4.data_length,t4.model
        FROM
            (
                SELECT
                    t2.id,
                    t2.py_name,
                    t2.pkg_name,
                    t2.py_module,
                    t2.remark,
                    t2.create_date
                FROM
                    t_mpk_project_model t1
                        LEFT JOIN t_mpk_file t2 ON t1.model_id = t2.id
                WHERE
                    t1.project_id = #{params.projectId}
                    <if test="params.pyName != null and params.pyName != ''">
                        AND t2.py_name LIKE CONCAT('%',#{params.pyName},'%')
                    </if>
                ORDER BY
                    t2.create_date DESC
                    LIMIT #{params.offset},#{params.pageSize}
            ) t3
                LEFT JOIN t_mpk_model_method t4 ON t3.id = t4.mpk_file_id
    </select>
</mapper>