package com.pj.tb_item_rules;

import java.util.List;

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

/**
 * Service: tb_item_rules -- 费项因子
 * @author lbl
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class TbItemRulesService extends ServiceImpl<TbItemRulesMapper, TbItemRules> implements IService<TbItemRules>{

	/** 底层 Mapper 对象 */
	@Autowired
	TbItemRulesMapper tbItemRulesMapper;

	/** 增 */
	void add(TbItemRules t){
		save(t);
	}

	/** 删 */
	void delete(Long id){
		removeById(id);
	}

	/** 改 */
	void update(TbItemRules t){
		updateById(t);

	}

	/** 查 */
	TbItemRules getById(Long id){
		return super.getById(id);
	}

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

	/** 查集合 - 根据费项表） */
	public List<TbItemRulesVo> getAllList() {
		return tbItemRulesMapper.getAllList();
	}

	public List<TbItemRules> findByItemId(Long itemId) {
		QueryWrapper<TbItemRules>ew=new QueryWrapper<>();
		ew.lambda().eq(TbItemRules::getItemId,itemId);
		return list(ew);
	}

	public void removeByItemId(Long itemId) {
		QueryWrapper<TbItemRules>ew=new QueryWrapper<>();
		ew.lambda().eq(TbItemRules::getItemId,itemId);
		this.remove(ew);
	}
}
