@ -1,87 +1,90 @@
|
||||
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;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 食材Mapper接口
|
||||
*
|
||||
*
|
||||
* @author wonder
|
||||
* @date 2020-12-15
|
||||
*/
|
||||
public interface SysIngredientMapper
|
||||
{
|
||||
public interface SysIngredientMapper {
|
||||
/**
|
||||
* 查询食材
|
||||
*
|
||||
*
|
||||
* @param id 食材ID
|
||||
* @return 食材
|
||||
*/
|
||||
public SysIngredient selectSysIngredientById(Long id);
|
||||
SysIngredient selectSysIngredientById(Long id);
|
||||
|
||||
/**
|
||||
* 查询食材列表
|
||||
*
|
||||
*
|
||||
* @param sysIngredient 食材
|
||||
* @return 食材集合
|
||||
*/
|
||||
public List<SysIngredient> selectSysIngredientList(SysIngredient sysIngredient);
|
||||
List<SysIngredient> selectSysIngredientList(SysIngredient sysIngredient);
|
||||
|
||||
/**
|
||||
* 新增食材
|
||||
*
|
||||
*
|
||||
* @param sysIngredient 食材
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysIngredient(SysIngredient sysIngredient);
|
||||
int insertSysIngredient(SysIngredient sysIngredient);
|
||||
|
||||
/**
|
||||
* 修改食材
|
||||
*
|
||||
*
|
||||
* @param sysIngredient 食材
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysIngredient(SysIngredient sysIngredient);
|
||||
int updateSysIngredient(SysIngredient sysIngredient);
|
||||
|
||||
/**
|
||||
* 删除食材
|
||||
*
|
||||
*
|
||||
* @param id 食材ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysIngredientById(Long id);
|
||||
int deleteSysIngredientById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除食材
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysIngredientByIds(Long[] ids);
|
||||
int deleteSysIngredientByIds(Long[] ids);
|
||||
|
||||
public int batchIngredientRec(List<SysIngredientRec> ingredientRecList);
|
||||
int batchIngredientRec(List<SysIngredientRec> ingredientRecList);
|
||||
|
||||
public int batchIngredientNotRec(List<SysIngredientNotRec> ingredientNotRecList);
|
||||
int batchIngredientNotRec(List<SysIngredientNotRec> ingredientNotRecList);
|
||||
|
||||
public int deleteIngredentRecByIngredientId(Long recId);
|
||||
int deleteIngredientRecByIngredientId(Long recId);
|
||||
|
||||
public int deleteIngredentNotRecByIngredientId(Long notRecId);
|
||||
int deleteIngredientNotRecByIngredientId(Long notRecId);
|
||||
|
||||
public int deleteIngredentRecByIngredientIds(Long[] id);
|
||||
int deleteIngredientRecByIngredientIds(Long[] id);
|
||||
|
||||
public int deleteIngredentNotRecByIngredientIds(Long[] id);
|
||||
int deleteIngredientNotRecByIngredientIds(Long[] id);
|
||||
|
||||
/**
|
||||
* 根据食材名称查询食材信息
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public SysIngredient selectSysIngredientByName(@Param("name") String name);
|
||||
SysIngredient selectSysIngredientByName(@Param("name") String name);
|
||||
|
||||
int batchInsertIngredientImage(List<SysIngredentFile> list);
|
||||
|
||||
int deleteIngredientImageById(Long id);
|
||||
|
||||
}
|
@ -63,15 +63,7 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
|
||||
//
|
||||
insertNotRecommand(sysIngredient);
|
||||
//
|
||||
if (StringUtils.isNotNull(sysIngredient.getImgList())) {
|
||||
List<SysIngredentFile> fileList = sysIngredient.getImgList();
|
||||
for (SysIngredentFile file : fileList) {
|
||||
file.setIgdId(sysIngredient.getId());
|
||||
file.setCreateBy(SecurityUtils.getUsername());
|
||||
file.setCreateTime(DateUtils.getNowDate());
|
||||
}
|
||||
sysIngredientMapper.batchInsertIngredientImage(fileList);
|
||||
}
|
||||
insertImageFiles(sysIngredient);
|
||||
return rows;
|
||||
}
|
||||
|
||||
@ -117,6 +109,26 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增图片
|
||||
*
|
||||
* @param ingredient
|
||||
*/
|
||||
public void insertImageFiles(SysIngredient ingredient) {
|
||||
if (StringUtils.isNotNull(ingredient.getImgList())) {
|
||||
List<SysIngredentFile> fileList = ingredient.getImgList();
|
||||
for (SysIngredentFile file : fileList) {
|
||||
file.setIgdId(ingredient.getId());
|
||||
file.setCreateBy(SecurityUtils.getUsername());
|
||||
file.setCreateTime(DateUtils.getNowDate());
|
||||
}
|
||||
if (fileList.size() > 0) {
|
||||
sysIngredientMapper.batchInsertIngredientImage(fileList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改食材
|
||||
*
|
||||
@ -127,10 +139,12 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
|
||||
public int updateSysIngredient(SysIngredient sysIngredient) {
|
||||
sysIngredient.setUpdateTime(DateUtils.getNowDate());
|
||||
Long ingredientId = sysIngredient.getId();
|
||||
sysIngredientMapper.deleteIngredentNotRecByIngredientId(ingredientId);
|
||||
sysIngredientMapper.deleteIngredientNotRecByIngredientId(ingredientId);
|
||||
insertNotRecommand(sysIngredient);
|
||||
sysIngredientMapper.deleteIngredentRecByIngredientId(ingredientId);
|
||||
sysIngredientMapper.deleteIngredientRecByIngredientId(ingredientId);
|
||||
insertRecommand(sysIngredient);
|
||||
sysIngredientMapper.deleteIngredientImageById(ingredientId);
|
||||
insertImageFiles(sysIngredient);
|
||||
return sysIngredientMapper.updateSysIngredient(sysIngredient);
|
||||
}
|
||||
|
||||
@ -142,8 +156,8 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysIngredientByIds(Long[] ids) {
|
||||
sysIngredientMapper.deleteIngredentRecByIngredientIds(ids);
|
||||
sysIngredientMapper.deleteIngredentNotRecByIngredientIds(ids);
|
||||
sysIngredientMapper.deleteIngredientRecByIngredientIds(ids);
|
||||
sysIngredientMapper.deleteIngredientNotRecByIngredientIds(ids);
|
||||
return sysIngredientMapper.deleteSysIngredientByIds(ids);
|
||||
}
|
||||
|
||||
@ -155,8 +169,8 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysIngredientById(Long id) {
|
||||
sysIngredientMapper.deleteIngredentRecByIngredientId(id);
|
||||
sysIngredientMapper.deleteIngredentNotRecByIngredientId(id);
|
||||
sysIngredientMapper.deleteIngredientRecByIngredientId(id);
|
||||
sysIngredientMapper.deleteIngredientNotRecByIngredientId(id);
|
||||
return sysIngredientMapper.deleteSysIngredientById(id);
|
||||
}
|
||||
|
||||
|
@ -159,22 +159,22 @@
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteIngredentRecByIngredientId" parameterType="Long">
|
||||
<delete id="deleteIngredientRecByIngredientId" parameterType="Long">
|
||||
delete from sys_ingredient_rec where ingredient_id=#{ingredientId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteIngredentNotRecByIngredientId" parameterType="Long">
|
||||
<delete id="deleteIngredientNotRecByIngredientId" parameterType="Long">
|
||||
delete from sys_ingredient_not_rec where ingredient_id=#{ingredientId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteIngredentRecByIngredientIds" parameterType="Long">
|
||||
<delete id="deleteIngredientRecByIngredientIds" parameterType="Long">
|
||||
delete from sys_ingredient_rec where ingredient_id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteIngredentNotRecByIngredientIds" parameterType="String">
|
||||
<delete id="deleteIngredientNotRecByIngredientIds" parameterType="String">
|
||||
delete from sys_ingredient_not_rec where ingredient_id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
@ -239,7 +239,7 @@
|
||||
</select>
|
||||
|
||||
<!-- 删除图片记录-->
|
||||
<update id="deleteIngredentFileById" parameterType="Long">
|
||||
update sys_ingredent_file set del_flag=1 where id=#{id}
|
||||
</update>
|
||||
<delete id="deleteIngredientImageById" parameterType="Long">
|
||||
delete from sys_ingredient_file where igd_id=#{id}
|
||||
</delete>
|
||||
</mapper>
|
Reference in New Issue
Block a user