package com.goldenwater.web.controller.slgc;

import com.goldenwater.slgc.entity.slgc.DocCate;
import com.goldenwater.slgc.service.slgc.IDocCateService;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.goldenwater.common.annotation.Log;
import com.goldenwater.common.enums.BusinessType;
import org.springframework.validation.annotation.Validated;

import java.util.List;

@RestController
@Validated
@RequestMapping("/slgc/docCate")
public class DocCateController extends BaseController {
    @Autowired
    private IDocCateService docCateService;

    /**
     * 查询文档分类列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DocCate docCate) {
        startPage();
        List<DocCate> list = docCateService.selectList(docCate);
        return getDataTable(list);
    }

    /**
     * 获取文档分类详细信息
     */
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable String id) {
        return success(docCateService.selectById(id));
    }

    /**
     * 新增文档分类
     */
    @Log(title = "文档分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DocCate docCate) {
        return toAjax(docCateService.insert(docCate));
    }

    /**
     * 修改文档分类
     */
    @Log(title = "文档分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DocCate docCate) {
        return toAjax(docCateService.update(docCate));
    }

    /**
     * 删除文档分类
     */
    @Log(title = "文档分类", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(docCateService.deleteByIds(ids));
    }
}
