package com.leromro.core.controller;

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

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.leromro.common.core.domain.R;
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.leromro.common.annotation.Log;
import com.leromro.common.core.controller.BaseController;
import com.leromro.common.core.domain.AjaxResult;
import com.leromro.common.enums.BusinessType;
import com.leromro.core.domain.DeptRegionManagement;
import com.leromro.core.service.IDeptRegionManagementService;
import com.leromro.common.utils.poi.ExcelUtil;
import com.leromro.common.core.page.TableDataInfo;

/**
 * 公司管理地区Controller
 * 
 * @author ruoyi
 * @date 2025-05-14
 */
@RestController
@Api(tags = "公司管理地区，停用")
@RequestMapping("/core/dept/region-management")
public class DeptRegionManagementController extends BaseController
{
    @Autowired
    private IDeptRegionManagementService deptRegionManagementService;

    /**
     * 查询公司管理地区列表
     */
    @ApiOperation("查询公司管理地区列表")
    @PreAuthorize("@ss.hasPermi('core:dept:region-management:list')")
    @GetMapping("/list")
    public TableDataInfo<DeptRegionManagement> list(DeptRegionManagement deptRegionManagement)
    {
        startPage();
        List<DeptRegionManagement> list = deptRegionManagementService.selectDeptRegionManagementList(deptRegionManagement);
        return getDataTable(list);
    }



    /**
     * 获取公司管理地区详细信息
     */
    @ApiOperation("获取公司管理地区详细信息")
    @PreAuthorize("@ss.hasPermi('core:dept:region-management:query')")
    @GetMapping(value = "/{regionManagementId}")
    public R<DeptRegionManagement> getInfo(@PathVariable("regionManagementId") Long regionManagementId)
    {
        return R.ok(deptRegionManagementService.selectDeptRegionManagementByRegionManagementId(regionManagementId));
    }

    /**
     * 新增公司管理地区
     */
    @ApiOperation("新增公司管理地区")
    @PreAuthorize("@ss.hasPermi('core:dept:region-management:add')")
    @Log(title = "公司管理地区", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeptRegionManagement deptRegionManagement)
    {
        return toAjax(deptRegionManagementService.insertDeptRegionManagement(deptRegionManagement));
    }

    /**
     * 修改公司管理地区
     */
    @ApiOperation("修改公司管理地区")
    @PreAuthorize("@ss.hasPermi('core:dept:region-management:edit')")
    @Log(title = "公司管理地区", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeptRegionManagement deptRegionManagement)
    {
        return toAjax(deptRegionManagementService.updateDeptRegionManagement(deptRegionManagement));
    }

    /**
     * 删除公司管理地区
     */
    @ApiOperation("删除公司管理地区")
    @PreAuthorize("@ss.hasPermi('core:dept:region-management:remove')")
    @Log(title = "公司管理地区", businessType = BusinessType.DELETE)
	@DeleteMapping("/{regionManagementIds}")
    public R<Integer> remove(@PathVariable Long[] regionManagementIds)
    {
        return R.ok(deptRegionManagementService.deleteDeptRegionManagementByRegionManagementIds(regionManagementIds));
    }

    /**
     * 导出公司管理地区列表
     */
    @ApiOperation("导出公司管理地区列表")
    @PreAuthorize("@ss.hasPermi('core:dept:region-management:export')")
    @Log(title = "公司管理地区", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeptRegionManagement deptRegionManagement)
    {
        List<DeptRegionManagement> list = deptRegionManagementService.selectDeptRegionManagementList(deptRegionManagement);
        ExcelUtil<DeptRegionManagement> util = new ExcelUtil<DeptRegionManagement>(DeptRegionManagement.class);
        util.exportExcel(response, list, "公司管理地区数据");
    }
}
