package com.da.dangan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.da.common.annotation.Log;
import com.da.common.core.controller.BaseController;
import com.da.common.core.domain.AjaxResult;
import com.da.common.enums.BusinessType;
import com.da.dangan.domain.AreaSort;
import com.da.dangan.service.IAreaSortService;
import com.da.common.utils.poi.ExcelUtil;
import com.da.common.core.page.TableDataInfo;

/**
 * 档案行政分类Controller
 * 
 * @author hs
 * @date 2024-05-11
 */
@RestController
@RequestMapping("/dangan/areaSort")
public class AreaSortController extends BaseController
{
    @Autowired
    private IAreaSortService areaSortService;

    /**
     * 查询档案行政分类列表
     */
    @PreAuthorize("@ss.hasPermi('dangan:areaSort:list')")
    @GetMapping("/list")
    public TableDataInfo list(AreaSort areaSort)
    {
        startPage();
        List<AreaSort> list = areaSortService.selectAreaSortList(areaSort);
        return getDataTable(list);
    }

    /**
     * 导出档案行政分类列表
     */
    @PreAuthorize("@ss.hasPermi('dangan:areaSort:export')")
    @Log(title = "档案行政分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AreaSort areaSort)
    {
        List<AreaSort> list = areaSortService.selectAreaSortList(areaSort);
        ExcelUtil<AreaSort> util = new ExcelUtil<AreaSort>(AreaSort.class);
        util.exportExcel(response, list, "档案行政分类数据");
    }

    /**
     * 获取档案行政分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('dangan:areaSort:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(areaSortService.selectAreaSortById(id));
    }

    /**
     * 新增档案行政分类
     */
    @PreAuthorize("@ss.hasPermi('dangan:areaSort:add')")
    @Log(title = "档案行政分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AreaSort areaSort)
    {
        return toAjax(areaSortService.insertAreaSort(areaSort));
    }

    /**
     * 修改档案行政分类
     */
    @PreAuthorize("@ss.hasPermi('dangan:areaSort:edit')")
    @Log(title = "档案行政分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AreaSort areaSort)
    {
        return toAjax(areaSortService.updateAreaSort(areaSort));
    }

    /**
     * 删除档案行政分类
     */
    @PreAuthorize("@ss.hasPermi('dangan:areaSort:remove')")
    @Log(title = "档案行政分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(areaSortService.deleteAreaSortByIds(ids));
    }
}
