package com.goldenwater.web.controller.hzz;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import com.goldenwater.hzz.domain.RiverProjectDTO;
import com.goldenwater.hzz.service.RiverProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;

@RestController
@RequestMapping("/hzz/riverproject")
public class RiverProjectController extends BaseController {
    @Autowired private RiverProjectService service;
    @GetMapping("/list") public TableDataInfo list(@RequestParam(required=false) String projectName, @RequestParam(required=false) String buildStage, @RequestParam(defaultValue="1") int pageNum, @RequestParam(defaultValue="10") int pageSize) { return getDataTable(service.getShxmList(projectName,buildStage,pageNum,pageSize)); }
    @GetMapping("/all") public AjaxResult all(@RequestParam(required=false) String searchName) { return success(service.getShxmAll(searchName)); }
    @GetMapping("/detail/{guid}") public AjaxResult detail(@PathVariable String guid) { return success(service.getShxmById(guid)); }
    @GetMapping("/files/{guid}") public AjaxResult files(@PathVariable String guid) { return success(service.getFilesById(guid)); }
    @PostMapping public AjaxResult add(@RequestBody RiverProjectDTO p) { return toAjax(service.saveShxm(p)); }
    @PutMapping public AjaxResult edit(@RequestBody RiverProjectDTO p) { return toAjax(service.editShxm(p)); }
    @DeleteMapping("/{guid}") public AjaxResult del(@PathVariable String guid) { return toAjax(service.deleteShxm(guid)); }
}
