package com.red.circle.external.inner.endpoint.message;

import com.red.circle.external.inner.endpoint.message.api.ImAccountClientApi;
import com.red.circle.external.inner.model.cmd.message.RegisterAccountCmd;
import com.red.circle.external.inner.service.message.ImAccountClientService;
import com.red.circle.framework.dto.ResultResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * im 账号管理，前端控制器.
 *
 * @author pengliang on 2023/7/12
 */
@Validated
@RestController
@RequestMapping(value = ImAccountClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class ImAccountClientEndpoint implements ImAccountClientApi {

  private final ImAccountClientService imAccountClientService;

  @Override
  public ResultResponse<String> createUserSig(Long userId) {
    return ResultResponse.success(imAccountClientService.createUserSig(userId));
  }

  @Override
  public ResultResponse<Void> kick(Long userId) {
    imAccountClientService.kick(userId);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> register(RegisterAccountCmd cmd) {
    imAccountClientService.register(cmd);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> portraitSetAvatar(Long userId, String avatar) {
    imAccountClientService.portraitSetAvatar(userId, avatar);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> portraitSetNickname(Long userId, String nickname) {
    imAccountClientService.portraitSetNickname(userId, nickname);
    return ResultResponse.success();
  }

}
