package com.bonus.sgzb.app.controller;

import com.bonus.sgzb.app.domain.AppVersion;
import com.bonus.sgzb.app.domain.CriticalData;
import com.bonus.sgzb.app.domain.ToDoList;
import com.bonus.sgzb.app.service.AppService;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.bonus.sgzb.common.core.web.domain.AjaxResult.success;

/**
 * @author c liu
 * @date 2023/12/11
 */
@RestController
@RequestMapping("/base/app")
public class AppController {
    @Autowired
    private AppService service;

    @ApiOperation(value = "查询关键数据")
    @Log(title = "关键数据", businessType = BusinessType.QUERY)
    @GetMapping("/getCriticalData")
    public AjaxResult getCriticalData()
    {
        CriticalData data = service.getCriticalData();
        return success("操作成功",data);
    }

    @ApiOperation(value = "查询待办事项")
    @Log(title = "待办事项", businessType = BusinessType.QUERY)
    @GetMapping("/getToDoList")
    public AjaxResult getToDoList()
    {
        ToDoList data = service.getToDoList();
        return success("操作成功",data);
    }

    /**
     * 获取app版本信息
     *
     * @param
     * @return AjaxResult对象
     */
    @Log(title = "获取app版本信息", businessType = BusinessType.QUERY)
    @GetMapping("/getVersion")
    public AjaxResult getVersion() {
        try {
            List<AppVersion> list = service.getVersion();
            return success(list);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
