package com.ruoyi.interfaces.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.interfaces.domain.PtServiceLog;
import com.ruoyi.interfaces.service.IPtServiceLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务调用日志Controller
 * 
 * @author 朱得糠
 * @date 2025-09-01
 */
@RestController
@RequestMapping("/interfaces/log")
public class PtServiceLogController extends BaseController
{
    @Autowired
    private IPtServiceLogService ptServiceLogService;

    /**
     * 查询服务调用日志列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PtServiceLog ptServiceLog)
    {
        startPage();
        List<PtServiceLog> list = ptServiceLogService.selectPtServiceLogList(ptServiceLog);
        return getDataTable(list);
    }

    /**
     * 导出服务调用日志列表
     */
    @Log(title = "服务调用日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PtServiceLog ptServiceLog)
    {
        List<PtServiceLog> list = ptServiceLogService.selectPtServiceLogList(ptServiceLog);
        ExcelUtil<PtServiceLog> util = new ExcelUtil<PtServiceLog>(PtServiceLog.class);
        util.exportExcel(response, list, "服务调用日志数据");
    }

    /**
     * 获取服务调用日志详细信息
     */
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return success(ptServiceLogService.selectPtServiceLogByLogId(logId));
    }

    /**
     * 新增服务调用日志
     */
    @Log(title = "服务调用日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PtServiceLog ptServiceLog)
    {
        return toAjax(ptServiceLogService.insertPtServiceLog(ptServiceLog));
    }

    /**
     * 修改服务调用日志
     */
    @Log(title = "服务调用日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PtServiceLog ptServiceLog)
    {
        return toAjax(ptServiceLogService.updatePtServiceLog(ptServiceLog));
    }

    /**
     * 删除服务调用日志
     */
    @Log(title = "服务调用日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(ptServiceLogService.deletePtServiceLogByLogIds(logIds));
    }
}
