“djh”
2 天以前 45c3b7aacf3d20e1915e597152ad30a3b40377a2
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
<?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.ItemMapper">
    <insert id="insertItemUser">
        INSERT INTO `item_user` ( `item_id`, `user_id`, `user_name`)
        VALUES
            <foreach collection="users" item="item" separator=",">
                ( #{item.itemId}, #{item.userId}, #{item.userName} )
            </foreach>
 
    </insert>
    <delete id="deleteItemUser">
        delete from item_user where item_id =#{id}
    </delete>
 
 
    <select id="selectItemList" resultType="com.gkhy.exam.system.domain.Item">
        SELECT
            `id`,
            `company_id`,
            `item_name`,
            `del_flag`,
            `create_by`,
            `create_time`,
            `update_by`,
            `update_time`
        FROM
            `item`
        where del_flag = 1
        <if test="companyId!=null">
            and company_id = #{companyId}
        </if>
    </select>
    <select id="selectItemListAll" resultType="com.gkhy.exam.system.domain.Item">
        SELECT
            i.`id`,
            i.`company_id`,
            i.`item_name`,
            i.`del_flag`,
            i.`create_by`,
            i.`create_time`,
            i.`update_by`,
            i.`update_time`
        FROM
            `item` i
            LEFT JOIN item_user iu ON i.id = iu.item_id
        WHERE
            i.del_flag = 1
            <if test="companyId!=null">
                and i.company_id = #{companyId}
            </if>
            <if test="userId!=null">
                and iu.user_id = #{userId}
            </if>
        GROUP BY
            i.id
 
    </select>
    <select id="selectItemUser" resultType="com.gkhy.exam.system.domain.ItemUser">
        SELECT
            iu.`id`,
            iu.`item_id`,
            iu.`user_id`,
            su.`name` as user_name,
            iu.`del_flag`
        FROM
            `item_user` iu
        left join sys_user su on iu.user_id = su.id
        where item_id = #{itemId}
    </select>
</mapper>