<?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.moral.mapper.AccountRoleMapper">
|
|
<resultMap id="ResultMap" type="com.moral.entity.AccountRole" >
|
<id column="id" property="id" jdbcType="INTEGER" />
|
<result column="account_id" property="accountId" jdbcType="INTEGER" />
|
<result column="role_id" property="roleId" jdbcType="INTEGER" />
|
</resultMap>
|
|
<resultMap id="BaseResultMap" type="com.moral.entity.AccountRole" extends="ResultMap">
|
<association property="account" javaType="com.moral.entity.Account">
|
<result column="account_id" jdbcType="INTEGER" property="id" />
|
<result column="account_name" jdbcType="VARCHAR" property="accountName" />
|
</association>
|
<association property="role" javaType="com.moral.entity.Role">
|
<result column="role_id" property="id" jdbcType="INTEGER" />
|
<result column="role_name" property="roleName" jdbcType="VARCHAR" />
|
</association>
|
</resultMap>
|
|
<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="getAccountRoleList" resultMap="BaseResultMap">
|
select
|
ar.*,
|
a.account_name,
|
r.role_name
|
from account_role ar
|
left join account a on ar.account_id = a.id
|
left join role r on ar.role_id = r.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.AccountRole" >
|
update account_role
|
set account_id = #{accountId,jdbcType=INTEGER},
|
role_id = #{roleId,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
</update>
|
|
<delete id="deleteByPrimaryKeyOwn" parameterType="java.lang.Integer" >
|
delete from account_role
|
where id = #{id,jdbcType=INTEGER}
|
</delete>
|
|
</mapper>
|