package com.xunmei.system.controller;

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.xunmei.common.log.annotation.Log;
import com.xunmei.common.log.enums.BusinessType;
import com.xunmei.common.security.annotation.RequiresPermissions;
import com.xunmei.system.domain.SysPhysicalDefenseConstruction;
import com.xunmei.system.service.ISysPhysicalDefenseConstructionService;
import com.xunmei.common.core.web.controller.BaseController;
import com.xunmei.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.xunmei.common.core.web.page.TableDataInfo;

/**
 * 机构物防建设Controller
 *
 * @author xunmei
 * @date 2023-08-16
 */
@Api(tags = {"SysPhysicalDefenseConstruction"})
@RestController
@RequestMapping("/PhysicalDefenseConstruction")
public class SysPhysicalDefenseConstructionController extends BaseController {
    @Autowired
    private ISysPhysicalDefenseConstructionService sysPhysicalDefenseConstructionService;

    /**
     * 查询机构物防建设列表
     */
    @ApiOperation(value = "查询SysPhysicalDefenseConstruction列表")
    @RequiresPermissions("system:construction:list")
    @GetMapping("/list")
    public TableDataInfo<SysPhysicalDefenseConstruction> list(SysPhysicalDefenseConstruction sysPhysicalDefenseConstruction) {

        return sysPhysicalDefenseConstructionService.selectPage(sysPhysicalDefenseConstruction);
    }


    /**
     * 获取机构物防建设详细信息
     */
    @ApiOperation(value = "获取SysPhysicalDefenseConstruction详细信息")
    @RequiresPermissions("system:construction:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysPhysicalDefenseConstructionService.selectSysPhysicalDefenseConstructionById(id));
    }

    /**
     * 新增机构物防建设
     */
    @ApiOperation(value = "新增SysPhysicalDefenseConstruction")
    @RequiresPermissions("system:construction:add")
    @Log(title = "机构物防建设", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysPhysicalDefenseConstruction sysPhysicalDefenseConstruction) {
        return toAjax(sysPhysicalDefenseConstructionService.insertSysPhysicalDefenseConstruction(sysPhysicalDefenseConstruction));
    }

    /**
     * 修改机构物防建设
     */
    @ApiOperation(value = "修改SysPhysicalDefenseConstruction")
    @RequiresPermissions("system:construction:edit")
    @Log(title = "机构物防建设", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysPhysicalDefenseConstruction sysPhysicalDefenseConstruction) {
        return toAjax(sysPhysicalDefenseConstructionService.updateSysPhysicalDefenseConstruction(sysPhysicalDefenseConstruction));
    }

    /**
     * 删除机构物防建设
     */
    @ApiOperation(value = "删除SysPhysicalDefenseConstruction")
    @RequiresPermissions("system:construction:remove")
    @Log(title = "机构物防建设", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysPhysicalDefenseConstructionService.deleteSysPhysicalDefenseConstructionByIds(ids));
    }
}
