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.service.SupervisionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/hzz/supervision")
public class SupervisionController extends BaseController {
    @Autowired
    private SupervisionService service;

    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int pageSize) {
        return getDataTable(service.getSupervisionList(pageNum, pageSize));
    }

    @GetMapping("/detail/{guid}")
    public AjaxResult detail(@PathVariable String guid) {
        AjaxResult r = success();
        r.put("attachments", service.getAttachmentByGuid(guid));
        r.put("divisions", service.getDivisionByGuid(guid));
        r.put("results", service.getResultByGuid(guid));
        return r;
    }

    @PostMapping("/audit")
    public AjaxResult audit(@RequestParam String guid, @RequestParam String audit, @RequestParam(required = false) String auditInfo) {
        return toAjax(service.audit(guid, audit, auditInfo));
    }
}
