mitao
2025-01-17 afa0dbb4f54e7244835dd67ec33c3e545f122f71
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
<?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.system.mapper.config.AdvertMapper">
 
    <resultMap type="Advert" id="AdvertResult">
        <result property="adId"    column="ad_id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="adUrl"    column="ad_url"    />
        <result property="adContent"    column="ad_content"    />
        <result property="targetType"    column="target_type"    />
        <result property="linkUrl"    column="link_url"    />
        <result property="jumpId"    column="jump_id"    />
        <result property="logoUrl"    column="logo_url"    />
        <result property="createTime"    column="create_time"    />
        <result property="createUserId"    column="create_user_id"    />
    </resultMap>
 
    <sql id="selectAdvertVo">
        select ad_id, del_flag, ad_url, ad_content, target_type, link_url, jump_id, logo_url, create_time, create_user_id from t_advert
    </sql>
 
    <select id="selectAdvertList" parameterType="Advert" resultMap="AdvertResult">
        <include refid="selectAdvertVo"/>
        <where>
            <if test="adUrl != null  and adUrl != ''"> and ad_url = #{adUrl}</if>
            <if test="adContent != null  and adContent != ''"> and ad_content = #{adContent}</if>
            <if test="targetType != null "> and target_type = #{targetType}</if>
            <if test="linkUrl != null  and linkUrl != ''"> and link_url = #{linkUrl}</if>
            <if test="jumpId != null  and jumpId != ''"> and jump_id = #{jumpId}</if>
            <if test="logoUrl != null  and logoUrl != ''"> and logo_url = #{logoUrl}</if>
            <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
        </where>
    </select>
 
    <select id="selectAdvertByAdId" parameterType="Long" resultMap="AdvertResult">
        <include refid="selectAdvertVo"/>
        where ad_id = #{adId}
    </select>
 
    <insert id="insertAdvert" parameterType="Advert" useGeneratedKeys="true" keyProperty="adId">
        insert into t_advert
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">del_flag,</if>
            <if test="adUrl != null">ad_url,</if>
            <if test="adContent != null">ad_content,</if>
            <if test="targetType != null">target_type,</if>
            <if test="linkUrl != null">link_url,</if>
            <if test="jumpId != null">jump_id,</if>
            <if test="logoUrl != null">logo_url,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createUserId != null">create_user_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">#{delFlag},</if>
            <if test="adUrl != null">#{adUrl},</if>
            <if test="adContent != null">#{adContent},</if>
            <if test="targetType != null">#{targetType},</if>
            <if test="linkUrl != null">#{linkUrl},</if>
            <if test="jumpId != null">#{jumpId},</if>
            <if test="logoUrl != null">#{logoUrl},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createUserId != null">#{createUserId},</if>
        </trim>
    </insert>
 
    <update id="updateAdvert" parameterType="Advert">
        update t_advert
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="adUrl != null">ad_url = #{adUrl},</if>
            <if test="adContent != null">ad_content = #{adContent},</if>
            <if test="targetType != null">target_type = #{targetType},</if>
            <if test="linkUrl != null">link_url = #{linkUrl},</if>
            <if test="jumpId != null">jump_id = #{jumpId},</if>
            <if test="logoUrl != null">logo_url = #{logoUrl},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createUserId != null">create_user_id = #{createUserId},</if>
        </trim>
        where ad_id = #{adId}
    </update>
 
    <delete id="deleteAdvertByAdId" parameterType="Long">
        delete from t_advert where ad_id = #{adId}
    </delete>
 
    <delete id="deleteAdvertByAdIds" parameterType="String">
        delete from t_advert where ad_id in
        <foreach item="adId" collection="array" open="(" separator="," close=")">
            #{adId}
        </foreach>
    </delete>
 
    <select id="getAdvertVo" resultType="com.ruoyi.system.domain.vo.AppAdvertVo">
        SELECT
        ad_id adId,
        ad_url adUrl,
        ad_content adContent,
        link_type linkType,
        target_type targetType,
        link_url linkUrl,
        jump_type jumpType,
        jump_id jumpId,
        logo_url logoUrl
        FROM t_advert WHERE del_flag = 0 ORDER BY create_time DESC LIMIT 1
    </select>
</mapper>