plantuml的例子

流程图

https://plantuml.com/zh/guide
https://plantuml.com/zh/activity-diagram-beta

案例

泳道关系的流程图

在这里插入图片描述

@startuml

|#lightYellow|用户|
start
:输入手机号;
:选择话费套餐;
|#lightBlue|充值APP|
:生成,提交订单;
|#lightgray|服务商|
:生成订单;
|充值APP|
:展示支付方式;
|用户|
:选择支付方式;
:支付套餐金额;
|服务商|
:支付结果通知;
split
:更新订单状态;
|充值APP|
:展示支付结果;
|用户|
:获取支付结果;
kill
split again
 |服务商|
  -[dashed]->
 if(支付成功) then(成功)
 :向运营商发起充值请求;
 |#pink|运营商|
 :接收到充值请求;
 :执行充值;
 :通知充值结果;
 |服务商|
 :更新订单状态;
 |充值APP|
 :展示充值结果;
 |用户|
 :获取充值结果;
 floating note left #red:充值流程结束
  end
 else(失败)
 |服务商|
 :失败处理流程;
 kill
 
@enduml

时序图

在这里插入图片描述

@startuml
'https://plantuml.com/sequence-diagram
title 时序图示例
header @author chenxiu
footer page  @author chenxiu
skinparam roundcorner 20
skinparam sequenceParticipant underline
skinparam LifeLineBackgroundColor #lightYellow
hide footbox
actor User as user #green
box ATM
control 屏幕 as app #lightBlue
participant 读卡器 as reader #yellow
end box
 
box BANK #lightBlue
participant service
entity 短信
queue   MessageQueue
database Mysql
 
activate user
user->reader #lightBlue:插如银行卡
activate reader
reader-> reader:读卡
activate reader
deactivate reader
reader->app:显示屏幕
deactivate reader
activate app
app ->user:提示输入密码
deactivate app
user->app:输入密码
activate app
app-> service:查询用户
activate service
service->Mysql:查询用户
activate Mysql
Mysql ->service:resultSet
deactivate Mysql
alt 用户存在
   service ->> MessageQueue:发送登陆ATM消息
activate MessageQueue
note over MessageQueue #red:通过消息队列消峰
   ...30秒...
   MessageQueue ->短信:发送短信
   activate 短信
   短信 -->user
   deactivate 短信
   deactivate MessageQueue
   service ->app:服务选项
   app -> user :提示选择服务
else 用户不存在
|||
   service->app:登陆失败
   deactivate service
   app-> user:重新输入密码
   deactivate app
end
 
@enduml

时序图的序号

@startuml
autonumber
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response

autonumber 15
Bob -> Alice : Another authentication Request
Bob <- Alice : Another authentication Response

autonumber "<b>[000]"
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response

autonumber 15 "<b>(<u>##</u>)"
Bob -> Alice : Another authentication Request
Bob <- Alice : Another authentication Response

autonumber 40 10 "<font color=red><b>Message 0  "
Bob -> Alice : Yet another authentication Request
Bob <- Alice : Yet another authentication Response

autonumber 10 10 "<b>[000]"
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response
autonumber stop

Bob -> Alice : dummy

autonumber resume "<font color=red><b>Message 0  "
Bob -> Alice : Yet another authentication Request
Bob <- Alice : Yet another authentication Response
autonumber stop

Bob -> Alice : dummy

autonumber resume 1 "<font color=blue><b>Message 0  "
Bob -> Alice : Yet another authentication Request
Bob <- Alice : Yet another authentication Response

autonumber 1.1.1
Alice -> Bob: Authentication request
Bob --> Alice: Response

autonumber inc A
'Now we have 2.1.1
Alice -> Bob: Another authentication request
Bob --> Alice: Response

autonumber inc B
'Now we have 2.2.1
Alice -> Bob: Another authentication request
Bob --> Alice: Response

autonumber inc A
'Now we have 3.1.1
Alice -> Bob: Another authentication request
autonumber inc B
'Now we have 3.2.1
Bob --> Alice: Response
@enduml

调整样式后的
在这里插入图片描述

@startuml
title
 <u>下划线</u> 标题 <i>斜体</i>  <font color=red>红色</font>
end title
box "Internal Service" #LightBlue
  participant Alice as Alice #red
  participant Bob  #green
end box
participant Log

Alice -[#red]>  Bob: <font color=red>认证请求</font>
alt#Gold #LightBlue 成功情况
  Bob -[#0000FF]-> Alice: 认证接受
else #Pink 某种失败情况
  Bob -> Alice: 认证失败
  group 我自己的标签 [我自己的标签2]
    Alice -> Log : 开始记录攻击日志
    loop 1000次
      Alice -> Bob: DNS 攻击
    end
    Alice -> Log : 结束记录攻击日志
  end
else 另一种失败
  Bob -> Alice: 请重复
end
@enduml
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值