package cn.hnthyy.thmz.service.impl.his;

import cn.hnthyy.thmz.entity.his.YpZdGroupName;
import cn.hnthyy.thmz.mapper.his.YpZdGroupNameMapper;
import cn.hnthyy.thmz.pageDto.YpZdGroupNamePageDto;
import cn.hnthyy.thmz.service.his.YpZdGroupNameService;
import cn.hnthyy.thmz.vo.YpZdGroupNameVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class YpZdGroupNameServiceImpl implements YpZdGroupNameService {
    @SuppressWarnings("all")
    @Autowired
    private YpZdGroupNameMapper ypZdGroupNameMapper;
    @Override
    public YpZdGroupName queryByGroupNo(String groupNo) {
        return ypZdGroupNameMapper.selectByGroupNo(groupNo);
    }

    @Override
    public List<YpZdGroupNameVo> queryYpZdGroupNamePage(YpZdGroupNamePageDto ypZdGroupNamePageDto) {
        return ypZdGroupNameMapper.selectYpZdGroupNamePage(ypZdGroupNamePageDto);
    }

    @Override
    public List<YpZdGroupName> queryAllYpZdGroupName() {
        return ypZdGroupNameMapper.selectYpZdGroupName();
    }

    @Override
    public int countYpZdGroupName(YpZdGroupName ypZdGroupName) {
        return ypZdGroupNameMapper.countYpZdGroupName(ypZdGroupName);
    }

    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
    @Override
    public int saveYpZdGroupName(YpZdGroupNameVo ypZdGroupNameVo) {
        if(ypZdGroupNameVo.getIsEdit() == 1){//修改
            ypZdGroupNameMapper.updateYpZdGroupName(ypZdGroupNameVo);
        }else{//新增
            ypZdGroupNameMapper.insertYpZdGroupName(ypZdGroupNameVo);
        }
        return 0;
    }

    @Override
    public int removeByGroupNo(String groupNo) {
        ypZdGroupNameMapper.deleteByGroupNo(groupNo);
        return 0;
    }
}
