mitao
2024-09-04 ecca9ab70a9a87bcb60977c92fbf81053b8fc1bb
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?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.admin.mapper.UserMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.admin.entity.User">
        <id column="id" property="id"/>
        <result column="user_no" property="userNo"/>
        <result column="nickname" property="nickname"/>
        <result column="phone" property="phone"/>
        <result column="profile_picture" property="profilePicture"/>
        <result column="state" property="state"/>
        <result column="createBy" property="createBy"/>
        <result column="updateBy" property="updateBy"/>
        <result column="createTime" property="createTime"/>
        <result column="updateTime" property="updateTime"/>
        <result column="is_delete" property="isDelete"/>
    </resultMap>
 
    <select id="userTrends" resultType="com.ruoyi.admin.vo.UserTrendsVO">
        SELECT DATE_FORMAT(createTime, '%Y-%m') AS date, COUNT(*) AS number
        FROM t_user
        <where>
            <if test="city != null and city.size() != 0">
                city_code in
                <foreach collection="city" item="city" open="(" separator="," close=")">
                #{city}
                </foreach>
            </if>
            and is_delete = 0
            and state = 1 and phone IS NOT NULL
        </where>
        GROUP BY DATE_FORMAT(createTime, '%Y-%m')
        ORDER BY date;
    </select>
 
 
    <select id="userTrends1" resultType="com.ruoyi.admin.vo.UserTrendsVO">
        SELECT DATE_FORMAT(createTime, '%Y-%m') AS date, COUNT(*) AS number
        FROM t_user
        <where>
            and is_delete = 0
            <if test="userIds != null and userIds.size() != 0">
                and id in
                <foreach collection="userIds" item="userId" open="(" separator="," close=")">
                    #{userId}
                </foreach>
            </if>
            and state = 1 and phone IS NOT NULL
        </where>
        GROUP BY DATE_FORMAT(createTime, '%Y-%m')
        ORDER BY date;
    </select>
 
    <select id="increaseNumberByYear" resultType="java.lang.Long">
        SELECT COUNT(*) AS number
        FROM t_user
        WHERE YEAR(createTime) = YEAR(NOW())
          and is_delete = 0 and phone IS NOT NULL
        <if test="cityList != null and cityList.size() != 0">
            and city_code in
            <foreach collection="cityList" item="city" open="(" separator="," close=")">
                #{city}
            </foreach>
        </if>
    </select>
 
    <select id="increaseNumberByYear1" resultType="java.lang.Long">
        SELECT COUNT(*) AS number
        FROM t_user
        WHERE YEAR(createTime) = YEAR(NOW())
        and is_delete = 0 and phone IS NOT NULL
        <if test="userIds != null and userIds.size() != 0">
            and id in
            <foreach collection="userIds" item="userId" open="(" separator="," close=")">
                #{userId}
            </foreach>
        </if>
    </select>
 
    <select id="increaseNumberByMonth" resultType="java.lang.Long">
        SELECT COUNT(*) AS number
        FROM t_user
        WHERE MONTH(createTime) = MONTH(NOW())
          AND YEAR(createTime) = YEAR(NOW()) and phone IS NOT NULL
        <if test="cityList != null and cityList.size() != 0">
            and city_code in
            <foreach collection="cityList" item="city" open="(" separator="," close=")">
                #{city}
            </foreach>
        </if>
    </select>
 
    <select id="increaseNumberByMonth1" resultType="java.lang.Long">
        SELECT COUNT(*) AS number
        FROM t_user
        WHERE MONTH(createTime) = MONTH(NOW())
        AND YEAR(createTime) = YEAR(NOW()) and phone IS NOT NULL
        <if test="userIds != null and userIds.size() != 0">
            and id in
            <foreach collection="userIds" item="userId" open="(" separator="," close=")">
                #{userId}
            </foreach>
        </if>
 
    </select>
 
</mapper>