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

import com.jeesharp.business.modules.ai.application.AiChatFeedbackApplicationService;
import com.jeesharp.business.modules.ai.dto.AiChatFeedbackSaveDTO;
import com.jeesharp.business.modules.ai.entity.AiChatFeedback;
import com.jeesharp.business.modules.ai.vo.AiChatFeedbackInfoVO;
import com.jeesharp.business.modules.ai.vo.AiChatFeedbackListVO;
import com.jeesharp.business.modules.ai.vo.AiChatFeedbackQueryVO;
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 jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "${jeesharp.web.adminPath}/manager/business/ai/chatFeedback/v1")
@Tag(name = "AI客服-反馈")
@AllArgsConstructor
public class AiChatFeedbackController extends BaseController {

    private final AiChatFeedbackApplicationService aiChatFeedbackApplicationService;

    @Operation(summary = "获取详情")
    @PreAuthorize("@ss.hasPermission('manager:business:ai:chatFeedback:info')")
    @GetMapping("info")
    public AjaxResult<AiChatFeedbackInfoVO> info(@RequestParam("id") String id) {
        return AjaxResult.okData(aiChatFeedbackApplicationService.get(id));
    }

    @Operation(summary = "分页列表")
    @PreAuthorize("@ss.hasPermission('manager:business:ai:chatFeedback:list')")
    @PostMapping("list")
    public AjaxResult<PageRespVO<AiChatFeedbackListVO>> list(@RequestBody AiChatFeedbackQueryVO query) {
        return AjaxResult.okData(aiChatFeedbackApplicationService.findPage(new Page<>(query), query));
    }

    @Operation(summary = "保存")
    @PreAuthorize("@ss.hasPermission('manager:business:ai:chatFeedback:save')")
    @PostMapping("save")
    public AjaxResult<Void> save(@RequestBody @Valid AiChatFeedbackSaveDTO dto) {
        aiChatFeedbackApplicationService.save(dto);
        return AjaxResult.ok("保存成功");
    }

    @Operation(summary = "删除")
    @PreAuthorize("@ss.hasPermission('manager:business:ai:chatFeedback:delete')")
    @GetMapping("delete")
    public AjaxResult<Void> delete(@RequestParam("ids") String ids) {
        aiChatFeedbackApplicationService.delete(ids);
        return AjaxResult.ok("删除成功");
    }
}
