ShopZxMapper.xml 2.86 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 11
        <result column="zx_to_examine" property="zxToExamine"/>
        <result column="zx_field" property="zxField"/>
        <result column="zx_address" property="zxAddress"/>
12
        <result column="zx_date" property="zxDate"/>
13 14 15 16 17 18
    </resultMap>
    <sql id="table">
        shop_zx
    </sql>

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

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

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

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

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

    <!--资讯内容倒叙查询-->
46
    <select id="selectPage" parameterType="java.lang.Integer" resultType="cn.wisenergy.model.app.zxUserDto">
47 48 49 50 51 52 53 54 55 56
      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.zx_address as zxAddress,
      b.invite_code as inviteCode,
      a.user_id as userId,
      a.head_image as headImage
57
      from shop_zx b inner join user_info a ON a.invite_code=b.invite_code
58
      WHERE zx_to_examine != 0
59
      order by zxid desc limit #{pageNum},#{pageSize}
60 61 62 63
    </select>
    <!--资讯总记录数查询-->
    <select id="selectAllNum" parameterType="cn.wisenergy.model.app.shopZx" >
    select count (*) from shop_zx
64
    </select>
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
    <!--资讯点赞专用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>

81 82 83 84 85 86 87 88 89 90 91 92
    <!--资讯审核-->
    <update id="updateZxToExaminezxid">
        UPDATE
        <include refid="table"/>
        <set>
            zx_to_examine = #{ZxToExamine}
        </set>
        <where>
            zx_id = #{zxid}
        </where>
    </update>

93
</mapper>