MonitorCompanyMapper.xml 8.9 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="com.ruoyi.web.controller.business.mapper.MonitorCompanyMapper">

    <resultMap type="com.ruoyi.web.controller.business.domain.MonitorCompany" id="MonitorCompanyResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="userId"    />
        <result property="companyId" column="company_id"/>
        <result property="ename"    column="ename"    />
        <result property="lrName"    column="lr_name"    />
        <result property="regStatus"    column="reg_status"    />
        <result property="regCapital"    column="reg_capital"    />
        <result property="establishDate"    column="establish_date"    />
        <result property="creditCode"    column="credit_code"    />
        <result property="monitorStatus"    column="monitor_status"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="createTime"    />
        <result property="updateTime"    column="updateTime"    />
    </resultMap>

    <sql id="selectMonitorCompanyVo">
        select id, userId, company_id ,ename, lr_name, reg_status, reg_capital, establish_date,  credit_code, monitor_status, status, createTime, updateTime from monitor_company
    </sql>

    <select id="selectMonitorCompanyList" parameterType="com.ruoyi.web.controller.business.domain.MonitorCompany" resultMap="MonitorCompanyResult">
        <include refid="selectMonitorCompanyVo"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="userId != null  and userId != '' "> and userId = #{userId}</if>
            <if test="ename != null  and ename != '' ">
                <bind name="ename" value=" '%'+ename+'%'"/>
                and ename like #{ename}
            </if>
            <if test="companyId != null and companyId !='' ">and company_id = #{companyId}</if>
            <if test="lrName != null  and lrName != '' "> and lr_name = #{lrName}</if>
            <if test="regStatus != null  and regStatus != '' "> and reg_status = #{regStatus}</if>
            <if test="regCapital != null  and regCapital != '' "> and reg_capital = #{regCapital}</if>
            <if test="establishDate != null  and establishDate != '' "> and establish_date = #{establishDate}</if>
            <if test="creditCode != null  and creditCode != '' "> and credit_code = #{creditCode}</if>
            <if test="monitorStatus != null  and monitorStatus != '' "> and monitor_status = #{monitorStatus}</if>
            <if test="status != null  and status != '' "> and status = #{status}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="updateTime != null "> and updateTime = #{updateTime}</if>
        </where>
    </select>

    <select id="selectMonitorCompanyById" parameterType="Integer" resultMap="MonitorCompanyResult">
        <include refid="selectMonitorCompanyVo"/>
        where id = #{id}
    </select>
    <select id="selectMonitorByUserId"
            resultType="com.ruoyi.web.controller.business.domain.MonitorCompany">
        SELECT
            *
        FROM
            monitor_company
        WHERE
            userId = #{userId} AND monitor_status = '0'
    </select>
    <select id="selectMonitorAuthorityList"
            resultType="com.ruoyi.web.controller.business.domain.MonitorCompanyVo">
        SELECT
        com.id as id,
        fu.userName as userName,
        fu.org_id as orgId,
        com.ename as ename,
        com.lr_name as lrName,
        com.reg_status as regStatus,
        com.reg_capital as regCapital,
        com.credit_code as creditCode,
        com.establish_date as establishDate
        FROM
        monitor_company   com
        LEFT JOIN org_dept od  ON com.company_id = od.dept_id
        LEFT JOIN front_user fu on com.userId=fu.id
        where od.org_id=#{orgId}
        <if test="ename != null and ename != '' " >
            AND  com.ename  like concat('%', #{ename}, '%')
        </if>
        <if test="status != null and status != '' " >
            AND com.status = #{status}
        </if>
        <if test="monitorStatus != null and monitorStatus != '' " >
            AND com.monitor_status = #{monitorStatus}
        </if>
    </select>

    <select id="getMonitorCompanySearchCount" parameterType="String" resultType="java.lang.Long">
        SELECT
            COUNT( id )
        FROM
            monitor_company
        WHERE
            monitor_status = 0
          AND `status` = 0
          AND  userId = #{id}
    </select>

    <insert id="insertMonitorCompany" parameterType="com.ruoyi.web.controller.business.domain.MonitorCompany" useGeneratedKeys="true" keyProperty="id">
        insert into monitor_company
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null  and userId != ''  ">userId,</if>
            <if test="ename != null  and ename != ''  ">ename,</if>
            <if test="companyId != null and companyId !='' ">company_id,</if>
            <if test="lrName != null  and lrName != ''  ">lr_name,</if>
            <if test="regStatus != null  and regStatus != ''  ">reg_status,</if>
            <if test="regCapital != null  and regCapital != ''  ">reg_capital,</if>
            <if test="establishDate != null  and establishDate != ''  ">establish_date,</if>
            <if test="creditCode != null  and creditCode != ''  ">credit_code,</if>
            <if test="monitorStatus != null  and monitorStatus != ''  ">monitor_status,</if>
            <if test="status != null  and status != ''  ">status,</if>
            <if test="createTime != null  ">createTime,</if>
            <if test="updateTime != null  ">updateTime,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null  and userId != ''  ">#{userId},</if>
            <if test="ename != null  and ename != ''  ">#{ename},</if>
            <if test="companyId != null and companyId !='' ">#{companyId},</if>
            <if test="lrName != null  and lrName != ''  ">#{lrName},</if>
            <if test="regStatus != null  and regStatus != ''  ">#{regStatus},</if>
            <if test="regCapital != null  and regCapital != ''  ">#{regCapital},</if>
            <if test="establishDate != null  and establishDate != ''  ">#{establishDate},</if>
            <if test="creditCode != null  and creditCode != ''  ">#{creditCode},</if>
            <if test="monitorStatus != null  and monitorStatus != ''  ">#{monitorStatus},</if>
            <if test="status != null  and status != ''  ">#{status},</if>
            <if test="createTime != null  ">#{createTime},</if>
            <if test="updateTime != null  ">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateMonitorCompany" parameterType="com.ruoyi.web.controller.business.domain.MonitorCompany">
        update monitor_company
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null  and userId != ''  ">userId = #{userId},</if>
            <if test="ename != null  and ename != ''  ">ename = #{ename},</if>
            <if test="companyId != null and companyId !='' ">company_id = #{companyId}</if>
            <if test="lrName != null  and lrName != ''  ">lr_name = #{lrName},</if>
            <if test="regStatus != null  and regStatus != ''  ">reg_status = #{regStatus},</if>
            <if test="regCapital != null  and regCapital != ''  ">reg_capital = #{regCapital},</if>
            <if test="establishDate != null  and establishDate != ''  ">establish_date = #{establishDate},</if>
            <if test="creditCode != null  and creditCode != ''  ">credit_code = #{creditCode},</if>
            <if test="monitorStatus != null  and monitorStatus != ''  ">monitor_status = #{monitorStatus},</if>
            <if test="status != null  and status != ''  ">status = #{status},</if>
            <if test="createTime != null  ">createTime = #{createTime},</if>
            <if test="updateTime != null  ">updateTime = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMonitorCompanyById" parameterType="Integer">
        delete from monitor_company where id = #{id}
    </delete>

    <delete id="deleteMonitorCompanyByIds" parameterType="String">
        delete from monitor_company where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <update id="updateMonitorStatus" parameterType="String">
        update monitor_company set monitor_status='1',updateTime=now() where userId=#{userId} and ename = #{ename}
    </update>

    <update id="updateMonitorCode" parameterType="com.ruoyi.web.controller.business.domain.MonitorCompany">
        update monitor_company set monitor_status='0',updateTime=now() where userId=#{userId} and ename = #{ename}
    </update>
</mapper>