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.domain.R;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.ServletUtils;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.company.domain.CompanySmsPackage;
import com.fs.company.param.CompanySmsPackageBuyParam;
import com.fs.company.service.ICompanySmsPackageService;
import com.fs.core.security.LoginUser;
import com.fs.core.web.service.TokenService;
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/companySmsPackage")
public class CompanySmsPackageController extends BaseController
{
    @Autowired
    private ICompanySmsPackageService companySmsPackageService;
    @Autowired
    private TokenService tokenService;
    /**
     * 查询短信套餐包列表
     */
    @GetMapping("/getSmsPackage")
    public R getSmsPackage( )
    {
        CompanySmsPackage companySmsPackage=new CompanySmsPackage();
        companySmsPackage.setStatus(1l);
        List<CompanySmsPackage> list = companySmsPackageService.selectCompanySmsPackageList(companySmsPackage);
        return R.ok().put("data",list);
    }


    @PreAuthorize("@ss.hasPermi('company:companySmsPackage:buy')")
    @PostMapping("/buySmsPackage")
    public R buySmsPackage(@RequestBody CompanySmsPackageBuyParam param)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.setCompanyId(loginUser.getCompany().getCompanyId());
        return companySmsPackageService.buySmsPackage(param);

    }


}
