package com.pj.project.tb_business_item;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pj.utils.so.SoMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Service: tb_business_item -- 业务作业项
 * @author qzy 
 */
@Service
@Transactional
public class TbBusinessItemService extends ServiceImpl<TbBusinessItemMapper,TbBusinessItem> implements IService<TbBusinessItem> {

	/** 底层 Mapper 对象 */
	@Autowired
    TbBusinessItemMapper tbBusinessItemMapper;

	/** 增 */
	int add(TbBusinessItem t){
		return tbBusinessItemMapper.add(t);
	}



	/** 改 */
	int update(TbBusinessItem t){
		return tbBusinessItemMapper.update(t);
	}

	/** 查 */
	TbBusinessItem getById(String id){
		return tbBusinessItemMapper.getById(id);
	}

	/** 查集合 - 根据条件（参数为空时代表忽略指定条件） */  
	List<TbBusinessItem> getList(SoMap so) {
		return tbBusinessItemMapper.getList(so);	
	}


	public void removeByBusinessId(String businessId) {
		QueryWrapper<TbBusinessItem>ew=new QueryWrapper<>();
		ew.eq("business_id",businessId);
		this.remove(ew);
	}

    public List<TbBusinessItem> findByBusinessId(String businessId) {
		QueryWrapper<TbBusinessItem>ew=new QueryWrapper<>();
		ew.eq("business_id",businessId);
		return list(ew);
    }

	public TbBusinessItem findByBusinessIdAndTypeName(String businessId, String itemTypeName) {
		QueryWrapper<TbBusinessItem>ew=new QueryWrapper<>();
		ew.eq("business_id",businessId);
		ew.eq("item_type_name",itemTypeName);
		return getOne(ew);
	}
}
