package com.phm.manage.controller;

import com.phm.common.annotation.Log;
import com.phm.common.core.controller.BaseController;
import com.phm.common.core.domain.AjaxResult;
import com.phm.common.core.page.TableDataInfo;
import com.phm.common.enums.BusinessType;
import com.phm.common.utils.poi.ExcelUtil;
import com.phm.manage.domain.DeepIsolationModel;
import com.phm.manage.service.IDeepIsolationModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 深度隔离模型Controller
 *
 * @author phm
 * @date 2023-08-22
 */
@RestController
@RequestMapping("/manage/deepIsolationModel")
public class DeepIsolationModelController extends BaseController {
    @Autowired
    private IDeepIsolationModelService deepIsolationModelService;

    /**
     * 查询深度隔离模型列表
     */
    @PreAuthorize("@ss.hasPermi('manage:deepIsolationModel:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeepIsolationModel deepIsolationModel) {
        startPage();
        List<DeepIsolationModel> list = deepIsolationModelService.selectDeepIsolationModelList(deepIsolationModel);
        return getDataTable(list);
    }

    /**
     * 导出深度隔离模型列表
     */
    @PreAuthorize("@ss.hasPermi('manage:deepIsolationModel:export')")
    @Log(title = "深度隔离模型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeepIsolationModel deepIsolationModel) {
        List<DeepIsolationModel> list = deepIsolationModelService.selectDeepIsolationModelList(deepIsolationModel);
        ExcelUtil<DeepIsolationModel> util = new ExcelUtil<DeepIsolationModel>(DeepIsolationModel.class);
        util.exportExcel(response, list, "深度隔离模型数据");
    }

    /**
     * 获取深度隔离模型详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:deepIsolationModel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(deepIsolationModelService.selectDeepIsolationModelById(id));
    }

    /**
     * 新增深度隔离模型
     */
    @PreAuthorize("@ss.hasPermi('manage:deepIsolationModel:add')")
    @Log(title = "深度隔离模型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeepIsolationModel deepIsolationModel) {
        return toAjax(deepIsolationModelService.insertDeepIsolationModel(deepIsolationModel));
    }

    /**
     * 修改深度隔离模型
     */
    @PreAuthorize("@ss.hasPermi('manage:deepIsolationModel:edit')")
    @Log(title = "深度隔离模型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeepIsolationModel deepIsolationModel) {
        return toAjax(deepIsolationModelService.updateDeepIsolationModel(deepIsolationModel));
    }

    /**
     * 删除深度隔离模型
     */
    @PreAuthorize("@ss.hasPermi('manage:deepIsolationModel:remove')")
    @Log(title = "深度隔离模型", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(deepIsolationModelService.deleteDeepIsolationModelByIds(ids));
    }
}
