package com.ruoyi.hezhi.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.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.hezhi.domain.TbEvaluateAgencyClass;
import com.ruoyi.hezhi.service.ITbEvaluateAgencyClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 评价机构分类Controller
 *
 * @author ruoyi
 * @date 2024-10-23
 */
@RestController
@RequestMapping("/hezhi/evaluateAgencyClass")
public class TbEvaluateAgencyClassController extends BaseController
{
    @Autowired
    private ITbEvaluateAgencyClassService tbEvaluateAgencyClassService;

    /**
     * 查询评价机构分类列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:evaluateAgencyClass:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbEvaluateAgencyClass tbEvaluateAgencyClass)
    {
        startPage();
        List<TbEvaluateAgencyClass> list = tbEvaluateAgencyClassService.selectTbEvaluateAgencyClassList(tbEvaluateAgencyClass);
        return getDataTable(list);
    }

    /**
     * 导出评价机构分类列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:evaluateAgencyClass:export')")
    @Log(title = "评价机构分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbEvaluateAgencyClass tbEvaluateAgencyClass)
    {
        List<TbEvaluateAgencyClass> list = tbEvaluateAgencyClassService.selectTbEvaluateAgencyClassList(tbEvaluateAgencyClass);
        ExcelUtil<TbEvaluateAgencyClass> util = new ExcelUtil<TbEvaluateAgencyClass>(TbEvaluateAgencyClass.class);
        util.exportExcel(response, list, "评价机构分类数据");
    }

    /**
     * 获取评价机构分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:evaluateAgencyClass:query')")
    @GetMapping(value = "/{evaluateAgencyClassId}")
    public AjaxResult getInfo(@PathVariable("evaluateAgencyClassId") Long evaluateAgencyClassId)
    {
        return success(tbEvaluateAgencyClassService.selectTbEvaluateAgencyClassByEvaluateAgencyClassId(evaluateAgencyClassId));
    }

    /**
     * 新增评价机构分类
     */
    @PreAuthorize("@ss.hasPermi('hezhi:evaluateAgencyClass:add')")
    @Log(title = "评价机构分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbEvaluateAgencyClass tbEvaluateAgencyClass)
    {
        return toAjax(tbEvaluateAgencyClassService.insertTbEvaluateAgencyClass(tbEvaluateAgencyClass));
    }

    /**
     * 修改评价机构分类
     */
    @PreAuthorize("@ss.hasPermi('hezhi:evaluateAgencyClass:edit')")
    @Log(title = "评价机构分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbEvaluateAgencyClass tbEvaluateAgencyClass)
    {
        return toAjax(tbEvaluateAgencyClassService.updateTbEvaluateAgencyClass(tbEvaluateAgencyClass));
    }

    /**
     * 删除评价机构分类
     */
    @PreAuthorize("@ss.hasPermi('hezhi:evaluateAgencyClass:remove')")
    @Log(title = "评价机构分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{evaluateAgencyClassIds}")
    public AjaxResult remove(@PathVariable Long[] evaluateAgencyClassIds)
    {
        return toAjax(tbEvaluateAgencyClassService.deleteTbEvaluateAgencyClassByEvaluateAgencyClassIds(evaluateAgencyClassIds));
    }

    /**
     * 所有评价机构分类列表
     * @return
     */
    @GetMapping("/getAllEvaluateAgencyClassList")
    public AjaxResult getAllEvaluateAgencyClassList() {
        TbEvaluateAgencyClass evaluateAgencyClass = new TbEvaluateAgencyClass();
        evaluateAgencyClass.setDelFlag(0);
        return AjaxResult.success(tbEvaluateAgencyClassService.selectTbEvaluateAgencyClassList(evaluateAgencyClass));
    }
}
