CompanyVoiceConfigController.java 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. package com.fs.company.controller;
  2. import java.util.List;
  3. import cn.hutool.json.JSONUtil;
  4. import com.fs.common.core.domain.R;
  5. import com.fs.company.config.CompanyVoiceCalleeConfig;
  6. import com.fs.company.config.CompanyVoiceCallerConfig;
  7. import com.fs.company.param.CompanyVoiceConfigParam;
  8. import com.fs.company.service.ICompanyService;
  9. import com.fs.company.vo.CompanyVoiceConfigListVO;
  10. import com.fs.company.vo.CompanyVoiceConfigVO;
  11. import org.springframework.security.access.prepost.PreAuthorize;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.web.bind.annotation.GetMapping;
  14. import org.springframework.web.bind.annotation.PostMapping;
  15. import org.springframework.web.bind.annotation.PutMapping;
  16. import org.springframework.web.bind.annotation.DeleteMapping;
  17. import org.springframework.web.bind.annotation.PathVariable;
  18. import org.springframework.web.bind.annotation.RequestBody;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RestController;
  21. import com.fs.common.annotation.Log;
  22. import com.fs.common.core.controller.BaseController;
  23. import com.fs.common.core.domain.AjaxResult;
  24. import com.fs.common.enums.BusinessType;
  25. import com.fs.company.domain.CompanyVoiceConfig;
  26. import com.fs.company.service.ICompanyVoiceConfigService;
  27. import com.fs.common.utils.poi.ExcelUtil;
  28. import com.fs.common.core.page.TableDataInfo;
  29. /**
  30. * 呼叫频率配置Controller
  31. *
  32. * @author fs
  33. * @date 2021-11-13
  34. */
  35. @RestController
  36. @RequestMapping("/company/companyVoiceConfig")
  37. public class CompanyVoiceConfigController extends BaseController
  38. {
  39. @Autowired
  40. private ICompanyVoiceConfigService companyVoiceConfigService;
  41. @Autowired
  42. private ICompanyService companyService;
  43. /**
  44. * 查询呼叫频率配置列表
  45. */
  46. @PreAuthorize("@ss.hasPermi('company:companyVoiceConfig:list')")
  47. @GetMapping("/list")
  48. public TableDataInfo list(CompanyVoiceConfig companyVoiceConfig)
  49. {
  50. startPage();
  51. List<CompanyVoiceConfigListVO> list = companyVoiceConfigService.selectCompanyVoiceConfigListVO(companyVoiceConfig);
  52. return getDataTable(list);
  53. }
  54. /**
  55. * 导出呼叫频率配置列表
  56. */
  57. @PreAuthorize("@ss.hasPermi('company:companyVoiceConfig:export')")
  58. @Log(title = "呼叫频率配置", businessType = BusinessType.EXPORT)
  59. @GetMapping("/export")
  60. public AjaxResult export(CompanyVoiceConfig companyVoiceConfig)
  61. {
  62. List<CompanyVoiceConfig> list = companyVoiceConfigService.selectCompanyVoiceConfigList(companyVoiceConfig);
  63. ExcelUtil<CompanyVoiceConfig> util = new ExcelUtil<CompanyVoiceConfig>(CompanyVoiceConfig.class);
  64. return util.exportExcel(list, "companyVoiceConfig");
  65. }
  66. /**
  67. * 获取呼叫频率配置详细信息
  68. */
  69. @PreAuthorize("@ss.hasPermi('company:companyVoiceConfig:query')")
  70. @GetMapping(value = "/{configId}")
  71. public AjaxResult getInfo(@PathVariable("configId") Long configId)
  72. {
  73. CompanyVoiceConfig config=companyVoiceConfigService.selectCompanyVoiceConfigById(configId);
  74. CompanyVoiceCalleeConfig voiceCalleeConfigBO=JSONUtil.toBean(config.getCalleeJson(), CompanyVoiceCalleeConfig.class);
  75. CompanyVoiceCallerConfig voiceCallerConfigBO=JSONUtil.toBean(config.getCallerJson(), CompanyVoiceCallerConfig.class);
  76. CompanyVoiceConfigVO vo=new CompanyVoiceConfigVO();
  77. vo.setCompanyId(config.getCompanyId());
  78. vo.setConfigId(config.getConfigId());
  79. vo.setCalleeDay(voiceCalleeConfigBO.getCalleeDay());
  80. vo.setCalleeHour(voiceCalleeConfigBO.getCalleeHour());
  81. vo.setCalleeWeek(voiceCalleeConfigBO.getCalleeWeek());
  82. vo.setCalleeMinute(voiceCalleeConfigBO.getCalleeMinute());
  83. vo.setCalleeMonth(voiceCalleeConfigBO.getCalleeMonth());
  84. vo.setCallerDay(voiceCallerConfigBO.getCallerDay());
  85. vo.setCallerHour(voiceCallerConfigBO.getCallerHour());
  86. vo.setCallerWeek(voiceCallerConfigBO.getCallerWeek());
  87. vo.setCallerMonth(voiceCallerConfigBO.getCallerMonth());
  88. vo.setCallerMinute(voiceCallerConfigBO.getCallerMinute());
  89. return AjaxResult.success(vo);
  90. }
  91. /**
  92. * 新增呼叫频率配置
  93. */
  94. @PreAuthorize("@ss.hasPermi('company:companyVoiceConfig:add')")
  95. @Log(title = "呼叫频率配置", businessType = BusinessType.INSERT)
  96. @PostMapping
  97. public R add(@RequestBody CompanyVoiceConfigParam companyVoiceConfig)
  98. {
  99. //查询企业是否存在
  100. CompanyVoiceConfig config=companyVoiceConfigService.selectCompanyVoiceConfigByCompanyId(companyVoiceConfig.getCompanyId());
  101. if(config!=null){
  102. return R.error("企业已存在");
  103. }
  104. CompanyVoiceCalleeConfig voiceCalleeConfigBO=new CompanyVoiceCalleeConfig();
  105. voiceCalleeConfigBO.setCalleeDay(companyVoiceConfig.getCalleeDay());
  106. voiceCalleeConfigBO.setCalleeHour(companyVoiceConfig.getCalleeHour());
  107. voiceCalleeConfigBO.setCalleeMinute(companyVoiceConfig.getCalleeMinute());
  108. voiceCalleeConfigBO.setCalleeMonth(companyVoiceConfig.getCalleeMonth());
  109. voiceCalleeConfigBO.setCalleeWeek(companyVoiceConfig.getCalleeWeek());
  110. CompanyVoiceCallerConfig voiceCallerConfigBO=new CompanyVoiceCallerConfig();
  111. voiceCallerConfigBO.setCallerDay(companyVoiceConfig.getCallerDay());
  112. voiceCallerConfigBO.setCallerHour(companyVoiceConfig.getCallerHour());
  113. voiceCallerConfigBO.setCallerMinute(companyVoiceConfig.getCallerMinute());
  114. voiceCallerConfigBO.setCallerWeek(companyVoiceConfig.getCallerWeek());
  115. voiceCallerConfigBO.setCallerMonth(companyVoiceConfig.getCallerMonth());
  116. config=new CompanyVoiceConfig();
  117. config.setCompanyId(companyVoiceConfig.getCompanyId());
  118. config.setCalleeJson(JSONUtil.toJsonStr(voiceCalleeConfigBO));
  119. config.setCallerJson(JSONUtil.toJsonStr(voiceCallerConfigBO));
  120. companyVoiceConfigService.insertCompanyVoiceConfig(config);
  121. return R.ok("操作成功");
  122. }
  123. /**
  124. * 修改呼叫频率配置
  125. */
  126. @PreAuthorize("@ss.hasPermi('company:companyVoiceConfig:edit')")
  127. @Log(title = "呼叫频率配置", businessType = BusinessType.UPDATE)
  128. @PutMapping
  129. public R edit(@RequestBody CompanyVoiceConfigParam companyVoiceConfig)
  130. {
  131. CompanyVoiceCalleeConfig voiceCalleeConfigBO=new CompanyVoiceCalleeConfig();
  132. voiceCalleeConfigBO.setCalleeDay(companyVoiceConfig.getCalleeDay());
  133. voiceCalleeConfigBO.setCalleeHour(companyVoiceConfig.getCalleeHour());
  134. voiceCalleeConfigBO.setCalleeMinute(companyVoiceConfig.getCalleeMinute());
  135. voiceCalleeConfigBO.setCalleeMonth(companyVoiceConfig.getCalleeMonth());
  136. voiceCalleeConfigBO.setCalleeWeek(companyVoiceConfig.getCalleeWeek());
  137. CompanyVoiceCallerConfig voiceCallerConfigBO=new CompanyVoiceCallerConfig();
  138. voiceCallerConfigBO.setCallerDay(companyVoiceConfig.getCallerDay());
  139. voiceCallerConfigBO.setCallerHour(companyVoiceConfig.getCallerHour());
  140. voiceCallerConfigBO.setCallerMinute(companyVoiceConfig.getCallerMinute());
  141. voiceCallerConfigBO.setCallerWeek(companyVoiceConfig.getCallerWeek());
  142. voiceCallerConfigBO.setCallerMonth(companyVoiceConfig.getCallerMonth());
  143. CompanyVoiceConfig config=new CompanyVoiceConfig();
  144. config.setConfigId(companyVoiceConfig.getConfigId());
  145. config.setCalleeJson(JSONUtil.toJsonStr(voiceCalleeConfigBO));
  146. config.setCallerJson(JSONUtil.toJsonStr(voiceCallerConfigBO));
  147. companyVoiceConfigService.updateCompanyVoiceConfig(config);
  148. return R.ok("修改成功");
  149. }
  150. /**
  151. * 删除呼叫频率配置
  152. */
  153. @PreAuthorize("@ss.hasPermi('company:companyVoiceConfig:remove')")
  154. @Log(title = "呼叫频率配置", businessType = BusinessType.DELETE)
  155. @DeleteMapping("/{configIds}")
  156. public AjaxResult remove(@PathVariable Long[] configIds)
  157. {
  158. return toAjax(companyVoiceConfigService.deleteCompanyVoiceConfigByIds(configIds));
  159. }
  160. }