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.AttRvBase;
import com.goldenwater.slgc.domain.AttReaBase;
import com.goldenwater.slgc.domain.AttLkBase;
import com.goldenwater.slgc.service.RiverService;
import com.goldenwater.slgc.service.ReachService;
import com.goldenwater.slgc.service.LakeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "06. 河流河道湖泊信息管理")
@RestController
@RequestMapping("/slgc/river")
public class RiverController extends BaseController {
    @Autowired
    private RiverService riverService;
    @Autowired
    private ReachService reachService;
    @Autowired
    private LakeService lakeService;

    @Operation(summary = "06.01 查询河流信息列表")
    @GetMapping("/rv/list")
    public TableDataInfo rvList(AttRvBase attRvBase) {
        startPage();
        List<AttRvBase> list = riverService.selectAttRvBaseList(attRvBase);
        return getDataTable(list);
    }

    @Operation(summary = "06.02 获取河流信息详细信息")
    @GetMapping("/rv/{rvCode}")
    public AjaxResult rvGetInfo(@PathVariable String rvCode) {
        return success(riverService.selectAttRvBaseById(rvCode));
    }

    @Operation(summary = "06.03 新增河流信息")
    @Log(title = "河流管理", businessType = BusinessType.INSERT)
    @PostMapping("/rv")
    public AjaxResult rvAdd(@RequestBody AttRvBase attRvBase) {
        return toAjax(riverService.insertAttRvBase(attRvBase));
    }

    @Operation(summary = "06.04 修改河流信息")
    @Log(title = "河流管理", businessType = BusinessType.UPDATE)
    @PutMapping("/rv")
    public AjaxResult rvEdit(@RequestBody AttRvBase attRvBase) {
        return toAjax(riverService.updateAttRvBase(attRvBase));
    }

    @Operation(summary = "06.05 删除河流信息")
    @Log(title = "河流管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/rv/{rvCodes}")
    public AjaxResult rvRemove(@PathVariable String[] rvCodes) {
        return toAjax(riverService.deleteAttRvBaseByIds(rvCodes));
    }

    @Operation(summary = "06.06 查询河道信息列表")
    @GetMapping("/rea/list")
    public TableDataInfo reaList(AttReaBase attReaBase) {
        startPage();
        List<AttReaBase> list = reachService.selectAttReaBaseList(attReaBase);
        return getDataTable(list);
    }

    @Operation(summary = "06.07 获取河道信息详细信息")
    @GetMapping("/rea/{reaCode}")
    public AjaxResult reaGetInfo(@PathVariable String reaCode) {
        return success(reachService.selectAttReaBaseById(reaCode));
    }

    @Operation(summary = "06.08 新增河道信息")
    @Log(title = "河道管理", businessType = BusinessType.INSERT)
    @PostMapping("/rea")
    public AjaxResult reaAdd(@RequestBody AttReaBase attReaBase) {
        return toAjax(reachService.insertAttReaBase(attReaBase));
    }

    @Operation(summary = "06.09 修改河道信息")
    @Log(title = "河道管理", businessType = BusinessType.UPDATE)
    @PutMapping("/rea")
    public AjaxResult reaEdit(@RequestBody AttReaBase attReaBase) {
        return toAjax(reachService.updateAttReaBase(attReaBase));
    }

    @Operation(summary = "06.10 删除河道信息")
    @Log(title = "河道管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/rea/{reaCodes}")
    public AjaxResult reaRemove(@PathVariable String[] reaCodes) {
        return toAjax(reachService.deleteAttReaBaseByIds(reaCodes));
    }

    @Operation(summary = "06.11 查询湖泊信息列表")
    @GetMapping("/lk/list")
    public TableDataInfo lkList(AttLkBase attLkBase) {
        startPage();
        List<AttLkBase> list = lakeService.selectAttLkBaseList(attLkBase);
        return getDataTable(list);
    }

    @Operation(summary = "06.12 获取湖泊信息详细信息")
    @GetMapping("/lk/{lkCode}")
    public AjaxResult lkGetInfo(@PathVariable String lkCode) {
        return success(lakeService.selectAttLkBaseById(lkCode));
    }

    @Operation(summary = "06.13 新增湖泊信息")
    @Log(title = "湖泊管理", businessType = BusinessType.INSERT)
    @PostMapping("/lk")
    public AjaxResult lkAdd(@RequestBody AttLkBase attLkBase) {
        return toAjax(lakeService.insertAttLkBase(attLkBase));
    }

    @Operation(summary = "06.14 修改湖泊信息")
    @Log(title = "湖泊管理", businessType = BusinessType.UPDATE)
    @PutMapping("/lk")
    public AjaxResult lkEdit(@RequestBody AttLkBase attLkBase) {
        return toAjax(lakeService.updateAttLkBase(attLkBase));
    }

    @Operation(summary = "06.15 删除湖泊信息")
    @Log(title = "湖泊管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/lk/{lkCodes}")
    public AjaxResult lkRemove(@PathVariable String[] lkCodes) {
        return toAjax(lakeService.deleteAttLkBaseByIds(lkCodes));
    }
}
