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
<?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="cn.wisenergy.mapper.ShopZxMapper">
<resultMap id="zxMap" type="cn.wisenergy.model.app.shopZx">
<id column="zx_id" property="zxid"/>
<result column="zx_url" property="zxUrl"/>
<result column="zx_likes" property="zxLikes"/>
<result column="invite_code" property="inviteCode"/>
<result column="zx_to_examine" property="zxToExamine"/>
<result column="zx_field" property="zxField"/>
<result column="zx_date" property="zxDate"/>
</resultMap>
<sql id="table">
shop_zx
</sql>
<sql id="cols_all">
zx_id as zxid,
<include refid="cols_exclude_id"/>
</sql>
<sql id="cols_exclude_id">
zx_url,zx_field,invite_code,zx_date
</sql>
<sql id="vals">
#{zxUrl},#{zxField},#{inviteCode},#{zxDate}
</sql>
<sql id="updateCondition">
<if test="zxLikes != null">zx_likes = #{zxLikes},</if>
</sql>
<!--资讯内容插入-->
<insert id="zxadd" parameterType="cn.wisenergy.model.app.shopZx">
insert into
<include refid="table"/>
(<include refid="cols_exclude_id"/>)
value(
<include refid="vals"/>
)
</insert>
<!--用户头像插入-->
<update id="zxadd1" parameterType="cn.wisenergy.model.app.User">
UPDATE
user_info
<set>
head_image=#{headImage}
</set>
<where>
user_id=#{userId}
</where>
</update>
<!--资讯内容倒叙查询-->
<select id="selectPage" parameterType="java.lang.Integer" resultType="cn.wisenergy.model.app.zxUserDto">
select
b.zx_id as zxid,
b.zx_url as zxUrl,
b.zx_likes as zxLikes,
b.zx_field as zxField,
b.zx_date as zxDate,
b.invite_code as inviteCode,
a.user_id as userId,
a.head_image as headImage
from shop_zx b left join user_info a ON a.invite_code=b.invite_code
WHERE zx_to_examine != 0
AND a.user_id !=0
order by zxid desc limit #{pageNum},#{pageSize}
</select>
<!--资讯总记录数查询-->
<select id="selectAllNum" parameterType="cn.wisenergy.model.app.shopZx" >
select count (*) from shop_zx
</select>
<!--查询点赞记录-->
<select id="selectlikes" parameterType="cn.wisenergy.model.app.userLikes" >
select * from user_likes
</select>
<!--资讯点赞专用sql-->
<select id="selectByzxid" parameterType="java.lang.Integer" resultType="cn.wisenergy.model.app.shopZx">
select * from shop_zx where zx_id=#{zxid}
</select>
<update id="updateByzxid">
UPDATE
<include refid="table"/>
<set>
zx_likes = #{zxLikes}
</set>
<where>
zx_id = #{zxid}
</where>
</update>
<!--资讯审核-->
<update id="updateZxToExaminezxid">
UPDATE
<include refid="table"/>
<set>
zx_to_examine = #{ZxToExamine}
</set>
<where>
zx_id = #{zxid}
</where>
</update>
<!--资讯内容与用户内容倒叙查询-->
<select id="selectAll" parameterType="java.lang.Integer" resultType="cn.wisenergy.model.app.zxUserVo">
select
b.zx_id as zxid,
b.zx_url as zxUrl,
b.zx_likes as zxLikes,
b.zx_field as zxField,
b.zx_date as zxDate,
b.invite_code as inviteCode,
a.user_id as userId,
a.head_image as headImage
from shop_zx b left join user_info a ON a.invite_code=b.invite_code
order by zx_id desc limit #{pageNum},#{pageSize}
</select>
</mapper>