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
| <?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.other.mapper.ShopPointMapper">
|
| <select id="findLatestChangeByType" resultType="com.ruoyi.other.api.domain.ShopPoint">
| SELECT
| id,
| shop_id,
| type,
| historical_point,
| variable_point,
| create_time,
| create_user_id,
| object_id
| FROM
| (
| SELECT
| id,
| shop_id,
| type,
| historical_point,
| variable_point,
| create_time,
| create_user_id,
| object_id,
| ROW_NUMBER() OVER ( PARTITION BY type ORDER BY create_time DESC ) AS rn
| FROM
| t_shop_point
|
| <where>
| <if test="shopIds != null and shopIds.size() > 0">
| AND shop_id IN
| <foreach collection="shopIds" item="shopId" open="(" close=")" separator=",">
| #{shopId}
| </foreach>
| </if>
| <if test="type != null">
| AND `type` = #{type}
| </if>
| <if test="startTime != null and endTime != null">
| AND create_time BETWEEN #{startTime} AND #{endTime}
| </if>
| </where>
| ) AS subquery
| WHERE
| rn = 1
| </select>
| </mapper>
|
|