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