package com.red.circle.other.app.inner.service.sys.impl;

import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.app.inner.service.sys.SysUserSpecialIdLogClientService;
import com.red.circle.other.infra.convertor.sys.OperationLogInnerConvertor;
import com.red.circle.other.infra.database.rds.service.sys.SysUserSpecialIdLogService;
import com.red.circle.other.inner.model.cmd.sys.PageUserSpecialIdCmd;
import com.red.circle.other.inner.model.cmd.sys.SysUserSpecialIdLogCmd;
import com.red.circle.other.inner.model.dto.sys.SysUserSpecialIdLogDTO;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 靓号使用日志记录 服务实现类
 * </p>
 *
 * @author pengliang
 * @since 2022-02-16
 */
@Service
@RequiredArgsConstructor
public class SysUserSpecialIdLogClientServiceImpl implements
    SysUserSpecialIdLogClientService {

  private final OperationLogInnerConvertor operationLogInnerConvertor;
  private final SysUserSpecialIdLogService sysUserSpecialIdLogService;

  @Override
  public List<SysUserSpecialIdLogDTO> listLatest(Long userId, Integer size) {
    return operationLogInnerConvertor.toListUserSpecialIdLogDTO(
        sysUserSpecialIdLogService.listLatest(userId, size));
  }

  @Override
  public PageResult<SysUserSpecialIdLogDTO> pageSpecialIdLog(PageUserSpecialIdCmd param) {
    return sysUserSpecialIdLogService.pageSpecialIdLog(param)
        .convert(operationLogInnerConvertor::toSysUserSpecialIdLogDTO);
  }

  @Override
  public void addSpecialIdLog(SysUserSpecialIdLogCmd param) {
    sysUserSpecialIdLogService.save(operationLogInnerConvertor.toSysUserSpecialIdLogCmd(param));
  }
}
