package com.ruoyi.web.controller.back;

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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.voluntary.domain.BusiAgentsLocation;
import com.ruoyi.voluntary.service.IBusiAgentsLocationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 代理商区域Controller
 * 
 * @author voluntary
 * @date 2022-11-20
 */
@RestController
@RequestMapping("/voluntary/busiAgentsLocation")
public class BackBusiAgentsLocationController extends BaseController
{
    @Autowired
    private IBusiAgentsLocationService busiAgentsLocationService;

    /**
     * 查询代理商区域列表
     */
    @PreAuthorize("@ss.hasPermi('voluntary:busiAgentsLocation:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusiAgentsLocation busiAgentsLocation)
    {
        startPage();
        List<BusiAgentsLocation> list = busiAgentsLocationService.selectBusiAgentsLocationList(busiAgentsLocation);
        return getDataTable(list);
    }

    /**
     * 导出代理商区域列表
     */
    @PreAuthorize("@ss.hasPermi('voluntary:busiAgentsLocation:export')")
    @Log(title = "代理商区域", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusiAgentsLocation busiAgentsLocation)
    {
        List<BusiAgentsLocation> list = busiAgentsLocationService.selectBusiAgentsLocationList(busiAgentsLocation);
        ExcelUtil<BusiAgentsLocation> util = new ExcelUtil<BusiAgentsLocation>(BusiAgentsLocation.class);
        util.exportExcel(response, list, "代理商区域数据");
    }

    /**
     * 获取代理商区域详细信息
     */
    @PreAuthorize("@ss.hasPermi('voluntary:busiAgentsLocation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(busiAgentsLocationService.selectBusiAgentsLocationById(id));
    }

    /**
     * 新增代理商区域
     */
    @PreAuthorize("@ss.hasPermi('voluntary:busiAgentsLocation:add')")
    @Log(title = "代理商区域", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusiAgentsLocation busiAgentsLocation)
    {
        return toAjax(busiAgentsLocationService.insertBusiAgentsLocation(busiAgentsLocation));
    }

    /**
     * 修改代理商区域
     */
    @PreAuthorize("@ss.hasPermi('voluntary:busiAgentsLocation:edit')")
    @Log(title = "代理商区域", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusiAgentsLocation busiAgentsLocation)
    {
        return toAjax(busiAgentsLocationService.updateBusiAgentsLocation(busiAgentsLocation));
    }

    /**
     * 删除代理商区域
     */
    @PreAuthorize("@ss.hasPermi('voluntary:busiAgentsLocation:remove')")
    @Log(title = "代理商区域", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(busiAgentsLocationService.deleteBusiAgentsLocationByIds(ids));
    }
}
