OprMemDictMapper.xml 2.59 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.subsidy.mapper.OprMemDictMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.subsidy.model.OprMemDictDO">
        <id column="id" property="id" />
        <result column="create_date" property="createDate" />
        <result column="update_date" property="updateDate" />
        <result column="delete_date" property="deleteDate" />
        <result column="user_id" property="userId" />
        <result column="opr_type" property="oprType" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, user_id, opr_type
    </sql>


    <select id="getHistory" resultType="com.subsidy.vo.opr.GetHistoryVO">
        SELECT
            t.id,
            t2.user_name,
            t3.company_name,
            t.opr_type,
            t.create_date,
            t.result
        FROM
            opr_mem_dict t
            LEFT JOIN member t2 ON t.user_id = t2.id
            LEFT JOIN company_dict t3 ON t2.company_id = t3.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
            <if test="userName != null and userName !=''">
                and t2.user_name like concat('%',#{userName} ,'%')
            </if>
            AND DATE_FORMAT( t.create_date, '%Y-%m-%d' ) BETWEEN DATE_FORMAT( #{startDate}, '%Y-%m-%d' )
            AND DATE_FORMAT( #{endDate}, '%Y-%m-%d' )
        ORDER BY
            t.create_date DESC
    </select>

    <select id="getRecordByDate" resultType="com.subsidy.model.OprMemDictDO">
        SELECT
            *
        FROM
            opr_mem_dict
        WHERE
            create_date &lt; (NOW() - INTERVAL 10 DAY)
    </select>

    <select id="getLatestLoginInfo" parameterType="long" resultType="com.subsidy.model.OprMemDictDO">
        SELECT t.id,
            t.ip_address,
            t.opr_type,
            t.result,
            t.user_id,
            t.create_date
        FROM
            opr_mem_dict t
        WHERE
            t.delete_date IS NULL
            AND t.result = 1
            AND t.user_id =#{userId}
            order by t.create_date desc
            limit 1
    </select>

    <delete id="deleteData" parameterType="com.subsidy.model.OprMemDictDO">
        DELETE
        FROM
            opr_mem_dict
        WHERE
            delete_date IS NULL
            AND id = #{id}
    </delete>
</mapper>