SafetyController.java 2.97 KB
package com.ruoyi.service.controller;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.Inventory;
import com.ruoyi.service.domain.Safety;
import com.ruoyi.service.domain.SafetyDetail;
import com.ruoyi.service.domain.Tree;
import com.ruoyi.service.service.InventoryService;
import com.ruoyi.service.service.SafetyService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 安全检查
 * 
 * @author ym
 */
@RestController
@RequestMapping("/service/safety")
public class SafetyController extends BaseController
{

    @Resource
    private SafetyService safetyService;

    @GetMapping("/treeselect")
    public AjaxResult treeselect(SysDept dept)
    {
        List<Tree> tree=safetyService.treeSelect();
        return AjaxResult.success(tree);
    }

    @PreAuthorize("@ss.hasPermi('service:safety:add')")
    @Log(title = "安全检查", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody Safety safety)
    {
        return toAjax(safetyService.insert(safety));
    }


    @PreAuthorize("@ss.hasPermi('service:safety:edit')")
    @Log(title = "安全检查", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody Safety safety)
    {
        if (safetyService.update(safety) > 0)
        {
            return AjaxResult.success();
        }
        return AjaxResult.error("编辑失败,请联系管理员");
    }

    @PreAuthorize("@ss.hasPermi('service:safety:remove')")
    @Log(title = "安全检查", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        safetyService.delete(id);
        return success();
    }

    @PreAuthorize("@ss.hasPermi('service:safety:list')")
    @GetMapping("/list")
    public TableDataInfo list(Safety safety)
    {
        startPage();
        List<Safety> list = safetyService.selectList(safety);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('service:safetyDetail:add')")
    @Log(title = "安全检查详情", businessType = BusinessType.INSERT)
    @PostMapping("/addDetail")
    public AjaxResult addDetail(@Validated @RequestBody SafetyDetail safetyDetail)
    {
        return toAjax(safetyService.insertDetail(safetyDetail));
    }

    @PreAuthorize("@ss.hasPermi('service:safetyDetail:list')")
    @GetMapping("/detailList")
    public TableDataInfo detailList(SafetyDetail safetyDetail)
    {
        List<SafetyDetail> list = safetyService.selectDetailList(safetyDetail);
        return getDataTable(list);
    }
}