<?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">
|
<!--
|
* @title: 客户角色菜单权限表
|
* @description: 自定义sql,请自行实现业务逻辑
|
* @company: hugeinfo
|
* @author: liyj
|
* @time:2024-08-19 20:04:19
|
* @version 1.0.0
|
-->
|
<mapper namespace="cn.huge.module.ctrole.dao.mapper.CtRolefunMapper">
|
<!-- 结果集 -->
|
<resultMap id="dataResult" type="cn.huge.module.ctrole.domain.po.CtRolefun">
|
<result property="id" column="id"/>
|
<result property="roleId" column="role_id"/>
|
<result property="powerId" column="power_id"/>
|
<result property="powerName" column="power_name"/>
|
<result property="powerTag" column="power_tag"/>
|
<result property="powerUrl" column="power_url"/>
|
<result property="powerIcon" column="power_icon"/>
|
<result property="powerType" column="power_type"/>
|
<result property="appClient" column="app_client"/>
|
<result property="parentId" column="parent_id"/>
|
<result property="custId" column="cust_id"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateTime" column="update_time"/>
|
</resultMap>
|
<!-- 表 -->
|
<sql id='table-name'>dyh_ct_rolefun</sql>
|
<!-- 字段 -->
|
<sql id="column-part">
|
id,
|
role_id,
|
power_id,
|
power_name,
|
power_tag,
|
power_url,
|
power_icon,
|
power_type,
|
app_client,
|
parent_id,
|
cust_id,
|
create_time,
|
update_time
|
</sql>
|
<!-- 更新实体字段 -->
|
<sql id="set-part">
|
<if test="entity.roleId != null">role_id = #{entity.roleId},</if>
|
<if test="entity.powerId != null">power_id = #{entity.powerId},</if>
|
<if test="entity.powerName != null">power_name = #{entity.powerName},</if>
|
<if test="entity.powerTag != null">power_tag = #{entity.powerTag},</if>
|
<if test="entity.powerUrl != null">power_url = #{entity.powerUrl},</if>
|
<if test="entity.powerIcon != null">power_icon = #{entity.powerIcon},</if>
|
<if test="entity.powerType != null">power_type = #{entity.powerType},</if>
|
<if test="entity.appClient != null">app_client = #{entity.appClient},</if>
|
<if test="entity.parentId != null">parent_id = #{entity.parentId},</if>
|
<if test="entity.custId != null">cust_id = #{entity.custId},</if>
|
<if test="entity.createTime != null">create_time = #{entity.createTime},</if>
|
<if test="entity.updateTime != null">update_time = #{entity.updateTime}</if>
|
</sql>
|
<!-- 条件 -->
|
<sql id="where-part">
|
<if test="terms != null">
|
<where>
|
<if test="terms.id != null and terms.id !=''">
|
and id = #{terms.id}
|
</if>
|
<if test="terms.roleId != null and terms.roleId !=''">
|
and role_id = #{terms.roleId}
|
</if>
|
<if test="terms.powerId != null and terms.powerId !=''">
|
and power_id = #{terms.powerId}
|
</if>
|
<if test="terms.powerName != null and terms.powerName !=''">
|
and power_name = #{terms.powerName}
|
</if>
|
<if test="terms.powerTag != null and terms.powerTag !=''">
|
and power_tag = #{terms.powerTag}
|
</if>
|
<if test="terms.powerUrl != null and terms.powerUrl !=''">
|
and power_url = #{terms.powerUrl}
|
</if>
|
<if test="terms.powerIcon != null and terms.powerIcon !=''">
|
and power_icon = #{terms.powerIcon}
|
</if>
|
<if test="terms.powerType != null and terms.powerType !=''">
|
and power_type = #{terms.powerType}
|
</if>
|
<if test="terms.appClient != null and terms.appClient !=''">
|
and app_client = #{terms.appClient}
|
</if>
|
<if test="terms.parentId != null and terms.parentId !=''">
|
and parent_id = #{terms.parentId}
|
</if>
|
<if test="terms.custId != null and terms.custId !=''">
|
and cust_id = #{terms.custId}
|
</if>
|
<if test="terms.createTime != null and terms.createTime !=''">
|
and DATE_FORMAT(create_time,'%Y-%m-%d') = #{terms.createTime}
|
</if>
|
<if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
|
and (DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.createStart}
|
and DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.createEnd})
|
</if>
|
<if test="terms.updateTime != null and terms.updateTime !=''">
|
and DATE_FORMAT(update_time,'%Y-%m-%d') = #{terms.updateTime}
|
</if>
|
<if test="terms.updateStart != null and terms.updateStart !='' and terms.updateEnd != null and terms.updateEnd !=''">
|
and (DATE_FORMAT(update_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.updateStart}
|
and DATE_FORMAT(update_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.updateEnd})
|
</if>
|
</where>
|
</if>
|
</sql>
|
<!-- 更新对象 -->
|
<update id="updateCtRolefun">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<where>
|
id = #{entity.id}
|
</where>
|
</update>
|
<!-- 条件更新对象 -->
|
<update id="updateCtRolefunTerms">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<include refid="where-part"/>
|
</update>
|
<!-- 根据编号物理删除 -->
|
<delete id="deleteCtRolefun">
|
delete from
|
<include refid="table-name" />
|
where id = #{id}
|
</delete>
|
<!-- 根据条件查询 -->
|
<select id="listTerms" resultMap="dataResult">
|
select
|
<include refid="column-part"/>
|
from
|
<include refid="table-name" />
|
<include refid="where-part"/>
|
</select>
|
<!-- 根据条件统计 -->
|
<select id="countTerms" resultType="java.lang.Long">
|
select
|
COUNT(1)
|
from
|
<include refid="table-name" />
|
<include refid="where-part"/>
|
</select>
|
<!-- 根据条件分页查询 -->
|
<select id="pageTerms" resultMap="dataResult">
|
SELECT
|
<include refid="column-part"/>
|
FROM
|
<include refid="table-name" />
|
<include refid="where-part"/>
|
<if test="page.sort != null">
|
<foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
|
isnull(${s.property}), ${s.property} ${s.direction}
|
</foreach>
|
</if>
|
<if test="page.sort == null">
|
order by isnull(create_time), create_time desc
|
</if>
|
limit #{page.offset}, #{page.size}
|
</select>
|
|
</mapper>
|