package com.citygis.web.controller;


import com.citygis.common.annotation.Log;
import com.citygis.common.core.domain.AjaxResult;
import com.citygis.common.enums.BusinessType;
import com.citygis.web.domain.DataSun;
import com.citygis.web.service.ITabDatasourceMsgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 接入数据资源详情 前端控制器
 * </p>
 *
 * @author citygis
 * @since 2025-01-08
 */
@Api(tags = "接入数据资源详情")
@RestController
@RequestMapping("/web/tab-datasource-msg")
public class TabDatasourceMsgController {

    @Resource
    ITabDatasourceMsgService tabDatasourceMsgService;

    @Log(title = "接入数据资源详情", businessType = BusinessType.INSERT)
    @ApiOperation("添加接入数据资源详情")
    @PostMapping("insertDataSun")
    public AjaxResult insertDataSun(@Validated @RequestBody DataSun dataSun) {
        return tabDatasourceMsgService.insertDataSun(dataSun);
    }

    @Log(title = "接入数据资源详情", businessType = BusinessType.UPDATE)
    @ApiOperation("修改接入数据资源详情")
    @PostMapping("updateDataSun")
    public AjaxResult updateDataSun(@RequestBody DataSun dataSun) {
        return tabDatasourceMsgService.updateDataSun(dataSun);
    }


    @Log(title = "接入数据资源详情", businessType = BusinessType.DELETE)
    @ApiOperation("删除接入数据资源详情")
    @DeleteMapping("deleteDataSun/{id}")
    public AjaxResult deleteDataSun(@PathVariable Long id) {
        return tabDatasourceMsgService.deleteDataSun(id);
    }


    @Log(title = "接入数据资源详情", businessType = BusinessType.SELECT)
    @ApiOperation("查询接入数据资源详情")
    @PostMapping("getDataSunByAccessOnlyId/{accessOnlyId}")
    public AjaxResult getDataSun(@PathVariable Long accessOnlyId) {
        return tabDatasourceMsgService.getDataSun(accessOnlyId);
    }

    @Log(title = "接入数据资源详情", businessType = BusinessType.DELETE)
    @ApiOperation("删除kafka子项")
    @DeleteMapping("deleteKafKaSun/{id}")
    public AjaxResult deleteKafKaSun(@PathVariable Long id) {
        return tabDatasourceMsgService.deleteKafkaSun(id);
    }

    @Log(title = "接入数据资源详情", businessType = BusinessType.DELETE)
    @ApiOperation("删除url子项")
    @DeleteMapping("deleteUrlSun/{id}")
    public AjaxResult deleteUrlSun(@PathVariable Long id) {
        return tabDatasourceMsgService.deleteUrlSun(id);
    }

    @Log(title = "接入数据资源详情", businessType = BusinessType.DELETE)
    @ApiOperation("删除etl和kb子项")
    @DeleteMapping("deleteEtlAndKbSun/{id}")
    public AjaxResult deleteEtlSun(@PathVariable Long id) {
        return tabDatasourceMsgService.deleteEtlAndKbSun(id);
    }


}

