package com.bjtdba.thirdPartWares.service.impl;

import com.bjtdba.entity.thirdPartyWares.ThirdPartyGoods;
import com.bjtdba.thirdPartWares.dao.ThirdPartyGoodsDao;
import com.bjtdba.thirdPartWares.service.ThirdPartyGoodsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ThirdPartyGoods)表服务实现类
 *
 * @author 何海强
 * @since 2023-02-16 16:51:02
 */
@Service("thirdPartyGoodsService")
public class ThirdPartyGoodsServiceImpl implements ThirdPartyGoodsService {
    @Resource
    private ThirdPartyGoodsDao thirdPartyGoodsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param  主键
     * @return 实例对象
     */
    @Override
    public ThirdPartyGoods queryById( ) {
        return this.thirdPartyGoodsDao.queryById();
    }

    /**
     * 分页查询
     *
     * @param thirdPartyGoods 筛选条件
     * @return 查询结果
     */
    @Override
//    public Page<ThirdPartyGoods> queryByPage(ThirdPartyGoods thirdPartyGoods, PageRequest pageRequest) {
//        long total = this.thirdPartyGoodsDao.count(thirdPartyGoods);
//        return new PageImpl<>(this.thirdPartyGoodsDao.queryAllByLimit(thirdPartyGoods, pageRequest), pageRequest, total);
//    }
    public List<ThirdPartyGoods> queryAllByLimit(ThirdPartyGoods thirdPartyGoods){

        return this.thirdPartyGoodsDao.queryAllByLimit(thirdPartyGoods);

    }

    /**
     * 新增数据
     *
     * @param thirdPartyGoods 实例对象
     * @return 实例对象
     */
    @Override
    public ThirdPartyGoods insert(ThirdPartyGoods thirdPartyGoods) {
        this.thirdPartyGoodsDao.insert(thirdPartyGoods);
        return thirdPartyGoods;
    }

    public  void insertBatch(List<ThirdPartyGoods> thirdPartyGoods){
        this.thirdPartyGoodsDao.insertBatch(thirdPartyGoods);
    }

    /**
     * 修改数据
     *
     * @param thirdPartyGoods 实例对象
     * @return 实例对象
     */
    @Override
    public void update(ThirdPartyGoods thirdPartyGoods) {
        this.thirdPartyGoodsDao.update(thirdPartyGoods);
    }

    /**
     * 通过主键删除数据
     *
     * @param  主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById( ) {
        return this.thirdPartyGoodsDao.deleteById() > 0;
    }
}
