✨ feat(录像): 修改录像上传逻辑
This commit is contained in:
@@ -97,6 +97,9 @@ export default class GVGBattleRec extends BaseModel {
|
||||
@prop({ required: true, default: false })
|
||||
hasRpl: boolean; // 是否存在对应录像
|
||||
|
||||
@prop({ required: true, default: false })
|
||||
remoteUrl: string; // 录像地址
|
||||
|
||||
public static async createRec(configId: number, groupKey: string, warId: number, attackTeam: GVGTeamType, defenseTeam: GVGTeamType) {
|
||||
const battleCode = genCode(8);
|
||||
const result: GVGBattleRecType = await GVGBattleRecModel.findOneAndUpdate({ battleCode }, { $set: { configId, groupKey, warId, attackTeam, defenseTeam, isSuccess: false } }, { new: true, upsert: true }).lean();
|
||||
@@ -113,8 +116,8 @@ export default class GVGBattleRec extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async updateRplStatus(battleCode: string, hasRpl: boolean) {
|
||||
let result = await GVGBattleRecModel.findOneAndUpdate({ battleCode }, { hasRpl }, { new: true }).lean();
|
||||
public static async updateRplStatus(battleCode: string, hasRpl: boolean, remoteUrl: string) {
|
||||
let result = await GVGBattleRecModel.findOneAndUpdate({ battleCode }, { hasRpl, remoteUrl }, { new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,9 @@ export default class GVGVestigeRec extends BaseModel {
|
||||
@prop({ required: true, default: false })
|
||||
hasRpl: boolean; // 是否存在对应录像
|
||||
|
||||
@prop({ required: true, default: false })
|
||||
remoteUrl: string; // 录像文件
|
||||
|
||||
public static async createRec(configId: number, vestigeId: number, groupKey: string, warId: number, attackInfo: OppPlayerInfo, defenseInfo: OppPlayerInfo, leagueGoods: LeagueGood[]) {
|
||||
const battleCode = genCode(10);
|
||||
const result: GVGVestigeRecType = await GVGVestigeRecModel.findOneAndUpdate({ battleCode }, {
|
||||
@@ -110,8 +113,8 @@ export default class GVGVestigeRec extends BaseModel {
|
||||
}
|
||||
|
||||
|
||||
public static async updateRplStatus(battleCode: string, hasRpl: boolean) {
|
||||
let result: GVGVestigeRecType = await GVGVestigeRecModel.findOneAndUpdate({ battleCode }, { hasRpl }, { new: true }).lean();
|
||||
public static async updateRplStatus(battleCode: string, hasRpl: boolean, remoteUrl: string) {
|
||||
let result: GVGVestigeRecType = await GVGVestigeRecModel.findOneAndUpdate({ battleCode }, { hasRpl, remoteUrl }, { new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ export default class LadderMatchRec extends BaseModel {
|
||||
|
||||
@prop({ required: true, default: false })
|
||||
hasRpl: boolean; // 是否存在对应录像
|
||||
@prop({ required: true, default: false })
|
||||
remoteUrl: string; // 录像地址
|
||||
|
||||
public static async findByRoleId(roleId: string, getters = false) {
|
||||
const result: LadderMatchRecType = await LadderMatchRecModel.findOne({ roleId1: roleId }).lean({ getters});
|
||||
@@ -143,8 +145,8 @@ export default class LadderMatchRec extends BaseModel {
|
||||
|
||||
}
|
||||
|
||||
public static async updateRplStatus(battleCode: string, hasRpl: boolean) {
|
||||
let result = await LadderMatchRecModel.findOneAndUpdate({ battleCode }, { hasRpl }, { new: true }).lean();
|
||||
public static async updateRplStatus(battleCode: string, hasRpl: boolean, remoteUrl: string) {
|
||||
let result = await LadderMatchRecModel.findOneAndUpdate({ battleCode }, { hasRpl, remoteUrl }, { new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,8 @@ export default class PvpRecord extends BaseModel {
|
||||
|
||||
@prop({ required: true, default: false })
|
||||
hasRpl: boolean; // 是否存在对应录像
|
||||
@prop({ required: true, default: false })
|
||||
remoteUrl: string; // 远程地址
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
createTime: number;
|
||||
@@ -167,8 +169,8 @@ export default class PvpRecord extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async updateRplStatus(battleCode: string, hasRpl: boolean) {
|
||||
let result = await PvpRecordModel.findOneAndUpdate({ battleCode }, { hasRpl }, { new: true }).lean();
|
||||
public static async updateRplStatus(battleCode: string, hasRpl: boolean, remoteUrl: string) {
|
||||
let result = await PvpRecordModel.findOneAndUpdate({ battleCode }, { hasRpl, remoteUrl }, { new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { md5 } from './sdkUtil';
|
||||
const BATTLE_CLASS_MOD = 100; // 存档分类模数
|
||||
const CDN_URL_PREFIX_SQ = 'https://download-sgzzyz.yev242.com'; // sq cdn 服务器地址前缀
|
||||
const CDN_URL_PREFIX_ZYZ = 'http://zyz-download.trgame.cn'; // 公司下载服务器地址前缀
|
||||
const CDN_URL_PREFIX_YJZ = 'https://yjz-cdn.yev242.com'; // 公司下载服务器地址前缀
|
||||
|
||||
// 将字符串 crc32 处理后取模,以将随机字符串分组
|
||||
function modStr(str: string, mod: number) {
|
||||
@@ -23,8 +24,10 @@ function getPrefixByEnv(env: string) {
|
||||
case 'sq4':
|
||||
case 'sq7':
|
||||
case 'sq9':
|
||||
default:
|
||||
return CDN_URL_PREFIX_SQ;
|
||||
case 'zy1':
|
||||
return CDN_URL_PREFIX_YJZ;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +37,9 @@ export function getLocalRplUrl(roleId: string, warType: number, battleCode: stri
|
||||
return writePath;
|
||||
}
|
||||
|
||||
export function getRemoteRplUrl(env: string, roleId: string, warType: number, battleCode: string) {
|
||||
export function getRemoteRplUrl(env: string, sshHost: string, roleId: string, warType: number, battleCode: string) {
|
||||
const battleClass = modStr(battleCode, BATTLE_CLASS_MOD); // 将存档文件按一定规则分批保存
|
||||
const rplUrl = `${getPrefixByEnv(env)}/rpls/${md5(env).substring(0, 4)}/${roleId}/${warType}/${battleClass}`;
|
||||
const rplUrl = `${getPrefixByEnv(env)}/rpls/${md5(sshHost).substring(0, 4)}/${roleId}/${warType}/${battleClass}`;
|
||||
return rplUrl;
|
||||
}
|
||||
|
||||
@@ -45,7 +48,8 @@ export function getRemoteRplPrefix(env: string) {
|
||||
return rplUrl;
|
||||
}
|
||||
|
||||
export function getRemoteRplFilePath(roleId: string, warType: number, battleCode: string) {
|
||||
export function getRemoteRplFilePath(remoteUrl: string, roleId: string, warType: number, battleCode: string) {
|
||||
if(remoteUrl) return remoteUrl;
|
||||
const battleClass = modStr(battleCode, BATTLE_CLASS_MOD); // 将存档文件按一定规则分批保存
|
||||
const rplUrl = `/${roleId}/${warType}/${battleClass}/${battleCode}.bin`;
|
||||
return rplUrl;
|
||||
|
||||
Reference in New Issue
Block a user