mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
<?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.panzhihua.service_community.dao.ComActEasyPhotoActivityMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActEasyPhotoActivityDO">
        <id column="id" property="id" />
        <result column="status" property="status" />
        <result column="content" property="content" />
        <result column="activity_start_at" property="activityStartAt" />
        <result column="activity_ent_at" property="activityEndAt" />
        <result column="release_at" property="releaseAt" />
        <result column="good_reward" property="goodReward" />
        <result column="excellent_reward" property="excellentReward" />
        <result column="ordinary_reward" property="ordinaryReward" />
        <result column="count" property="count" />
        <result column="logo" property="logo" />
        <result column="create_at" property="createAt" />
        <result column="commonly_reward" property="commonlyReward" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, status, content, activity_start_at, activity_end_at, release_at, good_reward, excellent_reward, ordinary_reward, count, create_at, logo, commonly_reward
    </sql>
 
    <select id="pageActivity" parameterType="com.panzhihua.common.model.dtos.community.easyPhoto.PageEasyPhotoActivityDTO"
            resultType="com.panzhihua.common.model.vos.community.ComActEasyPhotoActivityVO">
        select id,community_id,status,content,activity_start_at,activity_end_at,release_at,good_reward
        ,excellent_reward,ordinary_reward,commonly_reward,count,logo from com_act_easy_photo_activity
        <where>
            <if test="pageEasyPhotoActivityDTO.status != null">
                and status = #{pageEasyPhotoActivityDTO.status}
            </if>
 
            <if test="pageEasyPhotoActivityDTO.communityId != null">
                and community_id = ${pageEasyPhotoActivityDTO.communityId}
            </if>
 
            <if test="pageEasyPhotoActivityDTO.startTime != null and pageEasyPhotoActivityDTO.startTime != &quot;&quot;
            and pageEasyPhotoActivityDTO.endTime != null and pageEasyPhotoActivityDTO.endTime != &quot;&quot;">
                and (
                #{pageEasyPhotoActivityDTO.startTime} BETWEEN activity_start_at AND activity_end_at OR
                #{pageEasyPhotoActivityDTO.endTime} BETWEEN activity_start_at AND activity_end_at OR
                activity_start_at BETWEEN #{pageEasyPhotoActivityDTO.startTime} AND #{pageEasyPhotoActivityDTO.endTime} OR
                activity_end_at   BETWEEN #{pageEasyPhotoActivityDTO.startTime} AND #{pageEasyPhotoActivityDTO.endTime}
                )
            </if>
        </where>
 
        order by release_at desc
    </select>
 
    <select id="getEasyPhotoActivityTimeConflict" resultType="Integer">
        SELECT count(id)
        FROM com_act_easy_photo_activity
        WHERE status in (1,2) and (
        #{startTime} BETWEEN activity_start_at AND activity_end_at OR
        #{endTime} BETWEEN activity_start_at AND activity_end_at OR
        activity_start_at BETWEEN #{startTime} AND #{endTime} OR
        activity_end_at   BETWEEN #{startTime} AND #{endTime}
        )
        <if test="activityId != null">
            and id != #{activityId}
        </if>
 
        and community_id = ${communityId}
 
    </select>
 
    <select id="pageActivityUser" parameterType="com.panzhihua.common.model.dtos.community.easyPhoto.PageEasyPhotoActivityUserDTO"
            resultType="com.panzhihua.common.model.vos.community.easyPhoto.ComActEasyPhotoActivityUserVO">
        SELECT
            caep.id,
            su.nick_name,
            su.name as userName,
            su.phone,
            caep.detail,
            caep.activity_type,
            caep.activity_amount,
            caep.`status`,
            caep.create_at
        FROM
            com_act_easy_photo AS caep
            LEFT JOIN sys_user AS su ON su.user_id = caep.sponsor_id
            <where>
                <if test="pageEasyPhotoActivityUserDTO.activityId != null">
                    and activity_id = #{pageEasyPhotoActivityUserDTO.activityId}
                </if>
            </where>
            order by caep.create_at desc
    </select>
 
</mapper>