package com.ruoyi.web.controller.bgt;

import com.ruoyi.bgt.domain.BgtProjectRecruit;
import com.ruoyi.bgt.domain.dto.BgtProjectRecruitQueryDTO;
import com.ruoyi.bgt.domain.vo.BgtProjectRecruitDetailVO;
import com.ruoyi.bgt.domain.vo.BgtProjectRecruitVO;
import com.ruoyi.bgt.service.IBgtProjectRecruitService;
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-17
 */
@Api(value = "App包工头招工控制器", tags = {"App包工头招工管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/app/bgt/recruit")
public class AppBgtProjectRecruitController extends BaseController {

    private final IBgtProjectRecruitService iBgtProjectRecruitService;

    /**
     * 查询包工头招工列表
     */
    @ApiOperation("App我的招工")
    @GetMapping("/list")
    public TableDataInfo<BgtProjectRecruitVO> list(@Validated BgtProjectRecruitQueryDTO dto) {
        return iBgtProjectRecruitService.appQueryPageList(dto);
    }

    /**
     * 获取包工头招工详细信息
     */
    @ApiOperation("App我的招工任务详情")
    @GetMapping("/{id}")
    public AjaxResult<BgtProjectRecruitDetailVO> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("id") Long id) {
        return AjaxResult.success(iBgtProjectRecruitService.appQueryById(id));
    }

    /**
     * 新增包工头招工
     */
    @ApiOperation("App发布招工")
    @Log(title = "App发布招工", businessType = BusinessType.INSERT)
    @RepeatSubmit
    @PostMapping()
    public AjaxResult<Void> add(@Validated @RequestBody BgtProjectRecruit bo) {
        return toAjax(iBgtProjectRecruitService.insert(bo) ? 1 : 0);
    }


}
