@@ -0,0 +1,27 @@
 | 
			
		||||
package com.stdiet.custom.domain;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
public class SysIngredentFile {
 | 
			
		||||
 | 
			
		||||
    Long id;
 | 
			
		||||
 | 
			
		||||
    Long igdId;
 | 
			
		||||
 | 
			
		||||
    String fileUrl;
 | 
			
		||||
 | 
			
		||||
    String fileName;
 | 
			
		||||
 | 
			
		||||
    Integer delFlag;
 | 
			
		||||
 | 
			
		||||
    String createBy;
 | 
			
		||||
 | 
			
		||||
    Date createTime;
 | 
			
		||||
 | 
			
		||||
    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
 | 
			
		||||
@@ -15,8 +16,6 @@ import java.util.Date;
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
public class SysIngredient {
 | 
			
		||||
    private static final long serialVersionUID = 1L;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * id
 | 
			
		||||
     */
 | 
			
		||||
@@ -107,4 +106,11 @@ public class SysIngredient {
 | 
			
		||||
 | 
			
		||||
    private Long[] notRecIds;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 食材信息
 | 
			
		||||
     */
 | 
			
		||||
    private String info;
 | 
			
		||||
 | 
			
		||||
    private List<SysIngredentFile> imgList;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
package com.stdiet.custom.mapper;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import com.stdiet.custom.domain.SysIngredentFile;
 | 
			
		||||
import com.stdiet.custom.domain.SysIngredient;
 | 
			
		||||
import com.stdiet.custom.domain.SysIngredientNotRec;
 | 
			
		||||
import com.stdiet.custom.domain.SysIngredientRec;
 | 
			
		||||
@@ -80,4 +82,6 @@ public interface SysIngredientMapper
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public SysIngredient selectSysIngredientByName(@Param("name") String name);
 | 
			
		||||
 | 
			
		||||
    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;
 | 
			
		||||
@@ -60,24 +62,35 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
 | 
			
		||||
        insertRecommand(sysIngredient);
 | 
			
		||||
        //
 | 
			
		||||
        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);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -85,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);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -148,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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user