package com.red.circle.other.adapter.app.user.account;

import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.cmd.user.account.AccountCheckPwdCmd;
import com.red.circle.other.app.dto.cmd.user.account.ForgetPwdResetCmd;
import com.red.circle.other.app.service.user.account.AppUserAccountService;
import com.red.circle.other.inner.model.cmd.user.account.AccountPwdResetCmd;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户账号服务
 *
 * @author pengliang on 2023/5/29
 * @eo.api-type http
 * @eo.groupName 用户服务.账号管理
 * @eo.path /user/account
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/user/account", produces = MediaType.APPLICATION_JSON_VALUE)
public class AppUserAccountRestController extends BaseController {

  private final AppUserAccountService appUserAccountService;

  /**
   * 忘记密码重置(手机号).
   *
   * @eo.name 忘记密码重置(手机号).
   * @eo.url /forget-pwd-reset/phone
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping(value = "/forget-pwd-reset/phone", consumes = MediaType.APPLICATION_JSON_VALUE)
  public void forgetPwdResetPhone(@RequestBody @Validated ForgetPwdResetCmd cmd) {
    appUserAccountService.forgetPwdResetPhone(cmd);
  }


  /**
   * 删除账号密码
   */
  @PostMapping(value = "/account-pwd-reset", consumes = MediaType.APPLICATION_JSON_VALUE)
  public void accountPwdUpdate(@RequestBody @Validated AccountPwdResetCmd cmd) {
    appUserAccountService.accountPwdUpdate(cmd);
  }

  /**
   * 校验密码是否正确(账号).
   */
  @PostMapping(value = "/check-pwd/account", consumes = MediaType.APPLICATION_JSON_VALUE)
  public void accountCheckPwd(@RequestBody @Validated AccountCheckPwdCmd cmd) {
    appUserAccountService.accountCheckPwd(cmd);
  }


}
