package com.yuchen.saas.park.service.controller.security;


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.manage.system.api.param.CommonIdParam;
import com.yuchen.saas.park.api.entity.security.SaasParkFaceDetectEvent;
import com.yuchen.saas.park.service.service.security.ISaasParkFaceDetectEventService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * <p>
 * 宇视人脸检测事件表 前端控制器
 * </p>
 *
 * @author 洪铭铭
 * @since 2024-09-12
 */
@Api(tags = "人脸检测")
@RestController
@RequestMapping("/faceDetectEvent")
public class SaasParkFaceDetectEventController {
    @Autowired
    private ISaasParkFaceDetectEventService saasParkFaceDetectEventService;

    @PostMapping("/save")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新增", notes = "人脸检测新增")
    public R save(@Valid @RequestBody SaasParkFaceDetectEvent saasParkFaceDetectEvent) {
        return R.status(saasParkFaceDetectEventService.save(saasParkFaceDetectEvent));
    }

    @PostMapping("/list")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "列表", notes = "人脸检测列表")
    public R<List<SaasParkFaceDetectEvent>> list() {
        return R.data(saasParkFaceDetectEventService.getAll());
    }

    @PostMapping("/update")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "修改", notes = "人脸检测修改")
    public R update(@Valid @RequestBody SaasParkFaceDetectEvent saasParkFaceDetectEvent) {
        return R.status(saasParkFaceDetectEventService.saveOrUpdate(saasParkFaceDetectEvent));
    }

    @PostMapping("/delete")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "删除", notes = "人脸检测删除")
    public R delete(@Valid @RequestBody CommonIdParam param) {
        return R.data(saasParkFaceDetectEventService.removeById(param.getId()));
    }

    @GetMapping("/detail")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "详情", notes = "人脸检测详情")
    public R<SaasParkFaceDetectEvent> detail(@RequestParam("id") Long id) {
        return R.data(saasParkFaceDetectEventService.getById(id));
    }

}
