package com.yunfeiyun.agmp.common.web.system.controller;

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

import com.yunfeiyun.agmp.common.web.system.domain.SysCusarea;
import com.yunfeiyun.agmp.common.web.system.service.ISysCusareaService;
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.yunfeiyun.agmp.common.annotation.Log;
import com.yunfeiyun.agmp.common.core.controller.BaseController;
import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
import com.yunfeiyun.agmp.common.enums.BusinessType;
import com.yunfeiyun.agmp.common.core.page.TableDataInfo;

/**
 * 区域Controller
 * 
 * @author 杨晓辉
 * @date 2023-08-21
 */
@RestController
@RequestMapping("/system/SysCusarea")
public class SysCusareaController extends BaseController
{
    @Autowired
    private ISysCusareaService sysCusareaService;

    /**
     * 查询区域列表
     */
    @PreAuthorize("@ss.hasPermi('system:SysCusarea:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysCusarea sysCusarea)
    {
        startPage();
        List<SysCusarea> list = sysCusareaService.selectSysCusareaList(sysCusarea);
        return getDataTable(list);
    }



    /**
     * 获取区域详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:SysCusarea:query')")
    @GetMapping(value = "/info/{cusareaId}")
    public AjaxResult getInfo(@PathVariable("cusareaId") String cusareaId)
    {
        return success(sysCusareaService.selectSysCusareaByCusareaId(cusareaId));
    }

    /**
     * 新增区域
     */
    @PreAuthorize("@ss.hasPermi('system:SysCusarea:add')")
    @Log(title = "区域", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SysCusarea sysCusarea)
    {
        return toAjax(sysCusareaService.insertSysCusarea(sysCusarea));
    }

    /**
     * 修改区域
     */
    @PreAuthorize("@ss.hasPermi('system:SysCusarea:edit')")
    @Log(title = "区域", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody SysCusarea sysCusarea)
    {
        return toAjax(sysCusareaService.updateSysCusarea(sysCusarea));
    }

    /**
     * 删除区域
     */
    @PreAuthorize("@ss.hasPermi('system:SysCusarea:remove')")
    @Log(title = "区域", businessType = BusinessType.DELETE)
	@DeleteMapping("/delete/{cusareaIds}")
    public AjaxResult remove(@PathVariable String[] cusareaIds)
    {
        return toAjax(sysCusareaService.deleteSysCusareaByCusareaIds(cusareaIds));
    }
}
