package cn.iocoder.yudao.module.system.service.yk.impl;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.system.controller.admin.yk.vo.FundedElderlyInfoPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.yk.vo.FundedElderlyInfoSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.yk.YkFundedElderlyInfoDO;
import cn.iocoder.yudao.module.system.dal.mysql.yk.YkFundedElderlyInfoMapper;
import cn.iocoder.yudao.module.system.service.yk.FundedElderlyInfoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;

import java.util.Date;
import java.util.List;


/**
 * 自费长者信息 Service 实现类
 *
 * @author 系统管理员
 */
@Service
@Validated
public class FundedElderlyInfoServiceImpl implements FundedElderlyInfoService {

    @Resource
    private YkFundedElderlyInfoMapper ykFundedElderlyInfoMapper;

    @Override
    public Long createFundedElderlyInfo(YkFundedElderlyInfoDO createReqVO) {
        // 插入
        createReqVO.setCreatedTime(new Date());
        createReqVO.setTenantId(TenantContextHolder.getTenantId());
        ykFundedElderlyInfoMapper.insert(createReqVO);
        // 返回
        return createReqVO.getId();
    }

    @Override
    public void updateFundedElderlyInfo(FundedElderlyInfoSaveReqVO updateReqVO) {
        // 更新
        YkFundedElderlyInfoDO updateObj = BeanUtils.toBean(updateReqVO, YkFundedElderlyInfoDO.class);
        ykFundedElderlyInfoMapper.updateById(updateObj);
    }

    @Override
    public void deleteFundedElderlyInfo(Long id) {
        // 删除
        ykFundedElderlyInfoMapper.deleteById(id);
    }



    @Override
    public YkFundedElderlyInfoDO getFundedElderlyInfo(Long id) {
        return ykFundedElderlyInfoMapper.selectById(id);
    }

    @Override
    public PageResult<YkFundedElderlyInfoDO> getFundedElderlyInfoPage(FundedElderlyInfoPageReqVO pageReqVO) {
        return ykFundedElderlyInfoMapper.selectPage(pageReqVO);
    }

    @Override
    public void batchDeleteFundedElderlyInfo(List<Long> ids) {
        ykFundedElderlyInfoMapper.deleteBatchIds(ids);
    }

}