package com.fs.company.controller;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.company.domain.CompanySmsOrder;
import com.fs.company.param.CompanySmsOrderListParam;
import com.fs.company.service.ICompanySmsOrderService;
import com.fs.company.vo.CompanySmsOrderListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 短信购买订单Controller
 *
 * @author fs
 * @date 2023-01-09
 */
@RestController
@RequestMapping("/company/companySmsOrder")
public class CompanySmsOrderController extends BaseController
{
    @Autowired
    private ICompanySmsOrderService companySmsOrderService;

    /**
     * 查询短信购买订单列表
     */
    @PreAuthorize("@ss.hasPermi('company:companySmsOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanySmsOrderListParam param)
    {
        startPage();
        List<CompanySmsOrderListVO> list = companySmsOrderService.selectCompanySmsOrderList(param);
        return getDataTable(list);
    }

    /**
     * 导出短信购买订单列表
     */
    @PreAuthorize("@ss.hasPermi('company:companySmsOrder:export')")
    @Log(title = "短信购买订单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanySmsOrderListParam param)
    {
        List<CompanySmsOrderListVO> list = companySmsOrderService.selectCompanySmsOrderList(param);
        ExcelUtil<CompanySmsOrderListVO> util = new ExcelUtil<CompanySmsOrderListVO>(CompanySmsOrderListVO.class);
        return util.exportExcel(list, "companySmsOrder");
    }

    /**
     * 获取短信购买订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('company:companySmsOrder:query')")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId)
    {
        return AjaxResult.success(companySmsOrderService.selectCompanySmsOrderById(orderId));
    }

    /**
     * 新增短信购买订单
     */
    @PreAuthorize("@ss.hasPermi('company:companySmsOrder:add')")
    @Log(title = "短信购买订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanySmsOrder companySmsOrder)
    {
        return toAjax(companySmsOrderService.insertCompanySmsOrder(companySmsOrder));
    }

    /**
     * 修改短信购买订单
     */
    @PreAuthorize("@ss.hasPermi('company:companySmsOrder:edit')")
    @Log(title = "短信购买订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanySmsOrder companySmsOrder)
    {
        return toAjax(companySmsOrderService.updateCompanySmsOrder(companySmsOrder));
    }

    /**
     * 删除短信购买订单
     */
    @PreAuthorize("@ss.hasPermi('company:companySmsOrder:remove')")
    @Log(title = "短信购买订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable Long[] orderIds)
    {
        return toAjax(companySmsOrderService.deleteCompanySmsOrderByIds(orderIds));
    }
}
