From a73c63037e6a5276ce6442873afc627e8cb2c9b0 Mon Sep 17 00:00:00 2001
From: ZhuDongming <773644075@qq.com>
Date: Fri, 18 Oct 2019 14:46:42 +0800
Subject: [PATCH] update
---
src/main/resources/mapper/RoleMapper.xml | 195 ++++++++++++++++++++++++------------------------
1 files changed, 99 insertions(+), 96 deletions(-)
diff --git a/src/main/resources/mapper/RoleMapper.xml b/src/main/resources/mapper/RoleMapper.xml
index a45d1c3..95334fb 100644
--- a/src/main/resources/mapper/RoleMapper.xml
+++ b/src/main/resources/mapper/RoleMapper.xml
@@ -2,107 +2,62 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.mapper.RoleMapper">
- <resultMap id="BaseResultMap" type="com.moral.entity.Role">
- <id column="id" property="id" jdbcType="INTEGER"/>
- <result column="role_code" property="roleCode" jdbcType="VARCHAR"/>
- <result column="role_name" property="roleName" jdbcType="VARCHAR"/>
- <result column="is_delete" property="isDelete" jdbcType="CHAR"/>
- <result column="role_remark" property="roleRemark" jdbcType="VARCHAR"/>
- <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
- <result column="create_user" property="createUser" jdbcType="VARCHAR"/>
- <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
- <result column="update_user" property="updateUser" jdbcType="VARCHAR"/>
+ <resultMap id="ResultMap" type="com.moral.entity.Role">
+ <id column="id" property="id" jdbcType="INTEGER" />
+ <result column="role_code" property="roleCode" jdbcType="VARCHAR" />
+ <result column="role_name" property="roleName" jdbcType="VARCHAR" />
+ <result column="channel_id" property="channelId" jdbcType="INTEGER" />
+ <result column="is_delete" property="isDelete" jdbcType="CHAR" />
+ <result column="role_remark" property="roleRemark" jdbcType="VARCHAR" />
+ <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
+ <result column="create_user" property="createUser" jdbcType="VARCHAR" />
+ <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
+ <result column="update_user" property="updateUser" jdbcType="VARCHAR" />
</resultMap>
- <sql id="Base_Column_List">
- id, role_code, role_name, is_delete, role_remark, create_time, create_user, update_time,
- update_user
+ <resultMap id="BaseResultMap" type="com.moral.entity.Role" extends="ResultMap">
+ <association property="channel" javaType="com.moral.entity.Channel">
+ <result column="channel_id" jdbcType="INTEGER" property="id" />
+ <result column="channel_name" jdbcType="VARCHAR" property="channelName" />
+ </association>
+ </resultMap>
+
+ <sql id="Base_Column_List" >
+ id, role_code, role_name, channel_id, is_delete, role_remark, create_time, create_user,
+ update_time, update_user
</sql>
- <insert id="insertSelective" parameterType="com.moral.entity.Role">
- insert into role
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id != null">
- id,
- </if>
- <if test="roleCode != null">
- role_code,
- </if>
- <if test="roleName != null">
- role_name,
- </if>
- <if test="isDelete != null">
- is_delete,
- </if>
- <if test="roleRemark != null">
- role_remark,
- </if>
- <if test="createTime != null">
- create_time,
- </if>
- <if test="createUser != null">
- create_user,
- </if>
- <if test="updateTime != null">
- update_time,
- </if>
- <if test="updateUser != null">
- update_user,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id != null">
- #{id,jdbcType=INTEGER},
- </if>
- <if test="roleCode != null">
- #{roleCode,jdbcType=VARCHAR},
- </if>
- <if test="roleName != null">
- #{roleName,jdbcType=VARCHAR},
- </if>
- <if test="isDelete != null">
- #{isDelete,jdbcType=CHAR},
- </if>
- <if test="roleRemark != null">
- #{roleRemark,jdbcType=VARCHAR},
- </if>
- <if test="createTime != null">
- #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="createUser != null">
- #{createUser,jdbcType=VARCHAR},
- </if>
- <if test="updateTime != null">
- #{updateTime,jdbcType=TIMESTAMP},
- </if>
- <if test="updateUser != null">
- #{updateUser,jdbcType=VARCHAR},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.moral.entity.Role">
- update role
- <set>
- <if test="roleName != null">
- role_name=#{roleName,jdbcType=VARCHAR},
- </if>
- <if test="roleCode != null">
- role_code=#{roleCode,jdbcType=VARCHAR},
- </if>
- <if test="roleRemark != null">
- role_remark=#{roleRemark,jdbcType=VARCHAR},
- </if>
- <if test="updateTime != null">
- update_time=#{updateTime,jdbcType=TIMESTAMP},
- </if>
- <if test="updateUser != null">
- update_user=#{updateUser,jdbcType=VARCHAR},
- </if>
- </set>
- where id = #{id,jdbcType=INTEGER}
- </update>
+ <sql id="Example_Where_Clause" >
+ <where >
+ <foreach collection="oredCriteria" item="criteria" separator="or" >
+ <if test="criteria.valid" >
+ <trim prefix="(" suffix=")" prefixOverrides="and" >
+ <foreach collection="criteria.criteria" item="criterion" >
+ <choose >
+ <when test="criterion.noValue" >
+ and ${criterion.condition}
+ </when>
+ <when test="criterion.singleValue" >
+ and ${criterion.condition} #{criterion.value}
+ </when>
+ <when test="criterion.betweenValue" >
+ and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+ </when>
+ <when test="criterion.listValue" >
+ and ${criterion.condition}
+ <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
+ #{listItem}
+ </foreach>
+ </when>
+ </choose>
+ </foreach>
+ </trim>
+ </if>
+ </foreach>
+ </where>
+ </sql>
- <select id="getRoleList" resultMap="BaseResultMap">
+ <select id="getRoleListByName" resultMap="ResultMap">
select
<include refid="Base_Column_List"/>
from role
@@ -112,4 +67,52 @@
</if>
</select>
+ <select id="getRoleList" resultMap="BaseResultMap">
+ select
+ r.*,
+ c.channel_name
+ from role r
+ left join channel c on r.channel_id = c.id
+ <if test="_parameter != null" >
+ <include refid="Example_Where_Clause" />
+ </if>
+ <if test="orderByClause != null" >
+ order by ${orderByClause}
+ </if>
+ </select>
+
+ <update id="updateByPrimaryKey" parameterType="com.moral.entity.Role" >
+ update role
+ <set >
+ <if test="roleCode != null" >
+ role_code = #{roleCode,jdbcType=VARCHAR},
+ </if>
+ <if test="roleName != null" >
+ role_name = #{roleName,jdbcType=VARCHAR},
+ </if>
+ <if test="channelId != null" >
+ channel_id = #{channelId,jdbcType=INTEGER},
+ </if>
+ <if test="isDelete != null" >
+ is_delete = #{isDelete,jdbcType=CHAR},
+ </if>
+ <if test="roleRemark != null" >
+ role_remark = #{roleRemark,jdbcType=VARCHAR},
+ </if>
+ <if test="createTime != null" >
+ create_time = #{createTime,jdbcType=TIMESTAMP},
+ </if>
+ <if test="createUser != null" >
+ create_user = #{createUser,jdbcType=VARCHAR},
+ </if>
+ <if test="updateTime != null" >
+ update_time = #{updateTime,jdbcType=TIMESTAMP},
+ </if>
+ <if test="updateUser != null" >
+ update_user = #{updateUser,jdbcType=VARCHAR},
+ </if>
+ </set>
+ where id = #{id,jdbcType=INTEGER}
+ </update>
+
</mapper>
\ No newline at end of file
--
Gitblit v1.8.0