feat(37需求): 添加上报名称接口

This commit is contained in:
luying
2023-04-28 16:35:37 +08:00
parent 03bea4d932
commit f73ad9bc77
4 changed files with 71 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
/********** 37sdk **********/
import { RoleModel, RoleType } from "../db/Role";
import { Chat37Params, CheckGuild37Params, CheckName37Params, GetWordParam, PushMsg37Param } from "../domain/sdk";
import { Chat37Params, CheckGuild37Params, CheckName37Params, GetWordParam, PostGuild37Params, PostName37Params, PushMsg37Param } from "../domain/sdk";
import { sendMailByContent, sendMailToGuildByContent } from './mailService';
import { NAMEPLATE } from '../pubUtils/dicParam';
import { CHANNEL_PREFIX, FILENAME, getSdkChannelId, MAIL_TYPE, PUSH_ROUTE, REDIS_KEY, SDK_37_ADDR, SDK_37_CONST, SDK_PUSH_TARGET_TYPE, SDK_TA_CONST, STATUS, TA_EVENT, TA_USERSET_TYPE, THINKING_DATA_MODE, THINKING_DATA_MODE_LIST } from "../consts";
@@ -77,6 +77,7 @@ export async function checkRoleName(roleId: string, roleName: string, myRole?: R
} else if (result == 0) {
return false;
}
request37Post(SDK_37_ADDR.POST_NAME, new PostName37Params(myRole, roleName, myUser), SDK_37_CONST.CHAT_KEY);
}
return true;
}
@@ -91,6 +92,7 @@ export async function checkGuildName(guildCode: string, serverId: number, name:
} else if (result == 0) {
nameResult = false;
}
if(nameResult) request37Post(SDK_37_ADDR.POST_UNION, new PostGuild37Params(guildCode, serverId, 1, name), SDK_37_CONST.CHAT_KEY);
}
if(notice != undefined) {
if(notice == '') notice = ' ';
@@ -101,6 +103,7 @@ export async function checkGuildName(guildCode: string, serverId: number, name:
} else if (result == 0) {
noticeResult = false;
}
if(noticeResult) request37Post(SDK_37_ADDR.POST_UNION, new PostGuild37Params(guildCode, serverId, 2, notice), SDK_37_CONST.CHAT_KEY);
}
return nameResult && noticeResult
}

View File

@@ -17,6 +17,8 @@ export enum SDK_37_ADDR {
CHECK_CHAT = 'http://api.gamechat.37.com/checkChatV2.php',
CHECK_NAME = 'http://api.gamechat.37.com/checkName.php',
CHECK_UNION = 'http://api.gamechat.37.com/checkUnion.php',
POST_NAME = 'https://apigamechat.37.com/postName.php',
POST_UNION = 'https://apigamechat.37.com/postUnion.php',
GET_WORD = 'http://api.gamechat.37.com/getWord.php',
PUSH_MSG = 'https://pushdata.37.com/index.php?c=pushmessage&a=push_message',
}

View File

@@ -190,6 +190,39 @@ export class CheckName37Params {
}
}
export class PostName37Params {
game_key: string;
sid: number; // 游戏区
username: number; // channelInfo.uid
actor: string; // roleName
actor_id: string; // roleId
ip: string; // 玩家ip
time: number; // unix时间戳
sign: string;
constructor(role: RoleType, roleName: string, user: UserType) {
let channelInfo = <LoginValidateData37>user.channelInfo;
this.game_key = SDK_37_CONST.GAME_KEY;
this.sid = role.serverId;
this.username = channelInfo.uid;
this.actor = roleName;
this.actor_id = role.roleId;
this.ip = user.ip;
this.time = nowSeconds();
}
getBody() {
let { game_key, sid, username, actor_id, ip, time } = this;
return {
game_key, sid, username, actor_id, ip, time
}
}
setSign(sign: string) {
this.sign = sign;
}
}
export class CheckGuild37Params {
game_key: string;
sid: number; // 游戏区
@@ -220,6 +253,36 @@ export class CheckGuild37Params {
}
}
export class PostGuild37Params {
game_key: string;
sid: number; // 游戏区
guildid: string; // 军团code
time: number; // unix时间戳
sign: string;
type: number;
content: string; // 内容
constructor(guildCode: string, serverId: number, type: number, content: string) {
this.game_key = SDK_37_CONST.GAME_KEY;
this.sid = serverId;
this.guildid = guildCode;
this.time = nowSeconds();
this.type = type;
this.content = content;
}
getBody() {
let { game_key, sid, time, type } = this;
return {
game_key, sid, time, type
}
}
setSign(sign: string) {
this.sign = sign;
}
}
export class RoleNameCallBackParam {
username: number; // 玩家账号
game_key: string; // 游戏标识

View File

@@ -4,7 +4,7 @@ import { BANTU_VID_ADDR, BANTU_VID_APP_KEY, HTTP_METHOD } from '../consts';
import { checkVidObjSign, get37CheckChatMd5Sign, get37Md5SignA, get37Md5SignB, get37PushMsgMd5Sign, getVidObjSign } from "./sdkUtil";
import { STATUS } from '../consts'
import { resResult } from "./util";
import { Chat37Params, CheckGuild37Params, CheckName37Params, GetWordParam, PushMsg37Param } from "../domain/sdk";
import { Chat37Params, CheckGuild37Params, CheckName37Params, GetWordParam, PostGuild37Params, PostName37Params, PushMsg37Param } from "../domain/sdk";
// 通用请求http
export async function httpRequest(url: string, method: string, body: any, headers?: any, timeout = 150) {
@@ -195,7 +195,7 @@ export async function request37(url: string, body: any, key: string) {
return result;
}
export async function request37Post(url: string, body: CheckName37Params|CheckGuild37Params, key: string) {
export async function request37Post(url: string, body: CheckName37Params|CheckGuild37Params|PostName37Params|PostGuild37Params, key: string) {
body.setSign(get37Md5SignB(body.getBody(), key));
let result = await httpRequestForm(url, HTTP_METHOD.POST, body, 1 * 60 * 1000);