token增加了getUserId
This commit is contained in:
parent
203380f72a
commit
9ff276532f
|
|
@ -4,10 +4,12 @@ import { Action, Feature } from 'oak-frontend-base';
|
|||
import { Aspect, Context } from 'oak-domain/lib/types';
|
||||
import { RWLock } from 'oak-domain/lib/utils/concurrent';
|
||||
import { WechatMpEnv } from 'oak-app-domain/Token/Schema';
|
||||
import { Cache } from 'oak-frontend-base';
|
||||
|
||||
export class Token<ED extends EntityDict, Cxt extends Context<ED>, AD extends Record<string, Aspect<ED, Cxt>>> extends Feature<ED, Cxt, AD> {
|
||||
private token?: string;
|
||||
private rwLock: RWLock;
|
||||
private cache?: Cache<ED, Cxt, AD>;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
|
@ -96,4 +98,22 @@ export class Token<ED extends EntityDict, Cxt extends Context<ED>, AD extends Re
|
|||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
setCache(cache: Cache<ED, Cxt, AD>) {
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
async getUserId() {
|
||||
const token = await this.getToken();
|
||||
const result = await this.cache!.get('token', {
|
||||
data: {
|
||||
id: 1,
|
||||
userId: 1,
|
||||
},
|
||||
filter: {
|
||||
id: token!,
|
||||
}
|
||||
}, 'token:getUserId');
|
||||
return result[0].userId;
|
||||
}
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ Component({
|
|||
}
|
||||
else {
|
||||
// this.triggerEvent('add', tempFiles);
|
||||
this.data.createData(tempFiles);
|
||||
this.createData(tempFiles);
|
||||
/* const { globalData: { features } } = getApp();
|
||||
const { oakFullpath } = this.data;
|
||||
for (const file of tempFiles) {
|
||||
|
|
@ -54,6 +54,7 @@ Component({
|
|||
}
|
||||
}
|
||||
catch (err: any) {
|
||||
console.error(err);
|
||||
if (err.errMsg !== 'chooseMedia:fail cancel') {
|
||||
this.triggerEvent('error', {
|
||||
level: 'error',
|
||||
|
|
|
|||
Loading…
Reference in New Issue