package com.fs.company.controller;

import java.util.List;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.company.domain.CompanySalesPlan;
import com.fs.company.service.ICompanySalesPlanService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 销售计划Controller
 * 
 * @author fs
 * @date 2025-07-01
 */
@RestController
@RequestMapping("/company/companySalesPlan")
public class CompanySalesPlanController extends BaseController
{
    @Autowired
    private ICompanySalesPlanService companySalesPlanService;

    /**
     * 查询销售计划列表
     */
    @PreAuthorize("@ss.hasPermi('company:companySalesPlan:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanySalesPlan companySalesPlan)
    {
        startPage();
        List<CompanySalesPlan> list = companySalesPlanService.selectCompanySalesPlanList(companySalesPlan);
        return getDataTable(list);
    }

    /**
     * 导出销售计划列表
     */
    @PreAuthorize("@ss.hasPermi('company:companySalesPlan:export')")
    @Log(title = "销售计划", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanySalesPlan companySalesPlan)
    {
        List<CompanySalesPlan> list = companySalesPlanService.selectCompanySalesPlanList(companySalesPlan);
        ExcelUtil<CompanySalesPlan> util = new ExcelUtil<CompanySalesPlan>(CompanySalesPlan.class);
        return util.exportExcel(list, "销售计划数据");
    }

    /**
     * 获取销售计划详细信息
     */
    @PreAuthorize("@ss.hasPermi('company:companySalesPlan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(companySalesPlanService.selectCompanySalesPlanById(id));
    }

    /**
     * 新增销售计划
     */
    @PreAuthorize("@ss.hasPermi('company:companySalesPlan:add')")
    @Log(title = "销售计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanySalesPlan companySalesPlan)
    {
        return toAjax(companySalesPlanService.insertCompanySalesPlan(companySalesPlan));
    }

    /**
     * 修改销售计划
     */
    @PreAuthorize("@ss.hasPermi('company:companySalesPlan:edit')")
    @Log(title = "销售计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanySalesPlan companySalesPlan)
    {
        return toAjax(companySalesPlanService.updateCompanySalesPlan(companySalesPlan));
    }

    /**
     * 删除销售计划
     */
    @PreAuthorize("@ss.hasPermi('company:companySalesPlan:remove')")
    @Log(title = "销售计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(companySalesPlanService.deleteCompanySalesPlanByIds(ids));
    }
}
