package com.ruoyi.ibs.grid.controller;

import com.github.pagehelper.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataPageInfo;
import com.ruoyi.ibs.grid.domain.dto.GridRegionTransferDTO;
import com.ruoyi.ibs.grid.domain.dto.TransferApproveDTO;
import com.ruoyi.ibs.grid.domain.entity.GridRegionTransfer;
import com.ruoyi.ibs.grid.domain.vo.RegionGridCustVO;
import com.ruoyi.ibs.grid.service.RegionGridTransferService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import java.util.List;

/**
 * @Author 吴凯程
 * @Date 2025/6/24
 **/
@Api(tags = "地理网格移交接口")
@RestController
@RequestMapping("/grid/region/transfer")
public class RegionGridTransferController extends BaseController {

    @Resource
    private RegionGridTransferService regionGridTransferService;

    @ApiOperation("创建移交流程")
    @Log(title = "地理网格-创建移交流程" )
    @PostMapping("/add")
    public AjaxResult createGridTransfer(@RequestBody GridRegionTransferDTO gridRegionTransferDTO) {
        return AjaxResult.success(regionGridTransferService.createGridTransfer(gridRegionTransferDTO));
    }

    @ApiOperation("支行管理员审批")
    @Log(title = "地理网格-支行管理员审批" )
    @PostMapping("/approve/branch")
    public AjaxResult branchApprove(@RequestBody TransferApproveDTO transferApproveDTO) {
        return AjaxResult.success(regionGridTransferService.branchApprove(transferApproveDTO));
    }

    @ApiOperation("总行管理员审批")
    @Log(title = "地理网格-总行管理员审批" )
    @PostMapping("/approve/head")
    public AjaxResult headApprove(@RequestBody TransferApproveDTO transferApproveDTO) {
        return AjaxResult.success(regionGridTransferService.headApprove(transferApproveDTO));
    }

    @ApiOperation("审批列表")
    @Log(title = "地理网格-审批列表" )
    @GetMapping("/list")
    public TableDataPageInfo<GridRegionTransfer> getGridRegionTransferList() {
        Page<Object> page = startPage();
        List<GridRegionTransfer> gridRegionTransferList = regionGridTransferService.getGridRegionTransferList();
        return getDataTable(gridRegionTransferList, page);
    }

    @ApiOperation("获取网格列表")
    @Log(title = "地理网格-获取网格列表" )
    @GetMapping("/sec/grid")
    public AjaxResult getSecGridList() {
        return AjaxResult.success(regionGridTransferService.getSecGridList());
    }


}
