trigger 增加 userEntityGrant

This commit is contained in:
梁朝伟 2022-05-26 13:35:27 +08:00
parent 32ac0dfc2d
commit 7fa4b9af6b
11 changed files with 256 additions and 1 deletions

View File

@ -2,6 +2,8 @@ import { String, Text } from 'oak-domain/lib/types/DataType';
import { EntityShape } from 'oak-domain/lib/types/Entity';
import { Index } from 'oak-domain/lib/types/Storage';
import { Schema as User } from './User';
import { Schema as WechatQrCode } from './WechatQrCode';
import { ActionDef } from 'oak-domain/lib/types/Action';
export interface Schema extends EntityShape {
entity: String<32>;
@ -12,8 +14,18 @@ export interface Schema extends EntityShape {
uuid: String<32>;
granter: User;
grantee?: User;
files: Array<WechatQrCode>;
}
type IAction = 'confirm';
type IState = | 'init'| 'expire';
const IActionDef: ActionDef<IAction, IState> = {
stm: {
confirm: ['init', 'expire'],
},
is: 'init'
};
const indexes: Index<Schema>[] = [
{

View File

@ -3,5 +3,6 @@ import { EntityDict as BaseEntityDict } from 'oak-app-domain/EntityDict';
import { Trigger } from 'oak-domain/lib/types';
import addressTriggers from './address';
import userTriggers from './user';
import userEntityGrantTriggers from './userEntityGrant';
export default [...addressTriggers, ...userTriggers];
export default [...addressTriggers, ...userTriggers, ...userEntityGrantTriggers];

View File

@ -0,0 +1,28 @@
import { EntityDict } from 'oak-app-domain/EntityDict';
import { CreateTriggerInTxn, Trigger } from 'oak-domain/lib/types/Trigger';
import { GeneralRuntimeContext } from '../RuntimeContext';
import { assign } from "lodash";
import { OakRowInconsistencyException } from 'oak-domain/lib/types';
const triggers: Trigger<EntityDict, 'userEntityGrant', GeneralRuntimeContext<EntityDict>>[] = [
{
name: '当创建userEntityGrant时,查询是否有未过期的实体',
entity: 'userEntityGrant',
action: 'create',
when: 'before',
fn: async ({ operation }, context, params) => {
const { data, filter } = operation;
const { result } = await context.rowStore.select('userEntityGrant', {
data: Object.assign({
iState: 1
}, data),
filter: {
iState: 'init',
},
indexFrom: 0,
count: 1,
}, context, params);
}
},
];
export default triggers;

View File

@ -0,0 +1,9 @@
{
"navigationBarTitleText": "添加权限",
"usingComponents": {
"g-btn": "../../../components/UI/g-btn/index",
"g-input": "../../../components/UI/g-input/index",
"g-icon": "../../../components/UI/g-icon/index",
"g-panel": "../../../components/UI/g-panel/index"
}
}

View File

@ -0,0 +1,26 @@
/** index.wxss **/
@import "../../../styles/cell.less";
@import "../../../styles/mixins.less";
.page-body {
height: 100vh;
display: flex;
flex: 1;
flex-direction: column;
background-color: @background-color-base;
box-sizing: border-box;
.safe-area-inset-bottom();
}
.label {
display: flex;
align-items: center;
padding: @size-spacing-base;
border-bottom: 1px solid @background-color-base;
}
.cell-col {
display: flex;
flex-direction: column;
background-color: #fff;
border-top: 1px solid @background-color-base
}

View File

@ -0,0 +1,73 @@
OakPage({
path: 'userEntityGrant:detail',
entity: 'userEntityGrant',
projection: {
entity: 1,
entityId: 1,
relation: 1,
action: 1,
remark: 1,
uuid: 1,
granter: 1,
grantee: 1,
wechatQrCode$entity: {
$entity: 'wechatQrCode',
data: {
entity: 1,
entityId: 1,
type: 1,//类型
expiresAt: 1,// 过期时间
expired: 1, //是否过期
autoExtend: 1,
sceneStr: 1,
ticket: 1,
url: 1,
isPermanent: 1, //是否永久码
},
filter: {
entity: 'userEntityGrant',
expired: false,
},
indexFrom: 0,
count: 1,
},
},
isList: false,
formData: async ([userEntityGrant]) => ({
...userEntityGrant,
}),
}, {
properties: {
entity: String,
entityId: String,
relations: String,
},
data: {
},
lifetimes: {
ready(options) {
this.data.entity && this.setUpdateData('entity', this.data.entity);
this.data.entityId && this.setUpdateData('entityId', this.data.entityId);
this.setUpdateData('action', 'grant');
this.setData({
relationArr: JSON.parse(this.data.relations),
})
if (!this.data.wechatQrCode$entity[0] || this.data.wechatQrCode$entity[0].expiresAt) {
//请求创建wechatQrcode
// const result = await requestWechatQrcode();
this.setData({
url: result.url,
})
}
}
},
methods: {
radioChange(e) {
this.setUpdateData('relation', e.detail.value);
},
requestWechatQrcode() {
}
}
});

View File

@ -0,0 +1,14 @@
<!-- index.wxml -->
<view class="page-body">
<view class="cell-col">
<radio-group bindchange="radioChange" class="test">
<label class="label" wx:for="{{relationArr}}" wx:key="*this">
<view>
<radio value="{{item}}" checked="true" />
</view>
<view>{{item}}</view>
</label>
</radio-group>
</view>
<g-btn type="primary">确定</g-btn>
</view>

View File

@ -0,0 +1,9 @@
{
"navigationBarTitleText": "添加权限",
"usingComponents": {
"g-btn": "../../../components/UI/g-btn/index",
"g-input": "../../../components/UI/g-input/index",
"g-icon": "../../../components/UI/g-icon/index",
"g-panel": "../../../components/UI/g-panel/index"
}
}

View File

@ -0,0 +1,26 @@
/** index.wxss **/
@import "../../../styles/cell.less";
@import "../../../styles/mixins.less";
.page-body {
height: 100vh;
display: flex;
flex: 1;
flex-direction: column;
background-color: @background-color-base;
box-sizing: border-box;
.safe-area-inset-bottom();
}
.label {
display: flex;
align-items: center;
padding: @size-spacing-base;
border-bottom: 1px solid @background-color-base;
}
.cell-col {
display: flex;
flex-direction: column;
background-color: #fff;
border-top: 1px solid @background-color-base
}

View File

@ -0,0 +1,43 @@
OakPage({
path: 'userEntityGrant:upsert',
entity: 'userEntityGrant',
projection: {
entity: 1,
entityId: 1,
relation: 1,
action: 1,
remark: 1,
uuid: 1,
granter: 1,
grantee: 1,
},
isList: false,
formData: async ([userEntityGrant]) => ({
...userEntityGrant
}),
}, {
properties: {
entity: String,
entityId: String,
relations: String,
},
data: {
},
lifetimes: {
ready(options) {
this.setUpdateData('entity', this.data.entity);
this.setUpdateData('entityId', this.data.entityId);
this.setUpdateData('action', 'grant');
this.setData({
relationArr: JSON.parse(this.data.relations),
})
}
},
methods: {
radioChange(e) {
this.setUpdateData('relation', e.detail.value);
}
}
});

View File

@ -0,0 +1,14 @@
<!-- index.wxml -->
<view class="page-body">
<view class="cell-col">
<radio-group bindchange="radioChange" class="test">
<label class="label" wx:for="{{relationArr}}" wx:key="*this">
<view>
<radio value="{{item}}" checked="true" />
</view>
<view>{{item}}</view>
</label>
</radio-group>
</view>
<g-btn type="primary">确定</g-btn>
</view>