ghy-all/ghy-order/src/main/resources/mapper/order/OrderTemplateMapper.xml

172 lines
9.9 KiB
XML
Raw Normal View History

2023-02-23 00:19:00 +08:00
<?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.ghy.order.mapper.OrderTemplateMapper">
<resultMap id="ColumnMap" type="com.ghy.order.domain.OrderTemplate">
<id property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="templateName" column="template_name"/>
<result property="goodsBrand" column="goods_brand"/>
<result property="goodsSpecification" column="goods_specification"/>
<result property="videoUrl" column="video_url"/>
<result property="imageUrl" column="image_url"/>
<result property="addressId" column="address_id"/>
<result property="streetId" column="street_id"/>
<result property="fullAddress" column="full_address"/>
<result property="customerName" column="customer_name"/>
<result property="customerPhone" column="customer_phone"/>
<result property="orderMode" column="order_mode"/>
<result property="price" column="price"/>
<result property="agencyFund" column="agency_fund"/>
<result property="informationFee" column="information_fee"/>
<result property="bonus" column="bonus"/>
<result property="logisticsCode" column="logistics_code"/>
<result property="needWagon" column="need_wagon"/>
<result property="needCarry" column="need_carry"/>
<result property="floor" column="floor"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap>
<update id="update" parameterType="com.ghy.order.domain.OrderTemplate">
UPDATE order_template
<set>
<if test="templateName != null and templateName != 0">template_name = #{templateName},</if>
<if test="goodsBrand != null and goodsBrand != 0">goods_brand = #{goodsBrand},</if>
<if test="goodsSpecification != null and goodsSpecification != 0">goods_specification = #{goodsSpecification},</if>
<if test="videoUrl != null and videoUrl != 0">video_url = #{videoUrl},</if>
<if test="imageUrl != null and imageUrl != 0">image_url = #{imageUrl},</if>
<if test="addressId != null and addressId != 0">address_id = #{addressId},</if>
<if test="streetId != null and streetId != 0">street_id = #{streetId},</if>
<if test="fullAddress != null and fullAddress != 0">full_address = #{fullAddress},</if>
<if test="customerName != null and customerName != 0">customer_name = #{customerName},</if>
<if test="customerPhone != null and customerPhone != 0">customer_phone = #{customerPhone},</if>
<if test="orderMode != null and orderMode != 0">order_mode = #{orderMode},</if>
<if test="price != null and price != 0">price = #{price},</if>
<if test="agencyFund != null and agencyFund != 0">agency_fund = #{agencyFund},</if>
<if test="informationFee != null and informationFee != 0">information_fee = #{informationFee},</if>
<if test="bonus != null and bonus != 0">bonus = #{bonus},</if>
<if test="logisticsCode != null and logisticsCode != 0">logistics_code = #{logisticsCode},</if>
<if test="needWagon != null and needWagon != 0">need_wagon = #{needWagon},</if>
<if test="needCarry != null and needCarry != 0">need_carry = #{needCarry},</if>
<if test="floor != null and floor != 0">floor = #{floor},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = SYSDATE()
</set>
WHERE id = #{id}
</update>
<insert id="insert" parameterType="com.ghy.order.domain.OrderTemplate" useGeneratedKeys="true" keyProperty="id">
INSERT INTO order_template(
user_id,
<if test="templateName != null and templateName != 0">template_name,</if>
<if test="goodsBrand != null and goodsBrand != 0">goods_brand,</if>
<if test="goodsSpecification != null and goodsSpecification != 0">goods_specification = #{goodsSpecification},</if>
<if test="videoUrl != null and videoUrl != 0">video_url,</if>
<if test="imageUrl != null and imageUrl != 0">image_url,</if>
<if test="addressId != null and addressId != 0">address_id,</if>
<if test="streetId != null and streetId != 0">street_id,</if>
<if test="fullAddress != null and fullAddress != 0">full_address,</if>
<if test="customerName != null and customerName != 0">customer_name,</if>
<if test="customerPhone != null and customerPhone != 0">customer_phone,</if>
<if test="orderMode != null and orderMode != 0">order_mode,</if>
<if test="price != null and price != 0">price,</if>
<if test="agencyFund != null and agencyFund != 0">agency_fund,</if>
<if test="informationFee != null and informationFee != 0">information_fee,</if>
<if test="bonus != null and bonus != 0">bonus,</if>
<if test="logisticsCode != null and logisticsCode != 0">logistics_code,</if>
<if test="needWagon != null and needWagon != 0">need_wagon,</if>
<if test="needCarry != null and needCarry != 0">need_carry,</if>
<if test="floor != null and floor != 0">floor,</if>
create_time
)VALUES(
#{userId},
<if test="templateName != null and templateName != 0">#{templateName},</if>
<if test="goodsBrand != null and goodsBrand != 0">#{goodsBrand},</if>
<if test="goodsSpecification != null and goodsSpecification != 0">goods_specification = #{goodsSpecification},</if>
<if test="videoUrl != null and videoUrl != 0">#{videoUrl},</if>
<if test="imageUrl != null and imageUrl != 0">#{imageUrl},</if>
<if test="addressId != null and addressId != 0">#{addressId},</if>
<if test="streetId != null and streetId != 0">#{streetId},</if>
<if test="fullAddress != null and fullAddress != 0">#{fullAddress},</if>
<if test="customerName != null and customerName != 0">#{customerName},</if>
<if test="customerPhone != null and customerPhone != 0">#{customerPhone},</if>
<if test="orderMode != null and orderMode != 0">#{orderMode},</if>
<if test="price != null and price != 0">#{price},</if>
<if test="agencyFund != null and agencyFund != 0">#{agencyFund},</if>
<if test="informationFee != null and informationFee != 0">#{informationFee},</if>
<if test="bonus != null and bonus != 0">#{bonus},</if>
<if test="logisticsCode != null and logisticsCode != 0">#{logisticsCode},</if>
<if test="needWagon != null and needWagon != 0">#{needWagon},</if>
<if test="needCarry != null and needCarry != 0">#{needCarry},</if>
<if test="floor != null and floor != 0">#{floor},</if>
SYSDATE()
)
</insert>
<select id="select" parameterType="com.ghy.order.domain.OrderTemplate" resultMap="ColumnMap">
<include refid="selectColumns"/>
<where>
<if test="userId != null and userId != 0">
AND user_id = #{userId}
</if>
</where>
</select>
<select id="selectById" parameterType="long" resultMap="ColumnMap">
<include refid="selectColumns"/> WHERE id = #{id}
</select>
<select id="selectByIds" resultType="com.ghy.order.domain.OrderTemplate">
<include refid="selectColumns"/> WHERE id IN
<foreach collection="array" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<delete id="delete" parameterType="Long">
2023-02-23 10:28:11 +08:00
DELETE FROM order_template WHERE id = #{id}
2023-02-23 00:19:00 +08:00
</delete>
<delete id="batchDelete">
DELETE FROM order_template WHERE id IN
<foreach collection="array" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<sql id="selectColumns">
SELECT id, user_id, template_name,goods_brand, goods_specification, video_url, image_url,
address_id, street_id, full_address, customer_name, customer_phone, order_mode,
price, agency_fund, information_fee, bonus, logistics_code, need_wagon, need_carry, floor,
create_by, create_time, update_by, update_time, remark
FROM order_template
</sql>
<!-- order_template_goods SQL -->
<insert id="insertGoods">
INSERT INTO order_template_goods(order_template_id, goods_id, goods_name, dept_goodscategory_id, number)
VALUES(#{orderTemplateId}, #{goodsId}, #{goodsName}, #{deptGoodsCategoryId}, #{number})
</insert>
<delete id="deleteGoods" parameterType="Long">
DELETE FROM order_template_goods WHERE order_template_id = #{orderTemplateId}
</delete>
<select id="selectGoods" resultType="com.ghy.order.domain.OrderTemplateGoods">
SELECT order_template_id AS orderTemplateId,
goods_id AS goodsId,
goods_name AS goodsName,
dept_goodscategory_id AS deptGoodsCategoryId,
number
FROM order_template_goods
WHERE order_template_id = #{orderTemplateId}
</select>
</mapper>