refactor(server): 移动call指令到sdk中

pull/49/head
moonrailgun 3 years ago
parent 9f7f31fac0
commit 56ac064506

@ -82,7 +82,7 @@
// 输入框 // 输入框
.ant-input { .ant-input {
color: rgba(255, 255, 255, 0.65); color: rgba(255, 255, 255, 0.85);
background-color: transparent; background-color: transparent;
border-color: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.12);

@ -0,0 +1,4 @@
/**
* id
*/
export const SYSTEM_USERID = '000000000000000000000000';

@ -12,6 +12,7 @@ export type {
} from './services/types'; } from './services/types';
export { parseLanguageFromHead } from './services/lib/i18n/parser'; export { parseLanguageFromHead } from './services/lib/i18n/parser';
export { t } from './services/lib/i18n'; export { t } from './services/lib/i18n';
export { call } from './services/lib/call';
export { export {
config, config,
buildUploadUrl, buildUploadUrl,
@ -32,6 +33,8 @@ export type { UserStruct } from './structs/user';
// db // db
export * as db from './db'; export * as db from './db';
export * from './const';
// other // other
export { Utils, Errors } from 'moleculer'; export { Utils, Errors } from 'moleculer';

@ -1,7 +1,4 @@
import type { TcContext } from 'tailchat-server-sdk'; import { GroupStruct, UserStruct, SYSTEM_USERID, TcContext } from '../../index';
import type { Group } from '../models/group/group';
import type { User } from '../models/user/user';
import { SYSTEM_USERID } from './const';
export function call(ctx: TcContext) { export function call(ctx: TcContext) {
return { return {
@ -61,7 +58,7 @@ export function call(ctx: TcContext) {
/** /**
* *
*/ */
async getUserInfo(userId: string): Promise<User> { async getUserInfo(userId: string): Promise<UserStruct> {
return await ctx.call('user.getUserInfo', { return await ctx.call('user.getUserInfo', {
userId, userId,
}); });
@ -69,7 +66,7 @@ export function call(ctx: TcContext) {
/** /**
* *
*/ */
async getGroupInfo(groupId: string): Promise<Group> { async getGroupInfo(groupId: string): Promise<GroupStruct> {
return await ctx.call('group.getGroupInfo', { return await ctx.call('group.getGroupInfo', {
groupId, groupId,
}); });

@ -6,12 +6,12 @@ import {
TcService, TcService,
TcContext, TcContext,
UserStruct, UserStruct,
call,
} from 'tailchat-server-sdk'; } from 'tailchat-server-sdk';
import type { import type {
ConverseDocument, ConverseDocument,
ConverseModel, ConverseModel,
} from '../../../models/chat/converse'; } from '../../../models/chat/converse';
import { call } from '../../../lib/call';
interface ConverseService interface ConverseService
extends TcService, extends TcService,

@ -19,8 +19,8 @@ import {
TcContext, TcContext,
TcDbService, TcDbService,
PureContext, PureContext,
call,
} from 'tailchat-server-sdk'; } from 'tailchat-server-sdk';
import { call } from '../../../lib/call';
import moment from 'moment'; import moment from 'moment';
import { PERMISSION } from '../../../lib/role'; import { PERMISSION } from '../../../lib/role';

@ -1,5 +1,4 @@
import _ from 'lodash'; import _ from 'lodash';
import { call } from '../../../lib/call';
import { NoPermissionError } from '../../../lib/errors'; import { NoPermissionError } from '../../../lib/errors';
import type { import type {
GroupInvite, GroupInvite,
@ -11,6 +10,7 @@ import {
TcContext, TcContext,
TcDbService, TcDbService,
PureContext, PureContext,
call,
} from 'tailchat-server-sdk'; } from 'tailchat-server-sdk';
import { PERMISSION } from '../../../lib/role'; import { PERMISSION } from '../../../lib/role';

Loading…
Cancel
Save