package com.ruoyi.project.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.project.domain.TrsResults;
import com.ruoyi.project.domain.TrsWordResults;
import com.ruoyi.project.utils.JiaoduiUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 配置管理Controller
 * 
 * @author ruoyi
 * @date 2025-03-19
 */
@Api("智能审校")
@Controller
@RequestMapping("/project/jiaodui")
public class TrsJiaoduiController extends BaseController
{
    private String prefix = "project/jiaodui";

    @Autowired
    private JiaoduiUtils jiaoduiUtils;
    /**
     * 在线校对
     */
    @RequiresPermissions("jiaodui:local")
    @GetMapping("/edit")
    public String edit(ModelMap mmap)
    {
        return prefix + "/edit";
    }


    @ApiImplicitParams({
    @ApiImplicitParam(name = "content", value = "校对内容", required = true, dataType = "String", dataTypeClass = String.class),
    @ApiImplicitParam(name = "title", value = "标题", required = true, dataType = "String", dataTypeClass = String.class),
    @ApiImplicitParam(name = "type", value = "日志记录（1记录日志，0不记录）", required = true, dataType = "String", dataTypeClass = String.class)
    })
    @RequiresPermissions("jiaodui:local")
    @RequestMapping ("/jiaodui")
    @ResponseBody
    public AjaxResult jiaodui(String content, String title, String type, HttpServletRequest request)
    {
        List<TrsWordResults> jiaodui = jiaoduiUtils.getJiaodui(content,title, type,  request);
        return AjaxResult.success("校对完成", jiaodui);
    }


}
