package com.fdkankan.platform.user.controller.sso;

import com.fdkankan.platform.user.request.RequestUser;
import com.fdkankan.platform.user.service.sso.AppService;
import com.fdkankan.platform.user.vo.ResponseUser;
import com.fdkankan.platform.user.vo.SSOUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * 登陆管理-app登陆模块
 */
@RestController
@RequestMapping("/service/sso/app")
public class SsoAppController {

    @Autowired
    private AppService appService;

    /**
     * APP扫码登录
     * appUserName      相机设备码
     * appPassword      相机密码
     * uuid  uuid
     * @return
     */
    @PostMapping(value = "/login")
    public String qrCodeLogin(@RequestBody RequestUser user) throws Exception {
        return appService.qrCodeLogin(user);
    }

    /**
     * App登录
     * appUserName      相机设备码
     * appPassword      相机密码
     * @return
     */
    @PostMapping(value = "/login2")
    public HashMap<String, String> passwordLogin(@RequestBody RequestUser user) throws Exception {
        return appService.passwordLogin(user);
    }
    /**
     * 用户名登录
     * phoneNum      手机号
     * cameraType    相机类型，1双目，4八目
     * password      密码
     * @return
     */
    @PostMapping(value = "/userLogin")
    public SSOUserVo userNameLogin(@RequestBody RequestUser user) throws Exception {
        return appService.userNameLogin(user);
    }
    /**
     * 验证码登陆
     * phoneNum      手机号
     * cameraType    相机类型，1双目，4八目
     * msgAuthCode   验证码
     */
    @PostMapping(value = "/quickLogin")
    public SSOUserVo quickLogin(@RequestBody RequestUser user) throws Exception {
        return appService.quickLogin(user);
    }
    /**
     * 登出
     */
    @PostMapping(value = "/logout")
    public String logout(@RequestHeader String token) throws Exception {
        return appService.logout(token);
    }
    /**
     * app注册
     * phoneNum      用户名
     * password      密码
     * msgAuthCode   验证码
     * nickName     昵称
     * country      国家
     * @return
     */
    @PostMapping(value = "/register")
    public String register(@RequestBody RequestUser user) throws Exception {
        return appService.register(user);
    }
    /**
     * app获取随机昵称
     * @return
     */
    @PostMapping(value = "/getNickName")
    public ResponseUser getRandomNickName() throws Exception {
        return appService.getRandomNickName();
    }
    /**
     * app检验用户名
     * appUserName      app用户昵称
     * @return
     */
    @PostMapping(value = "/checkUserName")
    public String checkUserName(@RequestBody RequestUser user) throws Exception {
        return appService.checkUserName(user);
    }
    /**
     * app修改密码
     * password      用户密码
     * phoneNum      用户名（手机号）
     * msgAuthCode      手机验证码
     * @return
     */
    @PostMapping(value = "/resetPassword")
    public String resetPassword(@RequestBody RequestUser user) throws Exception {
        return appService.resetPassword(user);
    }


}
