package com.inkasso.factoring.org.service.impl;

import com.inkasso.adapter.exception.enums.ExceptionEnum;
import com.inkasso.adapter.service.KafubaoServiceImpl;
import com.inkasso.adapter.util.BeanUtilsProxy;
import com.inkasso.adapter.exception.ServiceException;
import com.inkasso.factoring.org.dao.ClickLogDAO;
import com.inkasso.factoring.org.entity.ClickLogDO;
import com.inkasso.factoring.org.model.dto.ClickLogDTO;
import com.inkasso.factoring.org.model.request.AddClickLogRequest;
import com.inkasso.factoring.org.model.request.EditClickLogRequest;
import com.inkasso.factoring.org.service.ClickLogService;
import org.springframework.stereotype.Service;

/**
* @author 
* @date  2023-10-13
*/
@Service
public class ClickLogServiceImpl extends KafubaoServiceImpl<ClickLogDAO, ClickLogDO, ClickLogDTO> implements ClickLogService {


    @Override
    public void addClickLog(AddClickLogRequest addClickLogRequest) {
      ClickLogDO clickLog = BeanUtilsProxy.copyPropertiesIgnoreNull(addClickLogRequest, ClickLogDO.class);
      this.baseMapper.insert(clickLog);
    }

    @Override
    public void editClickLog(EditClickLogRequest editClickLogRequest) {

      ClickLogDO clickLog = super.getById(editClickLogRequest.getId());
      if (clickLog == null) {
          throw new ServiceException(400, ExceptionEnum.SYSTEM_DATE_ERROR);
      }
      BeanUtilsProxy.copyPropertiesNotIgnoreNull(editClickLogRequest,clickLog);
      this.updateById(clickLog);
    }

    @Override
    public ClickLogDTO getClickLogDtoById(Long id) {
       ClickLogDO clickLog = super.getById(id);
       ClickLogDTO clickLogDto = BeanUtilsProxy.copyProperties(clickLog,ClickLogDTO.class);
       return clickLogDto;
    }

    @Override
    public void deleteClickLog(Long id) {

       this.removeById(id);
    }
}

