2025-04-03 15:06:05 +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">
|
2025-04-05 19:12:26 +08:00
|
|
|
<mapper namespace="com.bonus.canteen.core.menu.mapper.MenuMaterialMapper">
|
|
|
|
|
<resultMap type="com.bonus.canteen.core.menu.domain.MenuMaterial" id="MenuMaterialResult">
|
2025-04-03 15:06:05 +08:00
|
|
|
<result property="id" column="id" />
|
|
|
|
|
<result property="areaId" column="area_id" />
|
|
|
|
|
<result property="materialId" column="material_id" />
|
|
|
|
|
<result property="materialName" column="material_name" />
|
|
|
|
|
<result property="materialCode" column="material_code" />
|
|
|
|
|
<result property="pinyinInitials" column="pinyin_initials" />
|
|
|
|
|
<result property="pinyinFull" column="pinyin_full" />
|
|
|
|
|
<result property="imageUrl" column="image_url" />
|
|
|
|
|
<result property="nutritionId" column="nutrition_id" />
|
2025-04-17 14:04:14 +08:00
|
|
|
<result property="nutritionType" column="nutrition_type" />
|
|
|
|
|
<result property="nutritionName" column="nutrition_name" />
|
2025-04-03 15:06:05 +08:00
|
|
|
<result property="categoryId" column="category_id" />
|
2025-04-17 14:04:14 +08:00
|
|
|
<result property="categoryName" column="category_name" />
|
2025-04-03 15:06:05 +08:00
|
|
|
<result property="materialType" column="material_type" />
|
|
|
|
|
<result property="barCode" column="bar_code" />
|
|
|
|
|
<result property="unitId" column="unit_id" />
|
|
|
|
|
<result property="salePrice" column="sale_price" />
|
|
|
|
|
<result property="unitPrice" column="unit_price" />
|
|
|
|
|
<result property="salesMode" column="sales_mode" />
|
|
|
|
|
<result property="reserveRate" column="reserve_rate" />
|
|
|
|
|
<result property="shelfLifeType" column="shelf_life_type" />
|
|
|
|
|
<result property="shelfLifeDays" column="shelf_life_days" />
|
|
|
|
|
<result property="synopsis" column="synopsis" />
|
|
|
|
|
<result property="revision" column="revision" />
|
|
|
|
|
<result property="purPriceCeiling" column="pur_price_ceiling" />
|
|
|
|
|
<result property="certId" column="cert_id" />
|
|
|
|
|
<result property="bigCategoryId" column="big_category_id" />
|
|
|
|
|
<result property="size" column="size" />
|
|
|
|
|
<result property="taxRate" column="tax_rate" />
|
|
|
|
|
<result property="disableStatus" column="disable_status" />
|
|
|
|
|
<result property="convertGrams" column="convert_grams" />
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="selectMenuMaterialVo">
|
2025-04-09 09:21:57 +08:00
|
|
|
|
|
|
|
|
<!-- select id, area_id, material_id, material_name, material_code, pinyin_initials, pinyin_full, image_url, nutrition_id, category_id, material_type, bar_code, unit_id, sale_price, unit_price, sales_mode, reserve_rate, shelf_life_type, shelf_life_days, synopsis, revision, pur_price_ceiling, cert_id, big_category_id, size, tax_rate, disable_status, convert_grams from menu_material-->
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
mm.id,
|
|
|
|
|
mm.area_id,
|
|
|
|
|
aa.area_name,
|
|
|
|
|
mm.material_id,
|
|
|
|
|
mm.material_name,
|
|
|
|
|
mm.material_code,
|
|
|
|
|
mm.pinyin_initials,
|
|
|
|
|
mm.pinyin_full,
|
|
|
|
|
mm.image_url,
|
|
|
|
|
mm.nutrition_id,
|
2025-04-17 14:04:14 +08:00
|
|
|
mm.nutrition_type,
|
|
|
|
|
muu.nutrition_name,
|
2025-04-09 09:21:57 +08:00
|
|
|
mm.category_id,
|
|
|
|
|
mmc.category_name,
|
|
|
|
|
mm.material_type,
|
|
|
|
|
mm.bar_code,
|
|
|
|
|
mm.unit_id,
|
|
|
|
|
du.unit_name,
|
|
|
|
|
mm.sale_price,
|
|
|
|
|
mm.unit_price,
|
|
|
|
|
mm.sales_mode,
|
|
|
|
|
mm.reserve_rate,
|
|
|
|
|
mm.shelf_life_type,
|
|
|
|
|
mm.shelf_life_days,
|
|
|
|
|
mm.synopsis,
|
|
|
|
|
mm.revision,
|
|
|
|
|
mm.pur_price_ceiling,
|
|
|
|
|
mm.cert_id,
|
|
|
|
|
mm.big_category_id,
|
|
|
|
|
mm.size,
|
|
|
|
|
mm.tax_rate,
|
|
|
|
|
mm.disable_status,
|
|
|
|
|
mm.convert_grams
|
|
|
|
|
FROM
|
|
|
|
|
menu_material mm
|
|
|
|
|
LEFT JOIN alloc_area aa on aa.area_id = mm.area_id
|
|
|
|
|
LEFT JOIN menu_material_category mmc on mmc.category_id = mm.category_id
|
|
|
|
|
LEFT JOIN drp_unit du on du.unit_id = mm.unit_id
|
2025-04-17 14:04:14 +08:00
|
|
|
LEFT JOIN menu_nutrition muu on muu.nutrition_id = mm.nutrition_id
|
2025-04-03 15:06:05 +08:00
|
|
|
</sql>
|
|
|
|
|
|
2025-04-05 19:12:26 +08:00
|
|
|
<select id="selectMenuMaterialList" parameterType="com.bonus.canteen.core.menu.domain.MenuMaterial" resultMap="MenuMaterialResult">
|
2025-04-03 15:06:05 +08:00
|
|
|
<include refid="selectMenuMaterialVo"/>
|
2025-04-09 09:21:57 +08:00
|
|
|
<where>
|
2025-04-17 16:11:05 +08:00
|
|
|
<if test="areaId != null "> and aa.area_id = #{areaId}</if>
|
|
|
|
|
<if test="materialName != null and materialName != ''"> and mm.material_name like concat('%', #{materialName}, '%')</if>
|
|
|
|
|
<if test="materialCode != null and materialCode != ''"> and mm.material_code like concat('%', #{materialCode}, '%')</if>
|
|
|
|
|
<if test="barCode != null"> and mm.bar_code like concat('%', #{barCode}, '%')</if>
|
2025-04-17 18:15:25 +08:00
|
|
|
<if test="categoryIdList != null and categoryIdList.size() > 0">
|
|
|
|
|
and mm.category_id in
|
|
|
|
|
<foreach item="item" collection="categoryIdList" open="(" separator="," close=")">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
2025-04-03 15:06:05 +08:00
|
|
|
</where>
|
|
|
|
|
</select>
|
2025-04-09 09:21:57 +08:00
|
|
|
|
2025-04-03 15:06:05 +08:00
|
|
|
<select id="selectMenuMaterialById" parameterType="Long" resultMap="MenuMaterialResult">
|
|
|
|
|
<include refid="selectMenuMaterialVo"/>
|
2025-04-17 16:11:05 +08:00
|
|
|
where mm.id = #{id}
|
2025-04-03 15:06:05 +08:00
|
|
|
</select>
|
2025-04-09 09:21:57 +08:00
|
|
|
|
2025-04-05 19:12:26 +08:00
|
|
|
<insert id="insertMenuMaterial" parameterType="com.bonus.canteen.core.menu.domain.MenuMaterial" useGeneratedKeys="true" keyProperty="id">
|
2025-04-03 15:06:05 +08:00
|
|
|
insert into menu_material
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="areaId != null">area_id,</if>
|
|
|
|
|
<if test="materialId != null">material_id,</if>
|
|
|
|
|
<if test="materialName != null and materialName != ''">material_name,</if>
|
|
|
|
|
<if test="materialCode != null and materialCode != ''">material_code,</if>
|
|
|
|
|
<if test="pinyinInitials != null and pinyinInitials != ''">pinyin_initials,</if>
|
|
|
|
|
<if test="pinyinFull != null and pinyinFull != ''">pinyin_full,</if>
|
|
|
|
|
<if test="imageUrl != null and imageUrl != ''">image_url,</if>
|
|
|
|
|
<if test="nutritionId != null">nutrition_id,</if>
|
2025-04-17 14:04:14 +08:00
|
|
|
<if test="nutritionType != null">nutrition_type,</if>
|
2025-04-03 15:06:05 +08:00
|
|
|
<if test="categoryId != null">category_id,</if>
|
|
|
|
|
<if test="materialType != null">material_type,</if>
|
|
|
|
|
<if test="barCode != null">bar_code,</if>
|
|
|
|
|
<if test="unitId != null">unit_id,</if>
|
|
|
|
|
<if test="salePrice != null">sale_price,</if>
|
|
|
|
|
<if test="unitPrice != null">unit_price,</if>
|
|
|
|
|
<if test="salesMode != null">sales_mode,</if>
|
|
|
|
|
<if test="reserveRate != null">reserve_rate,</if>
|
|
|
|
|
<if test="shelfLifeType != null">shelf_life_type,</if>
|
|
|
|
|
<if test="shelfLifeDays != null">shelf_life_days,</if>
|
|
|
|
|
<if test="synopsis != null">synopsis,</if>
|
|
|
|
|
<if test="revision != null">revision,</if>
|
|
|
|
|
<if test="purPriceCeiling != null">pur_price_ceiling,</if>
|
|
|
|
|
<if test="certId != null">cert_id,</if>
|
|
|
|
|
<if test="bigCategoryId != null">big_category_id,</if>
|
|
|
|
|
<if test="size != null">size,</if>
|
|
|
|
|
<if test="taxRate != null">tax_rate,</if>
|
|
|
|
|
<if test="disableStatus != null">disable_status,</if>
|
|
|
|
|
<if test="convertGrams != null">convert_grams,</if>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="areaId != null">#{areaId},</if>
|
|
|
|
|
<if test="materialId != null">#{materialId},</if>
|
|
|
|
|
<if test="materialName != null and materialName != ''">#{materialName},</if>
|
|
|
|
|
<if test="materialCode != null and materialCode != ''">#{materialCode},</if>
|
|
|
|
|
<if test="pinyinInitials != null and pinyinInitials != ''">#{pinyinInitials},</if>
|
|
|
|
|
<if test="pinyinFull != null and pinyinFull != ''">#{pinyinFull},</if>
|
|
|
|
|
<if test="imageUrl != null and imageUrl != ''">#{imageUrl},</if>
|
|
|
|
|
<if test="nutritionId != null">#{nutritionId},</if>
|
2025-04-17 14:04:14 +08:00
|
|
|
<if test="nutritionType != null">#{nutritionType},</if>
|
2025-04-03 15:06:05 +08:00
|
|
|
<if test="categoryId != null">#{categoryId},</if>
|
|
|
|
|
<if test="materialType != null">#{materialType},</if>
|
|
|
|
|
<if test="barCode != null">#{barCode},</if>
|
|
|
|
|
<if test="unitId != null">#{unitId},</if>
|
|
|
|
|
<if test="salePrice != null">#{salePrice},</if>
|
|
|
|
|
<if test="unitPrice != null">#{unitPrice},</if>
|
|
|
|
|
<if test="salesMode != null">#{salesMode},</if>
|
|
|
|
|
<if test="reserveRate != null">#{reserveRate},</if>
|
|
|
|
|
<if test="shelfLifeType != null">#{shelfLifeType},</if>
|
|
|
|
|
<if test="shelfLifeDays != null">#{shelfLifeDays},</if>
|
|
|
|
|
<if test="synopsis != null">#{synopsis},</if>
|
|
|
|
|
<if test="revision != null">#{revision},</if>
|
|
|
|
|
<if test="purPriceCeiling != null">#{purPriceCeiling},</if>
|
|
|
|
|
<if test="certId != null">#{certId},</if>
|
|
|
|
|
<if test="bigCategoryId != null">#{bigCategoryId},</if>
|
|
|
|
|
<if test="size != null">#{size},</if>
|
|
|
|
|
<if test="taxRate != null">#{taxRate},</if>
|
|
|
|
|
<if test="disableStatus != null">#{disableStatus},</if>
|
|
|
|
|
<if test="convertGrams != null">#{convertGrams},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
2025-04-05 19:12:26 +08:00
|
|
|
<update id="updateMenuMaterial" parameterType="com.bonus.canteen.core.menu.domain.MenuMaterial">
|
2025-04-03 15:06:05 +08:00
|
|
|
update menu_material
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
|
<if test="areaId != null">area_id = #{areaId},</if>
|
|
|
|
|
<if test="materialId != null">material_id = #{materialId},</if>
|
|
|
|
|
<if test="materialName != null and materialName != ''">material_name = #{materialName},</if>
|
|
|
|
|
<if test="materialCode != null and materialCode != ''">material_code = #{materialCode},</if>
|
|
|
|
|
<if test="pinyinInitials != null and pinyinInitials != ''">pinyin_initials = #{pinyinInitials},</if>
|
|
|
|
|
<if test="pinyinFull != null and pinyinFull != ''">pinyin_full = #{pinyinFull},</if>
|
|
|
|
|
<if test="imageUrl != null and imageUrl != ''">image_url = #{imageUrl},</if>
|
|
|
|
|
<if test="nutritionId != null">nutrition_id = #{nutritionId},</if>
|
2025-04-17 14:04:14 +08:00
|
|
|
<if test="nutritionType != null">nutrition_type = #{nutritionType},</if>
|
2025-04-03 15:06:05 +08:00
|
|
|
<if test="categoryId != null">category_id = #{categoryId},</if>
|
|
|
|
|
<if test="materialType != null">material_type = #{materialType},</if>
|
|
|
|
|
<if test="barCode != null">bar_code = #{barCode},</if>
|
|
|
|
|
<if test="unitId != null">unit_id = #{unitId},</if>
|
|
|
|
|
<if test="salePrice != null">sale_price = #{salePrice},</if>
|
|
|
|
|
<if test="unitPrice != null">unit_price = #{unitPrice},</if>
|
|
|
|
|
<if test="salesMode != null">sales_mode = #{salesMode},</if>
|
|
|
|
|
<if test="reserveRate != null">reserve_rate = #{reserveRate},</if>
|
|
|
|
|
<if test="shelfLifeType != null">shelf_life_type = #{shelfLifeType},</if>
|
|
|
|
|
<if test="shelfLifeDays != null">shelf_life_days = #{shelfLifeDays},</if>
|
|
|
|
|
<if test="synopsis != null">synopsis = #{synopsis},</if>
|
|
|
|
|
<if test="revision != null">revision = #{revision},</if>
|
|
|
|
|
<if test="purPriceCeiling != null">pur_price_ceiling = #{purPriceCeiling},</if>
|
|
|
|
|
<if test="certId != null">cert_id = #{certId},</if>
|
|
|
|
|
<if test="bigCategoryId != null">big_category_id = #{bigCategoryId},</if>
|
|
|
|
|
<if test="size != null">size = #{size},</if>
|
|
|
|
|
<if test="taxRate != null">tax_rate = #{taxRate},</if>
|
|
|
|
|
<if test="disableStatus != null">disable_status = #{disableStatus},</if>
|
|
|
|
|
<if test="convertGrams != null">convert_grams = #{convertGrams},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteMenuMaterialById" parameterType="Long">
|
|
|
|
|
delete from menu_material where id = #{id}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteMenuMaterialByIds" parameterType="String">
|
2025-04-09 09:21:57 +08:00
|
|
|
delete from menu_material where id in
|
2025-04-03 15:06:05 +08:00
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
2025-04-09 09:21:57 +08:00
|
|
|
|
|
|
|
|
<select id="getLastId" resultType="int">
|
2025-04-17 14:04:14 +08:00
|
|
|
select ifnull(max(id) ,0) from menu_material
|
2025-04-09 09:21:57 +08:00
|
|
|
</select>
|
2025-04-12 20:56:31 +08:00
|
|
|
|
|
|
|
|
<select id="getOne" resultMap="MenuMaterialResult" parameterType="com.bonus.canteen.core.menu.domain.MenuMaterial">
|
|
|
|
|
select * from menu_material where material_name = #{materialName} and area_id = #{areaId}
|
|
|
|
|
</select>
|
2025-04-17 16:11:05 +08:00
|
|
|
|
2025-04-22 13:46:38 +08:00
|
|
|
<select id="selectMenuMaterialMaterialId" resultMap="MenuMaterialResult">
|
|
|
|
|
|
|
|
|
|
<include refid="selectMenuMaterialVo"/>
|
|
|
|
|
where mm.material_id = #{id}
|
|
|
|
|
</select>
|
2025-05-14 13:23:20 +08:00
|
|
|
<select id="selectMaterialIds" resultType="java.lang.Long">
|
|
|
|
|
select material_id from menu_material
|
|
|
|
|
where id in
|
|
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="checkIsExistRelation" resultType="java.lang.Integer">
|
|
|
|
|
select count(1) from menu_material_dishes where material_id = #{materialId}
|
|
|
|
|
</select>
|
2025-04-22 13:46:38 +08:00
|
|
|
|
2025-04-17 16:11:05 +08:00
|
|
|
|
2025-04-09 09:21:57 +08:00
|
|
|
</mapper>
|