package cn.iocoder.yudao.module.system.service.biz;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.biz.vo.EmergencyTrackingPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.biz.vo.EmergencyTrackingRespVO;
import cn.iocoder.yudao.module.system.controller.admin.biz.vo.EmergencyTrackingSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.biz.ElderlyEmergencyTrackingDO;
import cn.iocoder.yudao.module.system.dal.mysql.biz.EmergencyTrackingMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;


/**
 * 长者应急跟踪 Service 实现类
 *
 * @author 系统管理员
 */
@Service
@Validated
public class EmergencyTrackingServiceImpl implements EmergencyTrackingService {

    @Resource
    private EmergencyTrackingMapper emergencyTrackingMapper;


    @Override
    public Long createEmergencyTracking(EmergencyTrackingSaveReqVO createReqVO) {
        ElderlyEmergencyTrackingDO elderlyEmergencyTrackingDO = new ElderlyEmergencyTrackingDO();
        BeanUtils.copyProperties(createReqVO,elderlyEmergencyTrackingDO);
        emergencyTrackingMapper.insert(elderlyEmergencyTrackingDO);
        return elderlyEmergencyTrackingDO.getId();
    }

    @Override
    public PageResult<ElderlyEmergencyTrackingDO> getEmergencyTrackingPage(EmergencyTrackingPageReqVO pageReqVO) {
       return emergencyTrackingMapper.selectPage(pageReqVO);
    }

    @Override
    public void updateEmergencyTracking(EmergencyTrackingSaveReqVO updateReqVO) {
        ElderlyEmergencyTrackingDO elderlyEmergencyTrackingDO = emergencyTrackingMapper.selectById(updateReqVO.getId());
        BeanUtils.copyProperties(updateReqVO,elderlyEmergencyTrackingDO);
        emergencyTrackingMapper.updateById(elderlyEmergencyTrackingDO);
    }

    @Override
    public ElderlyEmergencyTrackingDO getEmergencyTracking(Long id) {
        return emergencyTrackingMapper.selectById(id);
    }
}