package thyyxxk.webserver.controller.reports;

import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.reports.reportQueryCenter.ReportForms;
import thyyxxk.webserver.service.reports.ReportQueryCenterService;

import java.util.List;

@RestController
@RequestMapping("/reportQueryCenter")
public class ReportQueryCenterController {
    private final ReportQueryCenterService service;

    public ReportQueryCenterController(ReportQueryCenterService service) {
        this.service = service;
    }

    @PostMapping("/addReportQueryCenter")
    public ResultVo<String> addReportQueryCenter(@RequestBody ReportForms param) {
        return service.addReportQueryCenter(param);
    }

    @PostMapping("/updateReportQueryCenter")
    public ResultVo<String> updateReportQueryCenter(@RequestBody ReportForms param) {
        return service.updateReportQueryCenter(param);
    }

    @GetMapping("/delReportQueryCenterById")
    public ResultVo<String> delReportQueryCenterById(@RequestParam("id") String id) {
        return service.delReportQueryCenterById(id);
    }

    @GetMapping("/getReportTree")
    public ResultVo<List<ReportForms>> getReportTree() {
        return service.getReportTree();
    }

    @GetMapping("/updateParentById")
    public ResultVo<String> updateParentById(@RequestParam("id") String id,
                                             @RequestParam("parentId") String parentId) {
        return service.updateParentById(id, parentId);
    }

    @GetMapping("/getRulesByCode")
    public ResultVo<List<String>> getRulesByCode(@RequestParam("userCode") String userCode) {
        return service.getRulesByCode(userCode);
    }

    @PostMapping("/saveThePersonRoleCode")
    public ResultVo<String> saveThePersonRoleCode(@RequestBody ReportQueryCenterService.PersonRoleCode data) {
        return service.saveThePersonRoleCode(data);
    }

    @GetMapping("/updateName")
    public ResultVo<String> updateName(@RequestParam("id") String id, @RequestParam("name") String name) {
        return service.updateName(id, name);
    }

}
