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.mapper.FamilyMembersMapper;
import com.ruoyi.ibs.list.service.IFamilyMembersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 家庭成员信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-01
 */
@Service
public class FamilyMembersServiceImpl implements IFamilyMembersService
{
    @Autowired
    private FamilyMembersMapper familyMembersMapper;

    /**
     * 查询家庭成员信息
     * 
     * @param custIsn 家庭成员信息主键
     * @return 家庭成员信息
     */
    @Override
    public FamilyMembers selectFamilyMembersByCustIsn(String custIsn)
    {
        return familyMembersMapper.selectFamilyMembersByCustIsn(custIsn);
    }

    /**
     * 查询家庭成员信息列表
     * 
     * @param familyMembers 家庭成员信息
     * @return 家庭成员信息
     */
    @Override
    public List<FamilyMembers> selectFamilyMembersList(FamilyMembers familyMembers)
    {
        return familyMembersMapper.selectFamilyMembersList(familyMembers);
    }

    /**
     * 新增家庭成员信息
     * 
     * @param familyMembers 家庭成员信息
     * @return 结果
     */
    @Override
    public AjaxResult insertFamilyMembers(FamilyMembers familyMembers)
    {
        FamilyMembers familyMember = new FamilyMembers();
        familyMember.setFmyName(familyMembers.getFmyName());
        List<FamilyMembers> familyMembersList = selectFamilyMembersList(familyMember);
        if (familyMembersList!=null&&familyMembersList.size()>0){
            return AjaxResult.error("已存在同名家庭成员，请修改家庭成员名称");
        }
        familyMembersMapper.insertFamilyMembers(familyMembers);
        return AjaxResult.success("家庭成员新增成功");
    }

    /**
     * 修改家庭成员信息
     * 
     * @param familyMembers 家庭成员信息
     * @return 结果
     */
    @Override
    public int updateFamilyMembers(FamilyMembers familyMembers)
    {
        return familyMembersMapper.updateFamilyMembers(familyMembers);
    }

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

    /**
     * 删除家庭成员信息信息
     * 
     * @param custIsn 家庭成员信息主键
     * @return 结果
     */
    @Override
    public int deleteFamilyMembersByCustIsn(String custIsn)
    {
        return familyMembersMapper.deleteFamilyMembersByCustIsn(custIsn);
    }
}
