package com.bonus.sgzb.base.service.impl;


import com.bonus.sgzb.base.domain.BmUnitPerson;
import com.bonus.sgzb.base.mapper.BmUnitPersonMapper;
import com.bonus.sgzb.base.service.BmUnitPersonService;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BmUnitPersonServiceImpl implements BmUnitPersonService {

    @Autowired
    private BmUnitPersonMapper bmUnitPersonMapper;

    @Override
    public List<BmUnitPerson> getUnitPersonAll() {

        return bmUnitPersonMapper.getUnitPersonAll();
    }

    @Override
    public List<BmUnitPerson> getUnitPerson(BmUnitPerson bmUnitPerson) {
        return bmUnitPersonMapper.getUnitPerson(bmUnitPerson);
    }

    @Override
    public AjaxResult unitPersonAdd(BmUnitPerson bmUnitPerson) {
        BmUnitPerson ben =bmUnitPersonMapper.getUnitPersons(bmUnitPerson.getUnitId());
        if(ben != null){
            return AjaxResult.error("保存失败！！！单位已绑定");
        }
        return AjaxResult.success(bmUnitPersonMapper.unitPersonAdd(bmUnitPerson));
    }

    @Override
    public void remove(Long[] unitIds) {
        bmUnitPersonMapper.remove(unitIds);
    }

    @Override
    public int updateBmUnitPerson(BmUnitPerson bmUnitPerson) {
        return bmUnitPersonMapper.updateBmUnitPerson(bmUnitPerson);
    }
}
