parent
f952e55e20
commit
eaeedc0080
Binary file not shown.
@ -0,0 +1,657 @@ |
||||
// | ------------------------------------------------------------
|
||||
// | @版本: version 0.1
|
||||
// | @创建人: 【Nie-x7129】
|
||||
// | @E-mail: x71291@outlook.com
|
||||
// | @所在项目: graphResource2
|
||||
// | @文件描述: index.dto.js -
|
||||
// | @创建时间: 2023-12-03 15:30
|
||||
// | @更新时间: 2023-12-03 15:30
|
||||
// | @修改记录:
|
||||
// | -*-*-*- (时间--修改人--修改说明) -*-*-*-
|
||||
// | =
|
||||
// | ------------------------------------------------------------
|
||||
|
||||
import makeDTO from '#common/dto/index.js'; |
||||
|
||||
export function GetBaseDictTreeDTO(data) { |
||||
const schema = { |
||||
type: 'object', |
||||
properties: { |
||||
atomModelId: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '元分类/模型ID必须是整数', |
||||
minimum: '元分类/模型ID是一个正整数', |
||||
}, |
||||
}, |
||||
reduce: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
default: 1, |
||||
errorMessage: { |
||||
type: '元分类/模型ID必须是整数', |
||||
minimum: '元分类/模型ID是一个正整数', |
||||
}, |
||||
}, |
||||
}, |
||||
}; |
||||
return makeDTO(data, schema); |
||||
} |
||||
|
||||
// @ 获取资源类列表
|
||||
export function GetResourceClassListDTO(data) { |
||||
const schema = { |
||||
type: 'object', |
||||
properties: { |
||||
atomModelId: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '元分类/模型ID必须是整数', |
||||
minimum: '元分类/模型ID是一个正整数', |
||||
}, |
||||
}, |
||||
searchData: { |
||||
type: 'string', |
||||
maxLength: 255, |
||||
errorMessage: { |
||||
type: '查询内容必须是一个字符串', |
||||
maxLength: '查询内容长度超出限制255', |
||||
}, |
||||
}, |
||||
}, |
||||
required: ['atomModelId'], |
||||
errorMessage: { |
||||
required: { |
||||
atomModelId: '元分类/模型ID为必填项', |
||||
}, |
||||
}, |
||||
}; |
||||
return makeDTO(data, schema); |
||||
} |
||||
|
||||
// @ 获取资源类分页
|
||||
export function GetResourceClassPageDTO(data) { |
||||
const schema = { |
||||
type: 'object', |
||||
properties: { |
||||
atomModelId: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '元分类/模型ID必须是整数', |
||||
minimum: '元分类/模型ID是一个正整数', |
||||
}, |
||||
}, |
||||
searchData: { |
||||
type: 'string', |
||||
maxLength: 255, |
||||
errorMessage: { |
||||
type: '查询内容必须是一个字符串', |
||||
maxLength: '查询内容长度超出限制255', |
||||
}, |
||||
}, |
||||
pageSize: { |
||||
type: 'integer', |
||||
minimum: 1, |
||||
maximum: 200, |
||||
default: 10, |
||||
errorMessage: { |
||||
type: '每页数量必须是一个数字', |
||||
minimum: '每页数量最少是1', |
||||
maximum: '每页数量最多是200', |
||||
}, |
||||
}, |
||||
pageNum: { |
||||
type: 'integer', |
||||
minimum: 1, |
||||
default: 1, |
||||
errorMessage: { |
||||
type: '页码必须是数字类型', |
||||
minimum: '页码最小是1', |
||||
}, |
||||
}, |
||||
}, |
||||
required: ['atomModelId'], |
||||
errorMessage: { |
||||
required: { |
||||
atomModelId: '元分类/模型ID为必填项', |
||||
}, |
||||
}, |
||||
}; |
||||
return makeDTO(data, schema); |
||||
} |
||||
|
||||
// @ 获取资源类树
|
||||
export function GetResourceClassTreeDTO(data) { |
||||
const schema = { |
||||
type: 'object', |
||||
properties: { |
||||
atomModelId: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '元分类/模型ID必须是整数', |
||||
minimum: '元分类/模型ID是一个正整数', |
||||
}, |
||||
}, |
||||
searchData: { |
||||
type: 'string', |
||||
maxLength: 255, |
||||
errorMessage: { |
||||
type: '查询内容必须是一个字符串', |
||||
maxLength: '查询内容长度超出限制255', |
||||
}, |
||||
}, |
||||
}, |
||||
required: ['atomModelId'], |
||||
errorMessage: { |
||||
required: { |
||||
atomModelId: '元分类/模型ID为必填项', |
||||
}, |
||||
}, |
||||
}; |
||||
return makeDTO(data, schema); |
||||
} |
||||
|
||||
// @ 添加资源类
|
||||
export function CreateResourceClassItemDTO(data) { |
||||
const schema = { |
||||
type: 'object', |
||||
properties: { |
||||
atomModelId: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '元分类/模型ID必须是整数', |
||||
minimum: '元分类/模型ID是一个正整数', |
||||
}, |
||||
}, |
||||
resourceClassBaseDefine: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '资源类来源必须是整数', |
||||
minimum: '资源类来源是一个正整数', |
||||
}, |
||||
}, |
||||
resourceClassBaseName: { |
||||
type: 'string', |
||||
minLength: 1, |
||||
maxLength: 255, |
||||
errorMessage: { |
||||
type: '资源类名必须是一个字符串', |
||||
maxLength: '资源类名长度超出限制255', |
||||
minLength: '资源类名长度过短', |
||||
}, |
||||
}, |
||||
resourceClassBaseDescribe: { |
||||
type: 'string', |
||||
minLength: 1, |
||||
maxLength: 2048, |
||||
errorMessage: { |
||||
type: '资源类描述必须是一个字符串', |
||||
maxLength: '资源类描述长度超出限制2048', |
||||
minLength: '资源类描述长度过短', |
||||
}, |
||||
}, |
||||
resourceClassBaseType: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
default: 0, |
||||
errorMessage: { |
||||
type: '资源类业务类型必须是整数', |
||||
minimum: '资源类业务类型是一个正整数', |
||||
}, |
||||
}, |
||||
resourceClassBaseIdentify: { |
||||
type: 'string', |
||||
minLength: 8, |
||||
maxLength: 8, |
||||
pattern: '^[a-zA-Z\\s]+$', |
||||
errorMessage: { |
||||
type: '资源类标识必须是一个字符串', |
||||
maxLength: '资源类标识是一个8位字符串', |
||||
minLength: '资源类标识是一个8位字符串', |
||||
pattern: '资源类标识必须为纯英文', |
||||
}, |
||||
}, |
||||
resourceClassBaseColor: { |
||||
type: 'string', |
||||
minLength: 1, |
||||
maxLength: 255, |
||||
errorMessage: { |
||||
type: '资源类颜色描述必须是一个字符串', |
||||
maxLength: '资源类颜色描述长度超出限制255', |
||||
minLength: '资源类颜色描述长度过短', |
||||
}, |
||||
}, |
||||
resourceClassBaseAvatar: { |
||||
type: 'string', |
||||
minLength: 1, |
||||
maxLength: 255, |
||||
errorMessage: { |
||||
type: '资源类图标必须是一个字符串', |
||||
maxLength: '资源类图标长度超出限制255', |
||||
minLength: '资源类图标长度过短', |
||||
}, |
||||
}, |
||||
resourceClassBaseFather: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
default: 0, |
||||
errorMessage: { |
||||
type: '父资源类必须是整数', |
||||
minimum: '父资源类是一个正整数', |
||||
}, |
||||
}, |
||||
}, |
||||
required: [ |
||||
'atomModelId', |
||||
'resourceClassBaseIdentify', |
||||
'resourceClassBaseDescribe', |
||||
'resourceClassBaseName', |
||||
], |
||||
errorMessage: { |
||||
required: { |
||||
atomModelId: '元分类/模型ID为必填项', |
||||
resourceClassBaseIdentify: '资源类标识为必填项', |
||||
resourceClassBaseDescribe: '资源类描述为必填项', |
||||
resourceClassBaseName: '资源类名称为必填项', |
||||
}, |
||||
}, |
||||
}; |
||||
return makeDTO(data, schema); |
||||
} |
||||
|
||||
// @ 编辑资源类
|
||||
export function EditResourceClassItemDTO(data) { |
||||
const schema = { |
||||
type: 'object', |
||||
properties: { |
||||
resourceClassBaseId: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '资源类ID必须是整数', |
||||
minimum: '资源类ID是一个正整数', |
||||
}, |
||||
}, |
||||
resourceClassBaseDefine: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '资源类来源必须是整数', |
||||
minimum: '资源类来源是一个正整数', |
||||
}, |
||||
}, |
||||
resourceClassBaseName: { |
||||
type: 'string', |
||||
minLength: 1, |
||||
maxLength: 255, |
||||
errorMessage: { |
||||
type: '资源类名必须是一个字符串', |
||||
maxLength: '资源类名长度超出限制255', |
||||
minLength: '资源类名长度过短', |
||||
}, |
||||
}, |
||||
resourceClassBaseDescribe: { |
||||
type: 'string', |
||||
minLength: 1, |
||||
maxLength: 2048, |
||||
errorMessage: { |
||||
type: '资源类描述必须是一个字符串', |
||||
maxLength: '资源类描述长度超出限制2048', |
||||
minLength: '资源类描述长度过短', |
||||
}, |
||||
}, |
||||
resourceClassBaseType: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
default: 0, |
||||
errorMessage: { |
||||
type: '资源类业务类型必须是整数', |
||||
minimum: '资源类业务类型是一个正整数', |
||||
}, |
||||
}, |
||||
resourceClassBaseIdentify: { |
||||
type: 'string', |
||||
minLength: 8, |
||||
maxLength: 8, |
||||
pattern: '^[a-zA-Z\\s]+$', |
||||
errorMessage: { |
||||
type: '资源类标识必须是一个字符串', |
||||
maxLength: '资源类标识是一个8位字符串', |
||||
minLength: '资源类标识是一个8位字符串', |
||||
pattern: '资源类标识必须为纯英文', |
||||
}, |
||||
}, |
||||
resourceClassBaseColor: { |
||||
type: 'string', |
||||
minLength: 1, |
||||
maxLength: 255, |
||||
errorMessage: { |
||||
type: '资源类颜色描述必须是一个字符串', |
||||
maxLength: '资源类颜色描述长度超出限制255', |
||||
minLength: '资源类颜色描述长度过短', |
||||
}, |
||||
}, |
||||
resourceClassBaseAvatar: { |
||||
type: 'string', |
||||
minLength: 1, |
||||
maxLength: 255, |
||||
errorMessage: { |
||||
type: '资源类图标必须是一个字符串', |
||||
maxLength: '资源类图标长度超出限制255', |
||||
minLength: '资源类图标长度过短', |
||||
}, |
||||
}, |
||||
}, |
||||
required: [ |
||||
'resourceClassBaseId', |
||||
'resourceClassBaseIdentify', |
||||
'resourceClassBaseDescribe', |
||||
'resourceClassBaseName', |
||||
], |
||||
errorMessage: { |
||||
required: { |
||||
resourceClassBaseId: '资源类ID为必填项', |
||||
resourceClassBaseIdentify: '资源类标识为必填项', |
||||
resourceClassBaseDescribe: '资源类描述为必填项', |
||||
resourceClassBaseName: '资源类名称为必填项', |
||||
}, |
||||
}, |
||||
}; |
||||
return makeDTO(data, schema); |
||||
} |
||||
|
||||
// @ 删除资源类
|
||||
export function DeleteResourceClassItemDTO(data) { |
||||
const schema = { |
||||
type: 'object', |
||||
properties: { |
||||
resourceClassBaseId: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '资源类ID必须是整数', |
||||
minimum: '资源类ID是一个正整数', |
||||
}, |
||||
}, |
||||
}, |
||||
required: ['resourceClassBaseId'], |
||||
errorMessage: { |
||||
required: { |
||||
resourceClassBaseId: '资源类ID为必填项', |
||||
}, |
||||
}, |
||||
}; |
||||
return makeDTO(data, schema); |
||||
} |
||||
|
||||
// @ 创建资源类关联
|
||||
export function CreateResourceClassRelationDTO(data) { |
||||
const schema = { |
||||
type: 'object', |
||||
properties: { |
||||
resourceClassRelationFather: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '父级资源类ID必须是整数', |
||||
minimum: '父级资源类ID是一个正整数', |
||||
}, |
||||
}, |
||||
resourceClassRelationTarget: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '父级资源类ID必须是整数', |
||||
minimum: '目标资源类ID是一个正整数', |
||||
}, |
||||
}, |
||||
}, |
||||
required: [ |
||||
'resourceClassRelationFather', |
||||
'resourceClassRelationTarget', |
||||
], |
||||
errorMessage: { |
||||
required: { |
||||
resourceClassRelationFather: '父级资源类ID为必填项', |
||||
resourceClassRelationTarget: '目标资源类ID为必填项', |
||||
}, |
||||
}, |
||||
}; |
||||
return makeDTO(data, schema); |
||||
} |
||||
|
||||
// @ 删除资源类关联
|
||||
export function DeleteResourceClassRelationDTO(data) { |
||||
const schema = { |
||||
type: 'object', |
||||
properties: { |
||||
resourceClassRelationId: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '资源类关联ID必须是整数', |
||||
minimum: '资源类关联ID是一个正整数', |
||||
}, |
||||
}, |
||||
}, |
||||
required: ['resourceClassRelationId'], |
||||
errorMessage: { |
||||
required: { |
||||
resourceClassRelationId: '资源类关联ID为必填项', |
||||
}, |
||||
}, |
||||
}; |
||||
return makeDTO(data, schema); |
||||
} |
||||
|
||||
// @ 获取资源类完整信息
|
||||
export function GetResourceClassCompleteInfoDTO(data) { |
||||
const schema = { |
||||
type: 'object', |
||||
properties: { |
||||
resourceClassBaseId: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '资源类关联ID必须是整数', |
||||
minimum: '资源类关联ID是一个正整数', |
||||
}, |
||||
}, |
||||
resourceClassBaseIdentify: { |
||||
type: 'string', |
||||
minLength: 8, |
||||
maxLength: 8, |
||||
pattern: '^[a-zA-Z\\s]+$', |
||||
errorMessage: { |
||||
type: '资源类标识必须是一个字符串', |
||||
maxLength: '资源类标识是一个8位字符串', |
||||
minLength: '资源类标识是一个8位字符串', |
||||
pattern: '资源类标识必须为纯英文', |
||||
}, |
||||
}, |
||||
}, |
||||
}; |
||||
return makeDTO(data, schema); |
||||
} |
||||
|
||||
// @ 创建资源类拓展字段
|
||||
export function CreateResourceClassExpandFieldItemDTO(data) { |
||||
const schema = { |
||||
type: 'object', |
||||
properties: { |
||||
resourceClassBaseId: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '资源类ID必须是整数', |
||||
minimum: '资源类ID是一个正整数', |
||||
}, |
||||
}, |
||||
resourceClassExpandFieldName: { |
||||
type: 'string', |
||||
minLength: 1, |
||||
maxLength: 255, |
||||
errorMessage: { |
||||
type: '资源类拓展字段名必须是一个字符串', |
||||
maxLength: '资源类拓展字段名长度超出限制255', |
||||
minLength: '资源类拓展字段名长度过短', |
||||
}, |
||||
}, |
||||
resourceClassExpandFieldIdentify: { |
||||
type: 'string', |
||||
minLength: 1, |
||||
maxLength: 64, |
||||
pattern: '^[a-zA-Z\\s]+$', |
||||
errorMessage: { |
||||
type: '资源类拓展字段标识必须是一个字符串', |
||||
maxLength: '资源类拓展字段标识是一个8位字符串', |
||||
minLength: '资源类拓展字段标识是一个8位字符串', |
||||
pattern: '资源类拓展字段标识必须为纯英文', |
||||
}, |
||||
}, |
||||
resourceClassExpandFieldDisplayType: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
default: 0, |
||||
errorMessage: { |
||||
type: '拓展字段显示类型必须是整数', |
||||
minimum: '拓展字段显示类型是一个正整数', |
||||
}, |
||||
}, |
||||
resourceClassExpandFieldRelationType: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '拓展字段关联类型必须是整数', |
||||
minimum: '拓展字段关联类型是一个正整数', |
||||
}, |
||||
}, |
||||
resourceClassExpandFieldValue: { |
||||
type: 'string', |
||||
minLength: 1, |
||||
maxLength: 255, |
||||
errorMessage: { |
||||
type: '资源类拓展字段值必须是一个字符串', |
||||
maxLength: '资源类拓展字段值长度超出限制255', |
||||
minLength: '资源类拓展字段值长度过短', |
||||
}, |
||||
}, |
||||
}, |
||||
required: ['resourceClassBaseId', 'resourceClassExpandFieldName', 'resourceClassExpandFieldIdentify', 'resourceClassExpandFieldValue'], |
||||
errorMessage: { |
||||
required: { |
||||
resourceClassBaseId: '资源类ID为必填项', |
||||
resourceClassExpandFieldName: '资源类拓展字段名为必填项', |
||||
resourceClassExpandFieldIdentify: '资源类拓展字段标识为必填项', |
||||
resourceClassExpandFieldValue: '资源类拓展字段值为必填项', |
||||
}, |
||||
}, |
||||
}; |
||||
return makeDTO(data, schema); |
||||
} |
||||
|
||||
// @ 编辑资源类拓展字段
|
||||
export function EditResourceClassExpandFieldItemDTO(data) { |
||||
const schema = { |
||||
type: 'object', |
||||
properties: { |
||||
resourceClassExpandFieldId: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '资源类拓展字段ID必须是整数', |
||||
minimum: '资源类拓展字段ID是一个正整数', |
||||
}, |
||||
}, |
||||
resourceClassExpandFieldName: { |
||||
type: 'string', |
||||
minLength: 1, |
||||
maxLength: 255, |
||||
errorMessage: { |
||||
type: '资源类拓展字段名必须是一个字符串', |
||||
maxLength: '资源类拓展字段名长度超出限制255', |
||||
minLength: '资源类拓展字段名长度过短', |
||||
}, |
||||
}, |
||||
resourceClassExpandFieldIdentify: { |
||||
type: 'string', |
||||
minLength: 1, |
||||
maxLength: 64, |
||||
pattern: '^[a-zA-Z\\s]+$', |
||||
errorMessage: { |
||||
type: '资源类拓展字段标识必须是一个字符串', |
||||
maxLength: '资源类拓展字段标识是一个8位字符串', |
||||
minLength: '资源类拓展字段标识是一个8位字符串', |
||||
pattern: '资源类拓展字段标识必须为纯英文', |
||||
}, |
||||
}, |
||||
resourceClassExpandFieldDisplayType: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
default: 0, |
||||
errorMessage: { |
||||
type: '拓展字段显示类型必须是整数', |
||||
minimum: '拓展字段显示类型是一个正整数', |
||||
}, |
||||
}, |
||||
resourceClassExpandFieldRelationType: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '拓展字段关联类型必须是整数', |
||||
minimum: '拓展字段关联类型是一个正整数', |
||||
}, |
||||
}, |
||||
resourceClassExpandFieldValue: { |
||||
type: 'string', |
||||
minLength: 1, |
||||
maxLength: 255, |
||||
errorMessage: { |
||||
type: '资源类拓展字段值必须是一个字符串', |
||||
maxLength: '资源类拓展字段值长度超出限制255', |
||||
minLength: '资源类拓展字段值长度过短', |
||||
}, |
||||
}, |
||||
}, |
||||
required: ['resourceClassExpandFieldId', 'resourceClassExpandFieldName', 'resourceClassExpandFieldIdentify', 'resourceClassExpandFieldValue'], |
||||
errorMessage: { |
||||
required: { |
||||
resourceClassExpandFieldId: '资源类拓展字段ID为必填项', |
||||
resourceClassExpandFieldName: '资源类拓展字段名为必填项', |
||||
resourceClassExpandFieldIdentify: '资源类拓展字段标识为必填项', |
||||
resourceClassExpandFieldValue: '资源类拓展字段值为必填项', |
||||
}, |
||||
}, |
||||
}; |
||||
return makeDTO(data, schema); |
||||
} |
||||
|
||||
// @ 删除资源类拓展字段
|
||||
export function DeleteResourceClassExpandFieldItemDTO(data) { |
||||
const schema = { |
||||
type: 'object', |
||||
properties: { |
||||
resourceClassExpandFieldId: { |
||||
type: ['integer'], |
||||
minimum: 0, |
||||
errorMessage: { |
||||
type: '资源类拓展字段ID必须是整数', |
||||
minimum: '资源类拓展字段ID是一个正整数', |
||||
}, |
||||
}, |
||||
}, |
||||
required: ['resourceClassExpandFieldId', ], |
||||
errorMessage: { |
||||
required: { |
||||
resourceClassExpandFieldId: '资源类拓展字段ID为必填项', |
||||
}, |
||||
}, |
||||
}; |
||||
return makeDTO(data, schema); |
||||
} |
@ -0,0 +1,137 @@ |
||||
// | ------------------------------------------------------------
|
||||
// | @版本: version 0.1
|
||||
// | @创建人: 【Nie-x7129】
|
||||
// | @E-mail: x71291@outlook.com
|
||||
// | @所在项目: graphResource2
|
||||
// | @文件描述: index.js -
|
||||
// | @创建时间: 2023-12-03 15:24
|
||||
// | @更新时间: 2023-12-03 15:24
|
||||
// | @修改记录:
|
||||
// | -*-*-*- (时间--修改人--修改说明) -*-*-*-
|
||||
// | =
|
||||
// | ------------------------------------------------------------
|
||||
import Router from "koa-router"; |
||||
import { |
||||
CreateResourceClassExpandFieldItemDTO, |
||||
CreateResourceClassItemDTO, |
||||
CreateResourceClassRelationDTO, DeleteResourceClassExpandFieldItemDTO, DeleteResourceClassItemDTO, |
||||
DeleteResourceClassRelationDTO, EditResourceClassExpandFieldItemDTO, EditResourceClassItemDTO, |
||||
GetResourceClassCompleteInfoDTO, |
||||
GetResourceClassListDTO, |
||||
GetResourceClassPageDTO, |
||||
GetResourceClassTreeDTO |
||||
} from "#routes/graphResource2/resourceClass/index.dto.js"; |
||||
|
||||
const resourceClass = new Router() |
||||
|
||||
// @ 获取资源类列表
|
||||
resourceClass.get('/getResourceClassList', async (ctx, next) => { |
||||
const verif = GetResourceClassListDTO(ctx.query) |
||||
if (!verif.status) { |
||||
return ctx.throw(400, { e: verif.error.map((i) => i.message) }); |
||||
} |
||||
ctx.body = 1 |
||||
}) |
||||
|
||||
// @ 获取资源类分页
|
||||
resourceClass.get('/getResourceClassPage', async (ctx, next) => { |
||||
const verif = GetResourceClassPageDTO(ctx.query) |
||||
if (!verif.status) { |
||||
return ctx.throw(400, { e: verif.error.map((i) => i.message) }); |
||||
} |
||||
ctx.body = 2 |
||||
}) |
||||
|
||||
// @ 获取资源类树
|
||||
resourceClass.get('/getResourceClassTree', async (ctx, next) => { |
||||
const verif = GetResourceClassTreeDTO(ctx.query) |
||||
if (!verif.status) { |
||||
return ctx.throw(400, { e: verif.error.map((i) => i.message) }); |
||||
} |
||||
ctx.body = 3 |
||||
}) |
||||
|
||||
|
||||
// @ 添加资源类
|
||||
resourceClass.post('/createResourceClassItem', async (ctx, next) => { |
||||
const verif = CreateResourceClassItemDTO(ctx.request.body) |
||||
if (!verif.status) { |
||||
return ctx.throw(400, { e: verif.error.map((i) => i.message) }); |
||||
} |
||||
ctx.body = 4 |
||||
}) |
||||
|
||||
// @ 编辑资源类
|
||||
resourceClass.post('/editResourceClassItem', async (ctx, next) => { |
||||
const verif = EditResourceClassItemDTO(ctx.request.body) |
||||
if (!verif.status) { |
||||
return ctx.throw(400, { e: verif.error.map((i) => i.message) }); |
||||
} |
||||
ctx.body = 5 |
||||
}) |
||||
|
||||
// @ 删除资源类
|
||||
resourceClass.delete('/deleteResourceClassItem', async (ctx, next) => { |
||||
const verif = DeleteResourceClassItemDTO(ctx.query) |
||||
if (!verif.status) { |
||||
return ctx.throw(400, { e: verif.error.map((i) => i.message) }); |
||||
} |
||||
ctx.body = 6 |
||||
}) |
||||
|
||||
// @ 创建资源类关联
|
||||
resourceClass.post('/createResourceClassRelation', async (ctx, next) => { |
||||
const verif = CreateResourceClassRelationDTO(ctx.request.body) |
||||
if (!verif.status) { |
||||
return ctx.throw(400, { e: verif.error.map((i) => i.message) }); |
||||
} |
||||
ctx.body = 7 |
||||
}) |
||||
|
||||
// @ 删除资源类关联
|
||||
resourceClass.delete('/deleteResourceClassRelation', async (ctx, next) => { |
||||
const verif = DeleteResourceClassRelationDTO(ctx.query) |
||||
if (!verif.status) { |
||||
return ctx.throw(400, { e: verif.error.map((i) => i.message) }); |
||||
} |
||||
ctx.body = 8 |
||||
}) |
||||
|
||||
// @ 获取资源类完整信息
|
||||
resourceClass.get('/getResourceClassCompleteInfo', async (ctx, next) => { |
||||
const verif = GetResourceClassCompleteInfoDTO(ctx.query) |
||||
if (!verif.status) { |
||||
return ctx.throw(400, { e: verif.error.map((i) => i.message) }); |
||||
} |
||||
ctx.body = 9 |
||||
}) |
||||
|
||||
// @ 创建资源类拓展字段
|
||||
resourceClass.post('/createResourceClassExpandFieldItem', async (ctx, next) => { |
||||
const verif = CreateResourceClassExpandFieldItemDTO(ctx.request.body) |
||||
if (!verif.status) { |
||||
return ctx.throw(400, { e: verif.error.map((i) => i.message) }); |
||||
} |
||||
ctx.body = 10 |
||||
}) |
||||
|
||||
// @ 编辑资源类拓展字段
|
||||
resourceClass.post('/editResourceClassExpandFieldItem', async (ctx, next) => { |
||||
const verif = EditResourceClassExpandFieldItemDTO(ctx.request.body) |
||||
if (!verif.status) { |
||||
return ctx.throw(400, { e: verif.error.map((i) => i.message) }); |
||||
} |
||||
ctx.body = 11 |
||||
}) |
||||
|
||||
// @ 删除资源类拓展字段
|
||||
resourceClass.delete('/deleteResourceClassExpandFieldItem', async (ctx, next) => { |
||||
const verif = DeleteResourceClassExpandFieldItemDTO(ctx.query) |
||||
if (!verif.status) { |
||||
return ctx.throw(400, { e: verif.error.map((i) => i.message) }); |
||||
} |
||||
ctx.body = 12 |
||||
}) |
||||
|
||||
|
||||
export default resourceClass |
@ -0,0 +1,131 @@ |
||||
// | ------------------------------------------------------------
|
||||
// | @版本: version 0.1
|
||||
// | @创建人: 【Nie-x7129】
|
||||
// | @E-mail: x71291@outlook.com
|
||||
// | @所在项目: graphResource2
|
||||
// | @文件描述: makeClass.js -
|
||||
// | @创建时间: 2023-12-03 16:41
|
||||
// | @更新时间: 2023-12-03 16:41
|
||||
// | @修改记录:
|
||||
// | -*-*-*- (时间--修改人--修改说明) -*-*-*-
|
||||
// | =
|
||||
// | ------------------------------------------------------------
|
||||
|
||||
|
||||
const obj = { |
||||
id: 1, |
||||
name: '何希', |
||||
age: 25 |
||||
} |
||||
|
||||
const f1 = { |
||||
id: 2, |
||||
name: '何希的妈妈', |
||||
age: 45 |
||||
} |
||||
|
||||
const f2 = { |
||||
id: 3, |
||||
name: '何希的爸爸', |
||||
age: 45 |
||||
} |
||||
|
||||
class resourceClass{ |
||||
baseInfo; |
||||
expandInfo; |
||||
fatherObject = {} |
||||
constructor(baseInfo, expandInfo = {}) { |
||||
this.baseInfo = baseInfo; |
||||
this.expandInfo = expandInfo |
||||
} |
||||
addFather(obj){ |
||||
this.fatherObject[obj.id] = obj |
||||
} |
||||
delFather(obj){ |
||||
delete this.fatherObject[obj.id] |
||||
} |
||||
get baseInfo(){ |
||||
return this.baseInfo |
||||
} |
||||
get expandInfo(){ |
||||
return this.expandInfo |
||||
} |
||||
get fatherId(){ |
||||
return Object.keys(this.fatherObject) |
||||
} |
||||
get fatherObj(){ |
||||
return this.fatherObj |
||||
} |
||||
get fatherList(){ |
||||
return Object.keys(this.fatherObj).map(i => this.fatherObject[i]) |
||||
} |
||||
} |
||||
|
||||
function makeClass(obj1, obj2 = {}){ |
||||
return new resourceClass(obj1, obj2) |
||||
} |
||||
|
||||
|
||||
|
||||
const R1 = makeClass(obj); |
||||
const R2 = makeClass(obj); |
||||
|
||||
obj.age++ |
||||
|
||||
console.log(R1.baseInfo) |
||||
console.log(R1) |
||||
console.log(R2.baseInfo) |
||||
|
||||
|
||||
|
||||
const resourceCache = { |
||||
// 基础数据库信息
|
||||
baseData:{ |
||||
// 基础资源类信息
|
||||
resourceClassList: [], |
||||
resourceClassObject:{}, |
||||
// 拓展资源类信息
|
||||
resourceClassExpandFieldList: [], |
||||
resourceClassExpandFieldObject: {}, |
||||
// 实体字段信息
|
||||
resourceEntityStructList: [], |
||||
resourceEntityStructObject: {}, |
||||
// 资源实体信息
|
||||
resourceEntityList: [], |
||||
resourceEntityObject: {}, |
||||
// 资源类关系信息
|
||||
resourceClassRelationList: [], |
||||
resourceClassRelationObject: {} |
||||
}, |
||||
// 合成资源信息,计算数据
|
||||
computedData:{ |
||||
// 资源类完整数据 - 继承于baseData-resourceClassObject
|
||||
resourceClassObject: { |
||||
resourceClassId: { |
||||
// 基础资源类信息,查找字典值
|
||||
baseClassData: { |
||||
|
||||
}, |
||||
// 拓展资源类信息,查找字典值
|
||||
expandClassData:{ |
||||
|
||||
}, |
||||
// 资源实体结构转化为对象格式
|
||||
entityStructData:{ |
||||
|
||||
}, |
||||
// 资源类的父节点,及其关联下的子节点
|
||||
relationClass:{ |
||||
fatherId:['childId'] |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
// 资源关联信息
|
||||
relationData:{} |
||||
} |
||||
|
||||
// 第一步加载数据库数据
|
||||
|
||||
|
||||
|
@ -0,0 +1,36 @@ |
||||
// | ------------------------------------------------------------
|
||||
// | @版本: version 0.1
|
||||
// | @创建人: 【Nie-x7129】
|
||||
// | @E-mail: x71291@outlook.com
|
||||
// | @所在项目: graphResource2
|
||||
// | @文件描述: testClassExtents.js -
|
||||
// | @创建时间: 2023-12-03 17:58
|
||||
// | @更新时间: 2023-12-03 17:58
|
||||
// | @修改记录:
|
||||
// | -*-*-*- (时间--修改人--修改说明) -*-*-*-
|
||||
// | =
|
||||
// | ------------------------------------------------------------
|
||||
console.log('START') |
||||
console.time(1) |
||||
let list = [] |
||||
|
||||
const a1 = performance.now(); |
||||
for(let i = 0; i < 100000000; i ++){ |
||||
list.push({ |
||||
name: '何希', |
||||
age: 35, |
||||
love: 'GY', |
||||
key: parseInt(Math.random() * 100000000) |
||||
}) |
||||
} |
||||
console.log('A') |
||||
const a2 = performance.now(); |
||||
const data = list.filter(i => { |
||||
return (i.name + i.love + i.key).includes('GY21') |
||||
}) |
||||
const a3 = performance.now(); |
||||
|
||||
console.log('makeData', a2-a1) |
||||
console.log('filterData', a3-a2) |
||||
console.log(data.length) |
||||
console.timeEnd(1) |
Loading…
Reference in new issue