Commit 15801353 authored by 任国军's avatar 任国军

add encodeUserSid

parent da428880
Pipeline #16590 passed with stage
in 48 seconds
......@@ -451,6 +451,38 @@ module.exports = {
}
return parseInt(rtn) >> 2;
},
encodeUserSid(userSid) {
const rand = 'OU1WjLvZCrRJ7Yo0gE2XDjuuaSAUuaH1bhHPuMymcdfEeKz0igRhXQkMuLTm1';
const randKey = 2019;
let rtn = '';
const code = userSid << 2;
const randLength = 11;
const len = String(code).length;
const codeLen = rand.slice(0, randLength);
const codeNums = rand.slice(randLength, randLength + 12);
const codeExt = rand.slice(randLength + 12, rand.length);
const begin = codeLen.slice(len - 1, len);
const ext = randLength - len - 1;
let temp = String(Math.floor(code / randKey)).replace('.', '');
temp = temp.slice(-ext);
let arrExtTemp = codeExt.split('');
let arrExt = temp.split('');
for (const v of arrExt) {
rtn += arrExtTemp[v];
}
let arrNumsTemp = codeNums.split('');
let arrNums = String(code).split('');
for (const v of arrNums) {
rtn += arrNumsTemp[v];
}
rtn = begin + rtn;
return rtn;
}
};
......@@ -42,7 +42,7 @@ class OptionService extends Service {
const { ctx } = this;
const cats = await ctx.classModel.v1.CourseCat.all({ where: { status: 1, is_deleted: 0 } });
const tree_cats = this.getTrees(cats, 0);
const tree_cats = this.getTrees(cats, 0);
const options = {
cats: tree_cats,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment