package com.ruoyi.ibs.list.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.ibs.list.domain.FamilyMembers;
import com.ruoyi.ibs.list.domain.FamilyMembersRecord;
import com.ruoyi.ibs.list.mapper.FamilyMembersRecordMapper;
import com.ruoyi.ibs.list.service.IFamilyMembersRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 建档家庭成员信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-20
 */
@Service
public class FamilyMembersRecordServiceImpl implements IFamilyMembersRecordService
{
    @Autowired
    private FamilyMembersRecordMapper familyMembersRecordMapper;

    /**
     * 查询建档家庭成员信息
     * 
     * @param custIdc 建档家庭成员信息主键
     * @return 建档家庭成员信息
     */
    @Override
    public FamilyMembersRecord selectFamilyMembersRecordByCustIdc(String custIdc)
    {
        return familyMembersRecordMapper.selectFamilyMembersRecordByCustIdc(custIdc);
    }

    /**
     * 查询建档家庭成员信息列表
     * 
     * @param familyMembersRecord 建档家庭成员信息
     * @return 建档家庭成员信息
     */
    @Override
    public List<FamilyMembersRecord> selectFamilyMembersRecordList(FamilyMembersRecord familyMembersRecord)
    {
        return familyMembersRecordMapper.selectFamilyMembersRecordList(familyMembersRecord);
    }

    /**
     * 新增建档家庭成员信息
     * 
     * @param familyMembersRecord 建档家庭成员信息
     * @return 结果
     */
    @Override
    public int insertFamilyMembersRecord(FamilyMembersRecord familyMembersRecord)
    {
        FamilyMembersRecord familyMembersReco = new FamilyMembersRecord();
        familyMembersReco.setFmyName(familyMembersRecord.getFmyName());
        familyMembersReco.setCustIdc(familyMembersRecord.getCustIdc());
        List<FamilyMembersRecord> familyMembersRecordsList = familyMembersRecordMapper.selectFamilyMembersRecordList(familyMembersReco);
        if (familyMembersRecordsList!=null&&familyMembersRecordsList.size()>0){
            throw new RuntimeException("已存在同名家庭成员，请修改家庭成员名称");
        }
        return familyMembersRecordMapper.insertFamilyMembersRecord(familyMembersRecord);
    }

    /**
     * 修改建档家庭成员信息
     * 
     * @param familyMembersRecord 建档家庭成员信息
     * @return 结果
     */
    @Override
    public int updateFamilyMembersRecord(FamilyMembersRecord familyMembersRecord)
    {
        return familyMembersRecordMapper.updateFamilyMembersRecord(familyMembersRecord);
    }

    /**
     * 批量删除建档家庭成员信息
     * 
     * @param custIdcs 需要删除的建档家庭成员信息主键
     * @return 结果
     */
    @Override
    public int deleteFamilyMembersRecordByCustIdcs(String[] custIdcs)
    {
        return familyMembersRecordMapper.deleteFamilyMembersRecordByCustIdcs(custIdcs);
    }

    /**
     * 删除建档家庭成员信息信息
     * 
     * @param custIdc 建档家庭成员信息主键
     * @return 结果
     */
    @Override
    public int deleteFamilyMembersRecordByCustIdc(String custIdc)
    {
        return familyMembersRecordMapper.deleteFamilyMembersRecordByCustIdc(custIdc);
    }
}
