package jnpf.attendance.controller;

import io.swagger.v3.oas.annotations.Operation;
import jnpf.attendance.service.AttendanceCloudAlbumService;
import jnpf.base.ActionResult;
import jnpf.model.attendance.dto.CloudAlbumBatchSaveDto;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 考勤云相册
 *
 * @Description: 考勤云相册控制类
 * @Author: shiTou(他是小石头)
 * @Date: 2024-10-30 10:26
 */
@Slf4j
@RestController
@RequestMapping(value = "/attendance/cloudAlbum")
public class AttendanceCloudAlbumController {
    @Resource
    private AttendanceCloudAlbumService attendanceCloudAlbumService;

    @SneakyThrows
    @Operation(summary = "列表查询")
    @GetMapping("/getDataList")
    public ActionResult<List<String>> getDataList() {
        long st = System.currentTimeMillis();
        List<String> dataList = attendanceCloudAlbumService.getDataList();
        long ent = System.currentTimeMillis();
        log.info("列表查询，耗时=>{}", ent - st + " 毫秒");
        return ActionResult.success(dataList);
    }

    @SneakyThrows
    @Operation(summary = "批量保存图片")
    @PostMapping("/batchSave")
    public ActionResult<Boolean> batchSave(@Valid @RequestBody CloudAlbumBatchSaveDto dto) {
        long st = System.currentTimeMillis();
        attendanceCloudAlbumService.batchSave(dto.getPicUrlList());
        long ent = System.currentTimeMillis();
        log.info("批量保存图片，耗时=>{}", ent - st + " 毫秒");
        return ActionResult.success();
    }

    @SneakyThrows
    @Operation(summary = "获取登录用户水印")
    @GetMapping("/getUserWatermark")
    public ActionResult<String> getUserWatermark() {
        long st = System.currentTimeMillis();
        String watermark = attendanceCloudAlbumService.getUserWatermark();
        long ent = System.currentTimeMillis();
        log.info("获取登录用户水印，耗时=>{}", ent - st + " 毫秒");
        return ActionResult.success("获取成功",watermark);
    }
}
