package com.gxwebsoft.ai.controller;

import com.alibaba.fastjson.JSONObject;
import com.gxwebsoft.ai.dto.AuditContentRequest;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.ai.service.AuditContentService3;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 审计内容3控制器 - 重大经济决策调查表
 */
@Tag(name = "审计内容3-重大经济决策")
@RestController
@RequestMapping("/api/ai/auditContent3")
public class AuditContentController3 extends BaseController {
    
    @Autowired
    private AuditContentService3 auditContentService3;
    
    /**
     * 生成重大经济决策调查表数据
     */
    @Operation(summary = "生成重大经济决策调查表")
    @PostMapping("/generateDecisionTable")
    public ApiResult<?> generateDecisionTable(@RequestBody AuditContentRequest request) {
        
        final User loginUser = getLoginUser();
        try {
            // 生成重大经济决策调查表数据
            JSONObject result = auditContentService3.generateDecisionTableData(
                request.getKbIds(), 
                request.getLibraryIds(), 
                request.getProjectLibrary(), 
                loginUser.getUsername(), 
                request.getHistory(), 
                request.getSuggestion()
            );
            
            return success(result);
        } catch (Exception e) {
            return fail("生成重大经济决策调查表失败: " + e.getMessage());
        }
    }
    
}