json-schema-mock
Version:
data mocker for json-schema.
150 lines (149 loc) • 6.04 kB
JavaScript
var DataMocker = require( '../src/index' );
console.log( 'result', DataMocker( {
"type": "object",
"description": "说明下换购信息部分的逻辑:\n- 先查看用户是否具有换购资格,若没有,则显示没有资格\n- 若有换购资格,且已经完成换购,则现实已经换购\n- 若有资格且为换购,则逻辑如下:\n- 若状态为available,展示可换购\n- 若为notBegin,根据当前的groupNum:\n- 若为第一个换购批次,显示换购尚未开始...\n- 若不是第一次,显示上一次换购已经结束,下一次换购....\n- 若状态为over,且allOver为true,显示 很遗憾您这个季度没有换购到奖品",
"properties": {
"activityInfo": {
"type": "object",
"description": "该季活动信息",
"properties": {
"desc": {
type: 'string',
allOf: [
{
maxLength: '2',
oneOf: [
{
enum: [ 'a', 'b' ]
},
{
enum: [ 'c', 'd' ]
}
]
},
{
minLength: '1'
}
]
},
"email": {
type: 'string',
format: 'email',
oneOf: [
{
enum: [ 'a', 'b' ]
},
{
enum: [ 'c', 'd' ]
}
]
},
taobaoItemURL: {
type: 'string',
anyOf: [
{
format: 'TAOBAO_DETAIL'
},
{
minLength: 100
}
]
},
tmallItemURL: {
type: 'string',
format: 'TMALL_DETAIL'
},
taobaoShopURL: {
type: 'string',
format: 'TAOBAO_SHOP'
},
tmallShopURL: {
type: 'string',
format: 'TMALL_SHOP'
},
"pic": {
"type": "string",
format: "CDN_PIC"
},
"state": {
"type": "string",
"description": "活动的当前状态,未开始,进行中,已经结束",
"enum": ["wait", "process", "over"]
},
"deadline": {
"type": "string",
"description": "活动的截至日期",
"format": "DATE_TIME"
},
"remainDays": {
"type": "integer",
"description": "活动剩余天数"
},
"needDays": {
"type": "integer",
"description": "活动需要累计判定的天数"
},
"seasonNum": {
"type": "integer",
"description": "当前为第几季度。前端可以根据这个值,对应到本季XX之星的名称",
"enum": [1, 2, 3, 4]
}
},
"required": ["state", "deadline", "remainDays", "needDays", "seasonNum"]
},
"exchangeInfo": {
"type": "object",
"description": "换购信息",
"properties": {
"currentGroupState": {
"type": "string",
"description": "当前批次换购状态\n\nnotBegin: 当前批次换购未开始\navailable:当前批次换购进行中\nover:当前换购批次已经结束",
"enum": ["notBegin", "available", "over"]
},
"allOver": {
"type": "boolean",
"description": "是否所有换购都已经结束"
},
"currentGroupNum": {
"type": "integer",
"description": "当前的换购批次"
},
"beginDate": {
"type": "integer",
"description": "当前批次换购开始时间,毫秒时间戳",
format: 'TIMESTAMP'
},
"exchangeUrl": {
"type": "string",
"description": "换购连接",
format: 'URL'
}
},
"required": ["allOver", "currentGroupNum", "beginDate"]
},
"participateInfo": {
"type": "object",
"description": "用户的参与情况",
"properties": {
"finishedDays": {
"type": "integer",
"description": "用户在该季活动中累计判定了的天数"
},
"getAdmit": {
"type": "boolean",
"description": "用户是否获得了该季评审之星资格"
},
"exchanged": {
"type": "boolean",
"description": "用户是否进行了换购"
},
"processLevel": {
"type": "integer",
"description": "用户当前进展的等级,从0开始"
}
},
"required": ["finishedDays", "getAdmit", "exchanged"]
}
},
"required": ["activityInfo", "exchangeInfo", "participateInfo"]
}));