package com.zhongzheng.controller.inform;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
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.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.modules.inform.vo.InformClassifyVo;
import com.zhongzheng.modules.inform.bo.InformClassifyQueryBo;
import com.zhongzheng.modules.inform.bo.InformClassifyAddBo;
import com.zhongzheng.modules.inform.bo.InformClassifyEditBo;
import com.zhongzheng.modules.inform.service.IInformClassifyService;
import com.zhongzheng.common.utils.poi.ExcelUtil;
import com.zhongzheng.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2021-11-23
 */
@Api(value = "【通知分类】控制器", tags = {"【通知分类】管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/classify")
public class InformClassifyController extends BaseController {

    private final IInformClassifyService iInformClassifyService;

    /**
     * 查询【通知分类】列表
     */
    @ApiOperation("查询【通知分类】列表")
    @PreAuthorize("@ss.hasPermi('system:classify:list')")
    @GetMapping("/list")
    public TableDataInfo<InformClassifyVo> list(InformClassifyQueryBo bo) {
        startPage();
        List<InformClassifyVo> list = iInformClassifyService.queryList(bo);
        return getDataTable(list);
    }


    /**
     * 获取【通知分类】详细信息
     */
    @ApiOperation("获取【通知分类】详细信息")
    @PreAuthorize("@ss.hasPermi('system:classify:query')")
    @GetMapping("/{classifyId}")
    public AjaxResult<InformClassifyVo> getInfo(@PathVariable("classifyId" ) Long classifyId) {
        return AjaxResult.success(iInformClassifyService.queryById(classifyId));
    }

    /**
     * 新增【通知分类】
     */
    @ApiOperation("新增【通知分类】")
    @PreAuthorize("@ss.hasPermi('system:classify:add')")
    @Log(title = "【通知分类】", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody InformClassifyAddBo bo) {
        return toAjax(iInformClassifyService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改【通知分类】
     */
    @ApiOperation("修改【通知分类】")
    @PreAuthorize("@ss.hasPermi('system:classify:edit')")
    @Log(title = "【通知分类】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody InformClassifyEditBo bo) {
        return toAjax(iInformClassifyService.updateByEditBo(bo) ? 1 : 0);
    }

}
