TSafeRiskOwner.xml 3.73 KB
Newer Older
Rensq's avatar
Rensq committed
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
<?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.testor.ddd.safetyControl.infrastructure.repository.riskOwner.dao.TSafeRiskOwnerDao">
    <!-- 开启二级缓存 -->
    <!-- <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> -->
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.testor.ddd.safetyControl.infrastructure.repository.riskOwner.entity.TSafeRiskOwnerDO">
        <id column="id" property="id"/>
        <id column="risk_id" property="riskId"/>
        <id column="user_id" property="userId"/>
        <id column="org_id" property="orgId"/>
        <id column="department_id" property="departmentId"/>
        <id column="type" property="type"/>
    </resultMap>

    <sql id="select_base_column">
        rs.id, rs.risk_id riskId, rs.user_id userId, rs.org_id orgId, rs.department_id departmentId,rs.type,
        rs.status, rs.remarks, rs.create_by createBy, rs.create_date createDate,
        rs.update_by as updateBy, rs.update_date updateDate
    </sql>

    <sql id="common_where_if">
        <if test="query.id!=null and query.id!=''">
            and rs.id=#{query.id}
        </if>
        <if test="query.orgId!=null and query.orgId!=''">
            and rs.org_id=#{query.orgId}
        </if>
        <if test="query.departmentId!='' and query.departmentId!=null">
            and rs.department_id=#{query.departmentId}
        </if>
        <if test="query.riskId!='' and query.riskId!=null">
            and rs.risk_id=#{query.riskId}
        </if>
        <if test="query.type!='' and query.type!=null">
            and rs.type=#{query.type}
        </if>
        <if test="query.userId!='' and query.userId!=null">
            and rs.user_id=#{userId}
        </if>
    </sql>

    <select id="listPage" resultType="com.testor.ddd.safetyControl.interfaces.model.vo.riskOwner.TSafeRiskOwnerVO"
            parameterType="com.testor.ddd.safetyControl.interfaces.model.dto.riskOwner.TSafeRiskOwnerDTOParam">
        select so.org_name as orgName,dpo.org_name as departmentName,
        su.user_name as userName,
        <include refid="select_base_column" />
        from t_safe_risk_owner rs
        left join t_sys_user su on rs.user_id = su.user_id
        left join t_sys_org so on so.org_id = rs.org_id
        left join t_sys_org dpo on dpo.org_id = rs.department_id
        <where>
            rs.status = '0'
            <include refid="common_where_if"></include>
            <if test="query.userName!='' and query.userName!=null">
                and su.user_name like concat('%',#{userName},'%')
            </if>
        </where>
        <if test="query.orderBy!='' and query.orderBy!=null and query.orderType!='' and query.orderType!=null" >
            order by ${query.orderBy} ${query.orderType}
        </if>

    </select>
    <select id="listAll"
            resultType="com.testor.ddd.safetyControl.interfaces.model.vo.riskOwner.TSafeRiskOwnerVO"
            parameterType="com.testor.ddd.safetyControl.interfaces.model.dto.riskOwner.TSafeRiskOwnerDTOParam">
        select so.org_name as orgName,dpo.org_name as departmentName,
        su.user_name as userName,
        <include refid="select_base_column" />
        from t_safe_risk_owner rs
        left join t_sys_user su on rs.user_id = su.user_id
        left join t_sys_org so on so.org_id = rs.org_id
        left join t_sys_org dpo on dpo.org_id = rs.department_id
        <where>
            rs.status = '0'
            <include refid="common_where_if"></include>
            <if test="query.userName!='' and query.userName!=null">
                and su.user_name like concat('%',#{userName},'%')
            </if>
        </where>
    </select>
</mapper>