package cn.reghao.bnt.web.admin.controller;

import cn.reghao.bnt.web.admin.model.vo.DashboardData;
import cn.reghao.bnt.web.admin.service.HomeViewService;
import cn.reghao.jutil.web.WebResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author reghao
 * @date 2023-04-17 10:06:05
 */
@Tag(name = "后台首页")
@Controller
public class HomeController {
    private final HomeViewService homeViewService;

    public HomeController(HomeViewService homeViewService) {
        this.homeViewService = homeViewService;
    }

    //@Operation(summary = "后台首页", description = "N")
    //@GetMapping(value = "/bg")
    public String index(Model model) {
        return homeViewService.getHomeView(model);
    }

    @Operation(summary = "后台首页", description = "N")
    @GetMapping(value = "/api/devops/dashboard", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public String dashboardData() {
        DashboardData dashboardData = homeViewService.getDashboardData();
        return WebResult.success(dashboardData);
    }
}
