package com.ruoyi.zhushi.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.zhushi.entity.DkCheckInRecordDTO;
import com.ruoyi.zhushi.service.DkRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 打卡记录数据
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/dk/record")
@Slf4j
public class DkRecordController extends BaseController {


    @Autowired
    private DkRecordService dkRecordService;


    // 主页面查询
    @GetMapping("/list")
    public TableDataInfo<DkCheckInRecordDTO> list(DkCheckInRecordDTO dkCheckInRecordDTO, PageQuery pageQuery) {
        return dkRecordService.queryPageList(dkCheckInRecordDTO, pageQuery);
    }


    /**
     * 导出结果列表
     */
    @PostMapping("/exportNew")
    @Log(title = "考勤记录", businessType = BusinessType.EXPORT)
    public void exportNew(DkCheckInRecordDTO bo, HttpServletResponse response) {
        dkRecordService.exportNew(bo, response);
    }

    /**
     * 修改打卡记录信息
     */
    @PutMapping()
    @Log(title = "考勤记录", businessType = BusinessType.UPDATE)
    public  R<Integer> updateDkRecord(@RequestBody DkCheckInRecordDTO bo) {
       return  R.ok(dkRecordService.updateDkRecord(bo));
    }
}
