package com.tongran.rocketmq.controller;

import com.tongran.common.core.web.controller.BaseController;
import com.tongran.common.core.web.domain.AjaxResult;
import com.tongran.common.log.annotation.Log;
import com.tongran.common.log.enums.BusinessType;
import com.tongran.common.security.annotation.RequiresPermissions;
import com.tongran.rocketmq.domain.AllDiskName;
import com.tongran.rocketmq.service.IAllDiskNameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 磁盘名称存储Controller
 * 
 * @author tongran
 * @date 2026-01-14
 */
@RestController
@RequestMapping("/allDiskName")
@RequiresPermissions("rocketmq:traffic")
public class AllDiskNameController extends BaseController
{
    @Autowired
    private IAllDiskNameService allDiskNameService;

    /**
     * 查询磁盘名称存储列表
     */
    @PostMapping("/list")
    public AjaxResult list(@RequestBody AllDiskName allDiskName)
    {
        List<AllDiskName> list = allDiskNameService.selectDiskInfoList(allDiskName);
        return success(list);
    }


    /**
     * 获取磁盘名称存储详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(allDiskNameService.selectAllDiskNameById(id));
    }

    /**
     * 测试磁盘IOPS/卸载分区
     * @param allDiskName
     * @return
     */
    @PostMapping("/issuanceOperation")
    public AjaxResult testIOPS(@RequestBody AllDiskName allDiskName){
        return toAjax(allDiskNameService.issuanceOperation(allDiskName));
    }


    /**
     * 修改磁盘名称存储
     */
    @Log(title = "磁盘名称存储", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AllDiskName allDiskName)
    {
        return toAjax(allDiskNameService.updateAllDiskName(allDiskName));
    }

    /**
     * 删除磁盘名称存储
     */
    @Log(title = "磁盘名称存储", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(allDiskNameService.deleteAllDiskNameByIds(ids));
    }
}
