liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
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
<?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="cn.com.basic.role.entity.SysRoleOrganization">
 
    <resultMap id="BaseResultMap" type="cn.com.basic.role.entity.SysRoleOrganization">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="role_id" property="roleId" jdbcType="VARCHAR"/>
        <result column="organization_id" property="organizationId" jdbcType="VARCHAR"/>
        <result column="is_valid" property="isValid" jdbcType="TINYINT"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="update_user_id" property="updateUserId" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
    id, role_id, organization_id, is_valid, update_time, update_user_id
  </sql>
 
    <sql id="Base_Where_Clause">
        <where>
            <trim prefixOverrides="and">
                <if test="id != null">and ID = #{id}</if>
                <if test="roleId != null">
                    and role_id = #{roleId,jdbcType=VARCHAR}
                </if>
                <if test="organizationId != null">
                    and organization_id = #{organizationId,jdbcType=VARCHAR}
                </if>
                <if test="isValid != null">
                    and is_valid = #{isValid,jdbcType=TINYINT}
                </if>
                <if test="updateTime != null">
                    and update_time = #{updateTime,jdbcType=TIMESTAMP}
                </if>
                <if test="updateUserId != null">
                    and update_user_id = #{updateUserId,jdbcType=VARCHAR}
                </if>
            </trim>
        </where>
        <if test="sorting != null">order by ${sorting}</if>
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </sql>
 
    <!-- 查询总数 -->
    <select id="selectCount" resultType="java.lang.Long" parameterType="java.util.Map">
        select count(ID)
        from re_sys_role_organization
        <include refid="Base_Where_Clause"/>
    </select>
 
    <!-- 查询 -->
    <select id="select" resultMap="BaseResultMap" parameterType="java.util.Map">
        select
        <include refid="Base_Column_List"/>
        from re_sys_role_organization
        <include refid="Base_Where_Clause"/>
    </select>
    <!-- 根据ID删除-->
    <delete id="deleteById" parameterType="java.lang.String">
    delete from
    re_sys_role_organization
    where ID = #{id}
  </delete>
 
    <delete id="delete" parameterType="java.util.Map">
        update re_sys_role_organization
        set is_valid=0
        <include refid="Base_Where_Clause"/>
    </delete>
    <!-- 根据ID查询 -->
    <select id="selectById" resultMap="BaseResultMap" parameterType="java.lang.String">
        select
        <include refid="Base_Column_List"/>
        from re_sys_role_organization
        where ID = #{id}
    </select>
    <!-- 添加 -->
    <insert id="insert" parameterType="cn.com.basic.role.entity.SysRoleOrganization">
    insert into re_sys_role_organization (id, role_id, organization_id,
      is_valid, update_time, update_user_id
      )
    values (#{id,jdbcType=VARCHAR}, #{roleId,jdbcType=VARCHAR}, #{organizationId,jdbcType=VARCHAR},
      #{isValid,jdbcType=TINYINT}, #{updateTime,jdbcType=TIMESTAMP}, #{updateUserId,jdbcType=VARCHAR}
      )
  </insert>
 
    <!-- 通过ID更新 -->
    <update id="updateByIdSelective" parameterType="cn.com.basic.role.entity.SysRoleOrganization">
        update re_sys_role_organization
        <set>
            <if test="roleId != null">
                role_id = #{roleId,jdbcType=VARCHAR},
            </if>
            <if test="organizationId != null">
                organization_id = #{organizationId,jdbcType=VARCHAR},
            </if>
            <if test="isValid != null">
                is_valid = #{isValid,jdbcType=TINYINT},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateUserId != null">
                update_user_id = #{updateUserId,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=VARCHAR}
    </update>
 
    <!-- 根据IDs删除 -->
    <delete id="deleteByIds">
        delete from
        re_sys_role_organization
        where
        <foreach collection="array" item="id" open="id in (" close=")" separator=",">
            '${id}'
        </foreach>
    </delete>
</mapper>