package com.ruoyi.web.controller.bgt;

import com.ruoyi.bgt.domain.dto.BgtDailyClockListDTO;
import com.ruoyi.bgt.domain.dto.BgtDailyClockUpdateDTO;
import com.ruoyi.bgt.domain.vo.BgtDailyClockDetailVO;
import com.ruoyi.bgt.domain.vo.BgtDailyClockListVO;
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 com.ruoyi.wgz.service.IWgzDailyClockService;
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/clock")
public class AppBgtDailyClockController extends BaseController {

    private final IWgzDailyClockService iWgzDailyClockService;

    /**
     * 查询日报打卡列表
     */
    @ApiOperation("查询日报打卡列表")
    @GetMapping("/list")
    public TableDataInfo<BgtDailyClockListVO> list(@Validated BgtDailyClockListDTO dto) {
        return iWgzDailyClockService.appQueryPageList(dto);
    }
    /**
     * 获取日报打卡详细信息
     */
    @ApiOperation("获取日报打卡详细信息")
    @GetMapping("/{id}")
    public AjaxResult<BgtDailyClockDetailVO> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("id") Long id) {
        return AjaxResult.success(iWgzDailyClockService.appQueryById(id));
    }

    /**
     * 修改日报打卡
     */
    @ApiOperation("已读和审批日报")
    @Log(title = "已读和审批日报", businessType = BusinessType.UPDATE)
    @RepeatSubmit
    @PutMapping()
    public AjaxResult<Void> edit(@Validated @RequestBody BgtDailyClockUpdateDTO dto) {
        return toAjax(iWgzDailyClockService.appUpdate(dto) ? 1 : 0);
    }

}
