package com.goldenwater.slgc.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.goldenwater.common.annotation.Log;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import com.goldenwater.common.enums.BusinessType;
import com.goldenwater.slgc.domain.RelDikeAd1;
import com.goldenwater.slgc.domain.RelDikeBas;
import com.goldenwater.slgc.domain.RelPustAd;
import com.goldenwater.slgc.domain.RelPustBas;
import com.goldenwater.slgc.domain.RelResAd1;
import com.goldenwater.slgc.domain.RelResBas;
import com.goldenwater.slgc.domain.RelWagaAd;
import com.goldenwater.slgc.domain.RelWagaBas;
import com.goldenwater.slgc.service.RelDikeAd1Service;
import com.goldenwater.slgc.service.RelDikeBasService;
import com.goldenwater.slgc.service.RelPustAdService;
import com.goldenwater.slgc.service.RelPustBasService;
import com.goldenwater.slgc.service.RelResAd1Service;
import com.goldenwater.slgc.service.RelResBasService;
import com.goldenwater.slgc.service.RelWagaAdService;
import com.goldenwater.slgc.service.RelWagaBasService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "10. 关联信息管理")
@RestController
@RequestMapping("/slgc/rel")
public class RelController extends BaseController {
    @Autowired
    private RelDikeBasService relDikeBasService;
    @Autowired
    private RelResBasService relResBasService;
    @Autowired
    private RelPustBasService relPustBasService;
    @Autowired
    private RelWagaBasService relWagaBasService;
    @Autowired
    private RelDikeAd1Service relDikeAd1Service;
    @Autowired
    private RelResAd1Service relResAd1Service;
    @Autowired
    private RelPustAdService relPustAdService;
    @Autowired
    private RelWagaAdService relWagaAdService;

    // ==================== REL_DIKE_BAS ====================

    @Operation(summary = "10.01 查询堤防基本信息关联列表")
    @GetMapping("/dike-bas/list")
    public TableDataInfo listDikeBas(RelDikeBas relDikeBas) {
        startPage();
        List<RelDikeBas> list = relDikeBasService.selectRelDikeBasList(relDikeBas);
        return getDataTable(list);
    }

    @Operation(summary = "10.02 获取堤防基本信息关联详细信息")
    @GetMapping("/dike-bas/{dikeCode}/{basCode}")
    public AjaxResult getInfoDikeBas(@PathVariable String dikeCode, @PathVariable String basCode) {
        RelDikeBas relDikeBas = new RelDikeBas();
        relDikeBas.setDikeCode(dikeCode);
        relDikeBas.setBasCode(basCode);
        return success(relDikeBasService.selectRelDikeBasById(relDikeBas));
    }

    @Operation(summary = "10.03 新增堤防基本信息关联")
    @Log(title = "关联管理", businessType = BusinessType.INSERT)
    @PostMapping("/dike-bas")
    public AjaxResult addDikeBas(@RequestBody RelDikeBas relDikeBas) {
        return toAjax(relDikeBasService.insertRelDikeBas(relDikeBas));
    }

    @Operation(summary = "10.04 修改堤防基本信息关联")
    @Log(title = "关联管理", businessType = BusinessType.UPDATE)
    @PutMapping("/dike-bas")
    public AjaxResult editDikeBas(@RequestBody RelDikeBas relDikeBas) {
        return toAjax(relDikeBasService.updateRelDikeBas(relDikeBas));
    }

    @Operation(summary = "10.05 删除堤防基本信息关联")
    @Log(title = "关联管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/dike-bas/{dikeCode}/{basCode}")
    public AjaxResult removeDikeBas(@PathVariable String dikeCode, @PathVariable String basCode) {
        RelDikeBas relDikeBas = new RelDikeBas();
        relDikeBas.setDikeCode(dikeCode);
        relDikeBas.setBasCode(basCode);
        return toAjax(relDikeBasService.deleteRelDikeBasById(relDikeBas));
    }

    // ==================== REL_RES_BAS ====================

    @Operation(summary = "10.06 查询水库基本信息关联列表")
    @GetMapping("/res-bas/list")
    public TableDataInfo listResBas(RelResBas relResBas) {
        startPage();
        List<RelResBas> list = relResBasService.selectRelResBasList(relResBas);
        return getDataTable(list);
    }

    @Operation(summary = "10.07 获取水库基本信息关联详细信息")
    @GetMapping("/res-bas/{resCode}/{basCode}")
    public AjaxResult getInfoResBas(@PathVariable String resCode, @PathVariable String basCode) {
        RelResBas relResBas = new RelResBas();
        relResBas.setResCode(resCode);
        relResBas.setBasCode(basCode);
        return success(relResBasService.selectRelResBasById(relResBas));
    }

    @Operation(summary = "10.08 新增水库基本信息关联")
    @Log(title = "关联管理", businessType = BusinessType.INSERT)
    @PostMapping("/res-bas")
    public AjaxResult addResBas(@RequestBody RelResBas relResBas) {
        return toAjax(relResBasService.insertRelResBas(relResBas));
    }

    @Operation(summary = "10.09 修改水库基本信息关联")
    @Log(title = "关联管理", businessType = BusinessType.UPDATE)
    @PutMapping("/res-bas")
    public AjaxResult editResBas(@RequestBody RelResBas relResBas) {
        return toAjax(relResBasService.updateRelResBas(relResBas));
    }

    @Operation(summary = "10.10 删除水库基本信息关联")
    @Log(title = "关联管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/res-bas/{resCode}/{basCode}")
    public AjaxResult removeResBas(@PathVariable String resCode, @PathVariable String basCode) {
        RelResBas relResBas = new RelResBas();
        relResBas.setResCode(resCode);
        relResBas.setBasCode(basCode);
        return toAjax(relResBasService.deleteRelResBasById(relResBas));
    }

    // ==================== REL_PUST_BAS ====================

    @Operation(summary = "10.11 查询水闸基本信息关联列表")
    @GetMapping("/pust-bas/list")
    public TableDataInfo listPustBas(RelPustBas relPustBas) {
        startPage();
        List<RelPustBas> list = relPustBasService.selectRelPustBasList(relPustBas);
        return getDataTable(list);
    }

    @Operation(summary = "10.12 获取水闸基本信息关联详细信息")
    @GetMapping("/pust-bas/{pustCode}/{basCode}")
    public AjaxResult getInfoPustBas(@PathVariable String pustCode, @PathVariable String basCode) {
        RelPustBas relPustBas = new RelPustBas();
        relPustBas.setPustCode(pustCode);
        relPustBas.setBasCode(basCode);
        return success(relPustBasService.selectRelPustBasById(relPustBas));
    }

    @Operation(summary = "10.13 新增水闸基本信息关联")
    @Log(title = "关联管理", businessType = BusinessType.INSERT)
    @PostMapping("/pust-bas")
    public AjaxResult addPustBas(@RequestBody RelPustBas relPustBas) {
        return toAjax(relPustBasService.insertRelPustBas(relPustBas));
    }

    @Operation(summary = "10.14 修改水闸基本信息关联")
    @Log(title = "关联管理", businessType = BusinessType.UPDATE)
    @PutMapping("/pust-bas")
    public AjaxResult editPustBas(@RequestBody RelPustBas relPustBas) {
        return toAjax(relPustBasService.updateRelPustBas(relPustBas));
    }

    @Operation(summary = "10.15 删除水闸基本信息关联")
    @Log(title = "关联管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/pust-bas/{pustCode}/{basCode}")
    public AjaxResult removePustBas(@PathVariable String pustCode, @PathVariable String basCode) {
        RelPustBas relPustBas = new RelPustBas();
        relPustBas.setPustCode(pustCode);
        relPustBas.setBasCode(basCode);
        return toAjax(relPustBasService.deleteRelPustBasById(relPustBas));
    }

    // ==================== REL_WAGA_BAS ====================

    @Operation(summary = "10.16 查询泵站基本信息关联列表")
    @GetMapping("/waga-bas/list")
    public TableDataInfo listWagaBas(RelWagaBas relWagaBas) {
        startPage();
        List<RelWagaBas> list = relWagaBasService.selectRelWagaBasList(relWagaBas);
        return getDataTable(list);
    }

    @Operation(summary = "10.17 获取泵站基本信息关联详细信息")
    @GetMapping("/waga-bas/{wagaCode}/{basCode}")
    public AjaxResult getInfoWagaBas(@PathVariable String wagaCode, @PathVariable String basCode) {
        RelWagaBas relWagaBas = new RelWagaBas();
        relWagaBas.setWagaCode(wagaCode);
        relWagaBas.setBasCode(basCode);
        return success(relWagaBasService.selectRelWagaBasById(relWagaBas));
    }

    @Operation(summary = "10.18 新增泵站基本信息关联")
    @Log(title = "关联管理", businessType = BusinessType.INSERT)
    @PostMapping("/waga-bas")
    public AjaxResult addWagaBas(@RequestBody RelWagaBas relWagaBas) {
        return toAjax(relWagaBasService.insertRelWagaBas(relWagaBas));
    }

    @Operation(summary = "10.19 修改泵站基本信息关联")
    @Log(title = "关联管理", businessType = BusinessType.UPDATE)
    @PutMapping("/waga-bas")
    public AjaxResult editWagaBas(@RequestBody RelWagaBas relWagaBas) {
        return toAjax(relWagaBasService.updateRelWagaBas(relWagaBas));
    }

    @Operation(summary = "10.20 删除泵站基本信息关联")
    @Log(title = "关联管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/waga-bas/{wagaCode}/{basCode}")
    public AjaxResult removeWagaBas(@PathVariable String wagaCode, @PathVariable String basCode) {
        RelWagaBas relWagaBas = new RelWagaBas();
        relWagaBas.setWagaCode(wagaCode);
        relWagaBas.setBasCode(basCode);
        return toAjax(relWagaBasService.deleteRelWagaBasById(relWagaBas));
    }

    // ==================== REL_DIKE_AD1 ====================

    @Operation(summary = "10.21 查询堤防行政信息关联列表")
    @GetMapping("/dike-ad1/list")
    public TableDataInfo listDikeAd1(RelDikeAd1 relDikeAd1) {
        startPage();
        List<RelDikeAd1> list = relDikeAd1Service.selectRelDikeAd1List(relDikeAd1);
        return getDataTable(list);
    }

    @Operation(summary = "10.22 获取堤防行政信息关联详细信息")
    @GetMapping("/dike-ad1/{dikeCode}/{adCode}")
    public AjaxResult getInfoDikeAd1(@PathVariable String dikeCode, @PathVariable String adCode) {
        RelDikeAd1 relDikeAd1 = new RelDikeAd1();
        relDikeAd1.setDikeCode(dikeCode);
        relDikeAd1.setAdCode(adCode);
        return success(relDikeAd1Service.selectRelDikeAd1ById(relDikeAd1));
    }

    @Operation(summary = "10.23 新增堤防行政信息关联")
    @Log(title = "关联管理", businessType = BusinessType.INSERT)
    @PostMapping("/dike-ad1")
    public AjaxResult addDikeAd1(@RequestBody RelDikeAd1 relDikeAd1) {
        return toAjax(relDikeAd1Service.insertRelDikeAd1(relDikeAd1));
    }

    @Operation(summary = "10.24 修改堤防行政信息关联")
    @Log(title = "关联管理", businessType = BusinessType.UPDATE)
    @PutMapping("/dike-ad1")
    public AjaxResult editDikeAd1(@RequestBody RelDikeAd1 relDikeAd1) {
        return toAjax(relDikeAd1Service.updateRelDikeAd1(relDikeAd1));
    }

    @Operation(summary = "10.25 删除堤防行政信息关联")
    @Log(title = "关联管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/dike-ad1/{dikeCode}/{adCode}")
    public AjaxResult removeDikeAd1(@PathVariable String dikeCode, @PathVariable String adCode) {
        RelDikeAd1 relDikeAd1 = new RelDikeAd1();
        relDikeAd1.setDikeCode(dikeCode);
        relDikeAd1.setAdCode(adCode);
        return toAjax(relDikeAd1Service.deleteRelDikeAd1ById(relDikeAd1));
    }

    // ==================== REL_RES_AD1 ====================

    @Operation(summary = "10.26 查询水库行政信息关联列表")
    @GetMapping("/res-ad1/list")
    public TableDataInfo listResAd1(RelResAd1 relResAd1) {
        startPage();
        List<RelResAd1> list = relResAd1Service.selectRelResAd1List(relResAd1);
        return getDataTable(list);
    }

    @Operation(summary = "10.27 获取水库行政信息关联详细信息")
    @GetMapping("/res-ad1/{resCode}/{adCode}")
    public AjaxResult getInfoResAd1(@PathVariable String resCode, @PathVariable String adCode) {
        RelResAd1 relResAd1 = new RelResAd1();
        relResAd1.setResCode(resCode);
        relResAd1.setAdCode(adCode);
        return success(relResAd1Service.selectRelResAd1ById(relResAd1));
    }

    @Operation(summary = "10.28 新增水库行政信息关联")
    @Log(title = "关联管理", businessType = BusinessType.INSERT)
    @PostMapping("/res-ad1")
    public AjaxResult addResAd1(@RequestBody RelResAd1 relResAd1) {
        return toAjax(relResAd1Service.insertRelResAd1(relResAd1));
    }

    @Operation(summary = "10.29 修改水库行政信息关联")
    @Log(title = "关联管理", businessType = BusinessType.UPDATE)
    @PutMapping("/res-ad1")
    public AjaxResult editResAd1(@RequestBody RelResAd1 relResAd1) {
        return toAjax(relResAd1Service.updateRelResAd1(relResAd1));
    }

    @Operation(summary = "10.30 删除水库行政信息关联")
    @Log(title = "关联管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/res-ad1/{resCode}/{adCode}")
    public AjaxResult removeResAd1(@PathVariable String resCode, @PathVariable String adCode) {
        RelResAd1 relResAd1 = new RelResAd1();
        relResAd1.setResCode(resCode);
        relResAd1.setAdCode(adCode);
        return toAjax(relResAd1Service.deleteRelResAd1ById(relResAd1));
    }

    // ==================== REL_PUST_AD ====================

    @Operation(summary = "10.31 查询水闸行政信息关联列表")
    @GetMapping("/pust-ad/list")
    public TableDataInfo listPustAd(RelPustAd relPustAd) {
        startPage();
        List<RelPustAd> list = relPustAdService.selectRelPustAdList(relPustAd);
        return getDataTable(list);
    }

    @Operation(summary = "10.32 获取水闸行政信息关联详细信息")
    @GetMapping("/pust-ad/{pustCode}/{adCode}")
    public AjaxResult getInfoPustAd(@PathVariable String pustCode, @PathVariable String adCode) {
        RelPustAd relPustAd = new RelPustAd();
        relPustAd.setPustCode(pustCode);
        relPustAd.setAdCode(adCode);
        return success(relPustAdService.selectRelPustAdById(relPustAd));
    }

    @Operation(summary = "10.33 新增水闸行政信息关联")
    @Log(title = "关联管理", businessType = BusinessType.INSERT)
    @PostMapping("/pust-ad")
    public AjaxResult addPustAd(@RequestBody RelPustAd relPustAd) {
        return toAjax(relPustAdService.insertRelPustAd(relPustAd));
    }

    @Operation(summary = "10.34 修改水闸行政信息关联")
    @Log(title = "关联管理", businessType = BusinessType.UPDATE)
    @PutMapping("/pust-ad")
    public AjaxResult editPustAd(@RequestBody RelPustAd relPustAd) {
        return toAjax(relPustAdService.updateRelPustAd(relPustAd));
    }

    @Operation(summary = "10.35 删除水闸行政信息关联")
    @Log(title = "关联管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/pust-ad/{pustCode}/{adCode}")
    public AjaxResult removePustAd(@PathVariable String pustCode, @PathVariable String adCode) {
        RelPustAd relPustAd = new RelPustAd();
        relPustAd.setPustCode(pustCode);
        relPustAd.setAdCode(adCode);
        return toAjax(relPustAdService.deleteRelPustAdById(relPustAd));
    }

    // ==================== REL_WAGA_AD ====================

    @Operation(summary = "10.36 查询泵站行政信息关联列表")
    @GetMapping("/waga-ad/list")
    public TableDataInfo listWagaAd(RelWagaAd relWagaAd) {
        startPage();
        List<RelWagaAd> list = relWagaAdService.selectRelWagaAdList(relWagaAd);
        return getDataTable(list);
    }

    @Operation(summary = "10.37 获取泵站行政信息关联详细信息")
    @GetMapping("/waga-ad/{wagaCode}/{adCode}")
    public AjaxResult getInfoWagaAd(@PathVariable String wagaCode, @PathVariable String adCode) {
        RelWagaAd relWagaAd = new RelWagaAd();
        relWagaAd.setWagaCode(wagaCode);
        relWagaAd.setAdCode(adCode);
        return success(relWagaAdService.selectRelWagaAdById(relWagaAd));
    }

    @Operation(summary = "10.38 新增泵站行政信息关联")
    @Log(title = "关联管理", businessType = BusinessType.INSERT)
    @PostMapping("/waga-ad")
    public AjaxResult addWagaAd(@RequestBody RelWagaAd relWagaAd) {
        return toAjax(relWagaAdService.insertRelWagaAd(relWagaAd));
    }

    @Operation(summary = "10.39 修改泵站行政信息关联")
    @Log(title = "关联管理", businessType = BusinessType.UPDATE)
    @PutMapping("/waga-ad")
    public AjaxResult editWagaAd(@RequestBody RelWagaAd relWagaAd) {
        return toAjax(relWagaAdService.updateRelWagaAd(relWagaAd));
    }

    @Operation(summary = "10.40 删除泵站行政信息关联")
    @Log(title = "关联管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/waga-ad/{wagaCode}/{adCode}")
    public AjaxResult removeWagaAd(@PathVariable String wagaCode, @PathVariable String adCode) {
        RelWagaAd relWagaAd = new RelWagaAd();
        relWagaAd.setWagaCode(wagaCode);
        relWagaAd.setAdCode(adCode);
        return toAjax(relWagaAdService.deleteRelWagaAdById(relWagaAd));
    }
}
