<?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.hzya.frame.sysnew.messageManageLog.dao.impl.SysMessageManageLogDaoImpl">

    <resultMap id="get-SysMessageManageLogEntity-result"
               type="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="messageManageId" column="message_manage_id" jdbcType="VARCHAR"/>
        <result property="theme" column="theme" jdbcType="VARCHAR"/>
        <result property="messageCode" column="message_code" jdbcType="VARCHAR"/>
        <result property="sendApp" column="send_app" jdbcType="VARCHAR"/>
        <result property="sendApi" column="send_api" jdbcType="VARCHAR"/>
        <result property="receiveCode" column="receive_code" jdbcType="VARCHAR"/>
        <result property="receiveApp" column="receive_app" jdbcType="VARCHAR"/>
        <result property="receiveApi" column="receive_api" jdbcType="VARCHAR"/>
        <result property="sourceData" column="source_data" jdbcType="VARCHAR"/>
        <result property="targetData" column="target_data" jdbcType="VARCHAR"/>
        <result property="returnData" column="return_data" jdbcType="VARCHAR"/>
        <result property="returnType" column="return_type" jdbcType="VARCHAR"/>
        <result property="errorStatus" column="error_status" jdbcType="VARCHAR"/>
        <result property="status" column="status" jdbcType="VARCHAR"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <result property="sorts" column="sorts" jdbcType="INTEGER"/>
        <result property="create_user_id" column="create_user_id" jdbcType="VARCHAR"/>
        <result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="modify_user_id" column="modify_user_id" jdbcType="VARCHAR"/>
        <result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
        <result property="sts" column="sts" jdbcType="VARCHAR"/>
        <result property="org_id" column="org_id" jdbcType="VARCHAR"/>
    </resultMap>
    <!-- 查询的字段-->
    <sql id="SysMessageManageLogEntity_Base_Column_List">
        id
       ,message_manage_id 
        ,theme 
        ,message_code 
        ,send_app 
        ,send_api 
        ,receive_code 
        ,receive_app 
        ,receive_api 
        ,source_data 
        ,target_data 
        ,return_data 
        ,return_type
        ,error_status
        ,status
        ,remark 
        ,sorts 
        ,create_user_id 
        ,create_time 
        ,modify_user_id 
        ,modify_time 
        ,sts 
        ,org_id 
     </sql>
    <!-- 查询 采用==查询 -->
    <select id="entity_list_base" resultMap="get-SysMessageManageLogEntity-result"
            parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">
        select
        <include refid="SysMessageManageLogEntity_Base_Column_List"/>
        from
        <choose>
            <when test=" status != null and status.trim() != '' and status == 3">
                sys_message_manage_log_success
            </when>
            <otherwise>
                sys_message_manage_log
            </otherwise>
        </choose>
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="messageManageId != null and messageManageId != ''">and message_manage_id = #{messageManageId}</if>
            <if test="theme != null and theme != ''">and theme = #{theme}</if>
            <if test="messageCode != null and messageCode != ''">and message_code = #{messageCode}</if>
            <if test="sendApp != null and sendApp != ''">and send_app = #{sendApp}</if>
            <if test="sendApi != null and sendApi != ''">and send_api = #{sendApi}</if>
            <if test="receiveCode != null and receiveCode != ''">and receive_code = #{receiveCode}</if>
            <if test="receiveApp != null and receiveApp != ''">and receive_app = #{receiveApp}</if>
            <if test="receiveApi != null and receiveApi != ''">and receive_api = #{receiveApi}</if>
            <if test="sourceData != null and sourceData != ''">and source_data = #{sourceData}</if>
            <if test="targetData != null and targetData != ''">and target_data = #{targetData}</if>
            <if test="returnData != null and returnData != ''">and return_data = #{returnData}</if>
            <if test="returnType != null and returnType != ''">and return_type = #{returnType}</if>
            <if test="errorStatus != null and errorStatus != ''">and error_status = #{errorStatus}</if>
            <if test="status != null and status != ''">and status = #{status}</if>
            <if test="remark != null and remark != ''">and remark = #{remark}</if>
            <if test="sorts != null">and sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
            <if test="create_time != null">and create_time = #{create_time}</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id = #{modify_user_id}</if>
            <if test="modify_time != null">and modify_time = #{modify_time}</if>
            <if test="sts != null and sts != ''">and sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
            and sts='Y'
        </trim>
        <if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
        <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
    </select>

    <!-- 查询符合条件的数量 -->
    <select id="entity_count" resultType="Integer"
            parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">
        select count(1) from sys_message_manage_log
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="messageManageId != null and messageManageId != ''">and message_manage_id = #{messageManageId}</if>
            <if test="theme != null and theme != ''">and theme = #{theme}</if>
            <if test="messageCode != null and messageCode != ''">and message_code = #{messageCode}</if>
            <if test="sendApp != null and sendApp != ''">and send_app = #{sendApp}</if>
            <if test="sendApi != null and sendApi != ''">and send_api = #{sendApi}</if>
            <if test="receiveCode != null and receiveCode != ''">and receive_code = #{receiveCode}</if>
            <if test="receiveApp != null and receiveApp != ''">and receive_app = #{receiveApp}</if>
            <if test="receiveApi != null and receiveApi != ''">and receive_api = #{receiveApi}</if>
            <if test="sourceData != null and sourceData != ''">and source_data = #{sourceData}</if>
            <if test="targetData != null and targetData != ''">and target_data = #{targetData}</if>
            <if test="returnData != null and returnData != ''">and return_data = #{returnData}</if>
            <if test="returnType != null and returnType != ''">and return_type = #{returnType}</if>
            <if test="errorStatus != null and errorStatus != ''">and error_status = #{errorStatus}</if>
            <if test="status != null and status != ''">and status = #{status}</if>
            <if test="remark != null and remark != ''">and remark = #{remark}</if>
            <if test="sorts != null">and sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
            <if test="create_time != null">and create_time = #{create_time}</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id = #{modify_user_id}</if>
            <if test="modify_time != null">and modify_time = #{modify_time}</if>
            <if test="sts != null and sts != ''">and sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
            and sts='Y'
        </trim>
        <if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
        <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
    </select>

    <!-- 分页查询列表 采用like格式 -->
    <select id="entity_list_like" resultMap="get-SysMessageManageLogEntity-result"
            parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">
        select
        <include refid="SysMessageManageLogEntity_Base_Column_List"/>
        from sys_message_manage_log
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id like concat('%',#{id},'%')</if>
            <if test="messageManageId != null and messageManageId != ''">and message_manage_id like
                concat('%',#{messageManageId},'%')
            </if>
            <if test="theme != null and theme != ''">and theme like concat('%',#{theme},'%')</if>
            <if test="messageCode != null and messageCode != ''">and message_code like concat('%',#{messageCode},'%')
            </if>
            <if test="sendApp != null and sendApp != ''">and send_app like concat('%',#{sendApp},'%')</if>
            <if test="sendApi != null and sendApi != ''">and send_api like concat('%',#{sendApi},'%')</if>
            <if test="receiveCode != null and receiveCode != ''">and receive_code like concat('%',#{receiveCode},'%')
            </if>
            <if test="receiveApp != null and receiveApp != ''">and receive_app like concat('%',#{receiveApp},'%')</if>
            <if test="receiveApi != null and receiveApi != ''">and receive_api like concat('%',#{receiveApi},'%')</if>
            <if test="sourceData != null and sourceData != ''">and source_data like concat('%',#{sourceData},'%')</if>
            <if test="targetData != null and targetData != ''">and target_data like concat('%',#{targetData},'%')</if>
            <if test="returnData != null and returnData != ''">and return_data like concat('%',#{returnData},'%')</if>
            <if test="returnType != null and returnType != ''">and return_type like concat('%',#{returnType},'%')</if>
            <if test="errorStatus != null and errorStatus != ''">and error_status like concat('%',#{errorStatus},'%')
            </if>
            <if test="status != null and status != ''">and status like concat('%',#{status},'%')</if>
            <if test="remark != null and remark != ''">and remark like concat('%',#{remark},'%')</if>
            <if test="sorts != null">and sorts like concat('%',#{sorts},'%')</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id like
                concat('%',#{create_user_id},'%')
            </if>
            <if test="create_time != null">and create_time like concat('%',#{create_time},'%')</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id like
                concat('%',#{modify_user_id},'%')
            </if>
            <if test="modify_time != null">and modify_time like concat('%',#{modify_time},'%')</if>
            <if test="sts != null and sts != ''">and sts like concat('%',#{sts},'%')</if>
            <if test="org_id != null and org_id != ''">and org_id like concat('%',#{org_id},'%')</if>
            and sts='Y'
        </trim>
        <if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
        <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
    </select>


    <!-- 分页查询列表 采用like格式 -->
    <select id="queryListByPageVo" resultType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogPageVo"
            parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">
        SELECT
        a.id AS id,
        a.message_manage_id AS messageManageId,
        a.theme AS theme,
        a.message_code AS messageCode,
        sendApp.name AS sendAppName,
        sendApi.api_name AS sendApiName,
        a.receive_code AS receiveCode,
        receiveApp.name AS receiveAppName,
        receiveApi.api_name AS receiveApiName,
        a.source_data AS sourceData,
        a.target_data AS targetData,
        a.return_data AS returnData,
        a.return_type AS returnType,
        a.error_status AS errorStatus,
        a.status AS status,
        a.remark AS remark
        FROM
        sys_message_manage_log a
        LEFT JOIN sys_app sendApp ON a.send_app = sendApp.id AND sendApp.sts = 'Y'
        LEFT JOIN sys_app_api sendApi ON a.send_api = sendApi.id AND sendApi.sts = 'Y'

        LEFT JOIN sys_app receiveApp ON a.receive_app = receiveApp.id AND receiveApp.sts = 'Y'
        LEFT JOIN sys_app_api receiveApi ON a.receive_api = receiveApi.id AND receiveApi.sts = 'Y'
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and a.id like concat('%',#{id},'%')</if>
            <if test="messageManageId != null and messageManageId != ''">and a.message_manage_id like
                concat('%',#{messageManageId},'%')
            </if>
            <if test="theme != null and theme != ''">and a.theme like concat('%',#{theme},'%')</if>
            <if test="messageCode != null and messageCode != ''">and a.message_code like concat('%',#{messageCode},'%')
            </if>
            <if test="sendApp != null and sendApp != ''">and a.send_app like concat('%',#{sendApp},'%')</if>
            <if test="sendApi != null and sendApi != ''">and a.send_api like concat('%',#{sendApi},'%')</if>
            <if test="receiveCode != null and receiveCode != ''">and a.receive_code like concat('%',#{receiveCode},'%')
            </if>
            <if test="receiveApp != null and receiveApp != ''">and a.receive_app like concat('%',#{receiveApp},'%')</if>
            <if test="receiveApi != null and receiveApi != ''">and a.receive_api like concat('%',#{receiveApi},'%')</if>
            <if test="sourceData != null and sourceData != ''">and a.source_data like concat('%',#{sourceData},'%')</if>
            <if test="targetData != null and targetData != ''">and a.target_data like concat('%',#{targetData},'%')</if>
            <if test="returnData != null and returnData != ''">and a.return_data like concat('%',#{returnData},'%')</if>
            <if test="returnType != null and returnType != ''">and a.return_type like concat('%',#{returnType},'%')</if>
            <if test="errorStatus != null and errorStatus != ''">and a.error_status like
                concat('%',#{errorStatus},'%')
            </if>
            <if test="status != null and status != ''">and a.status like concat('%',#{status},'%')</if>
            <if test="remark != null and remark != ''">and a.remark like concat('%',#{remark},'%')</if>
            <if test="sorts != null">and a.sorts like concat('%',#{sorts},'%')</if>
            <if test="create_user_id != null and create_user_id != ''">and a.create_user_id like
                concat('%',#{create_user_id},'%')
            </if>
            <if test="create_time != null">and a.create_time like concat('%',#{create_time},'%')</if>
            <if test="modify_user_id != null and modify_user_id != ''">and a.modify_user_id like
                concat('%',#{modify_user_id},'%')
            </if>
            <if test="modify_time != null">and a.modify_time like concat('%',#{modify_time},'%')</if>
            <if test="sts != null and sts != ''">and a.sts like concat('%',#{sts},'%')</if>
            <if test="org_id != null and org_id != ''">and a.org_id like concat('%',#{org_id},'%')</if>
            and a.sts='Y'
        </trim>
        <if test=" sort == null or sort == ''.toString() ">order by a.sorts asc</if>
    </select>


    <!-- 查询列表 字段采用or格式 -->
    <select id="SysMessageManageLogentity_list_or" resultMap="get-SysMessageManageLogEntity-result"
            parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">
        select
        <include refid="SysMessageManageLogEntity_Base_Column_List"/>
        from sys_message_manage_log
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">or id = #{id}</if>
            <if test="messageManageId != null and messageManageId != ''">or message_manage_id = #{messageManageId}</if>
            <if test="theme != null and theme != ''">or theme = #{theme}</if>
            <if test="messageCode != null and messageCode != ''">or message_code = #{messageCode}</if>
            <if test="sendApp != null and sendApp != ''">or send_app = #{sendApp}</if>
            <if test="sendApi != null and sendApi != ''">or send_api = #{sendApi}</if>
            <if test="receiveCode != null and receiveCode != ''">or receive_code = #{receiveCode}</if>
            <if test="receiveApp != null and receiveApp != ''">or receive_app = #{receiveApp}</if>
            <if test="receiveApi != null and receiveApi != ''">or receive_api = #{receiveApi}</if>
            <if test="sourceData != null and sourceData != ''">or source_data = #{sourceData}</if>
            <if test="targetData != null and targetData != ''">or target_data = #{targetData}</if>
            <if test="returnData != null and returnData != ''">or return_data = #{returnData}</if>
            <if test="returnType != null and returnType != ''">or return_type = #{returnType}</if>
            <if test="errorStatus != null and errorStatus != ''">or error_status = #{errorStatus}</if>
            <if test="status != null and status != ''">or status = #{status}</if>
            <if test="remark != null and remark != ''">or remark = #{remark}</if>
            <if test="sorts != null">or sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">or create_user_id = #{create_user_id}</if>
            <if test="create_time != null">or create_time = #{create_time}</if>
            <if test="modify_user_id != null and modify_user_id != ''">or modify_user_id = #{modify_user_id}</if>
            <if test="modify_time != null">or modify_time = #{modify_time}</if>
            <if test="sts != null and sts != ''">or sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">or org_id = #{org_id}</if>
            and sts='Y'
        </trim>
        <if test=" sort == null or sort == ''.toString()  ">order by sorts asc</if>
        <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
    </select>

    <!-- 查询 查询上个月16号到上个月最后一号的数据 -->
    <select id="entity_list_time" resultMap="get-SysMessageManageLogEntity-result"
            parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">
        select
        <include refid="SysMessageManageLogEntity_Base_Column_List"/>
        from sys_message_manage_log
        <trim prefix="where" prefixOverrides="and">
            <if test="create_time != null">and create_time &gt;= #{create_time}</if>
            <if test="modify_time != null">and modify_time &lt;= #{modify_time}</if>
            and sts='Y'
        </trim>
        <if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
        <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
    </select>

    <!--新增所有列-->
    <insert id="entity_insert" parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity"
            >
        insert into
        <choose>
            <when test=" status != null and status.trim() != '' and status == 3">
                sys_message_manage_log_success
            </when>
            <otherwise>
                sys_message_manage_log
            </otherwise>
        </choose>
        (
        <trim suffix="" suffixOverrides=",">
            <if test="id != null and id != ''">id ,</if>
            <if test="messageManageId != null and messageManageId != ''">message_manage_id ,</if>
            <if test="theme != null and theme != ''">theme ,</if>
            <if test="messageCode != null and messageCode != ''">message_code ,</if>
            <if test="sendApp != null and sendApp != ''">send_app ,</if>
            <if test="sendApi != null and sendApi != ''">send_api ,</if>
            <if test="receiveCode != null and receiveCode != ''">receive_code ,</if>
            <if test="receiveApp != null and receiveApp != ''">receive_app ,</if>
            <if test="receiveApi != null and receiveApi != ''">receive_api ,</if>
            <if test="sourceData != null and sourceData != ''">source_data ,</if>
            <if test="targetData != null and targetData != ''">target_data ,</if>
            <if test="returnData != null and returnData != ''">return_data ,</if>
            <if test="returnType != null and returnType != ''">return_type ,</if>
            <if test="errorStatus != null and errorStatus != ''">error_status ,</if>
            <if test="status != null and status != ''">status ,</if>
            <if test="remark != null and remark != ''">remark ,</if>
            <if test="sorts != null">sorts ,</if>
            <if test="create_user_id != null and create_user_id != ''">create_user_id ,</if>
            <if test="create_time != null">create_time ,</if>
            <if test="modify_user_id != null and modify_user_id != ''">modify_user_id ,</if>
            <if test="modify_time != null">modify_time ,</if>
            <if test="sts != null and sts != ''">sts ,</if>
            <if test="org_id != null and org_id != ''">org_id ,</if>
            <if test="sts == null ">sts,</if>
        </trim>
        )values(
        <trim suffix="" suffixOverrides=",">
            <if test="id != null and id != ''">#{id} ,</if>
            <if test="messageManageId != null and messageManageId != ''">#{messageManageId} ,</if>
            <if test="theme != null and theme != ''">#{theme} ,</if>
            <if test="messageCode != null and messageCode != ''">#{messageCode} ,</if>
            <if test="sendApp != null and sendApp != ''">#{sendApp} ,</if>
            <if test="sendApi != null and sendApi != ''">#{sendApi} ,</if>
            <if test="receiveCode != null and receiveCode != ''">#{receiveCode} ,</if>
            <if test="receiveApp != null and receiveApp != ''">#{receiveApp} ,</if>
            <if test="receiveApi != null and receiveApi != ''">#{receiveApi} ,</if>
            <if test="sourceData != null and sourceData != ''">#{sourceData} ,</if>
            <if test="targetData != null and targetData != ''">#{targetData} ,</if>
            <if test="returnData != null and returnData != ''">#{returnData} ,</if>
            <if test="returnType != null and returnType != ''">#{returnType} ,</if>
            <if test="errorStatus != null and errorStatus != ''">#{errorStatus} ,</if>
            <if test="status != null and status != ''">#{status} ,</if>
            <if test="remark != null and remark != ''">#{remark} ,</if>
            <if test="sorts != null">#{sorts} ,</if>
            <if test="create_user_id != null and create_user_id != ''">#{create_user_id} ,</if>
            <if test="create_time != null">#{create_time} ,</if>
            <if test="modify_user_id != null and modify_user_id != ''">#{modify_user_id} ,</if>
            <if test="modify_time != null">#{modify_time} ,</if>
            <if test="sts != null and sts != ''">#{sts} ,</if>
            <if test="org_id != null and org_id != ''">#{org_id} ,</if>
            <if test="sts == null ">'Y',</if>
        </trim>
        )
    </insert>
    <!-- 批量新增 -->
    <insert id="entityInsertBatch" >
        insert into sys_message_manage_log(message_manage_id, theme, message_code, send_app, send_api, receive_code,
        receive_app, receive_api, source_data, target_data, return_data, return_type,error_status, status, remark,
        sorts, create_user_id,
        create_time, modify_user_id, modify_time, sts, org_id, sts)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.messageManageId},#{entity.theme},#{entity.messageCode},#{entity.sendApp},#{entity.sendApi},#{entity.receiveCode},#{entity.receiveApp},#{entity.receiveApi},#{entity.sourceData},#{entity.targetData},#{entity.returnData},#{entity.returnType},#{entity.errorStatus},#{entity.status},#{entity.remark},#{entity.sorts},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},
            'Y')
        </foreach>
    </insert>
    <!-- 批量新增或者修改-->
    <insert id="entityInsertOrUpdateBatch" >
        insert into sys_message_manage_log(message_manage_id, theme, message_code, send_app, send_api, receive_code,
        receive_app, receive_api, source_data, target_data, return_data, return_type,error_status, status, remark,
        sorts, create_user_id,
        create_time, modify_user_id, modify_time, sts, org_id)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.messageManageId},#{entity.theme},#{entity.messageCode},#{entity.sendApp},#{entity.sendApi},#{entity.receiveCode},#{entity.receiveApp},#{entity.receiveApi},#{entity.sourceData},#{entity.targetData},#{entity.returnData},#{entity.returnType},#{entity.errorStatus},#{entity.status},#{entity.remark},#{entity.sorts},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id})
        </foreach>
        on duplicate key update
        message_manage_id = values(message_manage_id),
        theme = values(theme),
        message_code = values(message_code),
        send_app = values(send_app),
        send_api = values(send_api),
        receive_code = values(receive_code),
        receive_app = values(receive_app),
        receive_api = values(receive_api),
        source_data = values(source_data),
        target_data = values(target_data),
        return_data = values(return_data),
        return_type = values(return_type),
        error_status = values(error_status),
        status = values(status),
        remark = values(remark),
        sorts = values(sorts),
        create_user_id = values(create_user_id),
        create_time = values(create_time),
        modify_user_id = values(modify_user_id),
        modify_time = values(modify_time),
        sts = values(sts),
        org_id = values(org_id)
    </insert>
    <!--通过主键修改方法-->
    <update id="entity_update" parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">
        update sys_message_manage_log set
        <trim suffix="" suffixOverrides=",">
            <if test="messageManageId != null and messageManageId != ''">message_manage_id = #{messageManageId},</if>
            <if test="theme != null and theme != ''">theme = #{theme},</if>
            <if test="messageCode != null and messageCode != ''">message_code = #{messageCode},</if>
            <if test="sendApp != null and sendApp != ''">send_app = #{sendApp},</if>
            <if test="sendApi != null and sendApi != ''">send_api = #{sendApi},</if>
            <if test="receiveCode != null and receiveCode != ''">receive_code = #{receiveCode},</if>
            <if test="receiveApp != null and receiveApp != ''">receive_app = #{receiveApp},</if>
            <if test="receiveApi != null and receiveApi != ''">receive_api = #{receiveApi},</if>
            <if test="sourceData != null and sourceData != ''">source_data = #{sourceData},</if>
            <if test="targetData != null and targetData != ''">target_data = #{targetData},</if>
            <if test="returnData != null and returnData != ''">return_data = #{returnData},</if>
            <if test="returnType != null and returnType != ''">return_type = #{returnType},</if>
            <if test="errorStatus != null and errorStatus != ''">error_status = #{errorStatus},</if>
            <if test="status != null and status != ''">status = #{status},</if>
            <if test="remark != null and remark != ''">remark = #{remark},</if>
            <if test="sorts != null">sorts = #{sorts},</if>
            <if test="create_user_id != null and create_user_id != ''">create_user_id = #{create_user_id},</if>
            <if test="create_time != null">create_time = #{create_time},</if>
            <if test="modify_user_id != null and modify_user_id != ''">modify_user_id = #{modify_user_id},</if>
            <if test="modify_time != null">modify_time = #{modify_time},</if>
            <if test="sts != null and sts != ''">sts = #{sts},</if>
            <if test="org_id != null and org_id != ''">org_id = #{org_id},</if>
        </trim>
        where id = #{id}
    </update>
    <!-- 逻辑删除 -->
    <update id="entity_logicDelete"
            parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">
update sys_message_manage_log  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where id = #{id}
</update>
    <!-- 多条件逻辑删除 -->
    <update id="entity_logicDelete_Multi_Condition"
            parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">
        update sys_message_manage_log set sts= 'N',modify_time = #{modify_time},modify_user_id = #{modify_user_id}
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="messageManageId != null and messageManageId != ''">and message_manage_id = #{messageManageId}</if>
            <if test="theme != null and theme != ''">and theme = #{theme}</if>
            <if test="messageCode != null and messageCode != ''">and message_code = #{messageCode}</if>
            <if test="sendApp != null and sendApp != ''">and send_app = #{sendApp}</if>
            <if test="sendApi != null and sendApi != ''">and send_api = #{sendApi}</if>
            <if test="receiveCode != null and receiveCode != ''">and receive_code = #{receiveCode}</if>
            <if test="receiveApp != null and receiveApp != ''">and receive_app = #{receiveApp}</if>
            <if test="receiveApi != null and receiveApi != ''">and receive_api = #{receiveApi}</if>
            <if test="sourceData != null and sourceData != ''">and source_data = #{sourceData}</if>
            <if test="targetData != null and targetData != ''">and target_data = #{targetData}</if>
            <if test="returnData != null and returnData != ''">and return_data = #{returnData}</if>
            <if test="returnType != null and returnType != ''">and return_type = #{returnType}</if>
            <if test="errorStatus != null and errorStatus != ''">and error_status = #{errorStatus}</if>
            <if test="status != null and status != ''">and status = #{status}</if>
            <if test="remark != null and remark != ''">and remark = #{remark}</if>
            <if test="sorts != null">and sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
            <if test="create_time != null">and create_time = #{create_time}</if>
            <if test="sts != null and sts != ''">and sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
            and sts='Y'
        </trim>
    </update>
    <!--通过主键删除-->
    <delete id="entity_delete">
    delete from sys_message_manage_log where id = #{id}
</delete>

    <!-- 分页查询视图 采用like格式 -->
    <!--    <select id="queryListByErrorPageVo"-->
    <!--            resultType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogPageVo"-->
    <!--            parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">-->
    <!--        SELECT-->
    <!--        a.id AS id,-->
    <!--        a.message_manage_id AS messageManageId,-->
    <!--        a.theme AS theme,-->
    <!--        a.message_code AS messageCode,-->
    <!--        sendApp.name AS sendAppName,-->
    <!--        sendApi.api_name AS sendApiName,-->
    <!--        a.receive_code AS receiveCode,-->
    <!--        receiveApp.name AS receiveAppName,-->
    <!--        receiveApi.api_name AS receiveApiName,-->
    <!--        a.source_data AS sourceData,-->
    <!--        a.target_data AS targetData,-->
    <!--        a.return_data AS returnData,-->
    <!--        a.return_type AS returnType,-->
    <!--        a.error_status AS errorStatus,-->
    <!--        a.status AS status,-->
    <!--        a.remark AS remark,-->
    <!--        a.create_time AS createTime,-->
    <!--        a.modify_time AS modifyTime-->
    <!--        FROM-->
    <!--        sys_message_manage_log_llg a-->
    <!--        LEFT JOIN sys_application sendApp ON a.send_app = sendApp.id-->
    <!--        AND sendApp.sts = 'Y'-->
    <!--        LEFT JOIN sys_application_api sendApi ON a.send_api = sendApi.id-->
    <!--        AND sendApi.sts = 'Y'-->
    <!--        LEFT JOIN sys_application receiveApp ON a.receive_app = receiveApp.id-->
    <!--        AND receiveApp.sts = 'Y'-->
    <!--        LEFT JOIN sys_application_api receiveApi ON a.receive_api = receiveApi.id-->
    <!--        AND receiveApi.sts = 'Y'-->
    <!--        <trim prefix="where" prefixOverrides="and">-->
    <!--            <if test="id != null and id != ''">and a.id like concat('%',#{id},'%')</if>-->
    <!--            <if test="messageManageId != null and messageManageId != ''">and a.message_manage_id like-->
    <!--                concat('%',#{messageManageId},'%')-->
    <!--            </if>-->
    <!--            <if test="theme != null and theme != ''">and a.theme like concat('%',#{theme},'%')</if>-->
    <!--            <if test="messageCode != null and messageCode != ''">and a.message_code = #{messageCode}-->
    <!--            </if>-->
    <!--            <if test="sendApp != null and sendApp != ''">and a.send_app = #{sendApp}</if>-->
    <!--            <if test="sendApi != null and sendApi != ''">and a.send_api = #{sendApi}</if>-->
    <!--            <if test="receiveCode != null and receiveCode != ''">and a.receive_code = #{receiveCode}-->
    <!--            </if>-->
    <!--            <if test="receiveApp != null and receiveApp != ''">and a.receive_app = #{receiveApp}</if>-->
    <!--            <if test="receiveApi != null and receiveApi != ''">and a.receive_api = #{receiveApi}</if>-->
    <!--            <if test="sourceData != null and sourceData != ''">and a.source_data like concat('%',#{sourceData},'%')</if>-->
    <!--            <if test="targetData != null and targetData != ''">and a.target_data like concat('%',#{targetData},'%')</if>-->
    <!--            <if test="returnData != null and returnData != ''">and a.return_data like concat('%',#{returnData},'%')</if>-->
    <!--            <if test="returnType != null and returnType != ''">and a.return_type like concat('%',#{returnType},'%')</if>-->
    <!--            <if test="errorStatus != null and errorStatus != ''">and a.error_status = #{errorStatus}</if>-->
    <!--            <if test="status != null and status != ''">and a.status = #{status}</if>-->
    <!--            <if test="remark != null and remark != ''">and a.remark like concat('%',#{remark},'%')</if>-->
    <!--            <if test="sorts != null">and a.sorts like concat('%',#{sorts},'%')</if>-->
    <!--            <if test="create_user_id != null and create_user_id != ''">and a.create_user_id like-->
    <!--                concat('%',#{create_user_id},'%')-->
    <!--            </if>-->
    <!--            <if test="create_time != null">and a.create_time like concat('%',#{create_time},'%')</if>-->
    <!--            <if test="modify_user_id != null and modify_user_id != ''">and a.modify_user_id like-->
    <!--                concat('%',#{modify_user_id},'%')-->
    <!--            </if>-->
    <!--            <if test="modify_time != null">and a.modify_time like concat('%',#{modify_time},'%')</if>-->
    <!--            <if test="sts != null and sts != ''">and a.sts like concat('%',#{sts},'%')</if>-->
    <!--            <if test="org_id != null and org_id != ''">and a.org_id like concat('%',#{org_id},'%')</if>-->
    <!--            and a.sts='Y'-->
    <!--        </trim>-->
    <!--        ORDER BY a.create_time DESC-->
    <!--    </select>-->
    <select id="queryListByErrorPageVo"
            resultType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogPageVo"
                parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">
        SELECT
        a.id AS id,
        a.message_manage_id AS messageManageId,
        a.theme AS theme,
        a.message_code AS messageCode,
        sendApp.name AS sendAppName,
        a.receive_code AS receiveCode,
        a.source_data AS sourceData,
        a.target_data AS targetData,
        a.return_data AS returnData,
        a.return_type AS returnType,
        a.error_status AS errorStatus,
        a.status AS status,
        a.remark AS remark,
        a.create_time AS createTime,
        a.modify_time AS modifyTime,
        receiveApi.api_name AS receiveApiName
        FROM
        <choose>
            <when test=" status != null and status.trim() != '' and status == 3">
                sys_message_manage_log_success a
            </when>
            <otherwise>
                sys_message_manage_log a
            </otherwise>
        </choose>
        LEFT JOIN sys_application sendApp ON a.send_app = sendApp.id AND sendApp.sts = 'Y'
        LEFT JOIN sys_application_api receiveApi ON a.receive_code = receiveApi.api_code AND receiveApi.sts = 'Y'
        <trim prefix="where" prefixOverrides="and">
            <if test="ids != null and ids.size>0">
                AND a.id in
                <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
            and a.sts='Y'
        </trim>
        ORDER BY a.create_time DESC
    </select>

    <!-- 批量更新 -->
    <update id="entity_update_time"
            parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">
        UPDATE sys_message_manage_log
        SET sts = 'N'
        WHERE id IN
        <foreach item="entity" index="index" collection="list" open="(" separator="," close=")">
            #{entity.id}
        </foreach>
    </update>

    <!-- 批量删除 -->
    <delete id="entity_delete_time"
            parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">
        DELETE FROM sys_message_manage_log
        WHERE id IN
        <foreach item="entity" index="index" collection="list" open="(" separator="," close=")">
            #{entity.id}
        </foreach>
    </delete>


    <!-- 分页查询视图 采用like格式 -->
    <select id="querySysMessageManageLogIds" resultType="java.lang.String"
            parameterType="com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity">
        SELECT
        id
        FROM
        <choose>
            <when test=" status != null and status.trim() != '' and status == 3">
                sys_message_manage_log_success
            </when>
            <otherwise>
                sys_message_manage_log
            </otherwise>
        </choose>
        <trim prefix="where" prefixOverrides="and">
            sts = 'Y'
            <if test="messageCode != null and messageCode != ''">and message_code = #{messageCode}
            </if>
            <if test="sendApp != null and sendApp != ''">and send_app = #{sendApp}</if>
            <if test="sendApi != null and sendApi != ''">and send_api = #{sendApi}</if>
            <if test="receiveCode != null and receiveCode != ''">and receive_code = #{receiveCode}
            </if>
            <if test="receiveApp != null and receiveApp != ''">and receive_app = #{receiveApp}</if>
            <if test="receiveApi != null and receiveApi != ''">and receive_api = #{receiveApi}</if>
            <if test="status != null and status != ''">and status = #{status}</if>
            <if test="sourceData != null and sourceData != ''">and source_data like concat('%',#{sourceData},'%')</if>
            <if test="targetData != null and targetData != ''">and target_data like concat('%',#{targetData},'%')</if>
            <if test="returnData != null and returnData != ''">and return_data like concat('%',#{returnData},'%')</if>
            <if test="createTimeStart != null">and create_time &gt;= #{createTimeStart}</if>
            <if test="createTimeEnd != null">and create_time  &lt;= #{createTimeEnd}</if>
        </trim>
        ORDER BY create_time DESC
    </select>


</mapper>

