12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- import { Injectable } from '@nestjs/common'
- import { IAgentModuleService } from '@/interface/agent-module.interface'
- import { ServiceResponse } from '@/response/response.interface'
- import { BusinessCode, HttpStatusCode } from '@/response/status-code.enum'
- import { AgentModuleHttpService } from './agent-module-http.service'
- @Injectable()
- export class AgentModuleService implements IAgentModuleService {
- constructor(private readonly httpService: AgentModuleHttpService) {}
- async getModuleList(
- page: number,
- pageSize: number
- ): Promise<ServiceResponse<ModuleConfigurationType[]>> {
- const { code, data, msg } = await this.httpService.getModuleList(
- page,
- pageSize
- )
- if (code !== HttpStatusCode.OK) {
- return {
- code: BusinessCode.BAD_REQUEST,
- msg: msg || '获取模块列表失败',
- data: null
- }
- }
- return {
- code: BusinessCode.SUCCESS,
- data,
- msg: msg || '获取模块列表成功'
- }
- }
- async getModuleConfiguration(
- module_id: number
- ): Promise<ServiceResponse<ModuleConfigurationType>> {
- const { code, data, msg } =
- await this.httpService.getModuleConfiguration(module_id)
- if (code !== HttpStatusCode.OK) {
- return {
- code: BusinessCode.BAD_REQUEST,
- msg: msg || '获取模块配置失败',
- data: null
- }
- }
- return {
- code: BusinessCode.SUCCESS,
- data,
- msg: msg || '获取模块配置成功'
- }
- }
- async saveModuleConfiguration(
- module_id: number,
- name: string,
- display_name: string,
- default_agent_type: number,
- default_agent_id: number
- ): Promise<ServiceResponse<any>> {
- const { code, data, msg } = await this.httpService.saveModuleConfiguration(
- module_id,
- name,
- display_name,
- default_agent_type,
- default_agent_id
- )
- if (code !== HttpStatusCode.OK) {
- return {
- code: BusinessCode.BAD_REQUEST,
- msg: msg || '保存模块配置失败',
- data: null
- }
- }
- return {
- code: BusinessCode.SUCCESS,
- data,
- msg: msg || '保存模块配置成功'
- }
- }
- async getModuleAgentTypes(): Promise<ServiceResponse<any>> {
- const { code, data, msg } = await this.httpService.getModuleAgentTypes()
- if (code !== HttpStatusCode.OK) {
- return {
- code: BusinessCode.BAD_REQUEST,
- msg: msg || '获取模块代理类型失败',
- data: null
- }
- }
- return {
- code: BusinessCode.SUCCESS,
- data,
- msg: msg || '获取模块代理类型成功'
- }
- }
- }
|