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.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/gzqdgl")
public class GzqdglController {

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

    @Resource
    private GzqdglBPO gzqdglBPO;
    @Resource
    private CommonBPO commBPO;

/*
工作清单管理列表	getGzqdglList
工作清单信息获取   getGzqdById
工作清单管理删除	delGzqd
督办任务信息列表   getDbrwListByGzqdid  -公共
 */

    /**
     * 工作清单管理列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "工作清单管理列表", notes = "工作清单管理列表")
    @PostMapping(value = "/getGzqdglList")
    public AjaxResponse getGzqdglList(@RequestBody @Valid DbrwglGzqdglQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();

        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = gzqdglBPO.getGzqdglList(dto, pagenum, pagesize);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        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;
    }

    /**
     * 工作清单管理删除
     */
    @ApiOperation(value = "工作清单管理删除", notes = "工作清单管理删除")
    @PostMapping("/delGzqd")
    public AjaxResponse delGzqd(@RequestBody @Valid DbrwglCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        gzqdglBPO.delGzqd(dto);
        return ajaxResponse;
    }
    /**
     * 督办任务信息列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "督办任务信息列表", notes = "督办任务信息列表")
    @PostMapping(value = "/getDbrwListByGzqdid")
    public AjaxResponse getDbrwListByGzqdid(@RequestBody @Valid DbrwglCommQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();
        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = gzqdglBPO.getDbrwListByGzqdid(dto, pagenum, pagesize);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        return ajaxResponse;
    }

}
