ShopZxMapper.xml 3.91 KB
Newer Older
1 2
<?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">
licc's avatar
licc committed
3
<mapper namespace="cn.wisenergy.mapper.ShopZxMapper">
4
    <resultMap id="zxMap" type="cn.wisenergy.model.app.shopZx">
5 6 7
        <id column="zx_id" property="zxid"/>
        <result column="zx_url" property="zxUrl"/>
        <result column="zx_likes" property="zxLikes"/>
8
        <result column="invite_code" property="inviteCode"/>
9 10
        <result column="zx_to_examine" property="zxToExamine"/>
        <result column="zx_field" property="zxField"/>
11
        <result column="zx_date" property="zxDate"/>
12 13 14 15 16 17
    </resultMap>
    <sql id="table">
        shop_zx
    </sql>

    <sql id="cols_all">
18
        zx_id as zxid,
19 20 21 22
        <include refid="cols_exclude_id"/>
    </sql>

    <sql id="cols_exclude_id">
23
        zx_url,zx_field,invite_code,zx_date
24 25 26
    </sql>

    <sql id="vals">
27
        #{zxUrl},#{zxField},#{inviteCode},#{zxDate}
28
    </sql>
29 30 31 32 33

    <sql id="updateCondition">
        <if test="zxLikes != null">zx_likes = #{zxLikes},</if>
    </sql>

34 35 36 37 38 39 40 41 42 43
    <!--资讯内容插入-->
    <insert id="zxadd" parameterType="cn.wisenergy.model.app.shopZx">
        insert into
        <include refid="table"/>
        (<include refid="cols_exclude_id"/>)
        value(
        <include refid="vals"/>
        )
    </insert>

44
    <!--用户头像插入-->
45 46 47 48 49 50 51 52 53 54
    <update id="zxadd1" parameterType="cn.wisenergy.model.app.User">
        UPDATE
        user_info
        <set>
            head_image=#{headImage}
        </set>
        <where>
            user_id=#{userId}
        </where>
    </update>
55

56

57
    <!--资讯内容倒叙查询-->
58 59
    <!--资讯内容倒叙查询-->
    <select id="selectPage" parameterType="java.lang.Integer" resultType="cn.wisenergy.model.dto.ZxUserDto">
licc's avatar
licc committed
60 61 62 63 64 65 66 67 68 69
        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
licc's avatar
licc committed
70
        WHERE zx_to_examine = 1
licc's avatar
licc committed
71 72
        AND a.user_id !=0
        order by zxid desc limit #{pageNum},#{pageSize}
73
    </select>
74 75
    <!--资讯点赞专用sql-->
    <select id="selectByzxid" parameterType="java.lang.Integer" resultType="cn.wisenergy.model.app.shopZx">
licc's avatar
licc committed
76
        select * from shop_zx where zx_id=#{zxid}
77 78 79
    </select>
    <update id="updateByzxid">

licc's avatar
licc committed
80 81 82 83 84 85 86 87 88
        UPDATE
        <include refid="table"/>
        <set>
            zx_likes = #{zxLikes}
        </set>
        <where>
            zx_id = #{zxid}
        </where>
    </update>
89

90 91 92 93 94 95 96 97 98 99 100
    <!--资讯审核-->
    <update id="updateZxToExaminezxid">
        UPDATE
        <include refid="table"/>
        <set>
            zx_to_examine = #{ZxToExamine}
        </set>
        <where>
            zx_id = #{zxid}
        </where>
    </update>
101
    <!--资讯内容与用户内容倒叙查询-->
102
    <select id="getShopZxList" resultType="cn.wisenergy.model.vo.ShopZxUserVo">
licc's avatar
licc committed
103 104 105 106 107 108 109 110 111 112 113
        select
        b.zx_id as zxid,
        b.zx_url as zxUrl,
        b.zx_likes as zxLikes,
        b.zx_to_examine as auditStatus,
        b.zx_field as zxField,
        b.zx_date as zxDate,
        b.invite_code as inviteCode,
        a.user_id as userId,
        b.zx_to_examine as ZxToExamine
        from shop_zx b left join user_info a ON a.invite_code=b.invite_code
114 115 116 117 118 119
        <where>
            1=1
            <if test="userId != null and userId != ''">
                and user_id = #{userId}
            </if>
        </where>
licc's avatar
licc committed
120
        order by zx_id desc
121 122 123 124 125 126 127 128 129 130 131 132
        limit #{startNum},#{endNum}
    </select>

    <select id="count" resultType="java.lang.Integer">
        select count(1)
        from
        <include refid="table"/>
        <where>
            <if test="userId != null and userId != ''">
                zx_id = #{zxId}
            </if>
        </where>
133
    </select>
134

135
</mapper>