ShopZxMapper.xml 3.17 KB
Newer Older
1 2 3 4
<?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">
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
    <select id="selectPage" parameterType="java.lang.Integer" resultType="cn.wisenergy.model.app.zxUserDto">
59
       select
60 61 62 63 64 65 66 67
      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
68
      from shop_zx b left join user_info a ON a.invite_code=b.invite_code
69
      WHERE zx_to_examine != 0
70
      order by zxid desc limit #{pageNum},#{pageSize}
71 72 73 74
    </select>
    <!--资讯总记录数查询-->
    <select id="selectAllNum" parameterType="cn.wisenergy.model.app.shopZx" >
    select count (*) from shop_zx
75
    </select>
76 77 78 79
    <!--查询点赞记录-->
    <select id="selectlikes" parameterType="cn.wisenergy.model.app.userLikes" >
    select * from user_likes
    </select>
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
    <!--资讯点赞专用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>

96 97 98 99 100 101 102 103 104 105 106 107
    <!--资讯审核-->
    <update id="updateZxToExaminezxid">
        UPDATE
        <include refid="table"/>
        <set>
            zx_to_examine = #{ZxToExamine}
        </set>
        <where>
            zx_id = #{zxid}
        </where>
    </update>

108
</mapper>