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.AttDamBase;
import com.goldenwater.slgc.service.DamService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "05. 坝信息管理")
@RestController
@RequestMapping("/slgc/dam")
public class DamController extends BaseController {
    @Autowired
    private DamService damService;

    @Operation(summary = "05.01 查询坝信息列表")
    @GetMapping("/list")
    public TableDataInfo list(AttDamBase attDamBase) {
        startPage();
        List<AttDamBase> list = damService.selectAttDamBaseList(attDamBase);
        return getDataTable(list);
    }

    @Operation(summary = "05.02 获取坝信息详细信息")
    @GetMapping(value = "/{damCode}")
    public AjaxResult getInfo(@PathVariable String damCode) {
        return success(damService.selectAttDamBaseById(damCode));
    }

    @Operation(summary = "05.03 新增坝信息")
    @Log(title = "坝管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AttDamBase attDamBase) {
        return toAjax(damService.insertAttDamBase(attDamBase));
    }

    @Operation(summary = "05.04 修改坝信息")
    @Log(title = "坝管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AttDamBase attDamBase) {
        return toAjax(damService.updateAttDamBase(attDamBase));
    }

    @Operation(summary = "05.05 删除坝信息")
    @Log(title = "坝管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{damCodes}")
    public AjaxResult remove(@PathVariable String[] damCodes) {
        return toAjax(damService.deleteAttDamBaseByIds(damCodes));
    }
}
