package com.zjrs.zwnw.dbgl.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.mohrss.leaf.core.framework.persistens.PageResult;
import org.mohrss.leaf.core.framework.web.controller.AjaxResponse;
import com.zjrs.zwnw.dbgl.bpo.DbrwtbBPO;
import com.zjrs.zwnw.dbgl.bpo.GzqdglBPO;
import com.zjrs.zwnw.dbgl.dto.*;
import com.zjrs.zwnw.portal.bpo.CommonBPO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import jakarta.validation.Valid;

@Api("督办任务填报")
@RestController
@RequestMapping("/api/dbrwgl/dbrwtb")
public class DbrwtbController {

    private static final Logger logger = LoggerFactory.getLogger(DbrwtbController.class);

    @Resource
    private GzqdglBPO gzqdglBPO;
    @Resource
    private DbrwtbBPO dbrwtbBPO;
    @Resource
    private CommonBPO commBPO;
/*
    督办任务填报列表	getDbrwtbList
    督办任务填报保存	saveDbrwtb
*/

    /**
     * 督办任务填报列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "督办任务填报列表", notes = "督办任务填报列表")
    @PostMapping(value = "/getDbrwtbList")
    public AjaxResponse getDbrwtbList(@RequestBody @Valid DbrwglDbrwtbQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();

        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = dbrwtbBPO.getDbrwtbList(dto, pagenum, pagesize);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        return ajaxResponse;
    }
    /**
     * 督办任务填报保存
     */
    @ApiOperation(value = "督办任务填报保存", notes = "督办任务填报保存")
    @PostMapping("/saveDbrwtb")
    public AjaxResponse saveDbrwtb(@RequestBody @Valid DbrwglGzrwtbSaveDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        dbrwtbBPO.saveDbrwtb(dto);
        return ajaxResponse;
    }

    /**
     * 工作清单信息获取
     */
    @ApiOperation(value = "工作清单信息获取", notes = "工作清单信息获取")
    @PostMapping("/getGzqdById")
    public AjaxResponse getGzqdById(@RequestBody @Valid DbrwglCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setData("data", gzqdglBPO.getGzqdById(dto));
        return ajaxResponse;
    }

}
