package com.sz.admin.monitor.controller;


import cn.dev33.satoken.annotation.SaIgnore;
import com.sz.admin.monitor.pojo.dto.dataModel.DataModelDTO;
import com.sz.admin.monitor.pojo.que.dataModel.DataModelQue;
import com.sz.admin.monitor.service.impl.DataModelServiceImpl;
import com.sz.core.common.entity.ApiResult;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author xq
 * @description:
 * @date 2026/3/14 12:35
 */
@Slf4j
@RestController
@RequestMapping("/data/model")
public class DataModelController {
    @Autowired
    private DataModelServiceImpl dataModelService;

    @PostMapping("/getModelData")
    @SaIgnore
    public ApiResult<DataModelDTO> getModelData(@RequestBody DataModelQue que) {
        return dataModelService.getModelData(que);
    }

    /**
     * 保存数据模型
     *
     * @param dataModelDTO
     * @return
     */
    @PostMapping("/saveOrUpdate/modelData")
    public ApiResult saveOrUpdateModelData(
        @RequestBody DataModelDTO dataModelDTO, HttpServletRequest request, HttpServletResponse response) {
        return dataModelService.saveOrUpdateModelData(dataModelDTO, request, response);
    }

    @GetMapping("/test")
    public ApiResult test() {
        return ApiResult.success(dataModelService.getList());
    }
}
