| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- import fs from 'fs'
- import path from 'path'
- import { fileURLToPath } from 'url'
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
- const p = path.resolve(__dirname, '../../fs-saas-admin/src/main/java/com/fs/company/controller/CompanyEasyCallController.java')
- const content = `package com.fs.company.controller;
- import com.fs.aicall.domain.CcLlmAgentAccount;
- import com.fs.aicall.domain.CcTtsAliyun;
- import com.fs.aicall.service.ICcLlmAgentAccountService;
- import com.fs.aicall.service.ICompanyBindAiModelService;
- import com.fs.common.core.controller.BaseController;
- import com.fs.common.core.domain.R;
- import com.fs.company.mapper.CompanyVoiceCloneRefMapper;
- import com.fs.company.service.easycall.IEasyCallService;
- import com.fs.company.support.AdminCompanyScopeHelper;
- import com.fs.company.vo.easycall.EasyCallBusiGroupVO;
- import com.fs.company.vo.easycall.EasyCallGatewayVO;
- import com.fs.company.vo.easycall.EasyCallVoiceCodeVO;
- import com.fs.company.vo.easycall.ExtensionVO;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.stream.Collectors;
- /**
- * EasyCall \u5916\u547c\u57fa\u7840\u6570\u636e\uff08\u603b\u540e\u53f0\u6865\u63a5\uff09
- * \u9500\u552e\u7aef\u4ece\u767b\u5f55\u6001\u53d6 companyId\uff1b\u603b\u540e\u53f0\u901a\u8fc7 companyId \u53c2\u6570\u6307\u5b9a\u516c\u53f8\u3002
- */
- @Api(tags = "EasyCallCenter365\u5916\u547c\u7ba1\u7406(\u603b\u540e\u53f0)")
- @RestController
- @RequestMapping("/company/easyCall")
- public class CompanyEasyCallController extends BaseController {
- @Autowired
- private IEasyCallService easyCallService;
- @Autowired
- private ICompanyBindAiModelService companyBindAiModelService;
- @Autowired
- private ICcLlmAgentAccountService ccLlmAgentAccountService;
- @Autowired
- private CompanyVoiceCloneRefMapper companyVoiceCloneRefMapper;
- @ApiOperation("\u83b7\u53d6\u7f51\u5173\u5217\u8868")
- @GetMapping("/gateway/list")
- public R getGatewayList(@RequestParam Long companyId) {
- Long cid = AdminCompanyScopeHelper.requireCompanyId(companyId, "\u8bf7\u9009\u62e9\u9500\u552e\u516c\u53f8");
- List<EasyCallGatewayVO> list = easyCallService.getGatewayList(cid);
- return R.ok().put("data", list);
- }
- @ApiOperation("\u83b7\u53d6\u5927\u6a21\u578b\u914d\u7f6e\u5217\u8868")
- @GetMapping("/llmAccount/list")
- public R getLlmAccountList(@RequestParam Long companyId) {
- Long cid = AdminCompanyScopeHelper.requireCompanyId(companyId, "\u8bf7\u9009\u62e9\u9500\u552e\u516c\u53f8");
- List<Long> modelIds = companyBindAiModelService.selectVisibleModelIdsForCompany(cid);
- if (modelIds.isEmpty()) {
- return R.ok().put("data", new ArrayList<>());
- }
- CcLlmAgentAccount ccLlmAgentAccount = new CcLlmAgentAccount();
- ccLlmAgentAccount.setModelIds(modelIds);
- List<CcLlmAgentAccount> list = ccLlmAgentAccountService.selectCcLlmAgentAccountList(ccLlmAgentAccount);
- return R.ok().put("data", list);
- }
- @ApiOperation("\u83b7\u53d6\u97f3\u8272\u5217\u8868")
- @GetMapping("/voiceCode/list")
- public R getVoiceCodeList(@RequestParam Long companyId) {
- Long cid = AdminCompanyScopeHelper.requireCompanyId(companyId, "\u8bf7\u9009\u62e9\u9500\u552e\u516c\u53f8");
- List<Long> ttsIds = companyVoiceCloneRefMapper.selectActiveTtsIds(cid, null);
- List<CcTtsAliyun> ccTtsAliyuns = companyVoiceCloneRefMapper.selectCcTtsAliyunList();
- List<EasyCallVoiceCodeVO> result = ccTtsAliyuns.stream()
- .filter(item -> item.getPriority() == 1
- || (item.getPriority() == 0 && ttsIds.contains(item.getId())))
- .map(item -> {
- EasyCallVoiceCodeVO vo = new EasyCallVoiceCodeVO();
- vo.setVoiceCode(item.getVoiceCode());
- vo.setVoiceName(item.getVoiceName());
- vo.setVoiceSource(item.getVoiceSource());
- vo.setTtsModels(item.getTtsModels());
- return vo;
- })
- .collect(Collectors.toList());
- return R.ok().put("data", result);
- }
- @ApiOperation("\u83b7\u53d6\u6280\u80fd\u7ec4\u5217\u8868")
- @GetMapping("/busiGroup/list")
- public R getBusiGroupList(@RequestParam Long companyId) {
- Long cid = AdminCompanyScopeHelper.requireCompanyId(companyId, "\u8bf7\u9009\u62e9\u9500\u552e\u516c\u53f8");
- List<EasyCallBusiGroupVO> list = easyCallService.getBusiGroupList(cid);
- return R.ok().put("data", list);
- }
- @ApiOperation("\u83b7\u53d6\u5206\u673a\u53f7\u7801list")
- @GetMapping("/getExtensionList")
- public R getExtensionList(@RequestParam Long companyId) {
- Long cid = AdminCompanyScopeHelper.requireCompanyId(companyId, "\u8bf7\u9009\u62e9\u9500\u552e\u516c\u53f8");
- List<ExtensionVO> extensionList = easyCallService.getExtensionList(cid);
- return R.ok().put("data", extensionList);
- }
- }
- `
- fs.writeFileSync(p, content, 'utf8')
- const t = fs.readFileSync(p, 'utf8')
- console.log('written', p)
- console.log('FFFD', t.includes('\uFFFD'))
- console.log('sample', t.includes('\u8bf7\u9009\u62e9\u9500\u552e\u516c\u53f8'))
|