|
@@ -0,0 +1,85 @@
|
|
|
|
+import { Injectable } from '@nestjs/common'
|
|
|
|
+
|
|
|
|
+import { IAgentListService } from '@/interface/agent-list.interface'
|
|
|
|
+import { ServiceResponse } from '@/response/response.interface'
|
|
|
|
+import { BusinessCode, HttpStatusCode } from '@/response/status-code.enum'
|
|
|
|
+
|
|
|
|
+import { AgentListHttpService } from './agent-list-http.service'
|
|
|
|
+
|
|
|
|
+@Injectable()
|
|
|
|
+export class AgentListService implements IAgentListService {
|
|
|
|
+ constructor(private readonly httpService: AgentListHttpService) {}
|
|
|
|
+
|
|
|
|
+ async getNativeAgentList(
|
|
|
|
+ params: Record<string, any>
|
|
|
|
+ ): Promise<ServiceResponse<AgentListType[]>> {
|
|
|
|
+ const { code, data, msg } =
|
|
|
|
+ await this.httpService.getNativeAgentList(params)
|
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.BAD_REQUEST,
|
|
|
|
+ msg: msg || '获取客服列表失败',
|
|
|
|
+ data: null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.SUCCESS,
|
|
|
|
+ msg: '获取客服列表成功',
|
|
|
|
+ data: data
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async getNativeAgentConfiguration(
|
|
|
|
+ agentId: string
|
|
|
|
+ ): Promise<ServiceResponse<AgentConfigurationType[]>> {
|
|
|
|
+ const { code, data, msg } =
|
|
|
|
+ await this.httpService.getNativeAgentConfiguration(agentId)
|
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.BAD_REQUEST,
|
|
|
|
+ msg: msg || '获取客服列表失败',
|
|
|
|
+ data: null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.SUCCESS,
|
|
|
|
+ msg: '获取客服列表成功',
|
|
|
|
+ data: data
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async saveNativeAgentConfiguration(
|
|
|
|
+ params: SaveAgentConfigurationType
|
|
|
|
+ ): Promise<ServiceResponse<SaveAgentConfigurationType>> {
|
|
|
|
+ const { code, data, msg } =
|
|
|
|
+ await this.httpService.saveNativeAgentConfiguration(params)
|
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.BAD_REQUEST,
|
|
|
|
+ msg: msg || '保存客服列表失败',
|
|
|
|
+ data: null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.SUCCESS,
|
|
|
|
+ msg: '保存客服列表成功',
|
|
|
|
+ data: data
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async getToolList(): Promise<ServiceResponse<any>> {
|
|
|
|
+ const { code, data, msg } = await this.httpService.getToolList()
|
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.BAD_REQUEST,
|
|
|
|
+ msg: msg || '获取工具列表失败',
|
|
|
|
+ data: null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.SUCCESS,
|
|
|
|
+ msg: '获取工具列表成功',
|
|
|
|
+ data: data
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|