kongzy
2024-07-05 14821e28286d773ad5ff2c13510e39c5eb117daf
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
<?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.ExCourseMapper">
    <resultMap type="com.gkhy.exam.system.domain.ExCourse" id="ExCourseResult">
        <result property="id"       column="id"       />
        <result property="name"    column="name"    />
        <result property="categoryId"     column="category_id"     />
        <result property="status"         column="status"          />
        <result property="sort"         column="sort"          />
        <result property="logo"         column="logo"          />
        <result property="introduce"         column="introduce"          />
        <result property="state"         column="state"          />
        <result property="delFlag"         column="del_flag"          />
        <result property="companyId"         column="company_id"          />
        <result property="privatize"         column="privatize"          />
        <result property="period"         column="period"          />
        <result property="version"         column="version"          />
        <result property="createBy"       column="create_by"       />
        <result property="createTime"     column="create_time"     />
        <result property="updateBy"       column="update_by"       />
        <result property="updateTime"     column="update_time"     />
        <result property="remark"         column="remark"          />
        <result property="companyName"         column="company_name"          />
        <result property="categoryName"         column="category_name"          />
    </resultMap>
 
    <sql id="selectCourseVo">
        select a.id, a.name, a.category_id, a.status, a.logo,a.sort,a.introduce,a.state,a.company_id,
               a.privatize,a.period,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,b.name as company_name,c.name as category_name
        from ex_course a
        left join sys_company b on b.id=a.company_id
        left join sys_category c on c.id=a.category_id
    </sql>
 
    <update id="deleteByCourseId">
        update ex_course set de_flag=1 where id=#{courseId}
    </update>
 
    <select id="selectCourseList" resultMap="ExCourseResult">
        <include refid="selectCourseVo"/>
        <where>
            and a.del_flag=0
            <if test="name != null and name != ''">
                AND a.name like concat('%', #{name}, '%')
            </if>
            <if test="categoryId != null ">
                AND a.categoryId =#{categoryId}
            </if>
            <if test="status != null ">
                AND a.status =#{status}
            </if>
            <if test="state != null ">
                AND a.state =#{state}
            </if>
            <if test="privatize != null ">
                AND a.privatize =#{privatize}
            </if>
            <if test="companyId != null ">
                AND (a.company_id =#{companyId} or a.privatize=1)
            </if>
        </where>
        order by a.id desc
    </select>
 
    <select id="selectCourseById" resultMap="ExCourseResult">
        <include refid="selectCourseVo"/>
        where a.id=#{courseId}
    </select>
 
    <select id="checkNameUnique" resultType="com.gkhy.exam.system.domain.ExCourse">
        select id,name from ex_course where name=#{name} and company_id=#{companyId} and del_flag=0 limit 1
    </select>
 
    <select id="selectCourseState" resultType="java.lang.Integer">
        select state from ex_course where id=#{courseId}
    </select>
</mapper>