package com.tongran.mtragent.controller;

import com.tongran.common.core.utils.poi.ExcelUtil;
import com.tongran.common.core.web.controller.BaseController;
import com.tongran.common.core.web.domain.AjaxResult;
import com.tongran.common.core.web.page.TableDataInfo;
import com.tongran.common.log.annotation.Log;
import com.tongran.common.log.enums.BusinessType;
import com.tongran.common.security.annotation.RequiresPermissions;
import com.tongran.mtragent.domain.AllMtrClient;
import com.tongran.mtragent.service.IAllMtrClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * mtr探测丢包clinetId记录Controller
 * 
 * @author tongran
 * @date 2025-11-24
 */
@RestController
@RequestMapping("/allMtrClient")
@RequiresPermissions("mtragent:mtrClientRegistration")
public class AllMtrClientController extends BaseController
{
    @Autowired
    private IAllMtrClientService allMtrClientService;

    /**
     * 查询mtr探测丢包clinetId记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AllMtrClient allMtrClient)
    {
        startPage();
        List<AllMtrClient> list = allMtrClientService.selectAllMtrClientList(allMtrClient);
        return getDataTable(list);
    }

    /**
     * 导出mtr探测丢包clinetId记录列表
     */
    @Log(title = "mtr探测丢包clinetId记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AllMtrClient allMtrClient)
    {
        List<AllMtrClient> list = allMtrClientService.selectAllMtrClientList(allMtrClient);
        ExcelUtil<AllMtrClient> util = new ExcelUtil<AllMtrClient>(AllMtrClient.class);
        util.exportExcel(response, list, "mtr探测丢包clinetId记录数据");
    }

    /**
     * 获取mtr探测丢包clinetId记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(allMtrClientService.selectAllMtrClientById(id));
    }

    /**
     * 新增mtr探测丢包clinetId记录
     */
    @Log(title = "mtr探测丢包clinetId记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AllMtrClient allMtrClient)
    {
        return toAjax(allMtrClientService.insertAllMtrClient(allMtrClient));
    }

    /**
     * 修改mtr探测丢包clinetId记录
     */
    @Log(title = "mtr探测丢包clinetId记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AllMtrClient allMtrClient)
    {
        return toAjax(allMtrClientService.updateAllMtrClient(allMtrClient));
    }

    /**
     * 删除mtr探测丢包clinetId记录
     */
    @Log(title = "mtr探测丢包clinetId记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(allMtrClientService.deleteAllMtrClientByIds(ids));
    }
}
