package com.jeesharp.business.modules.contentsecurity.controller;

import com.jeesharp.business.modules.contentsecurity.application.ContentSecurityApplicationService;
import com.jeesharp.business.modules.contentsecurity.entity.ContentSecurityLog;
import com.jeesharp.business.modules.contentsecurity.vo.ContentSecurityLogListVO;
import com.jeesharp.business.modules.contentsecurity.vo.ContentSecurityLogQueryVO;
import com.jeesharp.framework.pojo.AjaxResult;
import com.jeesharp.framework.pojo.Page;
import com.jeesharp.framework.pojo.query.PageRespVO;
import com.jeesharp.framework.web.controller.BaseController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 管理端内容安全检测流水查询 REST 接口。
 *
 * @author jeesharp
 * @since 2026-06-27
 */
@RestController
@RequestMapping(value = "${jeesharp.web.adminPath}/manager/business/contentSecurity/log/v1")
@Tag(name = "内容安全-检测记录")
@AllArgsConstructor
public class ContentSecurityLogController extends BaseController {

    private final ContentSecurityApplicationService contentSecurityApplicationService;

    @Operation(summary = "检测记录列表（分页）")
    @PreAuthorize("@ss.hasPermission('manager:business:contentSecurity:log:list')")
    @PostMapping("list")
    public AjaxResult<PageRespVO<ContentSecurityLogListVO>> list(@RequestBody ContentSecurityLogQueryVO query) {
        Page<ContentSecurityLog> page = new Page<>(query);
        return AjaxResult.okData(contentSecurityApplicationService.findLogPage(page, query));
    }

    @Operation(summary = "检测记录详情")
    @PreAuthorize("@ss.hasPermission('manager:business:contentSecurity:log:list')")
    @GetMapping("info")
    public AjaxResult<ContentSecurityLogListVO> info(@RequestParam("id") String id) {
        return AjaxResult.okData(contentSecurityApplicationService.getLog(id));
    }
}
