From 094b715335ff3f9f863a9b2565a52b9e8853322c Mon Sep 17 00:00:00 2001 From: pqyt64hnf <2543568107@qq.com> Date: Sun, 30 Apr 2023 01:16:57 +0800 Subject: [PATCH] ADD file via upload --- .../com/service/FoodsMaterialInfoService.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/main/java/com/service/FoodsMaterialInfoService.java diff --git a/src/main/java/com/service/FoodsMaterialInfoService.java b/src/main/java/com/service/FoodsMaterialInfoService.java new file mode 100644 index 0000000..08d9175 --- /dev/null +++ b/src/main/java/com/service/FoodsMaterialInfoService.java @@ -0,0 +1,50 @@ +package com.example.service; + +import cn.hutool.core.collection.CollectionUtil; +import com.example.dao.FoodsMaterialInfoDao; +import com.example.entity.FoodsMaterialInfo; +import com.example.vo.FoodsMaterialInfoVo; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service +public class FoodsMaterialInfoService { + + @Resource + private FoodsMaterialInfoDao foodsMaterialInfoDao; + + public FoodsMaterialInfo add(FoodsMaterialInfo info) { + foodsMaterialInfoDao.insertSelective(info); + return info; + } + + public void delete(Long id) { + foodsMaterialInfoDao.deleteByPrimaryKey(id); + } + + public void update(FoodsMaterialInfo info) { + foodsMaterialInfoDao.updateByPrimaryKeySelective(info); + } + + public FoodsMaterialInfoVo findById(Long id) { + List list = foodsMaterialInfoDao.findByNameAndId(null, id); + if (!CollectionUtil.isEmpty(list)) { + return list.get(0); + } + return new FoodsMaterialInfoVo(); + } + + public List findAll() { + return foodsMaterialInfoDao.findByNameAndId("all", null); + } + + public PageInfo findPage(String name, Integer pageNum, Integer pageSize) { + PageHelper.startPage(pageNum, pageSize); + List info = foodsMaterialInfoDao.findByNameAndId(name, null); + return PageInfo.of(info); + } +}