package com.ruoyi.web.controller.fbs;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.fbs.domain.dto.AppTaskDTO;
import com.ruoyi.fbs.domain.vo.*;
import com.ruoyi.fbs.service.IFbsProjectTaskService;
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.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

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

    private final IFbsProjectTaskService iFbsProjectTaskService;

	/**
	 * 首页任务列表 任务状态 申请(0)  是否我的任务 false
	 * 我的任务列表 任务状态 申请(0) 进行(1) 完成(2)  是否我的任务 true
	 *
	 */
    @ApiOperation("App包工头任务列表/我的任务")
    @GetMapping("/list")
    public TableDataInfo<AppTaskVO> list(@Validated AppTaskDTO dto) {
        return iFbsProjectTaskService.appQueryPageList(dto);
    }

	@ApiOperation("App包工头任务列表（不分页）")
	@GetMapping("/listAll")
	public AjaxResult<List<AppTaskVO>> list() {
		return AjaxResult.success(iFbsProjectTaskService.appQueryList());
	}


	@ApiOperation("项目任务详细信息-基本信息")
	@GetMapping("/{id}")
	public AjaxResult<AppTaskDetailVO> getInfo(@NotNull(message = "主键不能为空")
											  @PathVariable("id") Long id) {
		return AjaxResult.success(iFbsProjectTaskService.appQueryById(id));
	}

	@ApiOperation("项目任务详细信息-考勤")
	@GetMapping("/attendance/{id}")
	public AjaxResult<AppTaskDetailAttendanceVO> getInfoAttendance(@NotNull(message = "主键不能为空")
											   @PathVariable("id") Long id) {
		return AjaxResult.success(iFbsProjectTaskService.attendance(id));
	}

	@ApiOperation("项目任务详细信息-进度")
	@GetMapping("/progress/{id}")
	public AjaxResult<AppTaskDetailProgressVO> getInfoProgress(@NotNull(message = "主键不能为空")
																   @PathVariable("id") Long id) {
		return AjaxResult.success(iFbsProjectTaskService.progress(id));
	}

	@ApiOperation("项目任务详细信息-结算")
	@GetMapping("/wage/{id}")
	public AjaxResult<AppTaskDetailWageVO> getInfoWage(@NotNull(message = "主键不能为空")
															   @PathVariable("id") Long id) {
		return AjaxResult.success(iFbsProjectTaskService.wage(id));
	}

	@ApiOperation("项目任务详细信息-务工人员")
	@GetMapping("/recruit/{id}")
	public AjaxResult<AppTaskDetailRecruitVO> getInfoRecruit(@NotNull(message = "主键不能为空")
															   @PathVariable("id") Long id) {
		return AjaxResult.success(iFbsProjectTaskService.recruit(id));
	}



}
