entrust-data-mapper.xml 2.64 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">

<!-- @author kongmingke -->
<mapper namespace="com.cjs.cms.dao.user.EntrustDataDao">

	<sql id="entrust_data_field">
		id, entrust_id, entrust_name, type, unit, storage_num, market_time, price, entrust_image, create_time, content, storage_total
	</sql>
	
    <sql id="searchCondition">
		where 1 = 1
		<if test="entrustId != null and entrustId != ''">
			and entrust_id = #{entrustId}
		</if>

		<if test="entrustName !=null and entrustName!=''">
			and entrust_name = #{entrustName}
		</if>
		<if test="type !=null and type!=''">
			and type = #{type}
		</if>
		<if test="beginDate != null and endDate == null">
			and market_time > = #{beginDate}
		</if>
		<if test="endDate != null and beginDate == null">
			and DATE_ADD(#{endDate}, INTERVAL +1 day)> =
			market_time
		</if>
		<if test="endDate != null and beginDate != null">
			and market_time between #{beginDate} and
			DATE_ADD(#{endDate}, INTERVAL +1 day)
		</if>
	</sql>
	<insert id="addEntrustInfo" parameterType="EntrustDataInfo">
		insert into
		entrust_data(entrust_id, entrust_name, type, unit, storage_num, market_time, price, entrust_image, create_time, content, storage_total)
		values(#{entrustId}, #{entrustName}, #{type}, #{unit}, #{storageNum}, #{marketTime}, #{price}, #{entrustImage}, now(), #{content}, #{storageTotal});
	</insert>

	<select id="searchList" parameterType="java.util.Map"
		resultType="EntrustDataInfo">
		select
		<include refid="entrust_data_field" />
		from entrust_data
		<include refid="searchCondition" />
		order by id desc
		<include refid="common.pageLimit" />
	</select>

	<select id="searchListCount" parameterType="java.util.Map"
		resultType="int">
		select count(1) from entrust_data
		<include refid="searchCondition" />
	</select>

	<select id="searchEntrust" parameterType="java.util.Map"
		resultType="java.util.Map">
		select entrust_id, entrust_name from entrust_data
	</select>

	<update id="addContent" parameterType="EntrustDataInfo">
		update entrust_data set content = #{content} where id = #{id}
	</update>

	<update id="updateEntrustInfo" parameterType="EntrustDataInfo">
		update entrust_data set
		entrust_id = #{entrustId},entrust_name = #{entrustName},type = #{type},unit = #{unit},
		storage_num = #{storageNum},market_time = #{marketTime},price = #{price},storage_total=#{storageTotal}
		<if test="entrustImage != null and entrustImage != ''">
			,entrust_image = #{entrustImage}
		</if>
		where id = #{id}
	</update>

	<delete id="deleteEntrust" parameterType="int">
		delete from entrust_data where id = #{id}
	</delete>
</mapper>