绑定微信号 二维码

This commit is contained in:
Wang Kejun 2023-04-26 09:52:16 +08:00
parent 08ea90acd8
commit 8f2b10044e
32 changed files with 756 additions and 154 deletions

15
lib/entities/WechatLogin.d.ts vendored Normal file
View File

@ -0,0 +1,15 @@
import { Text, Datetime } from 'oak-domain/lib/types/DataType';
import { EntityShape } from 'oak-domain/lib/types/Entity';
import { Schema as User } from './User';
import { Schema as WechatQrCode } from './WechatQrCode';
import { QrCodeType } from '../types/Config';
export interface Schema extends EntityShape {
user?: User;
type: 'bind' | 'login';
successed: Boolean;
remark?: Text;
qrCodeType: QrCodeType;
expiresAt?: Datetime;
expired?: Boolean;
codes: Array<WechatQrCode>;
}

View File

@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var indexes = [
{
name: 'index_uuid',
attributes: [
{
name: 'expired',
},
{
name: 'expiresAt',
}
],
},
];
var locale = {
zh_CN: {
name: '绑定微信号',
attr: {
user: '用户',
type: '类型',
successed: '是否成功',
remark: '备注',
codes: '微信码',
expired: '是否过期',
expiresAt: '过期时间',
qrCodeType: '二维码类型',
},
action: {
success: '成功',
},
v: {
type: {
bind: '绑定',
login: '登录',
},
qrCodeType: {
webForWechatPublic: '网站引流到公众号',
wechatMpDomainUrl: '小程序url码',
wechatMpWxaCode: '小程序码',
wechatPublic: '公众号关注码',
wechatPublicForMp: '公众号跳转小程序码',
},
},
},
};

View File

@ -29,4 +29,5 @@ export declare const ActionDefDict: {
userState: import("oak-domain/lib/types").ActionDef<string, string>; userState: import("oak-domain/lib/types").ActionDef<string, string>;
}; };
userEntityGrant: {}; userEntityGrant: {};
wechatLogin: {};
}; };

View File

@ -11,6 +11,7 @@ var Action_7 = require("./Notification/Action");
var Action_8 = require("./Token/Action"); var Action_8 = require("./Token/Action");
var Action_9 = require("./User/Action"); var Action_9 = require("./User/Action");
var Action_10 = require("./UserEntityGrant/Action"); var Action_10 = require("./UserEntityGrant/Action");
var Action_11 = require("./WechatLogin/Action");
exports.ActionDefDict = { exports.ActionDefDict = {
modi: Action_1.ActionDefDict, modi: Action_1.ActionDefDict,
article: Action_2.ActionDefDict, article: Action_2.ActionDefDict,
@ -21,5 +22,6 @@ exports.ActionDefDict = {
notification: Action_7.ActionDefDict, notification: Action_7.ActionDefDict,
token: Action_8.ActionDefDict, token: Action_8.ActionDefDict,
user: Action_9.ActionDefDict, user: Action_9.ActionDefDict,
userEntityGrant: Action_10.ActionDefDict userEntityGrant: Action_10.ActionDefDict,
wechatLogin: Action_11.ActionDefDict
}; };

View File

@ -34,6 +34,7 @@ import { EntityDef as System } from "./System/Schema";
import { EntityDef as Token } from "./Token/Schema"; import { EntityDef as Token } from "./Token/Schema";
import { EntityDef as UserSystem } from "./UserSystem/Schema"; import { EntityDef as UserSystem } from "./UserSystem/Schema";
import { EntityDef as UserWechatPublicTag } from "./UserWechatPublicTag/Schema"; import { EntityDef as UserWechatPublicTag } from "./UserWechatPublicTag/Schema";
import { EntityDef as WechatLogin } from "./WechatLogin/Schema";
import { EntityDef as WechatPublicTag } from "./WechatPublicTag/Schema"; import { EntityDef as WechatPublicTag } from "./WechatPublicTag/Schema";
import { EntityDef as WechatQrCode } from "./WechatQrCode/Schema"; import { EntityDef as WechatQrCode } from "./WechatQrCode/Schema";
import { EntityDef as WechatUser } from "./WechatUser/Schema"; import { EntityDef as WechatUser } from "./WechatUser/Schema";
@ -74,6 +75,7 @@ export declare type EntityDict = {
token: Token; token: Token;
userSystem: UserSystem; userSystem: UserSystem;
userWechatPublicTag: UserWechatPublicTag; userWechatPublicTag: UserWechatPublicTag;
wechatLogin: WechatLogin;
wechatPublicTag: WechatPublicTag; wechatPublicTag: WechatPublicTag;
wechatQrCode: WechatQrCode; wechatQrCode: WechatQrCode;
wechatUser: WechatUser; wechatUser: WechatUser;

View File

@ -9,24 +9,26 @@ import * as User from "../User/Schema";
import * as UserEntityGrant from "../UserEntityGrant/Schema"; import * as UserEntityGrant from "../UserEntityGrant/Schema";
import * as UserSystem from "../UserSystem/Schema"; import * as UserSystem from "../UserSystem/Schema";
import * as UserWechatPublicTag from "../UserWechatPublicTag/Schema"; import * as UserWechatPublicTag from "../UserWechatPublicTag/Schema";
import * as WechatLogin from "../WechatLogin/Schema";
import * as WechatPublicTag from "../WechatPublicTag/Schema"; import * as WechatPublicTag from "../WechatPublicTag/Schema";
import * as WechatQrCode from "../WechatQrCode/Schema"; import * as WechatQrCode from "../WechatQrCode/Schema";
import * as WechatUser from "../WechatUser/Schema"; import * as WechatUser from "../WechatUser/Schema";
export declare type OpSchema = EntityShape & { export declare type OpSchema = EntityShape & {
modiId: ForeignKey<"modi">; modiId: ForeignKey<"modi">;
entity: "user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string; entity: "user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatLogin" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string;
entityId: String<64>; entityId: String<64>;
}; };
export declare type OpAttr = keyof OpSchema; export declare type OpAttr = keyof OpSchema;
export declare type Schema = EntityShape & { export declare type Schema = EntityShape & {
modiId: ForeignKey<"modi">; modiId: ForeignKey<"modi">;
entity: "user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string; entity: "user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatLogin" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string;
entityId: String<64>; entityId: String<64>;
modi: Modi.Schema; modi: Modi.Schema;
user?: User.Schema; user?: User.Schema;
userEntityGrant?: UserEntityGrant.Schema; userEntityGrant?: UserEntityGrant.Schema;
userSystem?: UserSystem.Schema; userSystem?: UserSystem.Schema;
userWechatPublicTag?: UserWechatPublicTag.Schema; userWechatPublicTag?: UserWechatPublicTag.Schema;
wechatLogin?: WechatLogin.Schema;
wechatPublicTag?: WechatPublicTag.Schema; wechatPublicTag?: WechatPublicTag.Schema;
wechatQrCode?: WechatQrCode.Schema; wechatQrCode?: WechatQrCode.Schema;
wechatUser?: WechatUser.Schema; wechatUser?: WechatUser.Schema;
@ -46,11 +48,12 @@ declare type AttrFilter<E> = {
userEntityGrant: UserEntityGrant.Filter; userEntityGrant: UserEntityGrant.Filter;
userSystem: UserSystem.Filter; userSystem: UserSystem.Filter;
userWechatPublicTag: UserWechatPublicTag.Filter; userWechatPublicTag: UserWechatPublicTag.Filter;
wechatLogin: WechatLogin.Filter;
wechatPublicTag: WechatPublicTag.Filter; wechatPublicTag: WechatPublicTag.Filter;
wechatQrCode: WechatQrCode.Filter; wechatQrCode: WechatQrCode.Filter;
wechatUser: WechatUser.Filter; wechatUser: WechatUser.Filter;
}; };
export declare type Filter<E = Q_EnumValue<"user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>; export declare type Filter<E = Q_EnumValue<"user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatLogin" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
export declare type Projection = { export declare type Projection = {
"#id"?: NodeId; "#id"?: NodeId;
[k: string]: any; [k: string]: any;
@ -66,6 +69,7 @@ export declare type Projection = {
userEntityGrant?: UserEntityGrant.Projection; userEntityGrant?: UserEntityGrant.Projection;
userSystem?: UserSystem.Projection; userSystem?: UserSystem.Projection;
userWechatPublicTag?: UserWechatPublicTag.Projection; userWechatPublicTag?: UserWechatPublicTag.Projection;
wechatLogin?: WechatLogin.Projection;
wechatPublicTag?: WechatPublicTag.Projection; wechatPublicTag?: WechatPublicTag.Projection;
wechatQrCode?: WechatQrCode.Projection; wechatQrCode?: WechatQrCode.Projection;
wechatUser?: WechatUser.Projection; wechatUser?: WechatUser.Projection;
@ -88,6 +92,9 @@ declare type UserSystemIdProjection = OneOf<{
declare type UserWechatPublicTagIdProjection = OneOf<{ declare type UserWechatPublicTagIdProjection = OneOf<{
entityId: number; entityId: number;
}>; }>;
declare type WechatLoginIdProjection = OneOf<{
entityId: number;
}>;
declare type WechatPublicTagIdProjection = OneOf<{ declare type WechatPublicTagIdProjection = OneOf<{
entityId: number; entityId: number;
}>; }>;
@ -121,6 +128,8 @@ export declare type SortAttr = {
userSystem: UserSystem.SortAttr; userSystem: UserSystem.SortAttr;
} | { } | {
userWechatPublicTag: UserWechatPublicTag.SortAttr; userWechatPublicTag: UserWechatPublicTag.SortAttr;
} | {
wechatLogin: WechatLogin.SortAttr;
} | { } | {
wechatPublicTag: WechatPublicTag.SortAttr; wechatPublicTag: WechatPublicTag.SortAttr;
} | { } | {
@ -190,6 +199,17 @@ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity"
} | { } | {
entity: "userWechatPublicTag"; entity: "userWechatPublicTag";
entityId: String<64>; entityId: String<64>;
} | {
entity?: never;
entityId?: never;
wechatLogin: WechatLogin.CreateSingleOperation;
} | {
entity: "wechatLogin";
entityId: String<64>;
wechatLogin: WechatLogin.UpdateOperation;
} | {
entity: "wechatLogin";
entityId: String<64>;
} | { } | {
entity?: never; entity?: never;
entityId?: never; entityId?: never;
@ -259,6 +279,10 @@ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity"
userWechatPublicTag?: UserWechatPublicTag.CreateSingleOperation | UserWechatPublicTag.UpdateOperation | UserWechatPublicTag.RemoveOperation; userWechatPublicTag?: UserWechatPublicTag.CreateSingleOperation | UserWechatPublicTag.UpdateOperation | UserWechatPublicTag.RemoveOperation;
entityId?: never; entityId?: never;
entity?: never; entity?: never;
} | {
wechatLogin?: WechatLogin.CreateSingleOperation | WechatLogin.UpdateOperation | WechatLogin.RemoveOperation;
entityId?: never;
entity?: never;
} | { } | {
wechatPublicTag?: WechatPublicTag.CreateSingleOperation | WechatPublicTag.UpdateOperation | WechatPublicTag.RemoveOperation; wechatPublicTag?: WechatPublicTag.CreateSingleOperation | WechatPublicTag.UpdateOperation | WechatPublicTag.RemoveOperation;
entityId?: never; entityId?: never;
@ -272,7 +296,7 @@ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity"
entityId?: never; entityId?: never;
entity?: never; entity?: never;
} | { } | {
entity?: ("user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string) | null; entity?: ("user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatLogin" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string) | null;
entityId?: String<64> | null; entityId?: String<64> | null;
}) & { }) & {
[k: string]: any; [k: string]: any;
@ -288,6 +312,8 @@ export declare type RemoveOperationData = {} & (({
userSystem?: UserSystem.UpdateOperation | UserSystem.RemoveOperation; userSystem?: UserSystem.UpdateOperation | UserSystem.RemoveOperation;
} | { } | {
userWechatPublicTag?: UserWechatPublicTag.UpdateOperation | UserWechatPublicTag.RemoveOperation; userWechatPublicTag?: UserWechatPublicTag.UpdateOperation | UserWechatPublicTag.RemoveOperation;
} | {
wechatLogin?: WechatLogin.UpdateOperation | WechatLogin.RemoveOperation;
} | { } | {
wechatPublicTag?: WechatPublicTag.UpdateOperation | WechatPublicTag.RemoveOperation; wechatPublicTag?: WechatPublicTag.UpdateOperation | WechatPublicTag.RemoveOperation;
} | { } | {
@ -304,6 +330,7 @@ export declare type UserIdSubQuery = Selection<UserIdProjection>;
export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>; export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>;
export declare type UserSystemIdSubQuery = Selection<UserSystemIdProjection>; export declare type UserSystemIdSubQuery = Selection<UserSystemIdProjection>;
export declare type UserWechatPublicTagIdSubQuery = Selection<UserWechatPublicTagIdProjection>; export declare type UserWechatPublicTagIdSubQuery = Selection<UserWechatPublicTagIdProjection>;
export declare type WechatLoginIdSubQuery = Selection<WechatLoginIdProjection>;
export declare type WechatPublicTagIdSubQuery = Selection<WechatPublicTagIdProjection>; export declare type WechatPublicTagIdSubQuery = Selection<WechatPublicTagIdProjection>;
export declare type WechatQrCodeIdSubQuery = Selection<WechatQrCodeIdProjection>; export declare type WechatQrCodeIdSubQuery = Selection<WechatQrCodeIdProjection>;
export declare type WechatUserIdSubQuery = Selection<WechatUserIdProjection>; export declare type WechatUserIdSubQuery = Selection<WechatUserIdProjection>;

View File

@ -15,7 +15,7 @@ exports.desc = {
params: { params: {
length: 32 length: 32
}, },
ref: ["user", "userEntityGrant", "userSystem", "userWechatPublicTag", "wechatPublicTag", "wechatQrCode", "wechatUser"] ref: ["user", "userEntityGrant", "userSystem", "userWechatPublicTag", "wechatLogin", "wechatPublicTag", "wechatQrCode", "wechatUser"]
}, },
entityId: { entityId: {
notNull: true, notNull: true,

View File

@ -9,24 +9,26 @@ import * as User from "../User/Schema";
import * as UserEntityGrant from "../UserEntityGrant/Schema"; import * as UserEntityGrant from "../UserEntityGrant/Schema";
import * as UserSystem from "../UserSystem/Schema"; import * as UserSystem from "../UserSystem/Schema";
import * as UserWechatPublicTag from "../UserWechatPublicTag/Schema"; import * as UserWechatPublicTag from "../UserWechatPublicTag/Schema";
import * as WechatLogin from "../WechatLogin/Schema";
import * as WechatPublicTag from "../WechatPublicTag/Schema"; import * as WechatPublicTag from "../WechatPublicTag/Schema";
import * as WechatQrCode from "../WechatQrCode/Schema"; import * as WechatQrCode from "../WechatQrCode/Schema";
import * as WechatUser from "../WechatUser/Schema"; import * as WechatUser from "../WechatUser/Schema";
export declare type OpSchema = EntityShape & { export declare type OpSchema = EntityShape & {
operId: ForeignKey<"oper">; operId: ForeignKey<"oper">;
entity: "user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string; entity: "user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatLogin" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string;
entityId: String<64>; entityId: String<64>;
}; };
export declare type OpAttr = keyof OpSchema; export declare type OpAttr = keyof OpSchema;
export declare type Schema = EntityShape & { export declare type Schema = EntityShape & {
operId: ForeignKey<"oper">; operId: ForeignKey<"oper">;
entity: "user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string; entity: "user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatLogin" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string;
entityId: String<64>; entityId: String<64>;
oper: Oper.Schema; oper: Oper.Schema;
user?: User.Schema; user?: User.Schema;
userEntityGrant?: UserEntityGrant.Schema; userEntityGrant?: UserEntityGrant.Schema;
userSystem?: UserSystem.Schema; userSystem?: UserSystem.Schema;
userWechatPublicTag?: UserWechatPublicTag.Schema; userWechatPublicTag?: UserWechatPublicTag.Schema;
wechatLogin?: WechatLogin.Schema;
wechatPublicTag?: WechatPublicTag.Schema; wechatPublicTag?: WechatPublicTag.Schema;
wechatQrCode?: WechatQrCode.Schema; wechatQrCode?: WechatQrCode.Schema;
wechatUser?: WechatUser.Schema; wechatUser?: WechatUser.Schema;
@ -46,11 +48,12 @@ declare type AttrFilter<E> = {
userEntityGrant: UserEntityGrant.Filter; userEntityGrant: UserEntityGrant.Filter;
userSystem: UserSystem.Filter; userSystem: UserSystem.Filter;
userWechatPublicTag: UserWechatPublicTag.Filter; userWechatPublicTag: UserWechatPublicTag.Filter;
wechatLogin: WechatLogin.Filter;
wechatPublicTag: WechatPublicTag.Filter; wechatPublicTag: WechatPublicTag.Filter;
wechatQrCode: WechatQrCode.Filter; wechatQrCode: WechatQrCode.Filter;
wechatUser: WechatUser.Filter; wechatUser: WechatUser.Filter;
}; };
export declare type Filter<E = Q_EnumValue<"user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>; export declare type Filter<E = Q_EnumValue<"user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatLogin" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
export declare type Projection = { export declare type Projection = {
"#id"?: NodeId; "#id"?: NodeId;
[k: string]: any; [k: string]: any;
@ -66,6 +69,7 @@ export declare type Projection = {
userEntityGrant?: UserEntityGrant.Projection; userEntityGrant?: UserEntityGrant.Projection;
userSystem?: UserSystem.Projection; userSystem?: UserSystem.Projection;
userWechatPublicTag?: UserWechatPublicTag.Projection; userWechatPublicTag?: UserWechatPublicTag.Projection;
wechatLogin?: WechatLogin.Projection;
wechatPublicTag?: WechatPublicTag.Projection; wechatPublicTag?: WechatPublicTag.Projection;
wechatQrCode?: WechatQrCode.Projection; wechatQrCode?: WechatQrCode.Projection;
wechatUser?: WechatUser.Projection; wechatUser?: WechatUser.Projection;
@ -88,6 +92,9 @@ declare type UserSystemIdProjection = OneOf<{
declare type UserWechatPublicTagIdProjection = OneOf<{ declare type UserWechatPublicTagIdProjection = OneOf<{
entityId: number; entityId: number;
}>; }>;
declare type WechatLoginIdProjection = OneOf<{
entityId: number;
}>;
declare type WechatPublicTagIdProjection = OneOf<{ declare type WechatPublicTagIdProjection = OneOf<{
entityId: number; entityId: number;
}>; }>;
@ -121,6 +128,8 @@ export declare type SortAttr = {
userSystem: UserSystem.SortAttr; userSystem: UserSystem.SortAttr;
} | { } | {
userWechatPublicTag: UserWechatPublicTag.SortAttr; userWechatPublicTag: UserWechatPublicTag.SortAttr;
} | {
wechatLogin: WechatLogin.SortAttr;
} | { } | {
wechatPublicTag: WechatPublicTag.SortAttr; wechatPublicTag: WechatPublicTag.SortAttr;
} | { } | {
@ -187,6 +196,17 @@ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity"
} | { } | {
entity: "userWechatPublicTag"; entity: "userWechatPublicTag";
entityId: String<64>; entityId: String<64>;
} | {
entity?: never;
entityId?: never;
wechatLogin: WechatLogin.CreateSingleOperation;
} | {
entity: "wechatLogin";
entityId: String<64>;
wechatLogin: WechatLogin.UpdateOperation;
} | {
entity: "wechatLogin";
entityId: String<64>;
} | { } | {
entity?: never; entity?: never;
entityId?: never; entityId?: never;
@ -250,6 +270,10 @@ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity"
userWechatPublicTag?: UserWechatPublicTag.CreateSingleOperation | UserWechatPublicTag.UpdateOperation | UserWechatPublicTag.RemoveOperation; userWechatPublicTag?: UserWechatPublicTag.CreateSingleOperation | UserWechatPublicTag.UpdateOperation | UserWechatPublicTag.RemoveOperation;
entityId?: never; entityId?: never;
entity?: never; entity?: never;
} | {
wechatLogin?: WechatLogin.CreateSingleOperation | WechatLogin.UpdateOperation | WechatLogin.RemoveOperation;
entityId?: never;
entity?: never;
} | { } | {
wechatPublicTag?: WechatPublicTag.CreateSingleOperation | WechatPublicTag.UpdateOperation | WechatPublicTag.RemoveOperation; wechatPublicTag?: WechatPublicTag.CreateSingleOperation | WechatPublicTag.UpdateOperation | WechatPublicTag.RemoveOperation;
entityId?: never; entityId?: never;
@ -263,7 +287,7 @@ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity"
entityId?: never; entityId?: never;
entity?: never; entity?: never;
} | { } | {
entity?: ("user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string) | null; entity?: ("user" | "userEntityGrant" | "userSystem" | "userWechatPublicTag" | "wechatLogin" | "wechatPublicTag" | "wechatQrCode" | "wechatUser" | string) | null;
entityId?: String<64> | null; entityId?: String<64> | null;
}) & { }) & {
[k: string]: any; [k: string]: any;
@ -277,6 +301,8 @@ export declare type RemoveOperationData = {} & ({
userSystem?: UserSystem.UpdateOperation | UserSystem.RemoveOperation; userSystem?: UserSystem.UpdateOperation | UserSystem.RemoveOperation;
} | { } | {
userWechatPublicTag?: UserWechatPublicTag.UpdateOperation | UserWechatPublicTag.RemoveOperation; userWechatPublicTag?: UserWechatPublicTag.UpdateOperation | UserWechatPublicTag.RemoveOperation;
} | {
wechatLogin?: WechatLogin.UpdateOperation | WechatLogin.RemoveOperation;
} | { } | {
wechatPublicTag?: WechatPublicTag.UpdateOperation | WechatPublicTag.RemoveOperation; wechatPublicTag?: WechatPublicTag.UpdateOperation | WechatPublicTag.RemoveOperation;
} | { } | {
@ -293,6 +319,7 @@ export declare type UserIdSubQuery = Selection<UserIdProjection>;
export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>; export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>;
export declare type UserSystemIdSubQuery = Selection<UserSystemIdProjection>; export declare type UserSystemIdSubQuery = Selection<UserSystemIdProjection>;
export declare type UserWechatPublicTagIdSubQuery = Selection<UserWechatPublicTagIdProjection>; export declare type UserWechatPublicTagIdSubQuery = Selection<UserWechatPublicTagIdProjection>;
export declare type WechatLoginIdSubQuery = Selection<WechatLoginIdProjection>;
export declare type WechatPublicTagIdSubQuery = Selection<WechatPublicTagIdProjection>; export declare type WechatPublicTagIdSubQuery = Selection<WechatPublicTagIdProjection>;
export declare type WechatQrCodeIdSubQuery = Selection<WechatQrCodeIdProjection>; export declare type WechatQrCodeIdSubQuery = Selection<WechatQrCodeIdProjection>;
export declare type WechatUserIdSubQuery = Selection<WechatUserIdProjection>; export declare type WechatUserIdSubQuery = Selection<WechatUserIdProjection>;

View File

@ -15,7 +15,7 @@ exports.desc = {
params: { params: {
length: 32 length: 32
}, },
ref: ["user", "userEntityGrant", "userSystem", "userWechatPublicTag", "wechatPublicTag", "wechatQrCode", "wechatUser"] ref: ["user", "userEntityGrant", "userSystem", "userWechatPublicTag", "wechatLogin", "wechatPublicTag", "wechatQrCode", "wechatUser"]
}, },
entityId: { entityId: {
notNull: true, notNull: true,

View File

@ -37,9 +37,10 @@ var Storage_33 = require("./System/Storage");
var Storage_34 = require("./Token/Storage"); var Storage_34 = require("./Token/Storage");
var Storage_35 = require("./UserSystem/Storage"); var Storage_35 = require("./UserSystem/Storage");
var Storage_36 = require("./UserWechatPublicTag/Storage"); var Storage_36 = require("./UserWechatPublicTag/Storage");
var Storage_37 = require("./WechatPublicTag/Storage"); var Storage_37 = require("./WechatLogin/Storage");
var Storage_38 = require("./WechatQrCode/Storage"); var Storage_38 = require("./WechatPublicTag/Storage");
var Storage_39 = require("./WechatUser/Storage"); var Storage_39 = require("./WechatQrCode/Storage");
var Storage_40 = require("./WechatUser/Storage");
exports.storageSchema = { exports.storageSchema = {
actionAuth: Storage_1.desc, actionAuth: Storage_1.desc,
modi: Storage_2.desc, modi: Storage_2.desc,
@ -77,7 +78,8 @@ exports.storageSchema = {
token: Storage_34.desc, token: Storage_34.desc,
userSystem: Storage_35.desc, userSystem: Storage_35.desc,
userWechatPublicTag: Storage_36.desc, userWechatPublicTag: Storage_36.desc,
wechatPublicTag: Storage_37.desc, wechatLogin: Storage_37.desc,
wechatQrCode: Storage_38.desc, wechatPublicTag: Storage_38.desc,
wechatUser: Storage_39.desc wechatQrCode: Storage_39.desc,
wechatUser: Storage_40.desc
}; };

View File

@ -15,6 +15,7 @@ import * as Token from "../Token/Schema";
import * as UserEntityGrant from "../UserEntityGrant/Schema"; import * as UserEntityGrant from "../UserEntityGrant/Schema";
import * as UserSystem from "../UserSystem/Schema"; import * as UserSystem from "../UserSystem/Schema";
import * as UserWechatPublicTag from "../UserWechatPublicTag/Schema"; import * as UserWechatPublicTag from "../UserWechatPublicTag/Schema";
import * as WechatLogin from "../WechatLogin/Schema";
import * as WechatUser from "../WechatUser/Schema"; import * as WechatUser from "../WechatUser/Schema";
import * as ModiEntity from "../ModiEntity/Schema"; import * as ModiEntity from "../ModiEntity/Schema";
import * as OperEntity from "../OperEntity/Schema"; import * as OperEntity from "../OperEntity/Schema";
@ -73,6 +74,8 @@ export declare type Schema = EntityShape & {
userSystem$user$$aggr?: AggregationResult<UserSystem.Schema>; userSystem$user$$aggr?: AggregationResult<UserSystem.Schema>;
userWechatPublicTag$user?: Array<UserWechatPublicTag.Schema>; userWechatPublicTag$user?: Array<UserWechatPublicTag.Schema>;
userWechatPublicTag$user$$aggr?: AggregationResult<UserWechatPublicTag.Schema>; userWechatPublicTag$user$$aggr?: AggregationResult<UserWechatPublicTag.Schema>;
wechatLogin$user?: Array<WechatLogin.Schema>;
wechatLogin$user$$aggr?: AggregationResult<WechatLogin.Schema>;
wechatUser$user?: Array<WechatUser.Schema>; wechatUser$user?: Array<WechatUser.Schema>;
wechatUser$user$$aggr?: AggregationResult<WechatUser.Schema>; wechatUser$user$$aggr?: AggregationResult<WechatUser.Schema>;
modiEntity$entity?: Array<ModiEntity.Schema>; modiEntity$entity?: Array<ModiEntity.Schema>;
@ -202,6 +205,12 @@ export declare type Projection = {
userWechatPublicTag$user$$aggr?: UserWechatPublicTag.Aggregation & { userWechatPublicTag$user$$aggr?: UserWechatPublicTag.Aggregation & {
$entity: "userWechatPublicTag"; $entity: "userWechatPublicTag";
}; };
wechatLogin$user?: WechatLogin.Selection & {
$entity: "wechatLogin";
};
wechatLogin$user$$aggr?: WechatLogin.Aggregation & {
$entity: "wechatLogin";
};
wechatUser$user?: WechatUser.Selection & { wechatUser$user?: WechatUser.Selection & {
$entity: "wechatUser"; $entity: "wechatUser";
}; };
@ -302,6 +311,7 @@ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "refId">
userEntityGrant$grantee?: OakOperation<UserEntityGrant.UpdateOperation["action"], Omit<UserEntityGrant.UpdateOperationData, "grantee" | "granteeId">, UserEntityGrant.Filter> | OakOperation<"create", Omit<UserEntityGrant.CreateOperationData, "grantee" | "granteeId">[]> | Array<OakOperation<"create", Omit<UserEntityGrant.CreateOperationData, "grantee" | "granteeId">> | OakOperation<UserEntityGrant.UpdateOperation["action"], Omit<UserEntityGrant.UpdateOperationData, "grantee" | "granteeId">, UserEntityGrant.Filter>>; userEntityGrant$grantee?: OakOperation<UserEntityGrant.UpdateOperation["action"], Omit<UserEntityGrant.UpdateOperationData, "grantee" | "granteeId">, UserEntityGrant.Filter> | OakOperation<"create", Omit<UserEntityGrant.CreateOperationData, "grantee" | "granteeId">[]> | Array<OakOperation<"create", Omit<UserEntityGrant.CreateOperationData, "grantee" | "granteeId">> | OakOperation<UserEntityGrant.UpdateOperation["action"], Omit<UserEntityGrant.UpdateOperationData, "grantee" | "granteeId">, UserEntityGrant.Filter>>;
userSystem$user?: OakOperation<UserSystem.UpdateOperation["action"], Omit<UserSystem.UpdateOperationData, "user" | "userId">, UserSystem.Filter> | OakOperation<"create", Omit<UserSystem.CreateOperationData, "user" | "userId">[]> | Array<OakOperation<"create", Omit<UserSystem.CreateOperationData, "user" | "userId">> | OakOperation<UserSystem.UpdateOperation["action"], Omit<UserSystem.UpdateOperationData, "user" | "userId">, UserSystem.Filter>>; userSystem$user?: OakOperation<UserSystem.UpdateOperation["action"], Omit<UserSystem.UpdateOperationData, "user" | "userId">, UserSystem.Filter> | OakOperation<"create", Omit<UserSystem.CreateOperationData, "user" | "userId">[]> | Array<OakOperation<"create", Omit<UserSystem.CreateOperationData, "user" | "userId">> | OakOperation<UserSystem.UpdateOperation["action"], Omit<UserSystem.UpdateOperationData, "user" | "userId">, UserSystem.Filter>>;
userWechatPublicTag$user?: OakOperation<UserWechatPublicTag.UpdateOperation["action"], Omit<UserWechatPublicTag.UpdateOperationData, "user" | "userId">, UserWechatPublicTag.Filter> | OakOperation<"create", Omit<UserWechatPublicTag.CreateOperationData, "user" | "userId">[]> | Array<OakOperation<"create", Omit<UserWechatPublicTag.CreateOperationData, "user" | "userId">> | OakOperation<UserWechatPublicTag.UpdateOperation["action"], Omit<UserWechatPublicTag.UpdateOperationData, "user" | "userId">, UserWechatPublicTag.Filter>>; userWechatPublicTag$user?: OakOperation<UserWechatPublicTag.UpdateOperation["action"], Omit<UserWechatPublicTag.UpdateOperationData, "user" | "userId">, UserWechatPublicTag.Filter> | OakOperation<"create", Omit<UserWechatPublicTag.CreateOperationData, "user" | "userId">[]> | Array<OakOperation<"create", Omit<UserWechatPublicTag.CreateOperationData, "user" | "userId">> | OakOperation<UserWechatPublicTag.UpdateOperation["action"], Omit<UserWechatPublicTag.UpdateOperationData, "user" | "userId">, UserWechatPublicTag.Filter>>;
wechatLogin$user?: OakOperation<WechatLogin.UpdateOperation["action"], Omit<WechatLogin.UpdateOperationData, "user" | "userId">, WechatLogin.Filter> | OakOperation<"create", Omit<WechatLogin.CreateOperationData, "user" | "userId">[]> | Array<OakOperation<"create", Omit<WechatLogin.CreateOperationData, "user" | "userId">> | OakOperation<WechatLogin.UpdateOperation["action"], Omit<WechatLogin.UpdateOperationData, "user" | "userId">, WechatLogin.Filter>>;
wechatUser$user?: OakOperation<WechatUser.UpdateOperation["action"], Omit<WechatUser.UpdateOperationData, "user" | "userId">, WechatUser.Filter> | OakOperation<"create", Omit<WechatUser.CreateOperationData, "user" | "userId">[]> | Array<OakOperation<"create", Omit<WechatUser.CreateOperationData, "user" | "userId">> | OakOperation<WechatUser.UpdateOperation["action"], Omit<WechatUser.UpdateOperationData, "user" | "userId">, WechatUser.Filter>>; wechatUser$user?: OakOperation<WechatUser.UpdateOperation["action"], Omit<WechatUser.UpdateOperationData, "user" | "userId">, WechatUser.Filter> | OakOperation<"create", Omit<WechatUser.CreateOperationData, "user" | "userId">[]> | Array<OakOperation<"create", Omit<WechatUser.CreateOperationData, "user" | "userId">> | OakOperation<WechatUser.UpdateOperation["action"], Omit<WechatUser.UpdateOperationData, "user" | "userId">, WechatUser.Filter>>;
modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>; modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>; operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
@ -338,6 +348,7 @@ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "refId">
userEntityGrant$grantee?: UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation | OakOperation<"create", Omit<UserEntityGrant.CreateOperationData, "grantee" | "granteeId">[]> | Array<OakOperation<"create", Omit<UserEntityGrant.CreateOperationData, "grantee" | "granteeId">> | UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation>; userEntityGrant$grantee?: UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation | OakOperation<"create", Omit<UserEntityGrant.CreateOperationData, "grantee" | "granteeId">[]> | Array<OakOperation<"create", Omit<UserEntityGrant.CreateOperationData, "grantee" | "granteeId">> | UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation>;
userSystem$user?: UserSystem.UpdateOperation | UserSystem.RemoveOperation | OakOperation<"create", Omit<UserSystem.CreateOperationData, "user" | "userId">[]> | Array<OakOperation<"create", Omit<UserSystem.CreateOperationData, "user" | "userId">> | UserSystem.UpdateOperation | UserSystem.RemoveOperation>; userSystem$user?: UserSystem.UpdateOperation | UserSystem.RemoveOperation | OakOperation<"create", Omit<UserSystem.CreateOperationData, "user" | "userId">[]> | Array<OakOperation<"create", Omit<UserSystem.CreateOperationData, "user" | "userId">> | UserSystem.UpdateOperation | UserSystem.RemoveOperation>;
userWechatPublicTag$user?: UserWechatPublicTag.UpdateOperation | UserWechatPublicTag.RemoveOperation | OakOperation<"create", Omit<UserWechatPublicTag.CreateOperationData, "user" | "userId">[]> | Array<OakOperation<"create", Omit<UserWechatPublicTag.CreateOperationData, "user" | "userId">> | UserWechatPublicTag.UpdateOperation | UserWechatPublicTag.RemoveOperation>; userWechatPublicTag$user?: UserWechatPublicTag.UpdateOperation | UserWechatPublicTag.RemoveOperation | OakOperation<"create", Omit<UserWechatPublicTag.CreateOperationData, "user" | "userId">[]> | Array<OakOperation<"create", Omit<UserWechatPublicTag.CreateOperationData, "user" | "userId">> | UserWechatPublicTag.UpdateOperation | UserWechatPublicTag.RemoveOperation>;
wechatLogin$user?: WechatLogin.UpdateOperation | WechatLogin.RemoveOperation | OakOperation<"create", Omit<WechatLogin.CreateOperationData, "user" | "userId">[]> | Array<OakOperation<"create", Omit<WechatLogin.CreateOperationData, "user" | "userId">> | WechatLogin.UpdateOperation | WechatLogin.RemoveOperation>;
wechatUser$user?: WechatUser.UpdateOperation | WechatUser.RemoveOperation | OakOperation<"create", Omit<WechatUser.CreateOperationData, "user" | "userId">[]> | Array<OakOperation<"create", Omit<WechatUser.CreateOperationData, "user" | "userId">> | WechatUser.UpdateOperation | WechatUser.RemoveOperation>; wechatUser$user?: WechatUser.UpdateOperation | WechatUser.RemoveOperation | OakOperation<"create", Omit<WechatUser.CreateOperationData, "user" | "userId">[]> | Array<OakOperation<"create", Omit<WechatUser.CreateOperationData, "user" | "userId">> | WechatUser.UpdateOperation | WechatUser.RemoveOperation>;
modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>; modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>; operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;

View File

@ -0,0 +1,5 @@
import { GenericAction } from "oak-domain/lib/actions/action";
export declare type ParticularAction = 'success';
export declare type Action = GenericAction | ParticularAction | string;
export declare const actions: string[];
export declare const ActionDefDict: {};

View File

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActionDefDict = exports.actions = void 0;
exports.actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "success"];
exports.ActionDefDict = {};

View File

@ -0,0 +1,186 @@
import { String, Boolean, Text, Datetime, ForeignKey } from "oak-domain/lib/types/DataType";
import { Q_DateValue, Q_BooleanValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand";
import { OneOf } from "oak-domain/lib/types/Polyfill";
import * as SubQuery from "../_SubQuery";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, EntityShape, AggregationResult } from "oak-domain/lib/types/Entity";
import { Action, ParticularAction } from "./Action";
import { QrCodeType } from "../../types/Config";
import * as User from "../User/Schema";
import * as ModiEntity from "../ModiEntity/Schema";
import * as OperEntity from "../OperEntity/Schema";
import * as WechatQrCode from "../WechatQrCode/Schema";
export declare type OpSchema = EntityShape & {
userId?: ForeignKey<"user"> | null;
type: 'bind' | 'login';
successed: Boolean;
remark?: Text | null;
qrCodeType: QrCodeType;
expiresAt?: Datetime | null;
expired?: Boolean | null;
};
export declare type OpAttr = keyof OpSchema;
export declare type Schema = EntityShape & {
userId?: ForeignKey<"user"> | null;
type: 'bind' | 'login';
successed: Boolean;
remark?: Text | null;
qrCodeType: QrCodeType;
expiresAt?: Datetime | null;
expired?: Boolean | null;
user?: User.Schema | null;
modiEntity$entity?: Array<ModiEntity.Schema>;
modiEntity$entity$$aggr?: AggregationResult<ModiEntity.Schema>;
operEntity$entity?: Array<OperEntity.Schema>;
operEntity$entity$$aggr?: AggregationResult<OperEntity.Schema>;
wechatQrCode$entity?: Array<WechatQrCode.Schema>;
wechatQrCode$entity$$aggr?: AggregationResult<WechatQrCode.Schema>;
} & {
[A in ExpressionKey]?: any;
};
declare type AttrFilter = {
id: Q_StringValue | SubQuery.WechatLoginIdSubQuery;
$$createAt$$: Q_DateValue;
$$seq$$: Q_StringValue;
$$updateAt$$: Q_DateValue;
userId: Q_StringValue | SubQuery.UserIdSubQuery;
user: User.Filter;
type: Q_EnumValue<'bind' | 'login'>;
successed: Q_BooleanValue;
remark: Q_StringValue;
qrCodeType: Q_EnumValue<QrCodeType>;
expiresAt: Q_DateValue;
expired: Q_BooleanValue;
};
export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
export declare type Projection = {
"#id"?: NodeId;
[k: string]: any;
id?: number;
$$createAt$$?: number;
$$updateAt$$?: number;
$$seq$$?: number;
userId?: number;
user?: User.Projection;
type?: number;
successed?: number;
remark?: number;
qrCodeType?: number;
expiresAt?: number;
expired?: number;
modiEntity$entity?: ModiEntity.Selection & {
$entity: "modiEntity";
};
modiEntity$entity$$aggr?: ModiEntity.Aggregation & {
$entity: "modiEntity";
};
operEntity$entity?: OperEntity.Selection & {
$entity: "operEntity";
};
operEntity$entity$$aggr?: OperEntity.Aggregation & {
$entity: "operEntity";
};
wechatQrCode$entity?: WechatQrCode.Selection & {
$entity: "wechatQrCode";
};
wechatQrCode$entity$$aggr?: WechatQrCode.Aggregation & {
$entity: "wechatQrCode";
};
} & Partial<ExprOp<OpAttr | string>>;
declare type WechatLoginIdProjection = OneOf<{
id: number;
}>;
declare type UserIdProjection = OneOf<{
userId: number;
}>;
export declare type SortAttr = {
id: number;
} | {
$$createAt$$: number;
} | {
$$seq$$: number;
} | {
$$updateAt$$: number;
} | {
userId: number;
} | {
user: User.SortAttr;
} | {
type: number;
} | {
successed: number;
} | {
remark: number;
} | {
qrCodeType: number;
} | {
expiresAt: number;
} | {
expired: number;
} | {
[k: string]: any;
} | OneOf<ExprOp<OpAttr | string>>;
export declare type SortNode = {
$attr: SortAttr;
$direction?: "asc" | "desc";
};
export declare type Sorter = SortNode[];
export declare type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
export declare type Selection<P extends Object = Projection> = Omit<SelectOperation<P>, "action">;
export declare type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "userId">> & (({
userId?: never;
user?: User.CreateSingleOperation;
} | {
userId: String<64>;
user?: User.UpdateOperation;
} | {
userId?: String<64>;
})) & {
modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
wechatQrCode$entity?: OakOperation<WechatQrCode.UpdateOperation["action"], Omit<WechatQrCode.UpdateOperationData, "entity" | "entityId">, WechatQrCode.Filter> | OakOperation<"create", Omit<WechatQrCode.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<WechatQrCode.CreateOperationData, "entity" | "entityId">> | OakOperation<WechatQrCode.UpdateOperation["action"], Omit<WechatQrCode.UpdateOperationData, "entity" | "entityId">, WechatQrCode.Filter>>;
};
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "userId">> & (({
user: User.CreateSingleOperation;
userId?: never;
} | {
user: User.UpdateOperation;
userId?: never;
} | {
user: User.RemoveOperation;
userId?: never;
} | {
user?: never;
userId?: String<64> | null;
})) & {
[k: string]: any;
modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
wechatQrCode$entity?: WechatQrCode.UpdateOperation | WechatQrCode.RemoveOperation | OakOperation<"create", Omit<WechatQrCode.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<WechatQrCode.CreateOperationData, "entity" | "entityId">> | WechatQrCode.UpdateOperation | WechatQrCode.RemoveOperation>;
};
export declare type UpdateOperation = OakOperation<"update" | ParticularAction | string, UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {} & (({
user?: User.UpdateOperation | User.RemoveOperation;
}));
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation;
export declare type UserIdSubQuery = Selection<UserIdProjection>;
export declare type WechatLoginIdSubQuery = Selection<WechatLoginIdProjection>;
export declare type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: OakMakeAction<Action> | string;
Selection: Selection;
Aggregation: Aggregation;
Operation: Operation;
Create: CreateOperation;
Update: UpdateOperation;
Remove: RemoveOperation;
CreateSingle: CreateSingleOperation;
CreateMulti: CreateMultipleOperation;
ParticularAction: ParticularAction;
};
export {};

View File

@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@ -0,0 +1,3 @@
import { StorageDesc } from "oak-domain/lib/types/Storage";
import { OpSchema } from "./Schema";
export declare const desc: StorageDesc<OpSchema>;

View File

@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.desc = void 0;
var Action_1 = require("./Action");
exports.desc = {
attributes: {
userId: {
type: "ref",
ref: "user"
},
type: {
notNull: true,
type: "enum",
enumeration: ["bind", "login"]
},
successed: {
notNull: true,
type: "boolean"
},
remark: {
type: "text"
},
qrCodeType: {
notNull: true,
type: "enum",
enumeration: ["wechatMpDomainUrl", "wechatMpWxaCode", "wechatPublic", "wechatPublicForMp", "webForWechatPublic"]
},
expiresAt: {
type: "datetime"
},
expired: {
type: "boolean"
}
},
actionType: "crud",
actions: Action_1.actions,
indexes: [
{
name: 'index_uuid',
attributes: [
{
name: 'expired'
},
{
name: 'expiresAt'
}
]
}
]
};

View File

@ -0,0 +1 @@
{ "name": "绑定微信号", "attr": { "user": "用户", "type": "类型", "successed": "是否成功", "remark": "备注", "codes": "微信码", "expired": "是否过期", "expiresAt": "过期时间", "qrCodeType": "二维码类型" }, "action": { "success": "成功" }, "v": { "type": { "bind": "绑定", "login": "登录" }, "qrCodeType": { "webForWechatPublic": "网站引流到公众号", "wechatMpDomainUrl": "小程序url码", "wechatMpWxaCode": "小程序码", "wechatPublic": "公众号关注码", "wechatPublicForMp": "公众号跳转小程序码" } } }

View File

@ -8,6 +8,7 @@ import { QrCodeType } from "../../types/Config";
import * as Application from "../Application/Schema"; import * as Application from "../Application/Schema";
import * as User from "../User/Schema"; import * as User from "../User/Schema";
import * as UserEntityGrant from "../UserEntityGrant/Schema"; import * as UserEntityGrant from "../UserEntityGrant/Schema";
import * as WechatLogin from "../WechatLogin/Schema";
import * as ModiEntity from "../ModiEntity/Schema"; import * as ModiEntity from "../ModiEntity/Schema";
import * as OperEntity from "../OperEntity/Schema"; import * as OperEntity from "../OperEntity/Schema";
export declare type WechatQrCodeProps = { export declare type WechatQrCodeProps = {
@ -17,7 +18,7 @@ export declare type WechatQrCodeProps = {
isTabBar?: boolean; isTabBar?: boolean;
}; };
export declare type OpSchema = EntityShape & { export declare type OpSchema = EntityShape & {
entity: "user" | "userEntityGrant" | string; entity: "user" | "userEntityGrant" | "wechatLogin" | string;
entityId: String<64>; entityId: String<64>;
type: QrCodeType; type: QrCodeType;
allowShare: Boolean; allowShare: Boolean;
@ -34,7 +35,7 @@ export declare type OpSchema = EntityShape & {
}; };
export declare type OpAttr = keyof OpSchema; export declare type OpAttr = keyof OpSchema;
export declare type Schema = EntityShape & { export declare type Schema = EntityShape & {
entity: "user" | "userEntityGrant" | string; entity: "user" | "userEntityGrant" | "wechatLogin" | string;
entityId: String<64>; entityId: String<64>;
type: QrCodeType; type: QrCodeType;
allowShare: Boolean; allowShare: Boolean;
@ -51,6 +52,7 @@ export declare type Schema = EntityShape & {
application: Application.Schema; application: Application.Schema;
user?: User.Schema; user?: User.Schema;
userEntityGrant?: UserEntityGrant.Schema; userEntityGrant?: UserEntityGrant.Schema;
wechatLogin?: WechatLogin.Schema;
modiEntity$entity?: Array<ModiEntity.Schema>; modiEntity$entity?: Array<ModiEntity.Schema>;
modiEntity$entity$$aggr?: AggregationResult<ModiEntity.Schema>; modiEntity$entity$$aggr?: AggregationResult<ModiEntity.Schema>;
operEntity$entity?: Array<OperEntity.Schema>; operEntity$entity?: Array<OperEntity.Schema>;
@ -80,8 +82,9 @@ declare type AttrFilter<E> = {
props: Q_EnumValue<WechatQrCodeProps>; props: Q_EnumValue<WechatQrCodeProps>;
user: User.Filter; user: User.Filter;
userEntityGrant: UserEntityGrant.Filter; userEntityGrant: UserEntityGrant.Filter;
wechatLogin: WechatLogin.Filter;
}; };
export declare type Filter<E = Q_EnumValue<"user" | "userEntityGrant" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>; export declare type Filter<E = Q_EnumValue<"user" | "userEntityGrant" | "wechatLogin" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
export declare type Projection = { export declare type Projection = {
"#id"?: NodeId; "#id"?: NodeId;
[k: string]: any; [k: string]: any;
@ -106,6 +109,7 @@ export declare type Projection = {
props?: number; props?: number;
user?: User.Projection; user?: User.Projection;
userEntityGrant?: UserEntityGrant.Projection; userEntityGrant?: UserEntityGrant.Projection;
wechatLogin?: WechatLogin.Projection;
modiEntity$entity?: ModiEntity.Selection & { modiEntity$entity?: ModiEntity.Selection & {
$entity: "modiEntity"; $entity: "modiEntity";
}; };
@ -131,6 +135,9 @@ declare type UserIdProjection = OneOf<{
declare type UserEntityGrantIdProjection = OneOf<{ declare type UserEntityGrantIdProjection = OneOf<{
entityId: number; entityId: number;
}>; }>;
declare type WechatLoginIdProjection = OneOf<{
entityId: number;
}>;
export declare type SortAttr = { export declare type SortAttr = {
id: number; id: number;
} | { } | {
@ -173,6 +180,8 @@ export declare type SortAttr = {
user: User.SortAttr; user: User.SortAttr;
} | { } | {
userEntityGrant: UserEntityGrant.SortAttr; userEntityGrant: UserEntityGrant.SortAttr;
} | {
wechatLogin: WechatLogin.SortAttr;
} | { } | {
[k: string]: any; [k: string]: any;
} | OneOf<ExprOp<OpAttr | string>>; } | OneOf<ExprOp<OpAttr | string>>;
@ -214,6 +223,17 @@ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity"
} | { } | {
entity: "userEntityGrant"; entity: "userEntityGrant";
entityId: String<64>; entityId: String<64>;
} | {
entity?: never;
entityId?: never;
wechatLogin: WechatLogin.CreateSingleOperation;
} | {
entity: "wechatLogin";
entityId: String<64>;
wechatLogin: WechatLogin.UpdateOperation;
} | {
entity: "wechatLogin";
entityId: String<64>;
} | { } | {
entity?: string; entity?: string;
entityId?: string; entityId?: string;
@ -246,7 +266,11 @@ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity"
entityId?: never; entityId?: never;
entity?: never; entity?: never;
} | { } | {
entity?: ("user" | "userEntityGrant" | string) | null; wechatLogin?: WechatLogin.CreateSingleOperation | WechatLogin.UpdateOperation | WechatLogin.RemoveOperation;
entityId?: never;
entity?: never;
} | {
entity?: ("user" | "userEntityGrant" | "wechatLogin" | string) | null;
entityId?: String<64> | null; entityId?: String<64> | null;
}) & { }) & {
[k: string]: any; [k: string]: any;
@ -260,6 +284,8 @@ export declare type RemoveOperationData = {} & (({
user?: User.UpdateOperation | User.RemoveOperation; user?: User.UpdateOperation | User.RemoveOperation;
} | { } | {
userEntityGrant?: UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation; userEntityGrant?: UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation;
} | {
wechatLogin?: WechatLogin.UpdateOperation | WechatLogin.RemoveOperation;
} | { } | {
[k: string]: any; [k: string]: any;
}); });
@ -268,6 +294,7 @@ export declare type Operation = CreateOperation | UpdateOperation | RemoveOperat
export declare type ApplicationIdSubQuery = Selection<ApplicationIdProjection>; export declare type ApplicationIdSubQuery = Selection<ApplicationIdProjection>;
export declare type UserIdSubQuery = Selection<UserIdProjection>; export declare type UserIdSubQuery = Selection<UserIdProjection>;
export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>; export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>;
export declare type WechatLoginIdSubQuery = Selection<WechatLoginIdProjection>;
export declare type WechatQrCodeIdSubQuery = Selection<WechatQrCodeIdProjection>; export declare type WechatQrCodeIdSubQuery = Selection<WechatQrCodeIdProjection>;
export declare type EntityDef = { export declare type EntityDef = {
Schema: Schema; Schema: Schema;

View File

@ -10,7 +10,7 @@ exports.desc = {
params: { params: {
length: 32 length: 32
}, },
ref: ["user", "userEntityGrant"] ref: ["user", "userEntityGrant", "wechatLogin"]
}, },
entityId: { entityId: {
notNull: true, notNull: true,

View File

@ -34,6 +34,7 @@ import * as System from "./System/Schema";
import * as Token from "./Token/Schema"; import * as Token from "./Token/Schema";
import * as UserSystem from "./UserSystem/Schema"; import * as UserSystem from "./UserSystem/Schema";
import * as UserWechatPublicTag from "./UserWechatPublicTag/Schema"; import * as UserWechatPublicTag from "./UserWechatPublicTag/Schema";
import * as WechatLogin from "./WechatLogin/Schema";
import * as WechatPublicTag from "./WechatPublicTag/Schema"; import * as WechatPublicTag from "./WechatPublicTag/Schema";
import * as WechatQrCode from "./WechatQrCode/Schema"; import * as WechatQrCode from "./WechatQrCode/Schema";
import * as WechatUser from "./WechatUser/Schema"; import * as WechatUser from "./WechatUser/Schema";
@ -105,6 +106,8 @@ export declare type UserIdSubQuery = {
entity: "userSystem"; entity: "userSystem";
}) | (UserWechatPublicTag.UserIdSubQuery & { }) | (UserWechatPublicTag.UserIdSubQuery & {
entity: "userWechatPublicTag"; entity: "userWechatPublicTag";
}) | (WechatLogin.UserIdSubQuery & {
entity: "wechatLogin";
}) | (WechatUser.UserIdSubQuery & { }) | (WechatUser.UserIdSubQuery & {
entity: "wechatUser"; entity: "wechatUser";
}) | (User.UserIdSubQuery & { }) | (User.UserIdSubQuery & {
@ -291,6 +294,11 @@ export declare type UserWechatPublicTagIdSubQuery = {
entity: "userWechatPublicTag"; entity: "userWechatPublicTag";
}) | any; }) | any;
}; };
export declare type WechatLoginIdSubQuery = {
[K in "$in" | "$nin"]?: (WechatLogin.WechatLoginIdSubQuery & {
entity: "wechatLogin";
}) | any;
};
export declare type WechatPublicTagIdSubQuery = { export declare type WechatPublicTagIdSubQuery = {
[K in "$in" | "$nin"]?: (UserWechatPublicTag.WechatPublicTagIdSubQuery & { [K in "$in" | "$nin"]?: (UserWechatPublicTag.WechatPublicTagIdSubQuery & {
entity: "userWechatPublicTag"; entity: "userWechatPublicTag";

View File

@ -0,0 +1,118 @@
import { EntityDict } from '../../../general-app-domain';
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
const Interval = 2 * 60 * 1000;
export default OakComponent({
isList: false,
lifetimes: {
async attached() {
this.createWechatLogin();
(this as any).createTimer = setInterval(() => {
this.createWechatLogin();
}, Interval);
},
async detached() {
if ((this as any).createTimer) {
clearInterval((this as any).createTimer);
}
},
},
methods: {
async createWechatLogin() {
const userId = this.features.token.getUserId();
const wechatLoginId = await generateNewIdAsync();
await this.features.cache.operate('wechatLogin', {
id: await generateNewIdAsync(),
action: 'create',
data: {
id: wechatLoginId,
userId,
type: 'bind',
expiresAt: Date.now() + Interval,
expired: false,
qrCodeType: 'wechatPublic',
successed: false,
} as EntityDict['wechatLogin']['CreateSingle']['data'],
});
this.setState(
{
wechatLoginId,
},
() => {
this.getWechatLogin();
}
);
},
async getWechatLogin() {
const { wechatLoginId } = this.state;
const {
data: [wechatLogin],
} = await this.features.cache.refresh('wechatLogin', {
data: {
id: 1,
userId: 1,
type: 1,
qrCodeType: 1,
remark: 1,
expired: 1,
expiresAt: 1,
successed: 1,
wechatQrCode$entity: {
$entity: 'wechatQrCode',
data: {
id: 1,
entity: 1,
entityId: 1,
type: 1, //类型
ticket: 1,
url: 1,
buffer: 1,
expired: 1,
expiresAt: 1,
applicationId: 1,
},
filter: {
entity: 'userEntityGrant',
},
indexFrom: 0,
count: 1,
},
},
filter: {
id: wechatLoginId,
},
});
let qrCodeUrl = wechatLogin?.wechatQrCode$entity![0]?.url;
const buffer = wechatLogin?.wechatQrCode$entity![0]?.buffer;
if (buffer) {
const newBuffer = new ArrayBuffer(buffer.length * 2);
const newBufferToUint16 = new Uint16Array(newBuffer);
for (let i = 0; i < buffer.length; i++) {
newBufferToUint16[i] = buffer.charCodeAt(i);
}
if (process.env.OAK_PLATFORM === 'wechatMp') {
const base64Str = wx.arrayBufferToBase64(newBufferToUint16);
qrCodeUrl = 'data:image/png;base64,' + base64Str;
} else {
let binary = '';
const bytes = new Uint8Array(newBufferToUint16);
const len = bytes.byteLength;
for (let i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
const base64Str = window.btoa(binary);
// const buffer2 = Buffer.from(newBufferToUint16, 'base64');
// const base64Str = buffer2.toString('base64');
qrCodeUrl = 'data:image/png;base64,' + base64Str;
}
}
this.setState({
qrCodeUrl,
});
},
},
});

View File

@ -0,0 +1,3 @@
.container {
display: flex;
}

View File

@ -0,0 +1,28 @@
import React from 'react';
import QrCode from '../../../components/common/qrCode';
import { EntityDict } from '../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
import Style from './web.module.less';
export default function Render(
props: WebComponentProps<
EntityDict,
'wechatLogin',
true,
{
wechatLoginId: string;
qrCodeUrl: string;
},
{}
>
) {
const { oakFullpath, wechatLoginId, qrCodeUrl } = props.data;
return (
<div>
<QrCode url={qrCodeUrl} />
</div>
);
}

View File

@ -0,0 +1,74 @@
import { String, Text, Datetime, Int } from 'oak-domain/lib/types/DataType';
import { EntityShape } from 'oak-domain/lib/types/Entity';
import { LocaleDef } from 'oak-domain/lib/types/Locale';
import { Index } from 'oak-domain/lib/types/Storage';
import { Schema as User } from './User';
import { Schema as WechatQrCode } from './WechatQrCode';
import { QrCodeType } from '../types/Config';
export interface Schema extends EntityShape {
user?: User;
type: 'bind' | 'login';
successed: Boolean;
remark?: Text;
qrCodeType: QrCodeType;
expiresAt?: Datetime;
expired?: Boolean;
codes: Array<WechatQrCode>;
}
type Action = 'success';
const indexes: Index<Schema>[] = [
{
name: 'index_uuid',
attributes: [
{
name: 'expired',
},
{
name: 'expiresAt',
}
],
},
];
const locale: LocaleDef<
Schema,
Action,
'',
{
type: Schema['type'];
qrCodeType: QrCodeType;
}
> = {
zh_CN: {
name: '绑定微信号',
attr: {
user: '用户',
type: '类型',
successed: '是否成功',
remark: '备注',
codes: '微信码',
expired: '是否过期',
expiresAt: '过期时间',
qrCodeType: '二维码类型',
},
action: {
success: '成功',
},
v: {
type: {
bind: '绑定',
login: '登录',
},
qrCodeType: {
webForWechatPublic: '网站引流到公众号',
wechatMpDomainUrl: '小程序url码',
wechatMpWxaCode: '小程序码',
wechatPublic: '公众号关注码',
wechatPublicForMp: '公众号跳转小程序码',
},
},
},
};

View File

@ -1,5 +1,5 @@
{ {
"navigationBarTitleText": "修改个人信息", "navigationBarTitleText": "个人设置",
"oakDisablePulldownRefresh": true, "oakDisablePulldownRefresh": true,
"usingComponents": { "usingComponents": {
"l-button": "@oak-frontend-base/miniprogram_npm/lin-ui/button/index", "l-button": "@oak-frontend-base/miniprogram_npm/lin-ui/button/index",

View File

@ -44,10 +44,8 @@ export default OakComponent({
}, },
], ],
formData({ data }) { formData({ data }) {
const pagination = this.getPagination();
return { return {
list: data, list: data,
pagination,
}; };
}, },
data: { data: {

View File

@ -1,10 +1,9 @@
import * as React from 'react'; import * as React from 'react';
import { Table, Button, Space, Typography, Modal } from 'antd'; import { Table, Space, Typography } from 'antd';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { WebComponentProps } from 'oak-frontend-base';
import PageHeader from '../../../components/common/pageHeader'; import PageHeader from '../../../components/common/pageHeader';
import { EntityDict } from '../../../general-app-domain'; import { EntityDict } from '../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
import Style from './web.module.less'; import Style from './web.module.less';
export default function render( export default function render(
@ -23,15 +22,15 @@ export default function render(
> >
) { ) {
const { const {
pagination, oakPagination,
oakFullpath,
list = [], list = [],
oakLoading, oakLoading,
showBack, showBack,
variant, variant,
oakFullpath,
} = props.data; } = props.data;
const { pageSize, total, currentPage } = pagination || {}; const { pageSize, total, currentPage } = oakPagination || {};
const { t, setPageSize, setCurrentPage } = props.methods; const { t, setPageSize, setCurrentPage } = props.methods;

View File

@ -4,6 +4,7 @@ import userEntityGrantTriggers from './userEntityGrant';
import wechatQrCodeTriggers from './wechatQrCode'; import wechatQrCodeTriggers from './wechatQrCode';
import messageTriggers from './message'; import messageTriggers from './message';
import notificationTriggers from './notification'; import notificationTriggers from './notification';
import wechatLoginTriggers from './wechatLogin';
export default [ export default [
...addressTriggers, ...addressTriggers,
@ -12,4 +13,5 @@ export default [
...wechatQrCodeTriggers, ...wechatQrCodeTriggers,
...messageTriggers, ...messageTriggers,
...notificationTriggers, ...notificationTriggers,
...wechatLoginTriggers,
]; ];

View File

@ -5,13 +5,8 @@ import { EntityDict } from '../general-app-domain/EntityDict';
import { OakRowInconsistencyException, OakExternalException, SelectOpResult } from 'oak-domain/lib/types'; import { OakRowInconsistencyException, OakExternalException, SelectOpResult } from 'oak-domain/lib/types';
import { assert } from 'oak-domain/lib/utils/assert'; import { assert } from 'oak-domain/lib/utils/assert';
import {
createWechatQrCode,
getMpUnlimitWxaCode,
} from '../aspects/wechatQrCode';
import { firstLetterUpperCase } from 'oak-domain/lib/utils/string'; import { firstLetterUpperCase } from 'oak-domain/lib/utils/string';
import { RuntimeCxt } from '../types/RuntimeCxt'; import { RuntimeCxt } from '../types/RuntimeCxt';
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
const triggers: Trigger<EntityDict, 'userEntityGrant', RuntimeCxt>[] = [ const triggers: Trigger<EntityDict, 'userEntityGrant', RuntimeCxt>[] = [
{ {
@ -58,20 +53,6 @@ const triggers: Trigger<EntityDict, 'userEntityGrant', RuntimeCxt>[] = [
}, },
{} {}
); );
// await createWechatQrCode(
// {
// entity: 'userEntityGrant',
// entityId: id,
// props: {
// pathname: '/userEntityGrant/confirm',
// props: {
// oakId: id,
// },
// },
// type: userEntityGrantData.qrCodeType,
// },
// context as BackendRuntimeContext<EntityDict>
// );
}; };
if (data instanceof Array) { if (data instanceof Array) {
assert('授权不存在一对多的情况'); assert('授权不存在一对多的情况');
@ -265,44 +246,5 @@ const triggers: Trigger<EntityDict, 'userEntityGrant', RuntimeCxt>[] = [
return 1; return 1;
}, },
} as UpdateTrigger<EntityDict, 'userEntityGrant', RuntimeCxt>, } as UpdateTrigger<EntityDict, 'userEntityGrant', RuntimeCxt>,
// {
// name: '当userEntityGrant查询时使其相关的wechatQrCode动态生成buffer',
// entity: 'userEntityGrant',
// action: 'select',
// when: 'after',
// fn: async ({ operation, result }, context) => {
// if (operation?.data?.wechatQrCode$entity?.data?.buffer) {
// //如果projection写buffer 就动态获取,临时性代码
// for (let userEntityGrant of result) {
// if (userEntityGrant.qrCodeType === 'wechatMpWxaCode') {
// const wechatQrCode =
// userEntityGrant.wechatQrCode$entity &&
// userEntityGrant.wechatQrCode$entity[0];
// if (wechatQrCode) {
// const { id } = wechatQrCode;
// const backContext = context as BackendRuntimeContext<EntityDict>;
// const buffer = await getMpUnlimitWxaCode(
// wechatQrCode.id,
// backContext,
// );
// backContext.opRecords.forEach(
// ele => {
// if (ele.a === 's') {
// const { d } = ele as SelectOpResult<EntityDict>;
// if (d.wechatQrCode && d.wechatQrCode[id]) {
// Object.assign(d.wechatQrCode[id], {
// buffer,
// });
// }
// }
// }
// )
// }
// }
// }
// }
// return 1;
// },
// } as SelectTrigger<EntityDict, 'userEntityGrant', RuntimeCxt>,
]; ];
export default triggers; export default triggers;

View File

@ -0,0 +1,83 @@
import { generateNewId, generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
import { Trigger, CreateTrigger, UpdateTrigger, SelectTrigger } from 'oak-domain/lib/types/Trigger';
import { CreateOperationData as CreateWechatLoginData } from '../general-app-domain/WechatLogin/Schema';
import { EntityDict } from '../general-app-domain/EntityDict';
import { OakRowInconsistencyException, OakExternalException, SelectOpResult } from 'oak-domain/lib/types';
import { assert } from 'oak-domain/lib/utils/assert';
import { firstLetterUpperCase } from 'oak-domain/lib/utils/string';
import { RuntimeCxt } from '../types/RuntimeCxt';
const triggers: Trigger<EntityDict, 'wechatLogin', RuntimeCxt>[] = [
{
name: '当创建wechatLogin时尝试为之创建一个wechatQrCode',
entity: 'wechatLogin',
action: 'create',
when: 'before',
fn: async ({ operation }, context, params) => {
const { data, filter } = operation;
const fn = async (wechatLoginData: CreateWechatLoginData) => {
const { id } = wechatLoginData;
Object.assign(wechatLoginData, {
expired: false,
successed: false,
});
if (!wechatLoginData.expiresAt) {
Object.assign(wechatLoginData, {
expiresAt: Date.now() + 2 * 60 * 1000,
});
}
// 为之创建微信体系下的一个weChatQrCode
await context.operate(
'wechatQrCode',
{
id: await generateNewIdAsync(),
action: 'create',
data: {
id: await generateNewIdAsync(),
entity: 'wechatLogin',
entityId: id,
props: {
pathname: '/wechatLogin/confirm',
props: {
oakId: id,
},
},
type: wechatLoginData.qrCodeType,
},
},
{}
);
};
if (data instanceof Array) {
assert('授权不存在一对多的情况');
} else {
await fn(data);
}
return 0;
},
} as CreateTrigger<EntityDict, 'wechatLogin', RuntimeCxt>,
{
name: '当wechatLogin过期时使其相关的wechatQrCode也过期',
entity: 'wechatLogin',
action: 'update',
check: (operation) => {
const { data } = operation;
return !!data.expired;
},
when: 'before',
fn: async ({ operation }, context) => {
const { data } = operation;
data.wechatQrCode$entity = {
id: await generateNewIdAsync(),
action: 'update',
data: {
expired: true,
},
};
return 1;
},
} as UpdateTrigger<EntityDict, 'wechatLogin', RuntimeCxt>,
];
export default triggers;

View File

@ -12,57 +12,6 @@ import { Config as SysConfig, QrCodeType } from '../types/Config';
const triggers: Trigger<EntityDict, 'wechatQrCode', RuntimeCxt>[] = [ const triggers: Trigger<EntityDict, 'wechatQrCode', RuntimeCxt>[] = [
/* {
name: '选择wechatQrCode时动态生成需要的数据',
entity: 'wechatQrCode',
action: 'select',
when: 'after',
fn: async ({ result }, context, params) => {
let count = 0;
const application = await context.getApplication();
const { type: appType, config } = application!;
if (appType !== 'wechatMp' && config!.type !== 'wechatMp') {
} else {
assert(appType === 'wechatMp' || config!.type === 'wechatMp');
const config2 = config as WechatMpConfig;
const { appId, appSecret } = config2;
for (const code of result) {
const { type, expired, id } = code;
if (
type === 'wechatMpWxaCode' &&
code.hasOwnProperty('buffer')
) {
// 小程序码去实时获取(暂时不考虑缓存)
const wechatInstance = WechatSDK.getInstance(
appId,
'wechatMp',
appSecret
) as WechatMpInstance;
const buffer = await wechatInstance.getMpUnlimitWxaCode(
{
scene: shrinkUuidTo32Bytes(id!),
page: 'pages/index/index', // todo这里用其它的页面微信服务器拒绝因为没发布。应该是 pages/wechatQrCode/scan/index
}
);
// 把arrayBuffer转成字符串返回
const str = String.fromCharCode(
...new Uint8Array(buffer)
);
Object.assign(code, {
buffer: str,
});
count++;
} else if (expired && code.hasOwnProperty('url')) {
// 如果过期了,在这里生成新的临时码并修改值(公众号)
throw new Error('not implemented yet');
}
}
}
return count;
}
} as SelectTriggerAfter<EntityDict, 'wechatQrCode', RuntimeCxt>, */
{ {
name: '当生成wechatQrCode时,调用外部接口完善数据', name: '当生成wechatQrCode时,调用外部接口完善数据',
entity: 'wechatQrCode', entity: 'wechatQrCode',
@ -324,20 +273,6 @@ const triggers: Trigger<EntityDict, 'wechatQrCode', RuntimeCxt>[] = [
Object.assign( Object.assign(
wechatQrCode, updateData, wechatQrCode, updateData,
) )
// await context.operate(
// 'wechatQrCode',
// {
// id: await generateNewIdAsync(),
// action: 'update',
// data: updateData,
// filter: {
// id,
// }
// },
// {
// dontCollect: true,
// }
// );
} }
if (data instanceof Array) { if (data instanceof Array) {
for (const ele of data) { for (const ele of data) {