userEntityGrant
This commit is contained in:
parent
3c5b9e86a5
commit
7f1500b241
|
|
@ -1,5 +1,10 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const types_1 = require("oak-domain/lib/types");
|
||||||
|
const assert_1 = __importDefault(require("assert"));
|
||||||
const triggers = [
|
const triggers = [
|
||||||
{
|
{
|
||||||
name: '当创建userEntityGrant时,查询是否有未过期的实体',
|
name: '当创建userEntityGrant时,查询是否有未过期的实体',
|
||||||
|
|
@ -8,17 +13,36 @@ const triggers = [
|
||||||
when: 'before',
|
when: 'before',
|
||||||
fn: async ({ operation }, context, params) => {
|
fn: async ({ operation }, context, params) => {
|
||||||
const { data, filter } = operation;
|
const { data, filter } = operation;
|
||||||
// const { result } = await context.rowStore.select('userEntityGrant', {
|
const fn = async (userEntityGrantData) => {
|
||||||
// data: Object.assign({
|
const { action, entity, entityId, relation } = userEntityGrantData;
|
||||||
// id: 1,
|
const { result } = await context.rowStore.select('userEntityGrant', {
|
||||||
// iState: 1
|
data: {
|
||||||
// }, data),
|
id: 1,
|
||||||
// filter: {
|
action: 1,
|
||||||
// iState: 'init',
|
entity: 1,
|
||||||
// },
|
entityId: 1,
|
||||||
// indexFrom: 0,
|
relation: 1,
|
||||||
// count: 1,
|
},
|
||||||
// }, context, params);
|
filter: {
|
||||||
|
iState: 'init',
|
||||||
|
action,
|
||||||
|
entity,
|
||||||
|
entityId,
|
||||||
|
relation,
|
||||||
|
},
|
||||||
|
indexFrom: 0,
|
||||||
|
count: 1,
|
||||||
|
}, context, params);
|
||||||
|
if (result.length) {
|
||||||
|
throw new types_1.OakRowInconsistencyException(result[0], '该userEntityGrant未过期');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (data instanceof Array) {
|
||||||
|
(0, assert_1.default)('授权不存在一对多的情况');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fn(data);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { CreateOperationData as CreateUserEntityGrantData } from 'oak-app-domain
|
||||||
import { assign, keys } from 'lodash';
|
import { assign, keys } from 'lodash';
|
||||||
import { OakRowInconsistencyException } from 'oak-domain/lib/types';
|
import { OakRowInconsistencyException } from 'oak-domain/lib/types';
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import { OpRecord } from '../../../oak-domain/src/types/Entity';
|
|
||||||
const triggers: Trigger<EntityDict, 'userEntityGrant', GeneralRuntimeContext<EntityDict>>[] = [
|
const triggers: Trigger<EntityDict, 'userEntityGrant', GeneralRuntimeContext<EntityDict>>[] = [
|
||||||
{
|
{
|
||||||
name: '当创建userEntityGrant时,查询是否有未过期的实体',
|
name: '当创建userEntityGrant时,查询是否有未过期的实体',
|
||||||
|
|
@ -43,7 +43,7 @@ const triggers: Trigger<EntityDict, 'userEntityGrant', GeneralRuntimeContext<Ent
|
||||||
assert('授权不存在一对多的情况')
|
assert('授权不存在一对多的情况')
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fn(data)
|
await fn(data);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,9 @@ OakPage({
|
||||||
wx.navigateBack();
|
wx.navigateBack();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
reset() {
|
||||||
|
this.resetUpdateData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -13,8 +13,13 @@
|
||||||
<g-input error="{{!!oakFocused.detail}}" oak:value="detail" title="详细地址" placeholder="精确到门牌号码" confirm-type="done" bind:change="setValue" />
|
<g-input error="{{!!oakFocused.detail}}" oak:value="detail" title="详细地址" placeholder="精确到门牌号码" confirm-type="done" bind:change="setValue" />
|
||||||
</g-panel>
|
</g-panel>
|
||||||
<view style="flex: 1" />
|
<view style="flex: 1" />
|
||||||
<g-btn type="primary" long="true" class="{{ oakExecuting ? 'g-btn-loading' : ''}} {{ !oakDirty ? 'g-btn-disabled' : ''}}" disabled="{{oakExecuting || !oakDirty}}" bind:click="confirm">
|
<view style="display:flex;flex-direction:row;align-items:center">
|
||||||
<view class="g-btn-loading-inner" wx:if="{{oakExecuting}}"></view>
|
<g-btn type="primary" style="flex: 2" class="{{ oakExecuting ? 'g-btn-loading' : ''}} {{ !oakDirty ? 'g-btn-disabled' : ''}}" disabled="{{oakExecuting || !oakDirty}}" bind:click="confirm">
|
||||||
确定
|
<view class="g-btn-loading-inner" wx:if="{{oakExecuting}}"></view>
|
||||||
</g-btn>
|
确定
|
||||||
|
</g-btn>
|
||||||
|
<g-btn type="warning" style="flex: 1" disabled="{{!oakDirty}}" bind:click="reset">
|
||||||
|
重置
|
||||||
|
</g-btn>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -4,14 +4,15 @@ OakPage({
|
||||||
entity: 'userEntityGrant',
|
entity: 'userEntityGrant',
|
||||||
|
|
||||||
projection: {
|
projection: {
|
||||||
|
id: 1,
|
||||||
entity: 1,
|
entity: 1,
|
||||||
entityId: 1,
|
entityId: 1,
|
||||||
relation: 1,
|
relation: 1,
|
||||||
action: 1,
|
action: 1,
|
||||||
remark: 1,
|
remark: 1,
|
||||||
uuid: 1,
|
uuid: 1,
|
||||||
granter: 1,
|
granterId: 1,
|
||||||
grantee: 1,
|
granteeId: 1,
|
||||||
},
|
},
|
||||||
isList: false,
|
isList: false,
|
||||||
formData: async ([userEntityGrant]) => ({
|
formData: async ([userEntityGrant]) => ({
|
||||||
|
|
@ -26,7 +27,7 @@ OakPage({
|
||||||
data: {
|
data: {
|
||||||
},
|
},
|
||||||
lifetimes: {
|
lifetimes: {
|
||||||
ready(options) {
|
ready() {
|
||||||
this.setUpdateData('entity', this.data.entity);
|
this.setUpdateData('entity', this.data.entity);
|
||||||
this.setUpdateData('entityId', this.data.entityId);
|
this.setUpdateData('entityId', this.data.entityId);
|
||||||
this.setUpdateData('action', 'grant');
|
this.setUpdateData('action', 'grant');
|
||||||
|
|
@ -36,7 +37,7 @@ OakPage({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
radioChange(e) {
|
radioChange(e: WechatMiniprogram.RadioGroupChange) {
|
||||||
this.setUpdateData('relation', e.detail.value);
|
this.setUpdateData('relation', e.detail.value);
|
||||||
},
|
},
|
||||||
handleConfirm() {
|
handleConfirm() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue