后台服务
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

120 linhas
5.4 KiB

  1. package com.iformall.controller;
  2. import com.github.pagehelper.PageInfo;
  3. import com.iformall.common.ErrorCode;
  4. import com.iformall.common.ResultData;
  5. import com.iformall.domain.po.base.BaseEntity;
  6. import com.iformall.domain.po.sm.MouldPatch;
  7. import com.iformall.domain.po.sm.PersonMould;
  8. import com.iformall.domain.po.sm.UserMouldVideo;
  9. import com.iformall.domain.po.sm.VoiceMould;
  10. import com.iformall.enums.*;
  11. import com.iformall.language.LanguageDetect;
  12. import com.iformall.service.sm.MouldPatchService;
  13. import com.iformall.service.sm.MouldPatchSignService;
  14. import com.iformall.service.sm.PersonMouldService;
  15. import com.iformall.service.sm.VoiceMouldService;
  16. import io.swagger.annotations.Api;
  17. import io.swagger.annotations.ApiImplicitParam;
  18. import io.swagger.annotations.ApiImplicitParams;
  19. import io.swagger.annotations.ApiOperation;
  20. import org.apache.commons.lang3.StringUtils;
  21. import org.slf4j.Logger;
  22. import org.slf4j.LoggerFactory;
  23. import org.springframework.beans.factory.annotation.Autowired;
  24. import org.springframework.web.bind.annotation.*;
  25. import java.util.List;
  26. @RestController
  27. @RequestMapping("/api/voiceMould")
  28. @Api(description = "模板接口")
  29. public class VoiceMouldController extends BaseController {
  30. private final Logger logger = LoggerFactory.getLogger(this.getClass());
  31. @Autowired
  32. private VoiceMouldService voiceMouldService;
  33. @Autowired
  34. private PersonMouldService personMouldService;
  35. @Autowired
  36. private MouldPatchSignService mouldPatchSignService;
  37. @ApiOperation("分页列表接口")
  38. @GetMapping("list")
  39. @ApiImplicitParams({
  40. @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
  41. @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
  42. public ResultData list(@ModelAttribute VoiceMould record, Integer pageNum, Integer pageSize) {
  43. logger.debug("[" + getIpAddr() + "] MouldPatchController::list");
  44. if (record == null) record = new VoiceMould();
  45. // record.setSendType(EnumMouldSendType.auto.getCode());
  46. record.setStatus(EnumaMouldPatchStatus.put_on.getCode());
  47. record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC);
  48. final PageInfo<VoiceMould> page = voiceMouldService.cListAsPage(record, pageNum, pageSize);
  49. return new ResultData(page);
  50. }
  51. @ApiOperation("根据id查询接口")
  52. @GetMapping("/findById")
  53. @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
  54. public ResultData findById(Long id) {
  55. logger.debug("[" + getIpAddr() + "] MouldPatchController::findById");
  56. VoiceMould voiceMould = voiceMouldService.getDetailById(id);
  57. if(voiceMould != null
  58. && voiceMould.getParentId() == 0l && voiceMould.getCountSub() > 0){
  59. VoiceMould voiceQ = new VoiceMould();
  60. voiceQ.setParentId(voiceMould.getId());
  61. voiceQ.setVoiceType(EnumVoiceType.speak.getCode());//目前只查询说话风格
  62. voiceQ.setStatus(EnumaMouldPatchStatus.put_on.getCode());
  63. voiceQ.setSortColumns(BaseEntity.SortField.UpdateDate_DESC);
  64. List<VoiceMould> sublist = voiceMouldService.getClist(voiceQ);
  65. if(sublist != null && !sublist.isEmpty()){
  66. voiceMould.setSubVoiceMould(sublist);
  67. }
  68. }
  69. return new ResultData(voiceMould);
  70. }
  71. @ApiOperation("根据输入文案获取音色")
  72. @PostMapping("voiceList")
  73. @ApiImplicitParams({
  74. @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
  75. @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
  76. public ResultData voiceList(@RequestBody UserMouldVideo record, Integer pageNum, Integer pageSize) {
  77. logger.debug("[" + getIpAddr() + "] MouldPatchController::voiceList");
  78. if (record == null || StringUtils.isBlank(record.getPaperwork())) {
  79. return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
  80. }
  81. Integer sex = null;
  82. if(record.getPersonMouldId() != null){
  83. PersonMould personMode = personMouldService.getDetailById(record.getPersonMouldId());
  84. if(personMode == null){
  85. return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"选择模板不存在");
  86. }
  87. sex = personMode.getSex();
  88. }
  89. String detect = LanguageDetect.detect(record.getPaperwork());
  90. if(StringUtils.isBlank(detect)){
  91. return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"语种识别失败");
  92. }
  93. EnumLanguages anEnum = EnumLanguages.getEnum(detect);
  94. if(anEnum == null){
  95. return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"暂不支持该语种");
  96. }
  97. VoiceMould voiceMould = new VoiceMould();
  98. voiceMould.setParentId(0l);
  99. voiceMould.setSex(sex);
  100. voiceMould.setSendType(EnumMouldSendType.auto.getCode());
  101. voiceMould.setStatus(EnumaMouldPatchStatus.put_on.getCode());
  102. voiceMould.setLanguages(anEnum.getCode().longValue());
  103. voiceMould.setSortColumns(BaseEntity.SortField.UpdateDate_DESC);
  104. final PageInfo<VoiceMould> page = voiceMouldService.cListAsPage(voiceMould, pageNum, pageSize);
  105. return new ResultData(page);
  106. }
  107. }