PlantUML Integration 编写短信服务类图

PlantUML Integration 写一个类图,主要功能为
1、编写一个serviceSms短信服务类;
2、需要用到短信的地方统一调用基建层的服务即可;
3、可以随意切换、增加短信厂商,不需要更改场景代码,只需要更改application.yml 里面的配置参数smsEffective的值即可完成切换;
4、方法签名1、类型 2、手机号 3、模板ID 4、泛型;
5、pplication.yml 里面的配置参数smsTest的值为true的时候,真实发送短信验证码,值为false的时候,不给用户发送验证码,仅写入将手机号+使用场景type为key、123456为值,写入缓存中;
6、方法签名的中的“类型”使用枚举,包含验证码、通知,如果值为“验证码”,需要将手机号+使用场景type为key、随机验证码为value,写入缓存中,过期时间为5分钟;

@startuml

interface SmsService {
    + sendSms(type: SmsType, phoneNumber: String, templateId: String, content: T): boolean
}

interface SmsProvider {
    + sendSms(type: SmsType, phoneNumber: String, templateId: String, content: T): boolean
}

class SmsProviderA {
    + sendSms(type: SmsType, phoneNumber: String, templateId: String, content: T): boolean
}

class SmsProviderB {
    + sendSms(type: SmsType, phoneNumber: String, templateId: String, content: T): boolean
}

class InfrastructureLayer {
    - SmsProvider smsProvider
}

enum SmsType {
    VERIFICATION_CODE
    NOTIFICATION
}

class Cache {
    + put(key: String, value: String, expiry: int): void
    + get(key: String): String
}

class ApplicationConfiguration {
    - boolean smsTest
}

SmsService --* SmsProvider
SmsProvider <|.. SmsProviderA
SmsProvider <|.. SmsProviderB
SmsProviderA --* InfrastructureLayer
SmsProviderB --* InfrastructureLayer
SmsService *-- SmsType
SmsService o-- Cache
SmsService o-- ApplicationConfiguration

' 注释
note top of SmsService
短信服务类,提供短信发送功能,控制发送模式,管理验证码缓存
end note

note top of SmsProvider
短信厂商接口,定义了发送短信的方法
end note
note top of SmsProviderA
厂商A实现
end note
note top of SmsProviderB
厂商B实现
end note
note top of Cache
验证码缓存类,用于存储和检索验证码
end note
note top of ApplicationConfiguration
应用配置类,用于控制短信发送模式
end note
note top of SmsType
短信类型枚举
end note
note top of InfrastructureLayer
基础设施层
end note

@enduml

请添加图片描述

  • 10
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值