token projection 引用一个定义
This commit is contained in:
parent
8f7f960e4b
commit
ed8e3aec32
|
|
@ -10,6 +10,7 @@ var types_1 = require("oak-domain/lib/types");
|
||||||
var extraFile_1 = require("../utils/extraFile");
|
var extraFile_1 = require("../utils/extraFile");
|
||||||
var Exception_1 = require("../types/Exception");
|
var Exception_1 = require("../types/Exception");
|
||||||
var password_1 = require("../utils/password");
|
var password_1 = require("../utils/password");
|
||||||
|
var Token_1 = require("../types/Token");
|
||||||
function makeDistinguishException(userId, context) {
|
function makeDistinguishException(userId, context) {
|
||||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||||
var _a, user, password, passwordSha1, idState, wechatUser$user, email$user;
|
var _a, user, password, passwordSha1, idState, wechatUser$user, email$user;
|
||||||
|
|
@ -306,65 +307,7 @@ function loadTokenInfo(tokenId, context) {
|
||||||
return tslib_1.__generator(this, function (_a) {
|
return tslib_1.__generator(this, function (_a) {
|
||||||
switch (_a.label) {
|
switch (_a.label) {
|
||||||
case 0: return [4 /*yield*/, context.select('token', {
|
case 0: return [4 /*yield*/, context.select('token', {
|
||||||
data: {
|
data: Token_1.tokenProjection,
|
||||||
id: 1,
|
|
||||||
userId: 1,
|
|
||||||
ableState: 1,
|
|
||||||
user: {
|
|
||||||
id: 1,
|
|
||||||
nickname: 1,
|
|
||||||
name: 1,
|
|
||||||
userState: 1,
|
|
||||||
extraFile$entity: {
|
|
||||||
$entity: 'extraFile',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
tag1: 1,
|
|
||||||
origin: 1,
|
|
||||||
bucket: 1,
|
|
||||||
objectId: 1,
|
|
||||||
filename: 1,
|
|
||||||
extra1: 1,
|
|
||||||
type: 1,
|
|
||||||
entity: 1,
|
|
||||||
entityId: 1,
|
|
||||||
extension: 1,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
tag1: 'avatar',
|
|
||||||
},
|
|
||||||
indexFrom: 0,
|
|
||||||
count: 1,
|
|
||||||
},
|
|
||||||
mobile$user: {
|
|
||||||
$entity: 'mobile',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
mobile: 1,
|
|
||||||
userId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
userRole$user: {
|
|
||||||
$entity: 'userRole',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
userId: 1,
|
|
||||||
roleId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
player: {
|
|
||||||
id: 1,
|
|
||||||
userRole$user: {
|
|
||||||
$entity: 'userRole',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
userId: 1,
|
|
||||||
roleId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
filter: {
|
filter: {
|
||||||
id: tokenId,
|
id: tokenId,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -6,69 +6,7 @@ var Feature_1 = require("oak-frontend-base/lib/types/Feature");
|
||||||
var Exception_1 = require("oak-domain/lib/types/Exception");
|
var Exception_1 = require("oak-domain/lib/types/Exception");
|
||||||
var env_1 = require("../utils/env");
|
var env_1 = require("../utils/env");
|
||||||
var constants_1 = require("../constants");
|
var constants_1 = require("../constants");
|
||||||
var userProjection = {
|
var Token_1 = require("../types/Token");
|
||||||
id: 1,
|
|
||||||
nickname: 1,
|
|
||||||
name: 1,
|
|
||||||
userState: 1,
|
|
||||||
idState: 1,
|
|
||||||
gender: 1,
|
|
||||||
extraFile$entity: {
|
|
||||||
$entity: 'extraFile',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
tag1: 1,
|
|
||||||
origin: 1,
|
|
||||||
bucket: 1,
|
|
||||||
objectId: 1,
|
|
||||||
filename: 1,
|
|
||||||
extra1: 1,
|
|
||||||
type: 1,
|
|
||||||
entity: 1,
|
|
||||||
entityId: 1,
|
|
||||||
extension: 1,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
tag1: 'avatar',
|
|
||||||
},
|
|
||||||
indexFrom: 0,
|
|
||||||
count: 1,
|
|
||||||
},
|
|
||||||
mobile$user: {
|
|
||||||
$entity: 'mobile',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
mobile: 1,
|
|
||||||
userId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
userRole$user: {
|
|
||||||
$entity: 'userRole',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
userId: 1,
|
|
||||||
roleId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
var tokenProjection = {
|
|
||||||
id: 1,
|
|
||||||
userId: 1,
|
|
||||||
user: userProjection,
|
|
||||||
ableState: 1,
|
|
||||||
player: {
|
|
||||||
id: 1,
|
|
||||||
userRole$user: {
|
|
||||||
$entity: 'userRole',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
userId: 1,
|
|
||||||
roleId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
playerId: 1,
|
|
||||||
};
|
|
||||||
var Token = /** @class */ (function (_super) {
|
var Token = /** @class */ (function (_super) {
|
||||||
tslib_1.__extends(Token, _super);
|
tslib_1.__extends(Token, _super);
|
||||||
function Token(cache, storage) {
|
function Token(cache, storage) {
|
||||||
|
|
@ -87,7 +25,7 @@ var Token = /** @class */ (function (_super) {
|
||||||
return tslib_1.__generator(this, function (_a) {
|
return tslib_1.__generator(this, function (_a) {
|
||||||
switch (_a.label) {
|
switch (_a.label) {
|
||||||
case 0: return [4 /*yield*/, this.cache.refresh('token', {
|
case 0: return [4 /*yield*/, this.cache.refresh('token', {
|
||||||
data: tokenProjection,
|
data: Token_1.tokenProjection,
|
||||||
filter: {
|
filter: {
|
||||||
id: this.tokenValue,
|
id: this.tokenValue,
|
||||||
},
|
},
|
||||||
|
|
@ -213,7 +151,7 @@ var Token = /** @class */ (function (_super) {
|
||||||
Token.prototype.getToken = function (allowUnloggedIn) {
|
Token.prototype.getToken = function (allowUnloggedIn) {
|
||||||
if (this.tokenValue) {
|
if (this.tokenValue) {
|
||||||
return this.cache.get('token', {
|
return this.cache.get('token', {
|
||||||
data: tokenProjection,
|
data: Token_1.tokenProjection,
|
||||||
filter: {
|
filter: {
|
||||||
id: this.tokenValue,
|
id: this.tokenValue,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import { EntityDict } from '../general-app-domain';
|
||||||
|
export declare const userProjection: EntityDict['user']['Selection']['data'];
|
||||||
|
export declare const tokenProjection: EntityDict['token']['Selection']['data'];
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.tokenProjection = exports.userProjection = void 0;
|
||||||
|
exports.userProjection = {
|
||||||
|
id: 1,
|
||||||
|
nickname: 1,
|
||||||
|
name: 1,
|
||||||
|
userState: 1,
|
||||||
|
idState: 1,
|
||||||
|
gender: 1,
|
||||||
|
birth: 1,
|
||||||
|
extraFile$entity: {
|
||||||
|
$entity: 'extraFile',
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
tag1: 1,
|
||||||
|
origin: 1,
|
||||||
|
bucket: 1,
|
||||||
|
objectId: 1,
|
||||||
|
filename: 1,
|
||||||
|
extra1: 1,
|
||||||
|
type: 1,
|
||||||
|
entity: 1,
|
||||||
|
entityId: 1,
|
||||||
|
extension: 1,
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
tag1: 'avatar',
|
||||||
|
},
|
||||||
|
indexFrom: 0,
|
||||||
|
count: 1,
|
||||||
|
},
|
||||||
|
mobile$user: {
|
||||||
|
$entity: 'mobile',
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
mobile: 1,
|
||||||
|
userId: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
userRole$user: {
|
||||||
|
$entity: 'userRole',
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
userId: 1,
|
||||||
|
roleId: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
exports.tokenProjection = {
|
||||||
|
id: 1,
|
||||||
|
userId: 1,
|
||||||
|
user: exports.userProjection,
|
||||||
|
ableState: 1,
|
||||||
|
playerId: 1,
|
||||||
|
player: {
|
||||||
|
id: 1,
|
||||||
|
userRole$user: {
|
||||||
|
$entity: 'userRole',
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
userId: 1,
|
||||||
|
roleId: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
@ -47,7 +47,6 @@
|
||||||
"@types/cross-spawn": "^6.0.2",
|
"@types/cross-spawn": "^6.0.2",
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^9.0.13",
|
||||||
"@types/lodash": "^4.14.168",
|
"@types/lodash": "^4.14.168",
|
||||||
"@types/luxon": "^2.0.9",
|
|
||||||
"@types/mocha": "^8.2.0",
|
"@types/mocha": "^8.2.0",
|
||||||
"@types/node": "^14.18.12",
|
"@types/node": "^14.18.12",
|
||||||
"@types/qr-image": "^3.2.5",
|
"@types/qr-image": "^3.2.5",
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import { composeFileUrl, decomposeFileUrl } from '../utils/extraFile';
|
||||||
import { OakChangeLoginWayException, OakDistinguishUserException, OakUserDisabledException } from '../types/Exception';
|
import { OakChangeLoginWayException, OakDistinguishUserException, OakUserDisabledException } from '../types/Exception';
|
||||||
import { encryptPasswordSha1 } from '../utils/password';
|
import { encryptPasswordSha1 } from '../utils/password';
|
||||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||||
|
import { tokenProjection } from '../types/Token';
|
||||||
|
|
||||||
async function makeDistinguishException<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(userId: string, context: Cxt) {
|
async function makeDistinguishException<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(userId: string, context: Cxt) {
|
||||||
const [user] = await context.select('user', {
|
const [user] = await context.select('user', {
|
||||||
|
|
@ -246,65 +247,7 @@ async function loadTokenInfo<ED extends EntityDict, Cxt extends BackendRuntimeCo
|
||||||
await context.select(
|
await context.select(
|
||||||
'token',
|
'token',
|
||||||
{
|
{
|
||||||
data: {
|
data: tokenProjection,
|
||||||
id: 1,
|
|
||||||
userId: 1,
|
|
||||||
ableState: 1,
|
|
||||||
user: {
|
|
||||||
id: 1,
|
|
||||||
nickname: 1,
|
|
||||||
name: 1,
|
|
||||||
userState: 1,
|
|
||||||
extraFile$entity: {
|
|
||||||
$entity: 'extraFile',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
tag1: 1,
|
|
||||||
origin: 1,
|
|
||||||
bucket: 1,
|
|
||||||
objectId: 1,
|
|
||||||
filename: 1,
|
|
||||||
extra1: 1,
|
|
||||||
type: 1,
|
|
||||||
entity: 1,
|
|
||||||
entityId: 1,
|
|
||||||
extension: 1,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
tag1: 'avatar',
|
|
||||||
},
|
|
||||||
indexFrom: 0,
|
|
||||||
count: 1,
|
|
||||||
},
|
|
||||||
mobile$user: {
|
|
||||||
$entity: 'mobile',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
mobile: 1,
|
|
||||||
userId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
userRole$user: {
|
|
||||||
$entity: 'userRole',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
userId: 1,
|
|
||||||
roleId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
player: {
|
|
||||||
id: 1,
|
|
||||||
userRole$user: {
|
|
||||||
$entity: 'userRole',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
userId: 1,
|
|
||||||
roleId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
filter: {
|
filter: {
|
||||||
id: tokenId,
|
id: tokenId,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -7,74 +7,10 @@ import { WebEnv, WechatMpEnv } from '../general-app-domain/Token/Schema';
|
||||||
import { EntityDict } from '../general-app-domain';
|
import { EntityDict } from '../general-app-domain';
|
||||||
import { getEnv } from '../utils/env';
|
import { getEnv } from '../utils/env';
|
||||||
import { AspectDict } from '../aspects/AspectDict';
|
import { AspectDict } from '../aspects/AspectDict';
|
||||||
import { AspectWrapper } from 'oak-domain/lib/types';
|
|
||||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||||
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
|
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
|
||||||
import { ROOT_ROLE_ID } from '../constants';
|
import { ROOT_ROLE_ID } from '../constants';
|
||||||
|
import { tokenProjection } from '../types/Token';
|
||||||
const userProjection: EntityDict['user']['Selection']['data'] = {
|
|
||||||
id: 1,
|
|
||||||
nickname: 1,
|
|
||||||
name: 1,
|
|
||||||
userState: 1,
|
|
||||||
idState: 1,
|
|
||||||
gender: 1,
|
|
||||||
extraFile$entity: {
|
|
||||||
$entity: 'extraFile',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
tag1: 1,
|
|
||||||
origin: 1,
|
|
||||||
bucket: 1,
|
|
||||||
objectId: 1,
|
|
||||||
filename: 1,
|
|
||||||
extra1: 1,
|
|
||||||
type: 1,
|
|
||||||
entity: 1,
|
|
||||||
entityId: 1,
|
|
||||||
extension: 1,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
tag1: 'avatar',
|
|
||||||
},
|
|
||||||
indexFrom: 0,
|
|
||||||
count: 1,
|
|
||||||
},
|
|
||||||
mobile$user: {
|
|
||||||
$entity: 'mobile',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
mobile: 1,
|
|
||||||
userId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
userRole$user: {
|
|
||||||
$entity: 'userRole',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
userId: 1,
|
|
||||||
roleId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const tokenProjection: EntityDict['token']['Selection']['data'] = {
|
|
||||||
id: 1,
|
|
||||||
userId: 1,
|
|
||||||
user: userProjection,
|
|
||||||
ableState: 1,
|
|
||||||
player: {
|
|
||||||
id: 1,
|
|
||||||
userRole$user: {
|
|
||||||
$entity: 'userRole',
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
userId: 1,
|
|
||||||
roleId: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
playerId: 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
export class Token<
|
export class Token<
|
||||||
ED extends EntityDict,
|
ED extends EntityDict,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
|
||||||
|
|
||||||
|
import { EntityDict } from '../general-app-domain';
|
||||||
|
|
||||||
|
export const userProjection: EntityDict['user']['Selection']['data'] = {
|
||||||
|
id: 1,
|
||||||
|
nickname: 1,
|
||||||
|
name: 1,
|
||||||
|
userState: 1,
|
||||||
|
idState: 1,
|
||||||
|
gender: 1,
|
||||||
|
birth: 1,
|
||||||
|
extraFile$entity: {
|
||||||
|
$entity: 'extraFile',
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
tag1: 1,
|
||||||
|
origin: 1,
|
||||||
|
bucket: 1,
|
||||||
|
objectId: 1,
|
||||||
|
filename: 1,
|
||||||
|
extra1: 1,
|
||||||
|
type: 1,
|
||||||
|
entity: 1,
|
||||||
|
entityId: 1,
|
||||||
|
extension: 1,
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
tag1: 'avatar',
|
||||||
|
},
|
||||||
|
indexFrom: 0,
|
||||||
|
count: 1,
|
||||||
|
},
|
||||||
|
mobile$user: {
|
||||||
|
$entity: 'mobile',
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
mobile: 1,
|
||||||
|
userId: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
userRole$user: {
|
||||||
|
$entity: 'userRole',
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
userId: 1,
|
||||||
|
roleId: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export const tokenProjection: EntityDict['token']['Selection']['data'] = {
|
||||||
|
id: 1,
|
||||||
|
userId: 1,
|
||||||
|
user: userProjection,
|
||||||
|
ableState: 1,
|
||||||
|
playerId: 1,
|
||||||
|
player: {
|
||||||
|
id: 1,
|
||||||
|
userRole$user: {
|
||||||
|
$entity: 'userRole',
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
userId: 1,
|
||||||
|
roleId: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue