package com.usky.fire.controller.web;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.util.StringUtils;
import com.usky.common.log.annotation.Log;
import com.usky.common.log.enums.BusinessType;
import com.usky.fire.domain.PatrolInspectionAttendance;
import com.usky.fire.service.PatrolInspectionAttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * 签到、签退信息记录表 前端控制器
 * </p>
 *
 * @author fu
 * @since 2024-02-05
 */
@RestController
@RequestMapping("/patrolInspectionAttendance")
public class PatrolInspectionAttendanceController {
    @Autowired
    private PatrolInspectionAttendanceService patrolInspectionAttendanceService;
    /**
     * 分页查询签到记录
     * @param
     * @param
     * @return
     */
    @GetMapping("/pageQuery")
    public ApiResult<IPage<Map<String, Object>>> pageQuery(@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                                                           @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
                                                           @RequestParam(value = "operateCode", required = false, defaultValue = "") String operateCode,
                                                           @RequestParam(value = "operator", required = false, defaultValue = "") String operator,
                                                           @RequestParam(value = "startTime", required = false ) LocalDateTime startTime,
                                                           @RequestParam(value = "endTime", required = false, defaultValue = "#{T(java.time.LocalDateTime).now()}") LocalDateTime endTime) {
        return ApiResult.success(patrolInspectionAttendanceService.pageList(pageNum, pageSize, operateCode, operator, startTime, endTime));
    }

    /**
     * 新增
     * @param patrolInspectionAttendance
     * @return
     */
    @Log(title = " 签到、签退信息记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public ApiResult<Void> add(@RequestBody PatrolInspectionAttendance patrolInspectionAttendance){
        patrolInspectionAttendanceService.add(patrolInspectionAttendance);
        return ApiResult.success();
    }

    @GetMapping("/securityStatistics")
    public ApiResult<Map<String, Integer>> securityStatistics() {
        return ApiResult.success(patrolInspectionAttendanceService.securityStatistics());
    }
}


