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.TDictMajorCommon;
import com.goldenwater.slaj.hazard.service.ITDictMajorCommonService;

/**
 * 重大通用字典
 */
@RestController
@RequestMapping("/hazard/tdictmajorcommon")
public class TDictMajorCommonController extends BaseController {
    @Autowired
    private ITDictMajorCommonService tDictMajorCommonService;

    @GetMapping("/list")
    public TableDataInfo list(TDictMajorCommon tDictMajorCommon) {
        startPage();
        List<TDictMajorCommon> list = tDictMajorCommonService.selectTDictMajorCommonList(tDictMajorCommon);
        return getDataTable(list);
    }

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

    @PostMapping
    public AjaxResult add(@RequestBody TDictMajorCommon tDictMajorCommon) {
        return toAjax(tDictMajorCommonService.insertTDictMajorCommon(tDictMajorCommon));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody TDictMajorCommon tDictMajorCommon) {
        return toAjax(tDictMajorCommonService.updateTDictMajorCommon(tDictMajorCommon));
    }

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