package com.goldenwater.slaj.hazard.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import com.goldenwater.slaj.hazard.domain.TDictMajorSource;
import com.goldenwater.slaj.hazard.service.ITDictMajorSourceService;

/**
 * 重大危险源字典
 */
@RestController
@RequestMapping("/hazard/tdictmajorsource")
public class TDictMajorSourceController extends BaseController {
    @Autowired
    private ITDictMajorSourceService tDictMajorSourceService;

    @GetMapping("/list")
    public TableDataInfo list(TDictMajorSource tDictMajorSource) {
        startPage();
        List<TDictMajorSource> list = tDictMajorSourceService.selectTDictMajorSourceList(tDictMajorSource);
        return getDataTable(list);
    }

    @GetMapping("/{guid}")
    public AjaxResult getInfo(@PathVariable String guid) {
        return AjaxResult.success(tDictMajorSourceService.selectTDictMajorSourceByGuid(guid));
    }

    @PostMapping
    public AjaxResult add(@RequestBody TDictMajorSource tDictMajorSource) {
        return toAjax(tDictMajorSourceService.insertTDictMajorSource(tDictMajorSource));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody TDictMajorSource tDictMajorSource) {
        return toAjax(tDictMajorSourceService.updateTDictMajorSource(tDictMajorSource));
    }

    @DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids) {
        return toAjax(tDictMajorSourceService.deleteTDictMajorSourceByGuids(guids));
    }
}
