RoleAccountRelationMapper.xml 5 KB
<?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.glsx.merchants.mapper.RoleAccountRelationMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.merchants.entity.RoleAccountRelation">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="role_id" jdbcType="INTEGER" property="roleId"/>
        <result column="accounttype_id" jdbcType="INTEGER" property="accounttypeId"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
        <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
        <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
    </resultMap>
    <resultMap id="ResultMap" type="cn.com.glsx.merchants.model.response.RoleAccountRelationResponse">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="role_id" jdbcType="INTEGER" property="roleId"/>
        <result column="accounttype_id" jdbcType="INTEGER" property="accounttypeId"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
        <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
    </resultMap>
    <sql id="Base_Column_List">
    id, role_id, accounttype_id, created_by, created_time, updated_by, updated_time,
    del_flag
  </sql>
    <delete id="deleteByRoleId" parameterType="java.lang.Integer">
    update platform_merchant_role_accounttype_relation set del_flag = -1
    where 1 = 1 and role_id = #{roleId,jdbcType=INTEGER}
  </delete>
    <insert id="batchInsert" parameterType="map">
        insert into platform_merchant_role_accounttype_relation
        (id, role_id, accounttype_id, created_by, created_time, updated_by, updated_time,
        del_flag)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.id,jdbcType=INTEGER}, #{item.roleId,jdbcType=INTEGER}, #{item.accounttypeId,jdbcType=INTEGER},
            #{item.createdBy,jdbcType=INTEGER}, #{item.createdTime,jdbcType=TIMESTAMP},
            #{item.updatedBy,jdbcType=INTEGER},
            #{item.updatedTime,jdbcType=TIMESTAMP}, #{item.delFlag,jdbcType=TINYINT})
        </foreach>
    </insert>
    <select id="selectByCondition" resultMap="ResultMap"
            parameterType="cn.com.glsx.merchants.model.request.RoleAccountRelationRequest">
        select
        <include refid="Base_Column_List"/>
        from platform_merchant_role_accounttype_relation
        where del_flag = 0
        <if test="obj.roleId != null">
            and role_id = #{obj.roleId,jdbcType=INTEGER}
        </if>
        <if test="obj.accounttypeId != null">
            and accounttype_id = #{obj.accounttypeId,jdbcType=INTEGER}
        </if>
    </select>
    <select id="selectByRoleId" resultType="java.lang.Integer"
            parameterType="java.lang.Integer">
    select id from platform_merchant_role_accounttype_relation
    where del_flag = 0 and role_id = #{roleId,jdbcType=INTEGER}
  </select>
    <select id="selectByMerchantIds"
            resultType="cn.com.glsx.merchants.model.response.RoleAccountRelationResponse">
        select
        t1.*
        from platform_merchant_role_accounttype_relation t1
        left join platform_merchant_role t2 on t1.role_id=t2.id
        left join platform_merchant_role_function_relation t3 on t1.id=t3.role_accounttype_id
        where t1.del_flag = 0 and t2.del_flag=0 and t3.del_flag=0
        <if test="obj.accounttypeId != null">
            and t1.accounttype_id = #{obj.accounttypeId,jdbcType=INTEGER}
        </if>
        <if test="obj.productId != null">
            and t3.product_id = #{obj.productId,jdbcType=INTEGER}
        </if>
        <if test="obj.merchantIds != null">
            and t2.merchant_id in
            <foreach collection="obj.merchantIds" item="item" index="index"
                     open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        group by t1.id
    </select>

    <select id="findIdByRoleIds" resultType="java.lang.Integer">
        select id from platform_merchant_role_accounttype_relation where del_flag = 0 and role_id in
        <foreach collection="roleIds" item="item" index="index"
                 open="(" close=")" separator=",">
            #{item}
        </foreach>
    </select>

    <select id="findIdsByAccountIds" resultType="java.lang.Integer">
        select id from platform_merchant_role_accounttype_relation where del_flag = 0 and accounttype_id in
        <foreach collection="accountTypeIds" item="item" index="index"
                 open="(" close=")" separator=",">
            #{item}
        </foreach>
    </select>
</mapper>