package com.ruoyi.web.controller.bgt;

import com.ruoyi.bgt.domain.BgtProjectTaskProgress;
import com.ruoyi.bgt.domain.dto.BgtProjectTaskProgressQueryDTO;
import com.ruoyi.bgt.domain.vo.BgtProjectTaskProgressDetailVO;
import com.ruoyi.bgt.domain.vo.BgtProjectTaskProgressVO;
import com.ruoyi.bgt.service.IBgtProjectTaskProgressService;
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.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
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.*;

import javax.validation.constraints.NotNull;

/**
 * 包工头项目任务进度Controller
 *
 * @author ruoyi
 * @date 2025-02-18
 */
@Api(value = "App包工头项目任务进度控制器", tags = {"App包工头项目任务进度管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/app/bgt/progress")
public class AppBgtProjectTaskProgressController extends BaseController {

    private final IBgtProjectTaskProgressService iBgtProjectTaskProgressService;

    /**
     * 查询包工头项目任务进度列表
     */
    @ApiOperation("App查询包工头项目任务进度列表")
    @GetMapping("/list")
    public TableDataInfo<BgtProjectTaskProgressVO> list(@Validated BgtProjectTaskProgressQueryDTO bo) {
        return iBgtProjectTaskProgressService.appQueryPageList(bo);
    }


    /**
     * 获取包工头项目任务进度详细信息
     */
    @ApiOperation("App获取包工头项目任务进度详细信息")
    @GetMapping("/{id}")
    public AjaxResult<BgtProjectTaskProgressDetailVO> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("id") Long id) {
        return AjaxResult.success(iBgtProjectTaskProgressService.appQueryById(id));
    }

    /**
     * 新增包工头项目任务进度
     */
    @ApiOperation("App上传任务进度")
    @Log(title = "App上传任务进度", businessType = BusinessType.INSERT)
    @RepeatSubmit
    @PostMapping()
    public AjaxResult<Void> add(@Validated @RequestBody BgtProjectTaskProgress bo) {
        return toAjax(iBgtProjectTaskProgressService.insert(bo) ? 1 : 0);
    }

}
