123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- 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
- }
- }
- async deleteNativeAgentConfiguration(
- agentId: number
- ): Promise<ServiceResponse<any>> {
- const { code, data, msg } =
- await this.httpService.deleteNativeAgentConfiguration(agentId)
- if (code !== HttpStatusCode.OK) {
- return {
- code: BusinessCode.BAD_REQUEST,
- msg: msg || '删除客服列表失败',
- data: null
- }
- }
- return {
- code: BusinessCode.SUCCESS,
- msg: '删除客服列表成功',
- data: data
- }
- }
- }
|