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

import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.infra.database.rds.service.user.user.UserBeautifulNumberApplyService;
import com.red.circle.other.infra.database.rds.service.user.user.UserBeautifulNumberService;
import com.red.circle.other.app.inner.convertor.user.UserProfileInnerConvertor;
import com.red.circle.other.inner.model.cmd.user.BeautifulNumberQryCmd;
import com.red.circle.other.inner.model.cmd.user.UserBeautifulNumberApplyQryCmd;
import com.red.circle.other.inner.model.cmd.user.UserBeautifulNumberCmd;
import com.red.circle.other.inner.model.dto.user.BeautifulNumberDTO;
import com.red.circle.other.inner.model.dto.user.UserBeautifulNumberApplyDTO;
import com.red.circle.other.app.inner.service.user.user.UserBeautifulNumberClientService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户申请靓号记录 服务类.
 * </p>
 *
 * @author pengshigang
 * @since 2021-08-18
 */
@Service
@RequiredArgsConstructor
public class UserBeautifulNumberClientServiceImpl implements
    UserBeautifulNumberClientService {

  private final UserProfileInnerConvertor userProfileInnerConvertor;
  private final UserBeautifulNumberService userBeautifulNumberService;
  private final UserBeautifulNumberApplyService userBeautifulNumberApplyService;

  @Override
  public PageResult<UserBeautifulNumberApplyDTO> pageBeautifulNumberApply(
      UserBeautifulNumberApplyQryCmd query) {
    return userBeautifulNumberApplyService.page(query)
        .convert(userProfileInnerConvertor::toUserBeautifulNumberApplyDTO);
  }

  @Override
  public void handleApply(Long id, Integer state) {
    userBeautifulNumberApplyService.handleApply(id, state);
  }


  @Override
  public void updateBeautifulNumber(UserBeautifulNumberCmd cmd) {
    userBeautifulNumberService.updateBeautifulNumber(cmd);
  }

  @Override
  public void addBeautifulNumber(UserBeautifulNumberCmd cmd) {
    userBeautifulNumberService.addBeautifulNumber(cmd);
  }


  @Override
  public PageResult<BeautifulNumberDTO> pageBeautifulNumber(BeautifulNumberQryCmd query) {
    return userBeautifulNumberService.getBeautifulNumber(query)
        .convert(userProfileInnerConvertor::toBeautifulNumberDTO);
  }

  @Override
  public void deleteBeautifulNumber(Long id) {
    userBeautifulNumberService.removeById(id);
  }
}
