package com.xhkjedu.sapi.controller.cloud;

import com.xhkjedu.annotation.Action;
import com.xhkjedu.sapi.model.cloud.TCloud;
import com.xhkjedu.sapi.service.cloud.CloudService;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.vo.ResultVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ywx
 * @classname CloudController
 * @description 
 * @date 2021/6/30 14:48
 **/
@RestController
@RequestMapping("cloud")
public class CloudController {
    @Resource
    private CloudService cloudService;

    @PostMapping("/detail")
    public ResultVo detail() {
        TCloud tCloud = cloudService.findById();
        return new ResultVo(0,"获取平台详情成功",tCloud);
    }

    //修改主题色
    @PostMapping("/update")
    @Action("区域信息-修改主题")
    public ResultVo update(@RequestBody TCloud cloud) {
        N_Utils.validation(new Object[]{cloud.getCloudid(), "平台id", 1
        ,cloud.getTheme(),"主题色",2,cloud.getLoginbg(),"登录背景图片",2
        ,cloud.getLoginname(),"登录页面字体图片",2,cloud.getLoginico(),"区域设置的ico",2});
        cloudService.updateTheme(cloud);
        return new ResultVo(0,"修改成功");
    }

    //修改区域基础信息
    @PostMapping("/upinfo")
    @Action("区域信息-修改基础信息")
    public ResultVo updateInfo(@RequestBody TCloud cloud) {
        N_Utils.validation(new Object[]{cloud.getCloudid(), "平台id", 1,cloud.getCloudname(),"平台名称",2});
        cloudService.updateInfo(cloud);
        return new ResultVo(0,"修改成功");
    }

    @PostMapping("/list_level")
    public ResultVo listLevel() {
        List<Integer> list = cloudService.listLevel();
        return new ResultVo(0,"获取区域学段列表成功",list);
    }
}
