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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?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.BannerMapper">
 
    <resultMap type="Banner" id="BannerResult">
        <result property="bannerId"    column="banner_id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="bannerPosition"    column="banner_position"    />
        <result property="bannerUrl"    column="banner_url"    />
        <result property="targetType"    column="target_type"    />
        <result property="linkType"    column="link_type"    />
        <result property="linkUrl"    column="link_url"    />
        <result property="jumpType"    column="jump_type"    />
        <result property="jumpId"    column="jump_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="createUserId"    column="create_user_id"    />
    </resultMap>
 
    <!--<sql id="selectBannerVo">
        select banner_id, del_flag, banner_position, banner_url, target_type, link_type, link_url, jump_type, jump_id, create_time, create_user_id from t_banner
    </sql>
 
    <select id="selectBannerList" parameterType="Banner" resultMap="BannerResult">
        <include refid="selectBannerVo"/>
        <where>
            <if test="bannerPosition != null "> and banner_position = #{bannerPosition}</if>
            <if test="bannerUrl != null  and bannerUrl != ''"> and banner_url = #{bannerUrl}</if>
            <if test="targetType != null "> and target_type = #{targetType}</if>
            <if test="linkType != null "> and link_type = #{linkType}</if>
            <if test="linkUrl != null  and linkUrl != ''"> and link_url = #{linkUrl}</if>
            <if test="jumpType != null "> and jump_type = #{jumpType}</if>
            <if test="jumpId != null  and jumpId != ''"> and jump_id = #{jumpId}</if>
            <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
        </where>
    </select>
 
    <select id="selectBannerByBannerId" parameterType="Long" resultMap="BannerResult">
        <include refid="selectBannerVo"/>
        where banner_id = #{bannerId}
    </select>
 
    <insert id="insertBanner" parameterType="Banner" useGeneratedKeys="true" keyProperty="bannerId">
        insert into t_banner
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">del_flag,</if>
            <if test="bannerPosition != null">banner_position,</if>
            <if test="bannerUrl != null">banner_url,</if>
            <if test="targetType != null">target_type,</if>
            <if test="linkType != null">link_type,</if>
            <if test="linkUrl != null">link_url,</if>
            <if test="jumpType != null">jump_type,</if>
            <if test="jumpId != null">jump_id,</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="bannerPosition != null">#{bannerPosition},</if>
            <if test="bannerUrl != null">#{bannerUrl},</if>
            <if test="targetType != null">#{targetType},</if>
            <if test="linkType != null">#{linkType},</if>
            <if test="linkUrl != null">#{linkUrl},</if>
            <if test="jumpType != null">#{jumpType},</if>
            <if test="jumpId != null">#{jumpId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createUserId != null">#{createUserId},</if>
        </trim>
    </insert>
 
    <update id="updateBanner" parameterType="Banner">
        update t_banner
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="bannerPosition != null">banner_position = #{bannerPosition},</if>
            <if test="bannerUrl != null">banner_url = #{bannerUrl},</if>
            <if test="targetType != null">target_type = #{targetType},</if>
            <if test="linkType != null">link_type = #{linkType},</if>
            <if test="linkUrl != null">link_url = #{linkUrl},</if>
            <if test="jumpType != null">jump_type = #{jumpType},</if>
            <if test="jumpId != null">jump_id = #{jumpId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createUserId != null">create_user_id = #{createUserId},</if>
        </trim>
        where banner_id = #{bannerId}
    </update>
 
    <delete id="deleteBannerByBannerId" parameterType="Long">
        delete from t_banner where banner_id = #{bannerId}
    </delete>
 
    <delete id="deleteBannerByBannerIds" parameterType="String">
        delete from t_banner where banner_id in
        <foreach item="bannerId" collection="array" open="(" separator="," close=")">
            #{bannerId}
        </foreach>
    </delete>-->
 
    <select id="listHomeBannerVo" resultType="com.ruoyi.system.domain.vo.AppBannerVo">
        SELECT
        banner_id bannerId,
        banner_url bannerUrl,
        target_type targetType,
        link_type linkType,
        link_url linkUrl,
        jump_type jumpType,
        jump_id jumpId
        FROM t_banner WHERE del_flag = 0 AND banner_position = 1
        ORDER BY banner_sort DESC,create_time DESC LIMIT 5
    </select>
 
    <select id="pageMgtBannerVo" resultType="com.ruoyi.system.domain.vo.MgtBannerPageVo">
        SELECT
            banner_id bannerId,
            banner_url bannerUrl,
            CASE target_type
                WHEN 1 THEN "外链"
                WHEN 2 THEN "内链"
                ELSE "无"
                END targetType,
            create_time createTime
        FROM t_banner WHERE del_flag = 0
        ORDER BY create_time DESC
    </select>
</mapper>