package com.ruoyi.web.controller.fbs;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fbs.domain.dto.TaskApplyDTO;
import com.ruoyi.fbs.service.IFbsProjectTaskApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 分包商项目任务申请Controller
 *
 * @author ruoyi
 * @date 2025-02-17
 */
@Api(value = "分包商项目任务申请控制器", tags = {"分包商项目任务申请管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/app/fbs/apply")
public class AppFbsProjectTaskApplyController extends BaseController {

    private final IFbsProjectTaskApplyService iFbsProjectTaskApplyService;


    /**
     * 新增分包商项目任务申请
     */
    @ApiOperation("App申请承接项目任务")
    @Log(title = "App申请承接项目任务", businessType = BusinessType.INSERT)
    @RepeatSubmit
    @PostMapping()
    public AjaxResult<Void> appTaskApply(@Validated @RequestBody TaskApplyDTO dto) {
        return toAjax(iFbsProjectTaskApplyService.appTaskApply(dto) ? 1 : 0);
    }


	@ApiOperation("App取消申请项目任务")
	@Log(title = "App取消申请项目任务" , businessType = BusinessType.DELETE)
	@DeleteMapping()
	public AjaxResult<Void> cancelApply(TaskApplyDTO dto) {
		return toAjax(iFbsProjectTaskApplyService.cancelApply(dto) ? 1 : 0);
	}


}
