package com.usky.meeting.controller.web;


import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.meeting.domain.MeetingFaceVefLog;
import com.usky.meeting.service.MeetingFaceVefLogService;
import com.usky.meeting.service.vo.FaceResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zyj
 * @since 2024-03-08
 */
@RestController
@RequestMapping("/meetingFaceVefLog")
@Api("人脸日志接口")
@Slf4j
public class MeetingFaceVefLogController {

    @Autowired
    MeetingFaceVefLogService faceVefLogService;

    @GetMapping("/list")
    @ApiOperation(value = "日志接口",notes = "查询所有验证人脸日志信息")
    public ApiResult<CommonPage<MeetingFaceVefLog>> faceList(
            @RequestParam Integer current,
            @RequestParam Integer size,
            @RequestParam(required = false) String startTime,
            @RequestParam(required = false) String endTime,
            @RequestParam(required = false) String vefCode,
            @RequestParam(required = false) String loginName
    ){
        IPage<MeetingFaceVefLog> page = faceVefLogService.page(new Page(current, size), new QueryWrapper<MeetingFaceVefLog>()
                .like(StrUtil.isNotBlank(vefCode),"vef_code",vefCode)
                .like(StrUtil.isNotBlank(loginName),"login_name",loginName)
                .between(StrUtil.isNotBlank(startTime) && StrUtil.isNotBlank(endTime),"vef_time",startTime,endTime)
                .orderByDesc("vef_time"));
        return ApiResult.success(new CommonPage<>(page.getRecords(),page.getTotal(),size,current));
    }

}

