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

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.system.controller.admin.yk.vo.YkElderlySelfFundedRecordPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.yk.vo.YkElderlySelfFundedRecordSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.yk.YkElderlySelfFundedRecord;
import cn.iocoder.yudao.module.system.dal.mysql.yk.YkElderlySelfFundedRecordMapper;
import cn.iocoder.yudao.module.system.service.yk.YkElderlySelfFundedRecordService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

/**
 * 每日自费金额登记 Service 实现类
 *
 * @author 系统管理员
 */
@Service
@Validated
public class YkElderlySelfFundedRecordServiceImpl implements YkElderlySelfFundedRecordService {

    @Resource
    private YkElderlySelfFundedRecordMapper selfFundedRecordMapper;

    @Override
    public Long createSelfFundedRecord(YkElderlySelfFundedRecordSaveReqVO createReqVO) {
        YkElderlySelfFundedRecord record = BeanUtils.toBean(createReqVO, YkElderlySelfFundedRecord.class);
        record.setTenantId(TenantContextHolder.getTenantId());
        selfFundedRecordMapper.insert(record);
        return record.getId();
    }

    @Override
    public void updateSelfFundedRecord(YkElderlySelfFundedRecordSaveReqVO updateReqVO) {
        YkElderlySelfFundedRecord updateObj = BeanUtils.toBean(updateReqVO, YkElderlySelfFundedRecord.class);
        selfFundedRecordMapper.updateById(updateObj);
    }

    @Override
    public void deleteSelfFundedRecord(Long id) {
        selfFundedRecordMapper.deleteById(id);
    }

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

    @Override
    public YkElderlySelfFundedRecord getSelfFundedRecord(Long id) {
        return selfFundedRecordMapper.selectById(id);
    }

    @Override
    public PageResult<YkElderlySelfFundedRecord> getSelfFundedRecordPage(YkElderlySelfFundedRecordPageReqVO pageReqVO) {
        return selfFundedRecordMapper.selectPage(pageReqVO);
    }

}

