package com.jeelowcode.module.biz.controller;

import com.jeelowcode.core.framework.controller.BaseController;
import com.jeelowcode.framework.global.JeeLowCodeBaseConstant;
import com.jeelowcode.framework.tenant.annotation.JeeLowCodeTenantIgnore;
import com.jeelowcode.module.biz.service.IPortalTodoService;
import com.jeelowcode.tool.framework.common.pojo.CommonResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 门户待办有关接口
 *
 * @author yangchenjj
 */
@JeeLowCodeTenantIgnore
@Tag(name = "低代码框架 - 门户待办有关接口")
@RestController
@AllArgsConstructor
@RequestMapping(JeeLowCodeBaseConstant.REQUEST_URL_START + "/portal-to-do/push-todo")
public class PortalTodoController extends BaseController {

    private final IPortalTodoService portalTodoService;

    /**
     * 风险隐患推送待办完成
     *
     * @param workflowId 待办id
     * @return boolean 推送结果
     */
    @Operation(summary = "风险隐患推送待办完成")
    @RequestMapping(value = "/risk-hazard/{workflowId}", method = RequestMethod.POST)
    public CommonResult<Boolean> pushTodoRiskHazardWorkflow(@PathVariable("workflowId") Long workflowId) {
        return CommonResult.success(portalTodoService.pushDoneRiskHazardWorkflow(workflowId,"CHARGE_TODO"));
    }

    /**
     * 风险隐患推送待办取消
     *
     * @param workflowId 待办id
     * @return boolean 推送结果
     */
    @Operation(summary = "风险隐患推送待办取消")
    @RequestMapping(value = "/risk-hazard/{workflowId}", method = RequestMethod.DELETE)
    public CommonResult<Boolean> pushCancelRiskHazardWorkflow(@PathVariable("workflowId") Long workflowId) {
        return CommonResult.success(portalTodoService.pushCancelRiskHazardWorkflow(workflowId));
    }

}
