Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-domain into dev
This commit is contained in:
commit
c7fa64cbfe
|
|
@ -1123,7 +1123,8 @@ function constructFilter(statements, entity) {
|
|||
case 'Int':
|
||||
case 'Uint':
|
||||
case 'Float':
|
||||
case 'Double': {
|
||||
case 'Double':
|
||||
case 'Price': {
|
||||
type2 = factory.createTypeReferenceNode(factory.createIdentifier('Q_NumberValue'));
|
||||
break;
|
||||
}
|
||||
|
|
@ -1276,7 +1277,8 @@ function constructProjection(statements, entity) {
|
|||
case 'File':
|
||||
case 'SingleGeo':
|
||||
case 'Geo':
|
||||
case 'Object': {
|
||||
case 'Object':
|
||||
case 'Price': {
|
||||
properties.push([name_4, false]);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1639,7 +1641,8 @@ function constructSorter(statements, entity) {
|
|||
case 'Boolean':
|
||||
case 'Datetime':
|
||||
case 'Image':
|
||||
case 'File': {
|
||||
case 'File':
|
||||
case 'Price': {
|
||||
type2 = factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword);
|
||||
break;
|
||||
}
|
||||
|
|
@ -2658,6 +2661,7 @@ var initialStatements = function () { return [
|
|||
factory.createImportSpecifier(false, undefined, factory.createIdentifier('Text')),
|
||||
factory.createImportSpecifier(false, undefined, factory.createIdentifier('Datetime')),
|
||||
factory.createImportSpecifier(false, undefined, factory.createIdentifier('File')),
|
||||
factory.createImportSpecifier(false, undefined, factory.createIdentifier('Price')),
|
||||
factory.createImportSpecifier(false, undefined, factory.createIdentifier('Image')),
|
||||
factory.createImportSpecifier(false, undefined, factory.createIdentifier('PrimaryKey')),
|
||||
factory.createImportSpecifier(false, undefined, factory.createIdentifier('ForeignKey')),
|
||||
|
|
@ -2952,6 +2956,10 @@ function constructAttributes(entity) {
|
|||
attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("boolean")));
|
||||
break;
|
||||
}
|
||||
case 'Price': {
|
||||
attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("money")));
|
||||
break;
|
||||
}
|
||||
case 'Datetime': {
|
||||
attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("datetime")));
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ var indexes = [
|
|||
];
|
||||
var locale = {
|
||||
zh_CN: {
|
||||
name: '更新',
|
||||
attr: {
|
||||
targetEntity: '目标对象',
|
||||
entity: '关联对象',
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ var config = {
|
|||
};
|
||||
var locale = {
|
||||
zh_CN: {
|
||||
name: '更新对象连接',
|
||||
attr: {
|
||||
modi: '更新',
|
||||
entity: '关联对象',
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ var configuration = {
|
|||
};
|
||||
var locale = {
|
||||
zh_CN: {
|
||||
name: '操作',
|
||||
attr: {
|
||||
action: '动作',
|
||||
data: '数据',
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ var config = {
|
|||
};
|
||||
var locale = {
|
||||
zh_CN: {
|
||||
name: '操作对象连接',
|
||||
attr: {
|
||||
oper: '操作',
|
||||
entity: '关联对象',
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ var UserActionDef = {
|
|||
};
|
||||
var locale = {
|
||||
zh_CN: {
|
||||
name: '用户',
|
||||
attr: {
|
||||
name: '姓名',
|
||||
nickname: '昵称',
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
;
|
||||
var locale = {
|
||||
zh_CN: {
|
||||
name: '用户授权',
|
||||
attr: {
|
||||
relation: '关系',
|
||||
entity: '关联对象',
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ export declare type Image = string;
|
|||
export declare type File = string;
|
||||
export declare type Datetime = number | Date;
|
||||
export declare type Boolean = boolean;
|
||||
export declare type Price = number;
|
||||
export declare type PrimaryKey = string;
|
||||
export declare type ForeignKey<E extends string> = string;
|
||||
export declare type Sequence = string;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.unIndexedTypes = exports.types = void 0;
|
||||
exports.types = ['Int', 'Uint', 'Double', 'Float', 'String', 'Text', 'Datetime', 'Boolean', 'Image', 'File', 'Geo', 'SingleGeo'];
|
||||
exports.types = ['Int', 'Uint', 'Double', 'Float', 'String', 'Text', 'Datetime', 'Boolean', 'Image', 'File', 'Geo', 'SingleGeo', 'Price'];
|
||||
exports.unIndexedTypes = ['Text', 'Image', 'File', 'Object'];
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ declare type LocaleOfValue<V extends Record<string, string>> = {
|
|||
};
|
||||
export declare type LocaleDef<Sc extends Record<string, any>, Ac extends string, R extends string, V extends Record<string, string>> = {
|
||||
[L in Language]?: {
|
||||
name: string;
|
||||
attr: LocaleOfSchema<Sc> & {
|
||||
[A in keyof V]: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { RecurrenceRule, RecurrenceSpecDateRange, RecurrenceSpecObjLit } from 'node-schedule';
|
||||
import { EntityDict } from './Entity';
|
||||
import { AsyncContext } from "../store/AsyncRowStore";
|
||||
import { AsyncContext } from '../store/AsyncRowStore';
|
||||
declare type RoutineFn<ED extends EntityDict, Cxt extends AsyncContext<ED>> = (context: Cxt) => Promise<string>;
|
||||
export declare type Routine<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
|
||||
name: string;
|
||||
|
|
@ -7,7 +8,7 @@ export declare type Routine<ED extends EntityDict, Cxt extends AsyncContext<ED>>
|
|||
};
|
||||
export declare type Timer<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
|
||||
name: string;
|
||||
cron: string;
|
||||
cron: RecurrenceRule | RecurrenceSpecDateRange | RecurrenceSpecObjLit | Date | string | number;
|
||||
fn: RoutineFn<ED, Cxt>;
|
||||
};
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
export declare function schedule(cron: string, fn: (date: Date) => any): void;
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.schedule = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
var cronjs_matcher_1 = require("@datasert/cronjs-matcher");
|
||||
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
||||
function schedule(cron, fn) {
|
||||
var futureMatches = (0, cronjs_matcher_1.getFutureMatches)(cron, {
|
||||
matchCount: 1,
|
||||
});
|
||||
var date = (0, dayjs_1.default)(futureMatches[0]);
|
||||
var interval = date.diff((0, dayjs_1.default)(), 'ms');
|
||||
setTimeout(function () {
|
||||
fn(new Date());
|
||||
schedule(cron, fn);
|
||||
}, interval);
|
||||
}
|
||||
exports.schedule = schedule;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
declare const maskIdCard: (idCardNumber: string) => string;
|
||||
declare const maskMobile: (mobile: string) => string;
|
||||
declare const maskName: (name: string) => string;
|
||||
declare const maskStar: (str: string, front: number, end: number, star: string) => string;
|
||||
export { maskIdCard, maskMobile, maskName, maskStar, };
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.maskStar = exports.maskName = exports.maskMobile = exports.maskIdCard = void 0;
|
||||
var maskIdCard = function (idCardNumber) {
|
||||
if (!idCardNumber instanceof String) {
|
||||
throw new Error("身份证号码必须是String类型");
|
||||
}
|
||||
var begin = idCardNumber.slice(0, 4);
|
||||
var end = idCardNumber.slice(idCardNumber.length - 4, 4);
|
||||
for (var i = 0; i < idCardNumber.length - 8; i++) {
|
||||
begin = begin.concat("*");
|
||||
}
|
||||
return begin.concat(end);
|
||||
};
|
||||
exports.maskIdCard = maskIdCard;
|
||||
var maskMobile = function (mobile) {
|
||||
var begin = mobile.slice(0, 3);
|
||||
var end = mobile.slice(7, 11);
|
||||
return begin.concat("****").concat(end);
|
||||
};
|
||||
exports.maskMobile = maskMobile;
|
||||
var maskName = function (name) {
|
||||
return name.slice(0, name.length - 1).concat("*");
|
||||
};
|
||||
exports.maskName = maskName;
|
||||
var maskStar = function (str, frontLen, endLen, star) {
|
||||
if (star === void 0) { star = '*'; }
|
||||
var len = str.length - frontLen - endLen;
|
||||
var xing = '';
|
||||
for (var i = 0; i < len; i++) {
|
||||
xing += star;
|
||||
}
|
||||
return str.substring(0, frontLen) + xing + str.substring(str.length - endLen);
|
||||
};
|
||||
exports.maskStar = maskStar;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
declare const ToCent: (float: number) => number;
|
||||
declare const ToYuan: (int: number) => number;
|
||||
declare const StringToCent: (value: string, allowNegative?: true) => number | undefined;
|
||||
declare const CentToString: (value: number) => string | undefined;
|
||||
export { ToCent, ToYuan, StringToCent, CentToString, };
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CentToString = exports.StringToCent = exports.ToYuan = exports.ToCent = void 0;
|
||||
var ToCent = function (float) {
|
||||
return Math.round(float * 100);
|
||||
};
|
||||
exports.ToCent = ToCent;
|
||||
var ToYuan = function (int) {
|
||||
return Math.round(int) / 100;
|
||||
};
|
||||
exports.ToYuan = ToYuan;
|
||||
var StringToCent = function (value, allowNegative) {
|
||||
var numValue = parseInt(value, 10);
|
||||
if (typeof numValue === 'number' && (numValue >= 0 || allowNegative)) {
|
||||
return ToCent(numValue);
|
||||
}
|
||||
};
|
||||
exports.StringToCent = StringToCent;
|
||||
var CentToString = function (value) {
|
||||
if (typeof value === 'number') {
|
||||
return "".concat(ToYuan(value));
|
||||
}
|
||||
};
|
||||
exports.CentToString = CentToString;
|
||||
|
|
@ -27,6 +27,7 @@
|
|||
"@types/luxon": "^2.0.9",
|
||||
"@types/mocha": "^8.2.0",
|
||||
"@types/node": "^14.14.25",
|
||||
"@types/node-schedule": "^2.1.0",
|
||||
"@types/react": "^17.0.2",
|
||||
"@types/uuid": "^8.3.0",
|
||||
"@types/wechat-miniprogram": "^3.4.1",
|
||||
|
|
@ -40,9 +41,9 @@
|
|||
"typescript": "^4.7.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@datasert/cronjs-matcher": "^1.2.0",
|
||||
"dayjs": "^1.11.5",
|
||||
"lodash": "^4.17.21",
|
||||
"node-schedule": "^2.1.1",
|
||||
"uuid": "^9.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1642,7 +1642,8 @@ function constructFilter(statements: Array<ts.Statement>, entity: string) {
|
|||
case 'Int':
|
||||
case 'Uint':
|
||||
case 'Float':
|
||||
case 'Double': {
|
||||
case 'Double':
|
||||
case 'Price': {
|
||||
type2 = factory.createTypeReferenceNode(
|
||||
factory.createIdentifier('Q_NumberValue'),
|
||||
);
|
||||
|
|
@ -1897,7 +1898,8 @@ function constructProjection(statements: Array<ts.Statement>, entity: string) {
|
|||
case 'File':
|
||||
case 'SingleGeo':
|
||||
case 'Geo':
|
||||
case 'Object': {
|
||||
case 'Object':
|
||||
case 'Price': {
|
||||
properties.push(
|
||||
[name, false]
|
||||
)
|
||||
|
|
@ -2410,7 +2412,8 @@ function constructSorter(statements: Array<ts.Statement>, entity: string) {
|
|||
case 'Boolean':
|
||||
case 'Datetime':
|
||||
case 'Image':
|
||||
case 'File': {
|
||||
case 'File':
|
||||
case 'Price': {
|
||||
type2 = factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword);
|
||||
break;
|
||||
}
|
||||
|
|
@ -4417,6 +4420,11 @@ const initialStatements = () => [
|
|||
undefined,
|
||||
factory.createIdentifier('File')
|
||||
),
|
||||
factory.createImportSpecifier(
|
||||
false,
|
||||
undefined,
|
||||
factory.createIdentifier('Price')
|
||||
),
|
||||
factory.createImportSpecifier(
|
||||
false,
|
||||
undefined,
|
||||
|
|
@ -5399,6 +5407,15 @@ function constructAttributes(entity: string): ts.PropertyAssignment[] {
|
|||
);
|
||||
break;
|
||||
}
|
||||
case 'Price': {
|
||||
attrAssignments.push(
|
||||
factory.createPropertyAssignment(
|
||||
factory.createIdentifier("type"),
|
||||
factory.createStringLiteral("money")
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 'Datetime': {
|
||||
attrAssignments.push(
|
||||
factory.createPropertyAssignment(
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ const locale: LocaleDef<Schema, Action, '', {
|
|||
iState: IState,
|
||||
}> = {
|
||||
zh_CN: {
|
||||
name: '更新',
|
||||
attr: {
|
||||
targetEntity: '目标对象',
|
||||
entity: '关联对象',
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ const config: Configuration = {
|
|||
|
||||
const locale: LocaleDef<Schema, '', '', {}> = {
|
||||
zh_CN: {
|
||||
name: '更新对象连接',
|
||||
attr: {
|
||||
modi: '更新',
|
||||
entity: '关联对象',
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ const configuration: Configuration = {
|
|||
|
||||
const locale: LocaleDef<Schema, '', '', {}> = {
|
||||
zh_CN: {
|
||||
name: '操作',
|
||||
attr: {
|
||||
action: '动作',
|
||||
data: '数据',
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ const config: Configuration = {
|
|||
|
||||
const locale: LocaleDef<Schema, '', '', {}> = {
|
||||
zh_CN: {
|
||||
name: '操作对象连接',
|
||||
attr: {
|
||||
oper: '操作',
|
||||
entity: '关联对象',
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ const locale: LocaleDef<Schema, Action, '', {
|
|||
userState: UserState;
|
||||
}> = {
|
||||
zh_CN: {
|
||||
name: '用户',
|
||||
attr: {
|
||||
name: '姓名',
|
||||
nickname: '昵称',
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ const locale: LocaleDef<
|
|||
{}
|
||||
> = {
|
||||
zh_CN: {
|
||||
name: '用户授权',
|
||||
attr: {
|
||||
relation: '关系',
|
||||
entity: '关联对象',
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ export type Image = string;
|
|||
export type File = string;
|
||||
export type Datetime = number | Date;
|
||||
export type Boolean = boolean;
|
||||
export type Price = number;
|
||||
export type PrimaryKey = string;
|
||||
export type ForeignKey<E extends string> = string;
|
||||
export type Sequence = string; // 自增长序列,为了让人阅读方便,为了支持分布式这里用string,底层实现可自定义
|
||||
|
|
@ -17,5 +18,5 @@ export { Geo, SingleGeo } from './Geo';
|
|||
|
||||
export type DataTypes = number | string | Datetime | Geo | Object | SingleGeo;
|
||||
|
||||
export const types = ['Int', 'Uint', 'Double', 'Float', 'String', 'Text', 'Datetime', 'Boolean', 'Image', 'File', 'Geo', 'SingleGeo'];
|
||||
export const types = ['Int', 'Uint', 'Double', 'Float', 'String', 'Text', 'Datetime', 'Boolean', 'Image', 'File', 'Geo', 'SingleGeo', 'Price'];
|
||||
export const unIndexedTypes = ['Text', 'Image', 'File', 'Object'];
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ type LocaleOfValue<V extends Record<string, string>> = {
|
|||
|
||||
export type LocaleDef<Sc extends Record<string, any>, Ac extends string, R extends string, V extends Record<string, string>> = {
|
||||
[L in Language]?: {
|
||||
name: string;
|
||||
attr: LocaleOfSchema<Sc> & {
|
||||
[A in keyof V]: string; // 目前写在V里面的应该只有枚举变量和state
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
import { RecurrenceRule, RecurrenceSpecDateRange, RecurrenceSpecObjLit } from 'node-schedule';
|
||||
import { EntityDict } from './Entity';
|
||||
import { AsyncContext } from "../store/AsyncRowStore";
|
||||
import { AsyncContext } from '../store/AsyncRowStore';
|
||||
|
||||
type RoutineFn<ED extends EntityDict, Cxt extends AsyncContext<ED>> = (context: Cxt) => Promise<string>;
|
||||
type RoutineFn<ED extends EntityDict, Cxt extends AsyncContext<ED>> = (
|
||||
context: Cxt
|
||||
) => Promise<string>;
|
||||
|
||||
export type Routine<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
|
||||
name: string;
|
||||
|
|
@ -10,6 +13,6 @@ export type Routine<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
|
|||
|
||||
export type Timer<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
|
||||
name: string;
|
||||
cron: string;
|
||||
cron: RecurrenceRule | RecurrenceSpecDateRange | RecurrenceSpecObjLit | Date | string | number;
|
||||
fn: RoutineFn<ED, Cxt>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
import { getFutureMatches } from '@datasert/cronjs-matcher';
|
||||
import DayJs from 'dayjs';
|
||||
|
||||
export function schedule(cron: string, fn: (date: Date) => any) {
|
||||
const futureMatches = getFutureMatches(cron, {
|
||||
matchCount: 1,
|
||||
});
|
||||
const date = DayJs(futureMatches[0]);
|
||||
const interval = date.diff(DayJs(), 'ms');
|
||||
setTimeout(
|
||||
() => {
|
||||
fn(new Date());
|
||||
schedule(cron, fn);
|
||||
},
|
||||
interval
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
const maskIdCard: (idCardNumber: string) => string = (idCardNumber) => {
|
||||
if(!idCardNumber as any instanceof String) {
|
||||
throw new Error("身份证号码必须是String类型");
|
||||
}
|
||||
let begin = idCardNumber.slice(0, 4);
|
||||
let end = idCardNumber.slice(idCardNumber.length - 4, 4);
|
||||
for(let i = 0; i < idCardNumber.length - 8; i ++) {
|
||||
begin = begin.concat("*");
|
||||
}
|
||||
return begin.concat(end);
|
||||
}
|
||||
|
||||
const maskMobile: (mobile: string) => string = (mobile) => {
|
||||
let begin = mobile.slice(0, 3);
|
||||
let end = mobile.slice(7, 11);
|
||||
return begin.concat("****").concat(end);
|
||||
}
|
||||
|
||||
|
||||
const maskName: (name: string) => string = (name) => {
|
||||
return name.slice(0, name.length - 1).concat("*");
|
||||
}
|
||||
|
||||
const maskStar: (str: string, front: number, end: number, star: string) => string = (str, frontLen, endLen, star = '*') => {
|
||||
const len = str.length - frontLen - endLen;
|
||||
let xing = '';
|
||||
for (let i = 0; i < len; i++) {
|
||||
xing += star;
|
||||
}
|
||||
return str.substring(0, frontLen) + xing + str.substring(str.length - endLen);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export {
|
||||
maskIdCard,
|
||||
maskMobile,
|
||||
maskName,
|
||||
maskStar,
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
const ToCent: (float: number) => number = (float) => {
|
||||
return Math.round(float * 100);
|
||||
}
|
||||
|
||||
const ToYuan: (int: number) => number = ( int) => {
|
||||
return Math.round(int) / 100;
|
||||
}
|
||||
|
||||
const StringToCent: (value: string, allowNegative?: true) => number | undefined = (value, allowNegative) => {
|
||||
const numValue = parseInt(value, 10);
|
||||
if (typeof numValue === 'number' && (numValue >= 0 || allowNegative)) {
|
||||
return ToCent(numValue);
|
||||
}
|
||||
}
|
||||
|
||||
const CentToString: (value: number) => string | undefined = (value) => {
|
||||
if (typeof value === 'number') {
|
||||
return `${ToYuan(value)}`;
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
ToCent,
|
||||
ToYuan,
|
||||
StringToCent,
|
||||
CentToString,
|
||||
}
|
||||
Loading…
Reference in New Issue