package com.zanxiang.game.module.sdk.controller;


import com.zanxiang.game.module.sdk.annotation.UnSignCheck;
import com.zanxiang.game.module.sdk.annotation.ValidLogin;
import com.zanxiang.game.module.sdk.pojo.param.*;
import com.zanxiang.game.module.sdk.pojo.vo.CustomerVO;
import com.zanxiang.game.module.sdk.pojo.vo.GameShareVO;
import com.zanxiang.game.module.sdk.pojo.vo.UserVO;
import com.zanxiang.game.module.sdk.service.*;
import com.zanxiang.module.util.pojo.ResultVO;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author : lingfeng
 * @time : 2022-06-16
 * @description : 用户接口
 */
@RestController
@Slf4j
@RequestMapping(value = "/api/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @Autowired
    private IUserCardService userCardService;

    @Autowired
    private IGameUserRoleService gameUserRoleService;

    @Autowired
    private IUserShareService userShareService;

    @Autowired
    private IGameShellLogService gameShellLogService;

    @Autowired
    private IMsgSceneCheckService msgSceneCheckService;

    @GetMapping("/share/game")
    public ResultVO<GameShareVO> shareGame(UserData userData) {
        return ResultVO.ok(userShareService.getGameShare(userData));
    }

    @PostMapping("/find/password")
    public ResultVO<Boolean> findPassword(@Validated @RequestBody FindPasswordParam param, UserData userData) {
        return userService.findPassword(param, userData);
    }

    @PostMapping("/update/password")
    public ResultVO<Boolean> updatePassword(@Validated @RequestBody UpdatePasswordParam param, @ValidLogin UserData userData) {
        return userService.updatePassword(param, userData);
    }

    @PostMapping("/bind/phone")
    public ResultVO<Boolean> bindPhone(@Validated @RequestBody BindPhoneParam param, @ValidLogin UserData userData) {
        return userService.bindPhone(param, userData);
    }

    @PostMapping("/authentication")
    public ResultVO<Boolean> userAuthentication(@Validated @RequestBody UserCardUpdateParam param, @ValidLogin UserData userData) {
        return userCardService.userAuthentication(param, userData);
    }

    @GetMapping("/get/detail")
    public ResultVO<UserVO> getUserDetail(@ValidLogin UserData userData) {
        return ResultVO.ok(userService.getUserDetail(userData));
    }

    @GetMapping("/get/customer")
    public ResultVO<CustomerVO> getUserCustomer(UserData userData) {
        return ResultVO.ok(userService.getUserCustomer(userData));
    }

    @UnSignCheck
    @PostMapping("/cp/server/update/game/role")
    public ResultVO<Boolean> updateUserGameRole(@Validated @RequestBody GameUserRoleSubmitParam param) {
        return ResultVO.ok(gameUserRoleService.updateUserGameRole(param));
    }

    @PostMapping("/update/game/role")
    public ResultVO<Boolean> updateUserGameRole(@Validated @RequestBody GameUserRoleUpdateParam param, @ValidLogin UserData userData) {
        return ResultVO.ok(gameUserRoleService.updateUserGameRole(param, userData));
    }

    @PostMapping("/active/call/role")
    public ResultVO<Boolean> gameRoleActiveCall(@Validated @RequestBody GameRoleActiveCallParam param, @ValidLogin UserData userData) {
        return ResultVO.ok(gameUserRoleService.gameRoleActiveCall(userData, param));
    }

    @UnSignCheck
    @PostMapping("/game/shell/call")
    public ResultVO<Boolean> gameShellLogAdd(@Validated @RequestBody GameShellLogParam param, HttpServletRequest request) {
        return ResultVO.ok(gameShellLogService.gameShellLogAdd(param, request));
    }

    @PostMapping("/msg/check")
    public ResultVO<String> msgCheck(@Validated @RequestBody MsgSceneCheckParam param, @ValidLogin UserData userData) {
        return ResultVO.ok(msgSceneCheckService.msgCheck(param, userData));
    }
}
