ShopZxMapper.xml 3.72 KB
<?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>