package com.red.circle.console.app.service.app.user;

import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.console.app.dto.cmd.app.user.UserExpandDeviceListBlockCmd;
import com.red.circle.other.inner.model.cmd.user.UpdateUserExpandDeviceListBlockCmd;
import com.red.circle.other.inner.model.dto.user.UserExpandDTO;
import com.red.circle.other.inner.endpoint.user.user.UserExpandClient;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户扩展信息 服务实现类
 * </p>
 *
 * @author pengliang
 * @since 2019-11-08
 */

@Service
@RequiredArgsConstructor
public class UserExpandServiceImpl implements
    UserExpandService {

  private final UserExpandClient userExpandClient;


  @Override
  public UserExpandDTO getById(Long userId) {
    return ResponseAssert.requiredSuccess(userExpandClient.getByUserId(userId));
  }

  @Override
  public void updateDeviceListBlock(UserExpandDeviceListBlockCmd cmd) {
    UpdateUserExpandDeviceListBlockCmd innerCmd = new UpdateUserExpandDeviceListBlockCmd()
        .setUserId(cmd.getUserId())
        .setDeviceListBlock(cmd.getDeviceListBlock());
    ResponseAssert.requiredSuccess(userExpandClient.updateDeviceListBlock(innerCmd));
  }
}
