46 lines
2.0 KiB
XML
46 lines
2.0 KiB
XML
<?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.imyeyu.api.modules.gao.mapper.GaoProductUnitMapper">
|
|
<resultMap id="unitResultMap" type="com.imyeyu.api.modules.gao.entity.GaoProductUnit">
|
|
<id column="id" property="id"/>
|
|
<result column="product_id" property="productId"/>
|
|
<result column="name" property="name"/>
|
|
<result column="conversion_to_base" property="conversionToBase"/>
|
|
<result column="is_base" property="isBase"/>
|
|
<result column="allow_purchase" property="allowPurchase"/>
|
|
<result column="allow_sale" property="allowSale"/>
|
|
<result column="sort" property="sort"/>
|
|
<result column="created_at" property="createdAt"/>
|
|
<result column="updated_at" property="updatedAt"/>
|
|
<result column="deleted_at" property="deletedAt"/>
|
|
</resultMap>
|
|
<select id="selectByProductId" resultMap="unitResultMap">
|
|
SELECT * FROM `gao_product_unit`
|
|
WHERE `product_id` = #{productId} AND `deleted_at` IS NULL
|
|
ORDER BY `sort`, `created_at`
|
|
</select>
|
|
<select id="selectByProductIdList" resultMap="unitResultMap">
|
|
SELECT * FROM `gao_product_unit`
|
|
WHERE `deleted_at` IS NULL
|
|
<choose>
|
|
<when test="productIdList != null and !productIdList.isEmpty()">
|
|
AND `product_id` IN <foreach collection="productIdList" item="id" open="(" separator="," close=")">#{id}</foreach>
|
|
</when>
|
|
<otherwise>AND FALSE</otherwise>
|
|
</choose>
|
|
ORDER BY `product_id`, `sort`, `created_at`
|
|
</select>
|
|
<select id="selectForUpdate" resultMap="unitResultMap">
|
|
SELECT * FROM `gao_product_unit`
|
|
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
|
FOR UPDATE
|
|
</select>
|
|
<update id="updateUnit">
|
|
UPDATE `gao_product_unit`
|
|
SET `name` = #{name}, `conversion_to_base` = #{conversionToBase}, `is_base` = #{isBase},
|
|
`allow_purchase` = #{allowPurchase}, `allow_sale` = #{allowSale}, `sort` = #{sort},
|
|
`updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
|
WHERE `id` = #{id} AND `product_id` = #{productId} AND `deleted_at` IS NULL
|
|
</update>
|
|
</mapper>
|