Crates.io | crcnt_muligo |
lib.rs | crcnt_muligo |
version | 0.1.1 |
source | src |
created_at | 2022-12-24 12:27:56.638331 |
updated_at | 2022-12-24 12:30:21.354888 |
description | CRCNT Multi Languages Component |
homepage | https://github.com/CRCNT/crcnt_ddd/tree/main/muligo |
repository | https://github.com/CRCNT/crcnt_ddd/tree/main/muligo |
max_upload_size | |
id | 744926 |
size | 25,404 |
A Multi-Language configuration component.
CREATE TABLE t_mulingo (
id VARCHAR(32) PRIMARY KEY,
owner VARCHAR(60) NOT NULL,
name_space VARCHAR(60) NOT NULL,
msg_key VARCHAR(200) NOT NULL,
lang_key VARCHAR(20) NOT NULL,
version VARCHAR(20) NOT NULL,
msg_content VARCHAR(2048) NOT NULL,
memo VARCHAR(200) NULL,
create_at TIMESTAMP NOT NULL,
update_at TIMESTAMP NOT NULL
) comment 'multi language message configuration'
mysql_async
to provide Conn
to run the store functionstracing
& tracing_subscriber
to enable tracing and loggingThe domain Application is the function entrance which need be initialized at first.
use crcnt_mulingo::includes::Application;
fn create_application() {
let pool: Pool = Pool::new("mysql://<username>:<userpwd>@localhost:3306/promo");
let application = Application::new(pool);
application
}
The Application's create_mulingo
need seven arguments:
en
, zh_CN
, ...use crcnt_mulingo::includes::*;
async fn create_mulingo() {
let ns: MulingoNameSpace = "com.payby.promotion".into();
let owner: MulingoOwner = "SYS_PROMOTION".into();
let lang_key: MulingoLangKey = "en".into();
let version: MulingoVersion = "0.1.2".into();
let msg_key: MulingoMsgKey = "EC_600001".into();
let msg: MulingoMsgContent = "The promotion code is overflow".into();
let memo: Option<MulingoMemo> = Some("erro code for overflow".into());
let entity = app.create_mulingo(owner,
ns,
lang_key,
msg_key,
version,
msg,
memo)
.await;
}
The Application's fetch_latest_mulingo
can get the mulingo item of the latest version.
use crcnt_mulingo::includes::*;
async fn create_mulingo() {
let ns: MulingoNameSpace = "com.payby.promotion".into();
let owner: MulingoOwner = "SYS_PROMOTION".into();
let lang_key: MulingoLangKey = "en".into();
let msg_key: MulingoMsgKey = "EC_600001".into();
let mulingo = app.fetch_latest_mulingo(&owner, &ns, &msg_key, &lang_key).await;
}