HyperLeDger Fabric/HyperLeDger Composer网络定义用于课程注册绘图板



我想为"健身中心"创建一个区块链课程注册绘制。我使用Hyperledger Composer进行了示例,但没有发现出于我的目的的类似示例:

每个健身中心成员都应该能够 - 注册课程。 - 参加几门课程(1:N关系(。 - 删除他的出勤 - 或将课程注册到健身中心的另一名成员

我的问题:如何在Hyperledger作曲家中使用Fabric for我的用例构建智能设计模型?我在这里尝试:

我的主要问题:是1:n和n:n关系的设计(使业务网络组成部分:资产/参与者/交易和事件(,一个成员有多个课程,一门课程可能有多个组。

作为"织物/作曲家模型中的资产",我建议是课程和组(?(,但是匹配的Coursetogroup关系和参与者的关系关系是什么?我应该放在哪里?这将成为以功能写作的"业务逻辑"的一部分?

作为"面料/作曲家模型的参与者",我将放置与会者。

清楚我想做什么:在SQL中,我将创建此表来建立关系(简化用于插图, *= primalykey(:

(tbl: Course)
----------------------------------
CourseID* / Name
----------------------------------
001       ; Swim
002       ; Basic Training
003       ; Personal Training Class
(tbl: PersonalData)
----------------------------------
UserID*   / Name            
----------------------------------
1         ; Marc Miller
2         ; Tom Wood  
3         ; Mike Sun 
(tbl: MatchingCourseToGroup)
---------------------------------- 
GroupID*/ CourseID
----------------------------------
A       ;  001 (Group A belongs to the Swim Class)
B       ;  001 (Group B also belongs to the Swim Class)
C       ;  002 (Group C belongs to Basic Training)
D       ;  003 (and so on...) 
E       ;  003
F       ;  003
(tbl: ParticipantsInGroup)
---------------------------------- 
TicketID*/ UserID / CourseID
----------------------------------
01      ; 1 ; A
02      ; 1 ; B
03      ; 1 ; C
04      ; 2 ; A
05      ; 3 ; B
06      ; 3 ; C
Note:
Marc: takes part in 2 swim classes (Course with ID 001, received with primary key A) and (Course with ID 001, received with primary key B).
Other members can also take part in his Course.

结束:我不确定这种设计是否像我一样,在作曲家中工作,也许您有一些好的建议或类似的例子。

因为我的下一个问题将是进行良好的隐私实施,因此,正如我所理解的,我必须制定渠道,以将访问权限,更改可能性或将一个组的成员移至另一个组并达到达到联系管理权。

(想法是用户可以在入口处通过平板电脑自我注册(。

谢谢您的支持!

如果我正确理解您需要做什么,则可以尝试对.cto文件进行建模如下:

namespace org.test
participant Customer identified by customerId {
  o String customerId
  o String firstname
  o String lastname
  --> Course[] enrolledCourses
}
asset Course identified by courseId {
  o String courseId
  o String courseName
  o Integer participants
  o Integer maxParticipants default = 10
  o String status default = "OPEN"
  --> Customer[] participants 
}
transaction courseEnroll {
  --> Customer customer
  --> Course course
}

和逻辑JS文件中,您可以通过首先检查课程状态是否仍"打开"来实现courseEnroll事务。将客户添加到课程资产中的participants数组中,更新participants号码,并检查是否达到maxParticipants号码。在这种情况下,您可以将状态更改为"关闭"。

关于访问权限,您需要在权限文件中定义某些规则。ACL文件。例如,您可以从这两个规则开始:

rule CustomerEnroll {
  description: "Customers can enroll for a course only with their account"
  participant(t): "org.test.Customer"
  operation: ALL
  resource(v): "org.test.courseEnroll"
  condition:  (t.getIdentifier() == v.customer.getIdentifier())
  action: ALLOW
}
rule CustomerSeeUpdateThemselvesOnly {
  description: "Customers can see and update their own record only"
  participant(t): "org.test.Customer"
  operation: READ, UPDATE
  resource(v): "org.test.Customer"
  condition: (t.getIdentifier() == v.getIdentifier())
  action: ALLOW
}

最新更新