Blame view

OprMemDictMapper.xml 3.77 KB
涂亚平 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<?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>

邓敏 committed
23

涂亚平 committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
    <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>
邓敏 committed
48 49 50 51 52 53 54 55 56

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

    <select id="getLatestLoginInfo" parameterType="long" resultType="com.subsidy.model.OprMemDictDO">
涂亚平 committed
59 60
        SELECT t.id,
            t.ip_address,
涂亚平 committed
61 62 63
            t.opr_type,
            t.result,
            t.user_id,
涂亚平 committed
64
            t.create_date
涂亚平 committed
65 66 67 68
        FROM
            opr_mem_dict t
        WHERE
            t.delete_date IS NULL
涂亚平 committed
69 70
            AND t.result = 1
            AND t.user_id =#{userId}
涂亚平 committed
71 72
            and DATE_FORMAT( create_date, '%Y-%m-%d' ) = DATE_FORMAT( now(), '%Y-%m-%d' )
            order by t.id desc
涂亚平 committed
73
            limit 1
涂亚平 committed
74
    </select>
涂亚平 committed
75

涂亚平 committed
76 77 78 79 80 81 82 83 84 85 86 87 88 89


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

    <select id="onlineUsers" resultType="long">
        SELECT
        t1.user_id
涂亚平 committed
90
        FROM
涂亚平 committed
91 92 93 94 95 96 97 98
        (
        SELECT
        id,
        user_id,
        opr_type,
        max( create_date ) AS time1
        FROM
        opr_mem_dict
涂亚平 committed
99
        WHERE
涂亚平 committed
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
        DATE_FORMAT( create_date, '%Y-%m-%d ' ) = DATE_FORMAT( now(), '%Y-%m-%d ' )
        AND result = 1
        AND opr_type = "登录"
        GROUP BY
        user_id
        ORDER BY
        create_date DESC
        ) t1
        LEFT JOIN (
        SELECT
        id,
        user_id,
        opr_type,
        max( create_date ) AS time2
        FROM
        opr_mem_dict
        WHERE
        DATE_FORMAT( create_date, '%Y-%m-%d ' ) = DATE_FORMAT( now(), '%Y-%m-%d ' )
        AND result = 1
        AND opr_type = "登出"
        GROUP BY
        user_id
        ORDER BY
        create_date DESC
        ) t2 ON t1.user_id = t2.user_id
        WHERE
        t2.id IS NULL
        OR t2.time2 &lt; t1.time1
    </select>

<!--    <update id="insertLastStudyRecord">-->
<!--        -->
<!--    </update>-->
涂亚平 committed
133
</mapper>