heheng
4 天以前 4a91f037d3488ed7bc00664e1acc004810651f43
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?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.gkhy.exam.system.mapper.CatalogueMapper">
    <insert id="insertCatalogueData" keyProperty="id" useGeneratedKeys="true">
        INSERT INTO  `catalogue_data`
            (  `company_id`, `catalogue_id`, `content`, `analysis`,  `create_by`, `create_time` )
        VALUES
            ( #{companyId}, #{catalogueId}, #{content}, #{analysis}, #{createBy}, #{createTime} )
    </insert>
 
    <insert id="insertCatalogueDataFile">
        INSERT INTO `train_exam`.`catalogue_data_file`
            ( `catalogue_id`,`company_id`, `name`, `file_path`,`file_name`, `type`, `create_by`, `create_time` )
        VALUES
            ( #{catalogueId},#{companyId}, #{name}, #{filePath},#{fileName}, #{type}, #{createBy}, #{createTime} )
    </insert>
 
    <update id="updateCatalogueData">
        UPDATE `catalogue_data`
        <set>
            <if test="companyId!=null">
                `company_id` = #{companyId},
            </if>
            <if test="catalogueId!=null">
                `catalogue_id` = #{catalogueId},
            </if>
            <if test="content!=null and content!=''">
                `content` = #{content},
            </if>
            <if test="analysis!=null and analysis!=''">
                `analysis` = #{analysis},
            </if>
            <if test="delFlag!=null and delFlag!=''">
                `del_flag` = #{delFlag},
            </if>
            <if test="updateBy!=null and updateBy!=''">
                `update_by` = #{updateBy},
            </if>
            <if test="updateTime!=null">
                `update_time` = #{updateTime}
            </if>
        </set>
        WHERE
            `id` = #{id}
    </update>
    <update id="updateCatalogueDataFile">
            UPDATE `catalogue_data_file`
            <set>
                <if test="catalogueId!=null">
                    `catalogue_id` = #{catalogueId},
                </if>
                <if test="companyId!=null">
                    `company_id` = #{companyId},
                </if>
                <if test="name!=null">
                    `name` = #{name},
                </if>
                <if test="filePath!=null">
                    `file_path` = #{filePath},
                </if>
                <if test="fileName!=null">
                    `file_name` = #{fileName},
                </if>
                <if test="type!=null">
                    `type` = #{type},
                </if>
                <if test="delFlag != null and delFlag != ''" >
                    del_flag = #{delFlag},
                </if>
                <if test="updateBy != null" >
                    update_by = #{updateBy},
                </if>
                <if test="updateTime != null" >
                    update_time = #{updateTime}
                </if>
            </set>
            where id = #{id}
    </update>
    <update id="updateCatalogueDataFileByCompanyId">
        UPDATE catalogue_data_file set del_flag = #{delFlag} ,update_by = #{updateBy} , update_time=#{updateTime} where company_id =#{companyId} and catalogue_id = #{catalogueId}
    </update>
 
    <select id="selectCatalogueList" resultType="com.gkhy.exam.system.domain.vo.CatalogueVo">
        SELECT
            `id`,
            `parent_id`,
            `number`,
            `mess`,
            `type`,
            `del_flag`,
            `create_by`,
            `create_time`,
            `update_by`,
            `update_time`
        FROM
            catalogue
        WHERE del_flag = 1
          <if test="type!=null">
              and type = #{type}
          </if>
        ORDER BY create_time ASC
    </select>
    <select id="selectCatalogueDataList" resultType="com.gkhy.exam.system.domain.vo.CatalogueDataVo">
        SELECT
            cd.`id`,
            cd.`company_id`,
            sc.name,
            cd.`catalogue_id`,
            cd.`content`,
            cd.`analysis`,
            cd.`del_flag`,
            cd.`create_by`,
            cd.`create_time`,
            cd.`update_by`,
            cd.`update_time`
        FROM
            catalogue_data cd
        left join sys_company sc on cd.company_id = sc.id
        WHERE
            cd.del_flag = 1
          <if test="catalogueId!=null">
              and cd.catalogue_id = #{catalogueId}
          </if>
        <if test="companyId!=null">
            and cd.company_id = #{companyId}
        </if>
    </select>
    <select id="selectCatalogueDataFile" resultType="com.gkhy.exam.system.domain.CatalogueDataFile">
        SELECT
            id,
            `catalogue_data_id`,
            company_id,
            catalogue_id,
            `name`,
            `file_path`,
            file_name,
            `type`,
            `create_by`,
            `create_time`
        FROM
            catalogue_data_file
        WHERE
            company_id = #{companyId} and catalogue_id = #{catalogueId} and del_flag =1
    </select>
    <select id="selectByCompanyId" resultType="com.gkhy.exam.system.domain.CatalogueData">
        SELECT
            `id`,
            `company_id`,
            `catalogue_id`,
            `content`,
            `analysis`,
            `del_flag`,
            `create_by`,
            `create_time`,
            `update_by`,
            `update_time`
        FROM
            catalogue_data
        where company_id = #{companyId} and del_flag = 1 and catalogue_id = #{catalogueId}
 
    </select>
    <select id="selectCatalogueDataById" resultType="com.gkhy.exam.system.domain.CatalogueData">
        SELECT
            `id`,
            `company_id`,
            `catalogue_id`,
            `content`,
            `analysis`,
            `del_flag`,
            `create_by`,
            `create_time`,
            `update_by`,
            `update_time`
        FROM
            catalogue_data where del_flag = 1 and id=#{catalogueDataId}
    </select>
</mapper>