package org.springblade.modules.system.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springblade.modules.system.entity.VisualSubscribeNotifyConf;
import org.springblade.modules.system.enums.NotifyType;
import org.springblade.modules.system.service.ISystemBaseInfoService;
import org.springblade.modules.system.service.VisualSubscribeNotifyConfService;
import org.springblade.modules.system.vo.SystemBaseInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("system/base-info")
@Api(value = "系统基本信息接口", tags = "系统基本信息读取接口")
public class SystemBaseInfoController extends BladeController {


    @Autowired
    private VisualSubscribeNotifyConfService visualSubscribeNotifyConfService;

    @Autowired
    private ISystemBaseInfoService systemBaseInfoService;

    @GetMapping("/get")
    @ApiOperation("获取系统基本信息")
    public R<SystemBaseInfoVO> getSystemBaseInfo(){
        return R.data(systemBaseInfoService.getSystemBaseInfoVO());
    }

    @GetMapping("/env-list")
    @ApiOperation("查询.env文件说明")
    public R<List<VisualSubscribeNotifyConf>> getEnvName(){

        return R.data( visualSubscribeNotifyConfService.list(Wrappers.<VisualSubscribeNotifyConf>lambdaQuery()
                .eq(VisualSubscribeNotifyConf::getNotifyType,NotifyType.upgradeEnv.getValue())));
    }

    @GetMapping("/system/model-list")
    @ApiOperation("查询后端模块说明")
    public R<List<VisualSubscribeNotifyConf>> getSystemModel(NotifyType notifyType){

        return R.data( visualSubscribeNotifyConfService.list(Wrappers.<VisualSubscribeNotifyConf>lambdaQuery()
                .eq(VisualSubscribeNotifyConf::getNotifyType, notifyType)));
    }
}
