package com.goldenwater.slgc.controller;

import java.util.List;
import java.util.Map;
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.AttWagaBase;
import com.goldenwater.slgc.service.WagaService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "04. 泵站信息管理")
@RestController
@RequestMapping("/slgc/waga")
public class WagaController extends BaseController {
    @Autowired
    private WagaService wagaService;

    @Operation(summary = "04.01 查询泵站信息列表")
    @GetMapping("/list")
    public TableDataInfo list(AttWagaBase attWagaBase) {
        startPage();
        List<AttWagaBase> list = wagaService.selectAttWagaBaseList(attWagaBase);
        return getDataTable(list);
    }

    @Operation(summary = "04.02 获取泵站信息详细信息")
    @GetMapping(value = "/{wagaCode}")
    public AjaxResult getInfo(@PathVariable String wagaCode) {
        return success(wagaService.selectAttWagaBaseById(wagaCode));
    }

    @Operation(summary = "04.03 新增泵站信息")
    @Log(title = "泵站管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AttWagaBase attWagaBase) {
        return toAjax(wagaService.insertAttWagaBase(attWagaBase));
    }

    @Operation(summary = "04.04 修改泵站信息")
    @Log(title = "泵站管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AttWagaBase attWagaBase) {
        return toAjax(wagaService.updateAttWagaBase(attWagaBase));
    }

    @Operation(summary = "04.05 删除泵站信息")
    @Log(title = "泵站管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{wagaCodes}")
    public AjaxResult remove(@PathVariable String[] wagaCodes) {
        return toAjax(wagaService.deleteAttWagaBaseByIds(wagaCodes));
    }

    @Operation(summary = "04.06 统计泵站等级分布")
    @GetMapping("/countType")
    public AjaxResult countType() {
        List<Map<String, Object>> list = wagaService.countType();
        return success(list);
    }
}
