123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- package com.fs.company.controller;
- import java.util.List;
- import com.alibaba.fastjson.JSON;
- import com.fs.common.annotation.RepeatSubmit;
- import com.fs.company.domain.CompanySmsOrder;
- import com.fs.company.dto.CompBuySmsDTO;
- import com.fs.company.vo.CompanySmsListVO;
- import org.apache.commons.lang.exception.ExceptionUtils;
- import org.apache.http.util.Asserts;
- 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.CompanySms;
- import com.fs.company.service.ICompanySmsService;
- import com.fs.common.utils.poi.ExcelUtil;
- import com.fs.common.core.page.TableDataInfo;
- /**
- * 公司短信Controller
- *
- * @author fs
- * @date 2023-01-09
- */
- @RestController
- @RequestMapping("/company/companySms")
- public class CompanySmsController extends BaseController
- {
- @Autowired
- private ICompanySmsService companySmsService;
- /**
- * 查询公司短信列表
- */
- @PreAuthorize("@ss.hasPermi('company:companySms:list')")
- @PostMapping("/buySms")
- @RepeatSubmit
- public AjaxResult buySms(CompBuySmsDTO compBuySmsDTO){
- logger.info("开始执行购买短信接口,请求参数:{}", compBuySmsDTO);
- Asserts.notNull(compBuySmsDTO,"充值短信参数不能为空");
- Asserts.notNull(compBuySmsDTO.getCompanyId(),"公司id不能为空!");
- Asserts.notNull(compBuySmsDTO.getPackageId(),"短信套餐id不能为空!");
- CompanySmsOrder companySmsOrder=null;
- try{
- companySmsOrder = companySmsService.buySms(compBuySmsDTO);
- }catch (Exception e){
- logger.error("购买短信接口异常,异常信息:{}", ExceptionUtils.getFullStackTrace(e));
- throw e;
- }
- return AjaxResult.success(companySmsOrder);
- }
- /**
- * 查询公司短信列表
- */
- @PreAuthorize("@ss.hasPermi('company:companySms:list')")
- @GetMapping("/list")
- public TableDataInfo list(CompanySms companySms)
- {
- startPage();
- List<CompanySmsListVO> list = companySmsService.selectCompanySmsList(companySms);
- return getDataTable(list);
- }
- /**
- * 导出公司短信列表
- */
- @PreAuthorize("@ss.hasPermi('company:companySms:export')")
- @Log(title = "公司短信", businessType = BusinessType.EXPORT)
- @GetMapping("/export")
- public AjaxResult export(CompanySms companySms)
- {
- List<CompanySmsListVO> list = companySmsService.selectCompanySmsList(companySms);
- ExcelUtil<CompanySmsListVO> util = new ExcelUtil<CompanySmsListVO>(CompanySmsListVO.class);
- return util.exportExcel(list, "companySms");
- }
- /**
- * 获取公司短信详细信息
- */
- @PreAuthorize("@ss.hasPermi('company:companySms:query')")
- @GetMapping(value = "/{smsId}")
- public AjaxResult getInfo(@PathVariable("smsId") Long smsId)
- {
- return AjaxResult.success(companySmsService.selectCompanySmsById(smsId));
- }
- /**
- * 新增公司短信
- */
- @PreAuthorize("@ss.hasPermi('company:companySms:add')")
- @Log(title = "公司短信", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody CompanySms companySms)
- {
- return toAjax(companySmsService.insertCompanySms(companySms));
- }
- /**
- * 修改公司短信
- */
- @PreAuthorize("@ss.hasPermi('company:companySms:edit')")
- @Log(title = "公司短信", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody CompanySms companySms)
- {
- return toAjax(companySmsService.updateCompanySms(companySms));
- }
- /**
- * 删除公司短信
- */
- @PreAuthorize("@ss.hasPermi('company:companySms:remove')")
- @Log(title = "公司短信", businessType = BusinessType.DELETE)
- @DeleteMapping("/{smsIds}")
- public AjaxResult remove(@PathVariable Long[] smsIds)
- {
- return toAjax(companySmsService.deleteCompanySmsByIds(smsIds));
- }
- }
|