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.AttBridBase;
import com.goldenwater.slgc.domain.AttRudABase;
import com.goldenwater.slgc.domain.AttFlumBase;
import com.goldenwater.slgc.domain.AttPipeBase;
import com.goldenwater.slgc.service.BridgeService;
import com.goldenwater.slgc.service.RudaService;
import com.goldenwater.slgc.service.FlumeService;
import com.goldenwater.slgc.service.PipeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "07. 桥梁涵洞渡槽管道信息管理")
@RestController
@RequestMapping("/slgc/structure")
public class StructureController extends BaseController {
    @Autowired
    private BridgeService bridgeService;
    @Autowired
    private RudaService rudaService;
    @Autowired
    private FlumeService flumeService;
    @Autowired
    private PipeService pipeService;

    @Operation(summary = "07.01 查询桥梁信息列表")
    @GetMapping("/brid/list")
    public TableDataInfo bridList(AttBridBase attBridBase) {
        startPage();
        List<AttBridBase> list = bridgeService.selectAttBridBaseList(attBridBase);
        return getDataTable(list);
    }

    @Operation(summary = "07.02 获取桥梁信息详细信息")
    @GetMapping("/brid/{bridCode}")
    public AjaxResult bridGetInfo(@PathVariable String bridCode) {
        return success(bridgeService.selectAttBridBaseById(bridCode));
    }

    @Operation(summary = "07.03 新增桥梁信息")
    @Log(title = "桥梁管理", businessType = BusinessType.INSERT)
    @PostMapping("/brid")
    public AjaxResult bridAdd(@RequestBody AttBridBase attBridBase) {
        return toAjax(bridgeService.insertAttBridBase(attBridBase));
    }

    @Operation(summary = "07.04 修改桥梁信息")
    @Log(title = "桥梁管理", businessType = BusinessType.UPDATE)
    @PutMapping("/brid")
    public AjaxResult bridEdit(@RequestBody AttBridBase attBridBase) {
        return toAjax(bridgeService.updateAttBridBase(attBridBase));
    }

    @Operation(summary = "07.05 删除桥梁信息")
    @Log(title = "桥梁管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/brid/{bridCodes}")
    public AjaxResult bridRemove(@PathVariable String[] bridCodes) {
        return toAjax(bridgeService.deleteAttBridBaseByIds(bridCodes));
    }

    @Operation(summary = "07.06 查询涵洞信息列表")
    @GetMapping("/ruda/list")
    public TableDataInfo rudaList(AttRudABase attRudABase) {
        startPage();
        List<AttRudABase> list = rudaService.selectAttRudABaseList(attRudABase);
        return getDataTable(list);
    }

    @Operation(summary = "07.07 获取涵洞信息详细信息")
    @GetMapping("/ruda/{rudaCode}")
    public AjaxResult rudaGetInfo(@PathVariable String rudaCode) {
        return success(rudaService.selectAttRudABaseById(rudaCode));
    }

    @Operation(summary = "07.08 新增涵洞信息")
    @Log(title = "涵洞管理", businessType = BusinessType.INSERT)
    @PostMapping("/ruda")
    public AjaxResult rudaAdd(@RequestBody AttRudABase attRudABase) {
        return toAjax(rudaService.insertAttRudABase(attRudABase));
    }

    @Operation(summary = "07.09 修改涵洞信息")
    @Log(title = "涵洞管理", businessType = BusinessType.UPDATE)
    @PutMapping("/ruda")
    public AjaxResult rudaEdit(@RequestBody AttRudABase attRudABase) {
        return toAjax(rudaService.updateAttRudABase(attRudABase));
    }

    @Operation(summary = "07.10 删除涵洞信息")
    @Log(title = "涵洞管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/ruda/{rudaCodes}")
    public AjaxResult rudaRemove(@PathVariable String[] rudaCodes) {
        return toAjax(rudaService.deleteAttRudABaseByIds(rudaCodes));
    }

    @Operation(summary = "07.11 查询渡槽信息列表")
    @GetMapping("/flum/list")
    public TableDataInfo flumList(AttFlumBase attFlumBase) {
        startPage();
        List<AttFlumBase> list = flumeService.selectAttFlumBaseList(attFlumBase);
        return getDataTable(list);
    }

    @Operation(summary = "07.12 获取渡槽信息详细信息")
    @GetMapping("/flum/{flumCode}")
    public AjaxResult flumGetInfo(@PathVariable String flumCode) {
        return success(flumeService.selectAttFlumBaseById(flumCode));
    }

    @Operation(summary = "07.13 新增渡槽信息")
    @Log(title = "渡槽管理", businessType = BusinessType.INSERT)
    @PostMapping("/flum")
    public AjaxResult flumAdd(@RequestBody AttFlumBase attFlumBase) {
        return toAjax(flumeService.insertAttFlumBase(attFlumBase));
    }

    @Operation(summary = "07.14 修改渡槽信息")
    @Log(title = "渡槽管理", businessType = BusinessType.UPDATE)
    @PutMapping("/flum")
    public AjaxResult flumEdit(@RequestBody AttFlumBase attFlumBase) {
        return toAjax(flumeService.updateAttFlumBase(attFlumBase));
    }

    @Operation(summary = "07.15 删除渡槽信息")
    @Log(title = "渡槽管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/flum/{flumCodes}")
    public AjaxResult flumRemove(@PathVariable String[] flumCodes) {
        return toAjax(flumeService.deleteAttFlumBaseByIds(flumCodes));
    }

    @Operation(summary = "07.16 查询管道信息列表")
    @GetMapping("/pipe/list")
    public TableDataInfo pipeList(AttPipeBase attPipeBase) {
        startPage();
        List<AttPipeBase> list = pipeService.selectAttPipeBaseList(attPipeBase);
        return getDataTable(list);
    }

    @Operation(summary = "07.17 获取管道信息详细信息")
    @GetMapping("/pipe/{pipeCode}")
    public AjaxResult pipeGetInfo(@PathVariable String pipeCode) {
        return success(pipeService.selectAttPipeBaseById(pipeCode));
    }

    @Operation(summary = "07.18 新增管道信息")
    @Log(title = "管道管理", businessType = BusinessType.INSERT)
    @PostMapping("/pipe")
    public AjaxResult pipeAdd(@RequestBody AttPipeBase attPipeBase) {
        return toAjax(pipeService.insertAttPipeBase(attPipeBase));
    }

    @Operation(summary = "07.19 修改管道信息")
    @Log(title = "管道管理", businessType = BusinessType.UPDATE)
    @PutMapping("/pipe")
    public AjaxResult pipeEdit(@RequestBody AttPipeBase attPipeBase) {
        return toAjax(pipeService.updateAttPipeBase(attPipeBase));
    }

    @Operation(summary = "07.20 删除管道信息")
    @Log(title = "管道管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/pipe/{pipeCodes}")
    public AjaxResult pipeRemove(@PathVariable String[] pipeCodes) {
        return toAjax(pipeService.deleteAttPipeBaseByIds(pipeCodes));
    }
}
