banner-mapper.xml
2.43 KB
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
<?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.cjs.cms.dao.site.BannerDao">
<sql id="banner_field">
Id, title, image, url, target, sort, start_at, end_at, create_by, create_at, update_by, update_at, type, banner_location
</sql>
<sql id="getBannerCondition">
where 1 = 1
<if test="title != null and title != ''">
and title like CONCAT('%',#{title},'%')
</if>
<if test="beginDate != null and endDate == null">
and create_at> = #{beginDate}
</if>
<if test="endDate != null and beginDate == null">
and DATE_ADD(#{endDate} , INTERVAL +1 day)> = create_at
</if>
<if test="endDate != null and beginDate != null">
and create_at between #{beginDate} and
DATE_ADD(#{endDate}, INTERVAL +1 day)
</if>
<if test="type != null and type != ''">
and type = #{type}
</if>
<if test="bannerLocation != null and bannerLocation != ''">
and banner_location = #{bannerLocation}
</if>
</sql>
<insert id="addBanner" parameterType="java.util.Map">
insert into
banner(title, image, url, target, sort, start_at, end_at, create_by, create_at, update_by, update_at, type, banner_location)
values(#{title}, #{image}, #{url}, #{target}, #{sort}, #{startAt}, #{endAt}, #{createBy}, now(), #{updateBy}, now(), #{type}, #{bannerLocation})
</insert>
<update id="updateBanner" parameterType="java.util.Map">
update banner set
title = #{title},url = #{url},target = #{target},sort = #{sort},
start_at = #{startAt},end_at = #{endAt},update_by = #{updateBy},update_at = now(), type = #{type}, banner_location = #{bannerLocation}
<if test="image != null and image != ''">
,image = #{image}
</if>
where Id = #{id}
</update>
<delete id="deleteBanner" parameterType="int">
delete from banner where
Id = #{id}
</delete>
<select id="getBannerList" parameterType="java.util.Map"
resultType="BannerInfo">
select
<include refid="banner_field" />
from banner
<include refid="getBannerCondition" />
order by Id desc
<include refid="common.pageLimit" />
</select>
<select id="getBannerListCount" parameterType="java.util.Map"
resultType="int">
select count(*) from banner
<include refid="getBannerCondition" />
</select>
<select id="getBannerLocationCount" parameterType="int" resultType="int">
select count(*) from banner where banner_location = #{bannerLocation}
</select>
</mapper>