package com.sz.admin.monitor.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.sz.admin.monitor.pojo.dto.faceinfo.FaceInfoCreateDTO;
import com.sz.admin.monitor.pojo.dto.faceinfo.FaceInfoListDTO;
import com.sz.admin.monitor.pojo.dto.faceinfo.FaceInfoUpdateDTO;
import com.sz.admin.monitor.pojo.vo.faceinfo.FaceInfoVO;
import com.sz.admin.monitor.service.FaceImageService;
import com.sz.admin.monitor.service.FaceInfoService;
import com.sz.core.common.entity.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 人脸信息表 Controller
 * </p>
 *FaceInfoController
 * @author Lz
 * @since 2026-02-26
 */
@Tag(name =  "人脸信息表")
@RestController
@RequestMapping("ry-face-info")
@RequiredArgsConstructor
public class FaceInfoController  {

    private final FaceInfoService faceInfoService;


    @Operation(summary = "新增")
    @SaCheckPermission(value = "ry.face.info.create")
    @PostMapping
    public ApiResult<Void> create(@RequestBody FaceInfoCreateDTO dto) {
        faceInfoService.create(dto);
        return ApiResult.success();
    }

    @Operation(summary = "修改")
    @SaCheckPermission(value = "ry.face.info.update")
    @PutMapping
    public ApiResult<Void> update(@RequestBody FaceInfoUpdateDTO dto) {
        faceInfoService.update(dto);
        return ApiResult.success();
    }

    @Operation(summary = "删除")
    @SaCheckPermission(value = "ry.face.info.remove")
    @DeleteMapping
    public ApiResult<Void> remove(@RequestBody SelectIdsDTO dto) {
        faceInfoService.remove(dto);
        return ApiResult.success();
    }

    @Operation(summary = "列表查询")
    @SaCheckPermission(value = "ry.face.info.query_table")
    @GetMapping
    public ApiResult<PageResult<FaceInfoVO>> list(FaceInfoListDTO dto) {
        return ApiPageResult.success(faceInfoService.page(dto));
    }

    @Operation(summary = "详情")
    @SaCheckPermission(value = "ry.face.info.query_table")
    @GetMapping("/{id}")
    public ApiResult<FaceInfoVO> detail(@PathVariable Object id) {
        return ApiResult.success(faceInfoService.detail(id));
    }

    @Operation(summary = "导入")
    @Parameters({
      @Parameter(name = "file", description = "上传文件", schema = @Schema(type = "string", format = "binary"), required = true),
    })
    @SaCheckPermission(value = "ry.face.info.import")
    @PostMapping("/import")
    public void importExcel(@ModelAttribute ImportExcelDTO dto) {
        faceInfoService.importExcel(dto);
    }

    @Operation(summary = "导出")
    @SaCheckPermission(value = "ry.face.info.export")
    @PostMapping("/export")
    public void exportExcel(@RequestBody FaceInfoListDTO dto, HttpServletResponse response) {
        faceInfoService.exportExcel(dto, response);
    }
}