package com.red.circle.other.inner.endpoint.user.user.api;

import com.red.circle.common.business.enums.AccountStatusEnum;
import com.red.circle.framework.core.dto.CommonCommand;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.inner.model.cmd.user.ApprovalUserAccountStatusLogCmd;
import com.red.circle.other.inner.model.cmd.user.UserChannelCredentialCmd;
import com.red.circle.other.inner.model.cmd.user.account.AccountLoginCmd;
import com.red.circle.other.inner.model.cmd.user.account.CreateAccountCmd;
import com.red.circle.other.inner.model.cmd.user.account.MobileCredentialCmd;
import com.red.circle.other.inner.model.cmd.user.account.PunishmentAccountCmd;
import com.red.circle.other.inner.model.cmd.user.account.UnblockAccountCmd;
import com.red.circle.other.inner.model.dto.user.UserAuthTypeDTO;
import com.red.circle.other.inner.model.dto.user.account.MobileAuthDTO;
import com.red.circle.other.inner.model.dto.user.account.UserAccountDTO;
import com.red.circle.other.inner.model.dto.user.account.UserMobileUpdateCmd;
import com.red.circle.other.inner.model.cmd.user.UserAccountStatusLogQryCmd;
import com.red.circle.other.inner.model.dto.user.ApprovalUserAccountStatusLogDTO;
import java.util.List;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 用户账号服务.
 *
 * @author pengliang on 2023/5/25
 */
public interface AppUserAccountClientApi {

  String API_PREFIX = "/app-user/account";

  /**
   * 创建账号.
   */
  @PostMapping(value = "/create")
  ResultResponse<UserAccountDTO> create(@RequestBody @Validated CreateAccountCmd cmd);

  /**
   * 注销账号.
   */
  @PostMapping(value = "/logout")
  ResultResponse<Void> logout(@RequestBody CommonCommand cmd);

  /**
   * 退出登录.
   */
  @PostMapping(value = "/sign-out")
  ResultResponse<Void> signOut(@RequestBody CommonCommand cmd);

  /**
   * 通过手机号码，获取账号凭证信息.
   */
  @PostMapping(value = "/mobile/credential")
  ResultResponse<UserAccountDTO> mobileCredential(@RequestBody @Validated MobileCredentialCmd cmd);

  /**
   * 通过第三方渠道登录，获取账号凭证信息.
   */
  @PostMapping(value = "/channel/credential")
  ResultResponse<UserAccountDTO> channelCredential(
      @RequestBody @Validated UserChannelCredentialCmd cmd);

  /**
   * 解封账号.
   */
  @PostMapping(value = "/unblock")
  ResultResponse<Void> unblock(@RequestBody @Validated UnblockAccountCmd cmd);

  /**
   * 处理账号.
   */
  @PostMapping(value = "/punishment")
  ResultResponse<Void> punishment(@RequestBody @Validated PunishmentAccountCmd cmd);

  @PostMapping(value = "/account/login")
  ResultResponse<UserAccountDTO> accountLogin(@RequestBody @Validated AccountLoginCmd cmd);

  @GetMapping("/getByUserIdOne")
  ResultResponse<UserAuthTypeDTO> getByUserIdOne(@RequestParam("userId") Long userId);

  @GetMapping("/getMobileAuthByUserId")
  ResultResponse<MobileAuthDTO> getMobileAuthByUserId(@RequestParam("userId") Long userId);

  @GetMapping("/listByUserId")
  ResultResponse<List<UserAuthTypeDTO>> listByUserId(@RequestParam("userId") Long userId);

  @PostMapping(value = "/editUserMobileAuth")
  ResultResponse<Void> editUserMobileAuth(@RequestBody UserMobileUpdateCmd param);

  @GetMapping(value = "/deleteUserMobileAuth")
  ResultResponse<Void> deleteUserMobileAuth(@RequestParam("userId") Long userId);

  @GetMapping(value = "/deleteAccountAuthByUserId")
  ResultResponse<Void> deleteAccountAuthCacheByUserId(@RequestParam("userId") Long userId);

  @GetMapping(value = "/deleteUserAccountLogin")
  ResultResponse<Void> deleteUserAccountLogin(@RequestParam("userId") Long userId);

  @PostMapping("/saveApprovalLog")
  ResultResponse<Void> saveApprovalLog(@RequestBody ApprovalUserAccountStatusLogCmd cmd);

  @GetMapping(value = "/updateAccountFreeze")
  ResultResponse<Boolean> updateAccountFreeze(@RequestParam("userId") Long userId,
      @RequestParam("days") Integer days);

  @GetMapping(value = "/updateAccountStatus")
  ResultResponse<Boolean> updateAccountStatus(@RequestParam("userId") Long userId,
      @RequestParam("accountStatus") AccountStatusEnum accountStatus);

  @GetMapping(value = "/updateAccountStatusDays")
  ResultResponse<Boolean> updateAccountStatusDays(@RequestParam("userId") Long userId,
                                              @RequestParam("accountStatus") AccountStatusEnum accountStatus, @RequestParam Integer days);

  @PostMapping("/pgeApprovalUserAccountStatusLog")
  ResultResponse<PageResult<ApprovalUserAccountStatusLogDTO>> pgeApprovalUserAccountStatusLog(
      @RequestBody UserAccountStatusLogQryCmd cmd);

  @GetMapping(value = "/lastApprovalUserAccountStatusLog")
  ResultResponse<List<ApprovalUserAccountStatusLogDTO>> lastApprovalUserAccountStatusLog(
      @RequestParam("beApprovalUser") Long beApprovalUser, @RequestParam("size") Integer size);
}
