<?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.kmall.admin.dao.FeedbackDao">

	<resultMap type="com.kmall.admin.entity.FeedbackEntity" id="feedbackMap">
		<result property="msgId" column="msg_id"/>
		<result property="userId" column="user_id"/>
		<result property="userName" column="user_name"/>
		<result property="mobile" column="mobile"/>
		<result property="feedType" column="feed_Type"/>
		<result property="content" column="content"/>
		<result property="status" column="status"/>
		<result property="addTime" column="add_time"/>
	</resultMap>

	<select id="queryObject" resultType="com.kmall.admin.entity.FeedbackEntity">
		select
		`msg_id`,
		`user_id`,
		`user_name`,
		`mobile`,
		`feed_Type`,
		`content`,
		`status`,
		`add_time`
		from mall_feedback
		where msg_id = #{id}
	</select>

	<select id="queryList" resultType="com.kmall.admin.entity.FeedbackEntity">
		select
		`msg_id`,
		`user_id`,
		`user_name`,
		`mobile`,
		`feed_Type`,
		`content`,
		`status`,
		`add_time`
		from mall_feedback
		WHERE 1=1
		<if test="userName != null and userName.trim() != ''">
			AND user_name LIKE concat('%',#{userName},'%')
		</if>
		<choose>
			<when test="sidx != null and sidx.trim() != ''">
				order by ${sidx} ${order}
			</when>
			<otherwise>
				order by msg_id desc
			</otherwise>
		</choose>
		<if test="offset != null and limit != null">
			limit #{offset}, #{limit}
		</if>
	</select>

	<select id="queryTotal" resultType="int">
		select count(*) from mall_feedback
		WHERE 1=1
		<if test="userName != null and userName.trim() != ''">
			AND user_name LIKE concat('%',#{userName},'%')
		</if>
	</select>

	<insert id="save" parameterType="com.kmall.admin.entity.FeedbackEntity" useGeneratedKeys="true" keyProperty="msgId">
		insert into mall_feedback(
		`user_id`,
		`user_name`,
		`mobile`,
		`feed_Type`,
		`content`,
		`status`,
		`add_time`)
		values(
		#{userId},
		#{userName},
		#{mobile},
		#{feedType},
		#{content},
		#{status},
		#{addTime})
	</insert>

	<update id="update" parameterType="com.kmall.admin.entity.FeedbackEntity">
		update mall_feedback
		<set>
			<if test="userId != null">`user_id` = #{userId}, </if>
			<if test="userName != null">`user_name` = #{userName}, </if>
			<if test="mobile != null">`mobile` = #{mobile}, </if>
			<if test="feedType != null">`feed_Type` = #{feedType}, </if>
			<if test="content != null">`content` = #{content}, </if>
			<if test="status != null">`status` = #{status}, </if>
			<if test="addTime != null">`add_time` = #{addTime}</if>
		</set>
		where msg_id = #{msgId}
	</update>

	<delete id="delete">
		delete from mall_feedback where msg_id = #{value}
	</delete>

	<delete id="deleteBatch">
		delete from mall_feedback where msg_id in
		<foreach item="msgId" collection="array" open="(" separator="," close=")">
			#{msgId}
		</foreach>
	</delete>

</mapper>