package com.red.circle.other.app.inner.endpoint.sys;

import com.red.circle.common.business.dto.cmd.PageUserIdCmd;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.sys.SysImAccountClientService;
import com.red.circle.other.inner.endpoint.sys.api.SysImAccountClientApi;
import com.red.circle.other.inner.model.cmd.sys.SysImAccountCmd;
import com.red.circle.other.inner.model.dto.sys.SysImAccountDTO;
import com.red.circle.tool.core.tuple.ImmutableKeyValuePair;
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;

/**
 * 系统国家.
 *
 * @author pengliang on 2023/5/24
 */
@Validated
@RestController
@RequestMapping(value = SysImAccountClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class SysImAccountClientEndpoint implements SysImAccountClientApi {

  private final SysImAccountClientService imAccountClientService;


  @Override
  public ResultResponse<ImmutableKeyValuePair<String, String>> imUserLogin(String account,
      String password) {
    return ResultResponse.success(imAccountClientService.imUserLogin(account, password));
  }

  @Override
  public ResultResponse<PageResult<SysImAccountDTO>> pageImAccountVo(PageUserIdCmd cmd) {
    return ResultResponse.success(imAccountClientService.pageImAccountVo(cmd));
  }

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

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

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