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

import com.zanxiang.game.module.sdk.annotation.UnSignCheck;
import com.zanxiang.game.module.sdk.pojo.param.UserData;
import com.zanxiang.game.module.sdk.pojo.vo.GameInitVO;
import com.zanxiang.game.module.sdk.service.IGameAppletService;
import com.zanxiang.game.module.sdk.service.IGameAppletShellService;
import com.zanxiang.module.util.pojo.ResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author : lingfeng
 * @time : 2023-01-03
 * @description : sdk初始化接口
 */
@RestController
@Slf4j
@RequestMapping(value = "/api/init")
public class InitController {

    @Autowired
    private IGameAppletService gameAppletService;

    @Autowired
    private IGameAppletShellService gameAppletShellService;

    @UnSignCheck
    @PostMapping("/applet")
    public ResultVO<GameInitVO> h5AndAppletInit(UserData userData) {
        return ResultVO.ok(gameAppletService.h5AndAppletInit(userData));
    }

    @UnSignCheck
    @GetMapping("/shell/switch")
    public ResultVO<Integer> getShellSwitch(@RequestParam String appId, @RequestParam String version) {
        Integer shellSwitch = gameAppletShellService.getShellSwitch(appId, version);
        log.error("客保控制开关返回值, shellSwitch : {}", shellSwitch);
        return ResultVO.ok(shellSwitch);
    }
}
