package com.goomood.phm.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.goomood.common.annotation.Log;
import com.goomood.common.core.controller.BaseController;
import com.goomood.common.core.domain.AjaxResult;
import com.goomood.common.enums.BusinessType;
import com.goomood.phm.domain.BasicArea;
import com.goomood.phm.service.IBasicAreaService;
import com.goomood.common.utils.poi.ExcelUtil;

/**
 * 战区管理Controller
 * 
 * @author goomood
 * @date 2024-11-16
 */
@RestController
@RequestMapping("/basic/basicArea")
public class BasicAreaController extends BaseController
{
    @Autowired
    private IBasicAreaService basicAreaService;

    /**
     * 查询战区管理列表
     */
    @PreAuthorize("@ss.hasPermi('basic:basicArea:list')")
    @GetMapping("/list")
    public AjaxResult list(BasicArea basicArea)
    {
        List<BasicArea> list = basicAreaService.selectBasicAreaList(basicArea);
        return success(list);
    }

    /**
     * 导出战区管理列表
     */
    @PreAuthorize("@ss.hasPermi('basic:basicArea:export')")
    @Log(title = "战区管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasicArea basicArea)
    {
        List<BasicArea> list = basicAreaService.selectBasicAreaList(basicArea);
        ExcelUtil<BasicArea> util = new ExcelUtil<BasicArea>(BasicArea.class);
        util.exportExcel(response, list, "战区管理数据");
    }

    /**
     * 获取战区管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:basicArea:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(basicAreaService.selectBasicAreaById(id));
    }

    /**
     * 新增战区管理
     */
    @PreAuthorize("@ss.hasPermi('basic:basicArea:add')")
    @Log(title = "战区管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicArea basicArea)
    {
        return toAjax(basicAreaService.insertBasicArea(basicArea));
    }

    /**
     * 修改战区管理
     */
    @PreAuthorize("@ss.hasPermi('basic:basicArea:edit')")
    @Log(title = "战区管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicArea basicArea)
    {
        return toAjax(basicAreaService.updateBasicArea(basicArea));
    }

    /**
     * 删除战区管理
     */
    @PreAuthorize("@ss.hasPermi('basic:basicArea:remove')")
    @Log(title = "战区管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(basicAreaService.deleteBasicAreaByIds(ids));
    }
}
