123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <?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="com.caimei.modules.hehe.dao.CmHeheUserDao">
-
- <sql id="cmHeheUserColumns">
- a.id AS "id",
- a.userId AS "userId",
- a.name AS "name",
- a.mobile AS "mobile",
- a.userIdentity AS "userIdentity",
- a.nickName AS "nickName",
- a.openId AS "openId",
- a.addTime AS "addTime"
- </sql>
-
- <sql id="cmHeheUserJoins">
- </sql>
- <delete id="deleteUserActivity">
- delete from cm_hehe_user_activity where userId = #{userId} and productId = #{productId}
- </delete>
- <select id="get" resultType="CmHeheUser">
- SELECT
- <include refid="cmHeheUserColumns"/>
- FROM cm_hehe_user a
- <include refid="cmHeheUserJoins"/>
- WHERE a.id = #{id}
- </select>
-
- <select id="findList" resultType="CmHeheUser">
- SELECT
- <include refid="cmHeheUserColumns"/>
- FROM cm_hehe_user a
- <include refid="cmHeheUserJoins"/>
- <where>
- <if test="name != null and name != ''">
- AND a.name LIKE
- <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
- </if>
- <if test="mobile != null and mobile != ''">
- AND a.mobile = #{mobile}
- </if>
- <if test="userIdentity != null and userIdentity != ''">
- AND a.userIdentity = #{userIdentity}
- </if>
- <if test="nickName != null and nickName != ''">
- AND a.nickName LIKE concat('%',#{nickName},'%')
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY addTime DESC
- </otherwise>
- </choose>
- </select>
-
- <select id="findAllList" resultType="CmHeheUser">
- SELECT
- <include refid="cmHeheUserColumns"/>
- FROM cm_hehe_user a
- <include refid="cmHeheUserJoins"/>
- <where>
-
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
-
- <insert id="insert" parameterType="CmHeheUser" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_hehe_user(
- userId,
- name,
- mobile,
- userIdentity,
- nickName,
- openId,
- addTime
- ) VALUES (
- #{userId},
- #{name},
- #{mobile},
- #{userIdentity},
- #{nickName},
- #{openId},
- #{addTime}
- )
- </insert>
-
- <update id="update">
- UPDATE cm_hehe_user SET
- name = #{name},
- mobile = #{mobile},
- userIdentity = #{userIdentity},
- nickName = #{nickName},
- openId = #{openId},
- addTime = #{addTime}
- WHERE id = #{id}
- </update>
- <select id="findMobileOnly" resultType="integer">
- SELECT
- id
- FROM
- cm_hehe_user
- WHERE
- mobile = #{mobile}
- <if test="id != null and id != ''">
- AND id != #{id}
- </if>
- </select>
- <insert id="insertUser" parameterType="com.caimei.modules.user.entity.CmUser" keyColumn="userID" keyProperty="userID" useGeneratedKeys="true">
- INSERT INTO USER (
- bindMobile, userPermission, userIdentity,
- userName, password, name, registerTime,
- validFlag, registerUserTypeID
- )
- VALUES
- (
- #{bindMobile}, #{userPermission}, #{userIdentity},
- #{userName}, #{password}, #{name}, #{registerTime},
- #{validFlag}, #{registerUserTypeID}
- )
- </insert>
- <update id="updateUser">
- UPDATE
- user
- SET
- bindMobile = #{bindMobile},
- userName = #{userName},
- name = #{name}
- WHERE
- userID = #{userID}
- </update>
- <select id="activityProductList" resultType="com.caimei.modules.hehe.entity.CmHeheActivityProduct">
- SELECT
- a.id AS "id",
- a.userId AS "userId",
- a.activityId AS "activityId",
- a.productId AS "productId",
- a.sort AS "sort",
- chp.price AS "price",
- p.name AS "name",
- p.mainImage AS "mainImage",
- p.unit AS "unit",
- s.name AS "shopName"
- FROM
- cm_hehe_user_activity a
- LEFT JOIN cm_hehe_product chp ON chp.productId = a.productID
- LEFT JOIN product p ON a.productId = p.productID
- LEFT JOIN shop s ON s.shopID = p.shopID
- WHERE
- a.userId = #{userId}
- <if test="name != null and name != ''">
- AND p.name LIKE CONCAT('%',#{name},'%')
- </if>
- <if test="shopName != null and shopName != ''">
- AND s.name LIKE CONCAT('%',#{shopName},'%')
- </if>
- ORDER BY
- - a.sort DESC
- </select>
- <select id="findUserActivityProduct" resultType="integer">
- SELECT productId FROM cm_hehe_user_activity WHERE userId = #{userId}
- </select>
-
- <select id="findAllActivityProduct" resultType="com.caimei.modules.hehe.entity.CmHeheProduct">
- SELECT
- a.id AS "id",
- a.productId AS "productId",
- chp.price AS "price",
- p.name AS "name",
- p.mainImage AS "mainImage",
- s.name AS "shopName"
- FROM
- cm_hehe_activity_product a
- LEFT JOIN cm_hehe_product chp ON a.productId = chp.productId
- LEFT JOIN product p ON a.productId = p.productID
- LEFT JOIN shop s ON s.shopID = p.shopID
- WHERE
- a.delFlag = 0
- <if test="ids != null and ids.size() > 0 ">
- AND a.productId NOT IN
- <foreach collection="ids" open="(" close=")" item="id" separator=",">
- #{id}
- </foreach>
- </if>
- <if test="productId != null">
- AND a.productId = #{productId}
- </if>
- <if test="name != null and name != ''">
- AND p.name LIKE CONCAT('%',#{name},'%')
- </if>
- <if test="shopName != null and shopName != ''">
- AND s.name LIKE CONCAT('%',#{shopName},'%')
- </if>
- ORDER BY productId DESC
- </select>
- <insert id="insertUserActivity">
- INSERT INTO `cm_hehe_user_activity` (
- `userId`, `activityId`, `productId`,
- addTime
- )
- VALUES
- (
- #{userId}, #{activityId}, #{productId},
- NOW()
- )
- </insert>
- <update id="updateSortById">
- UPDATE cm_hehe_user_activity SET sort = #{sort} WHERE id =#{id}
- </update>
-
- </mapper>
|