Pu Zhibing
1 天以前 d0d6f8f40e5d9762d940b47c566da1876361020e
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
<?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.stylefeng.guns.modular.system.dao.TActivityMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TActivity">
        <id column="id" property="id"/>
        <result column="companyId" property="companyId"/>
        <result column="companyType" property="companyType"/>
        <result column="activityName" property="activityName"/>
        <result column="cover" property="cover"/>
        <result column="startTime" property="startTime"/>
        <result column="endTime" property="endTime"/>
        <result column="provinceName" property="provinceName"/>
        <result column="provinceCode" property="provinceCode"/>
        <result column="cityName" property="cityName"/>
        <result column="cityCode" property="cityCode"/>
        <result column="districtName" property="districtName"/>
        <result column="districtCode" property="districtCode"/>
        <result column="sortBy" property="sortBy"/>
        <result column="content" property="content"/>
        <result column="createTime" property="createTime"/>
        <result column="createBy" property="createBy"/>
        <result column="status" property="status"/>
    </resultMap>
    <select id="getList" resultType="com.stylefeng.guns.modular.system.model.TActivity">
        SELECT
        a.id,
        a.companyId,
        a.companyType,
        a.activityName,
        a.cover,
        a.startTime,
        a.endTime,
        a.sortBy,
        a.content,
        a.createTime,
        a.createBy,
        a.status,
        ta.provinceName,
        ta.provinceCode,
        ta.cityName,
        ta.cityCode,
        ta.areaName,
        ta.areaCode
            ,tbo.branchOfficeName
        FROM t_activity a
        LEFT JOIN t_activity_area ta on a.id = ta.activityId
            LEFT JOIN t_branch_office tbo on a.companyId = tbo.id
        <where>
            <if test="beginTime != null and endTime != null">
                and a.createTime between #{beginTime} and #{endTime}
            </if>
            <if test="objectId != null and objectId != 1">
                and a.companyId = #{objectId}
            </if>
            <if test="roleType !=null and roleType != 1">
                and a.companyType = #{roleType}
            </if>
            <if test="branchOfficeName != null and branchOfficeName != ''">
                and tbo.branchOfficeName like concat('%',#{branchOfficeName},'%')
            </if>
            <if test="provinceCode != null and provinceCode != ''">
                and ta.provinceCode = #{provinceCode}
            </if>
            <if test="activityName != null and activityName != ''">
                and a.activityName like concat('%', #{activityName},'%')
            </if>
            <if test="cityCode != null and cityCode != ''">
                and ta.cityCode = #{cityCode}
            </if>
            <if test="areaCode != null and areaCode != ''">
                and ta.areaCode = #{areaCode}
            </if>
            <if test="status != null and status == 1">
                and a.status = 1
            </if>
            <if test="status != null and status == 3">
                and a.status = 3
            </if>
            <if test="status != null and status == 4">
                and a.status = 2 and a.startTime &gt;= now()
            </if>
            <if test="status != null and status == 5">
                and a.status = 2 and a.startTime &lt; now() and a.endTime &gt;= now()
            </if>
            <if test="status != null and status == 6">
                and a.status = 2 and a.endTime &lt; now()
            </if>
            AND a.isDelete = 0
        </where>
        group by a.id
    </select>
 
 
</mapper>