食材添加信息
This commit is contained in:
		| @@ -17,11 +17,11 @@ public class SysIngredentFile { | ||||
|  | ||||
|     Integer delFlag; | ||||
|  | ||||
|     Long createBy; | ||||
|     String createBy; | ||||
|  | ||||
|     Date createTime; | ||||
|  | ||||
|     Long updateBy; | ||||
|     String updateBy; | ||||
|  | ||||
|     Date updateTime; | ||||
| } | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import lombok.Data; | ||||
|  | ||||
| import java.math.BigDecimal; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 食材对象 sys_ingredient | ||||
| @@ -110,4 +111,6 @@ public class SysIngredient { | ||||
|      */ | ||||
|     private String info; | ||||
|  | ||||
|     private List<SysIngredentFile> imgList; | ||||
|  | ||||
| } | ||||
| @@ -83,5 +83,5 @@ public interface SysIngredientMapper | ||||
|      */ | ||||
|     public SysIngredient selectSysIngredientByName(@Param("name") String name); | ||||
|  | ||||
|     int batchInsertIngredientImage(List<SysIngredentFile> ingredentFiles); | ||||
|     int batchInsertIngredientImage(List<SysIngredentFile> list); | ||||
| } | ||||
| @@ -1,7 +1,9 @@ | ||||
| package com.stdiet.custom.service.impl; | ||||
|  | ||||
| import com.stdiet.common.utils.DateUtils; | ||||
| import com.stdiet.common.utils.SecurityUtils; | ||||
| import com.stdiet.common.utils.StringUtils; | ||||
| import com.stdiet.custom.domain.SysIngredentFile; | ||||
| import com.stdiet.custom.domain.SysIngredient; | ||||
| import com.stdiet.custom.domain.SysIngredientNotRec; | ||||
| import com.stdiet.custom.domain.SysIngredientRec; | ||||
| @@ -61,26 +63,34 @@ public class SysIngredientServiceImpl implements ISysIngredientService { | ||||
|         // | ||||
|         insertNotRecommand(sysIngredient); | ||||
|         // | ||||
|          | ||||
|  | ||||
|         if (StringUtils.isNotNull(sysIngredient.getImgList())) { | ||||
|             List<SysIngredentFile> fileList = sysIngredient.getImgList(); | ||||
|             for (SysIngredentFile file : fileList) { | ||||
|                 file.setId(sysIngredient.getId()); | ||||
|                 file.setCreateBy(SecurityUtils.getUsername()); | ||||
|                 file.setCreateTime(DateUtils.getNowDate()); | ||||
|             } | ||||
|             sysIngredientMapper.batchInsertIngredientImage(fileList); | ||||
|         } | ||||
|         return rows; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 新增推荐标签 | ||||
|      * | ||||
|      * @param ingredient | ||||
|      */ | ||||
|     public void insertRecommand(SysIngredient ingredient) { | ||||
|         Long[] recIds = ingredient.getRecIds(); | ||||
|         if(StringUtils.isNotNull(recIds)) { | ||||
|         if (StringUtils.isNotNull(recIds)) { | ||||
|             List<SysIngredientRec> list = new ArrayList<SysIngredientRec>(); | ||||
|             for(Long recId: recIds) { | ||||
|             for (Long recId : recIds) { | ||||
|                 SysIngredientRec rec = new SysIngredientRec(); | ||||
|                 rec.setIngredientId(ingredient.getId()); | ||||
|                 rec.setRecommandId(recId); | ||||
|                 list.add(rec); | ||||
|             } | ||||
|             if(list.size() > 0) { | ||||
|             if (list.size() > 0) { | ||||
|                 sysIngredientMapper.batchIngredientRec(list); | ||||
|             } | ||||
|         } | ||||
| @@ -88,19 +98,20 @@ public class SysIngredientServiceImpl implements ISysIngredientService { | ||||
|  | ||||
|     /** | ||||
|      * 新增不推荐标签 | ||||
|      * | ||||
|      * @param ingredient | ||||
|      */ | ||||
|     public void insertNotRecommand(SysIngredient ingredient) { | ||||
|         Long[] notRecIds = ingredient.getNotRecIds(); | ||||
|         if(StringUtils.isNotNull(notRecIds)) { | ||||
|         if (StringUtils.isNotNull(notRecIds)) { | ||||
|             List<SysIngredientNotRec> list = new ArrayList<SysIngredientNotRec>(); | ||||
|             for(Long recId: notRecIds) { | ||||
|             for (Long recId : notRecIds) { | ||||
|                 SysIngredientNotRec notRec = new SysIngredientNotRec(); | ||||
|                 notRec.setIngredientId(ingredient.getId()); | ||||
|                 notRec.setRecommandId(recId); | ||||
|                 list.add(notRec); | ||||
|             } | ||||
|             if(list.size() > 0) { | ||||
|             if (list.size() > 0) { | ||||
|                 sysIngredientMapper.batchIngredientNotRec(list); | ||||
|             } | ||||
|         } | ||||
| @@ -151,11 +162,12 @@ public class SysIngredientServiceImpl implements ISysIngredientService { | ||||
|  | ||||
|     /** | ||||
|      * 根据食材名称查询食材信息 | ||||
|      * | ||||
|      * @param name | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public SysIngredient selectSysIngredientByName(String name){ | ||||
|     public SysIngredient selectSysIngredientByName(String name) { | ||||
|         return sysIngredientMapper.selectSysIngredientByName(name); | ||||
|     } | ||||
| } | ||||
| @@ -21,7 +21,7 @@ | ||||
|         <result property="notRec" column="not_rec"/> | ||||
|         <result property="reviewStatus" column="review_status"/> | ||||
|         <result property="info" column="info"/> | ||||
|         <association property="imgFiles" column="id" select="selectIngredentFileById"/> | ||||
|         <association property="imgList" column="id" select="selectIngredentFileById"/> | ||||
|     </resultMap> | ||||
|  | ||||
|     <sql id="selectSysIngredientVo"> | ||||
| @@ -126,6 +126,7 @@ | ||||
|             <if test="updateBy != null">update_by,</if> | ||||
|             <if test="updateTime != null">update_time,</if> | ||||
|             <if test="reviewStatus != null">review_status,</if> | ||||
|             <if test="info != null">info,</if> | ||||
|         </trim> | ||||
|         <trim prefix="values (" suffix=")" suffixOverrides=","> | ||||
|             <if test="name != null">#{name},</if> | ||||
| @@ -140,6 +141,7 @@ | ||||
|             <if test="updateBy != null">#{updateBy},</if> | ||||
|             <if test="updateTime != null">#{updateTime},</if> | ||||
|             <if test="reviewStatus != null">#{reviewStatus},</if> | ||||
|             <if test="info != null">#{info},</if> | ||||
|         </trim> | ||||
|     </insert> | ||||
|  | ||||
| @@ -194,6 +196,7 @@ | ||||
|             <if test="updateBy != null">update_by = #{updateBy},</if> | ||||
|             <if test="updateTime != null">update_time = #{updateTime},</if> | ||||
|             <if test="reviewStatus != null">review_status = #{reviewStatus},</if> | ||||
|             <if test="info != null">info = #{info},</if> | ||||
|         </trim> | ||||
|         where id = #{id} | ||||
|     </update> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user