Permana
2018-10-02 2429c55948869951cf10ffea42e8b79054e93068
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
<?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="id.co.accessmobile.carrier.billing.unipin.cstools.database.repository.MonitoringUserMapper">
 
    <resultMap id="user" type="id.co.accessmobile.carrier.billing.unipin.cstools.database.model.MonitoringUser">
        <result property="id"                 column="id"/>
        <result property="username"         column="user_name"/>
    </resultMap>
 
    <select id="selectForTechnicalUser"  resultMap="user">
        SELECT
          user.id,
          user.user_name
        FROM
          db_unipin_cs_tools.tbl_monitoring_user as user ,
          db_unipin_cs_tools.tbl_monitoring_user_rules as rules
        WHERE
          user.id=rules.id AND
          rules.rule='TECHNICAL'
    </select>
    <select id="selectForAdminUser"  resultMap="user">
        SELECT
        user.id,
        user.user_name
        FROM
        db_unipin_cs_tools.tbl_monitoring_user as user ,
        db_unipin_cs_tools.tbl_monitoring_user_rules as rules
        WHERE
        user.id=rules.id AND
        rules.rule='ADMIN'
    </select>
 
    <insert id="insertNewUser" parameterType="String">
        INSERT  INTO
          tbl_monitoring_user
        values
          (#{chatID},#{username},#{chatID})
    </insert>
 
    <select id="insertUserRule" parameterType="String" resultMap="user">
        INSERT  INTO
        tbl_monitoring_user_rules
        values
        (#{chatID},#{rule})
    </select>
    <select id="isAdmin" parameterType="String" resultMap="user">
        SELECT
          id
        FROM
          tbl_monitoring_user_rules
        WHERE
          id=#{id} AND
          rule='ADMIN'
    </select>
    <select id="isTechnical" parameterType="String" resultMap="user">
        SELECT
        id
        FROM
        tbl_monitoring_user_rules
        WHERE
        id=#{id} AND
        rule='TECHNICAL'
    </select>
 
    <select id="findByID" parameterType="String" resultMap="user">
        SELECT * from tbl_monitoring_user where id=#{id}
    </select>
</mapper>