修改parasitechcker
This commit is contained in:
parent
2cb3ce7560
commit
4272b91be4
|
|
@ -3,21 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
var tslib_1 = require("tslib");
|
||||
var types_1 = require("oak-domain/lib/types");
|
||||
var assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
var validator_1 = require("oak-domain/lib/utils/validator");
|
||||
var checkers = [
|
||||
{
|
||||
type: 'logical',
|
||||
type: 'data',
|
||||
action: 'create',
|
||||
entity: 'parasite',
|
||||
checker: function (operation, context, option) {
|
||||
var data = operation.data;
|
||||
checker: function (data, context) {
|
||||
// const { data } = operation as EntityDict['parasite']['Create'];
|
||||
(0, assert_1.default)(!(data instanceof Array));
|
||||
if (!data.expiresAt) {
|
||||
data.expiresAt = Date.now() + 3600 * 1000;
|
||||
}
|
||||
data.expired = false;
|
||||
if (!data.tokenLifeLength) {
|
||||
data.tokenLifeLength = 3600 * 1000;
|
||||
}
|
||||
(0, validator_1.checkAttributesNotNull)('parasite', data, ['expiresAt', 'tokenLifeLength']);
|
||||
if (data.userId) {
|
||||
var users2 = context.select('user', {
|
||||
data: {
|
||||
|
|
|
|||
|
|
@ -2,23 +2,17 @@ import { Checker, OakRowInconsistencyException } from 'oak-domain/lib/types';
|
|||
import assert from 'assert';
|
||||
import { EntityDict } from '../general-app-domain';
|
||||
import { RuntimeCxt } from '../types/RuntimeCxt';
|
||||
import { checkAttributesNotNull } from 'oak-domain/lib/utils/validator';
|
||||
|
||||
const checkers: Checker<EntityDict, 'parasite', RuntimeCxt>[] = [
|
||||
{
|
||||
type: 'logical',
|
||||
type: 'data',
|
||||
action: 'create',
|
||||
entity: 'parasite',
|
||||
checker: (operation, context, option) => {
|
||||
const { data } = operation as EntityDict['parasite']['Create'];
|
||||
checker: (data, context) => {
|
||||
// const { data } = operation as EntityDict['parasite']['Create'];
|
||||
assert(!(data instanceof Array));
|
||||
if (!data.expiresAt) {
|
||||
data.expiresAt = Date.now() + 3600 * 1000;
|
||||
}
|
||||
data.expired = false;
|
||||
if (!data.tokenLifeLength) {
|
||||
data.tokenLifeLength = 3600 * 1000;
|
||||
}
|
||||
|
||||
checkAttributesNotNull('parasite', data, ['expiresAt', 'tokenLifeLength']);
|
||||
if (data.userId) {
|
||||
const users2 = context.select(
|
||||
'user',
|
||||
|
|
|
|||
Loading…
Reference in New Issue