package com.cpxt.web.controller.biz;

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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cpxt.biz.domain.BizCar;
import com.cpxt.biz.domain.BizDriverClock;
import com.cpxt.biz.service.IBizDriverClockService;
import com.cpxt.common.constant.HttpStatus;
import org.checkerframework.checker.units.qual.A;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.cpxt.common.annotation.Log;
import com.cpxt.common.core.controller.BaseController;
import com.cpxt.common.core.domain.AjaxResult;
import com.cpxt.common.enums.BusinessType;
import com.cpxt.common.utils.poi.ExcelUtil;
import com.cpxt.common.core.page.TableDataInfo;

/**
 * 司机打卡记录Controller
 * 
 * @author ruoyi
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/system/clock")
public class BizDriverClockController extends BaseController
{
    @Autowired
    private IBizDriverClockService bizDriverClockService;

    /**
     * 查询司机打卡记录列表
     */
//    @PreAuthorize("@ss.hasPermi('system:clock:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizDriverClock bizDriverClock,
                              @RequestParam(defaultValue = "1") int pageNum,
                              @RequestParam(defaultValue = "10") int pageSize)
    {
        Page<BizDriverClock> recordPage = bizDriverClockService.selectBizDriverClockPage(bizDriverClock,pageNum,pageSize);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setMsg("查询成功");
        rspData.setRows(recordPage.getRecords());
        rspData.setTotal(recordPage.getTotal());
        return rspData;
    }

    /**
     * 导出司机打卡记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:clock:export')")
    @Log(title = "司机打卡记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizDriverClock bizDriverClock)
    {
        List<BizDriverClock> list = bizDriverClockService.selectBizDriverClockList(bizDriverClock);
        ExcelUtil<BizDriverClock> util = new ExcelUtil<BizDriverClock>(BizDriverClock.class);
        util.exportExcel(response, list, "司机打卡记录数据");
    }

    /**
     * 获取司机打卡记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:clock:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizDriverClockService.selectBizDriverClockById(id));
    }

    /**
     * 新增司机打卡记录
     */
    @Log(title = "司机打卡记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizDriverClock bizDriverClock)
    {
        return toAjax(bizDriverClockService.insertBizDriverClock(bizDriverClock));
    }

    /**
     * 修改司机打卡记录
     */
    @Log(title = "司机打卡记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizDriverClock bizDriverClock)
    {
        return toAjax(bizDriverClockService.updateBizDriverClock(bizDriverClock));
    }

    /**
     * 删除司机打卡记录
     */
    @PreAuthorize("@ss.hasPermi('system:clock:remove')")
    @Log(title = "司机打卡记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizDriverClockService.deleteBizDriverClockByIds(ids));
    }
}
