package com.td.boss.game.comsetting.controller;

import com.td.boss.common.controller.*;
import com.td.boss.common.pojo.Result;
import com.td.boss.config.enums.ResultEnum;
import com.td.boss.game.comsetting.pojo.ComSetting;
import com.td.boss.game.comsetting.vo.ComSettingVo;
import com.td.boss.game.comsetting.service.ComSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/game/comSetting/")
public class ComSettingController extends CommonController<ComSettingVo, ComSetting, String> {
    @Autowired
    private ComSettingService comSettingService;


    /**
     * 获取游戏设置
     *
     * @param userId
     * @return
     */
    @GetMapping("getGameSetting")
    public Result<ComSettingVo> getGameSettingFunction(@RequestParam(value = "userId") String userId) {
        //获取数据库相关配置
        ComSettingVo comSettingVo = comSettingService.get("1").getData();
        if (comSettingVo.equals(null)) {
            return Result.of(null, false, ResultEnum.SETTING_IS_NULL.getMessage(), ResultEnum.SETTING_IS_NULL.getCode());
        }
        return Result.of(comSettingVo);
    }
}
