package com.jsowell.pile.service.impl;

import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.MemberGroupRelation;
import com.jsowell.pile.mapper.MemberGroupRelationMapper;
import com.jsowell.pile.service.MemberGroupRelationService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class MemberGroupRelationServiceImpl implements MemberGroupRelationService{

    @Resource
    private MemberGroupRelationMapper memberGroupRelationMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return memberGroupRelationMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(MemberGroupRelation record) {
        return memberGroupRelationMapper.insert(record);
    }

    @Override
    public int insertOrUpdate(MemberGroupRelation record) {
        return memberGroupRelationMapper.insertOrUpdate(record);
    }

    @Override
    public int insertOrUpdateSelective(MemberGroupRelation record) {
        return memberGroupRelationMapper.insertOrUpdateSelective(record);
    }

    @Override
    public int insertSelective(MemberGroupRelation record) {
        return memberGroupRelationMapper.insertSelective(record);
    }

    @Override
    public MemberGroupRelation selectByPrimaryKey(Integer id) {
        return memberGroupRelationMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(MemberGroupRelation record) {
        return memberGroupRelationMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(MemberGroupRelation record) {
        return memberGroupRelationMapper.updateByPrimaryKey(record);
    }

    @Override
    public int updateBatch(List<MemberGroupRelation> list) {
        return memberGroupRelationMapper.updateBatch(list);
    }

    @Override
    public int updateBatchSelective(List<MemberGroupRelation> list) {
        return memberGroupRelationMapper.updateBatchSelective(list);
    }

    @Override
    public int batchInsert(List<MemberGroupRelation> list) {
        if (CollectionUtils.isEmpty(list)) {
            return 0;
        }
        return memberGroupRelationMapper.batchInsert(list);
    }

    @Override
    public int deleteRelationByGroupCodeAndMemberId(String groupCode, String memberId) {
        if (StringUtils.isBlank(groupCode) || StringUtils.isBlank(memberId)) {
            return 0;
        }
        return memberGroupRelationMapper.deleteRelationByGroupCodeAndMemberId(groupCode, memberId);
    }

}
