package cn.pluss.platform.controller.level;

import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.level.LevelOperateRecordService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author SSS
 */
@RequestMapping("/teamLevel")
@RestController
public class TeamLevelController {
    
    @Autowired
    private LevelOperateRecordService levelOperateRecordService;

    @GetMapping("/levelBenefitData")
    public Result<Map<String, Object>> levelBenefitData() {
        Map<String, Object> resultData = levelOperateRecordService.apiLevelBenefitData();
        return ResultGenerator.genSuccessResult(resultData);
    }

    @PostMapping("/changeLevel")
    public Result<Object> changeLevel(@RequestBody JSONObject param) {
        levelOperateRecordService.apiChangeLevel(param.getInteger("userId"), param.getString("level"));
        return ResultGenerator.genSuccessResult("操作成功", null);
    }

    @GetMapping("/levelBound")
    public Result<Object> levelBound(String userId) {
        Map<String, Object> resultMap = levelOperateRecordService.apiLevelBound(userId);
        return ResultGenerator.genSuccessResult(resultMap);
    }
}
