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.JgxxwhBPO;
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/jgxxwh")
public class JgxxwhController {

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

    @Resource
    private JgxxwhBPO jgxxwhBPO;
    @Resource
    private CommonBPO commBPO;
/*
机构信息维护列表	getJgxxwhList
机构信息获取	getJgxxwh
机构信息保存	saveJgxxwh
*/


    /**
     * 机构信息维护列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "机构信息维护列表", notes = "机构信息维护列表")
    @PostMapping(value = "/getJgxxwhList")
    public AjaxResponse getJgxxwhList(@RequestBody @Valid DbrwglJgxxwhQueryDTO dto){
        AjaxResponse ajaxResponse = new AjaxResponse();

        Integer pagenum = Math.toIntExact(dto.getPagenum());
        Integer pagesize = Math.toIntExact(dto.getPagesize());
        PageResult pageResult = jgxxwhBPO.getJgxxwhList(dto, pagenum, pagesize);
        ajaxResponse.setData("data", pageResult);
        ajaxResponse.setData("pagesize", pagesize);
        ajaxResponse.setData("pagenum", pagenum);
        return ajaxResponse;
    }
    /**
     * 机构信息获取
     */
    @ApiOperation(value = "机构信息获取", notes = "机构信息获取")
    @PostMapping("/getJgxxwh")
    public AjaxResponse getJgxxwh(@RequestBody @Valid DbrwglCommDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        ajaxResponse.setData("data", jgxxwhBPO.getJgxxwh(dto));
        return ajaxResponse;
    }

    /**
     * 机构信息保存
     */
    @ApiOperation(value = "机构信息保存", notes = "机构信息保存")
    @PostMapping("/saveJgxxwh")
    public AjaxResponse saveJgxxwh(@RequestBody @Valid DbrwglJgxxwhUDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        jgxxwhBPO.saveJgxxwh(dto);
        return ajaxResponse;
    }

}
