crcnt_muligo

Crates.iocrcnt_muligo
lib.rscrcnt_muligo
version0.1.1
sourcesrc
created_at2022-12-24 12:27:56.638331
updated_at2022-12-24 12:30:21.354888
descriptionCRCNT Multi Languages Component
homepagehttps://github.com/CRCNT/crcnt_ddd/tree/main/muligo
repositoryhttps://github.com/CRCNT/crcnt_ddd/tree/main/muligo
max_upload_size
id744926
size25,404
Zenas (zenas0810)

documentation

https://github.com/CRCNT/crcnt_ddd/tree/main/muligo

README

Mulingo

A Multi-Language configuration component.

DDL

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'

Usage

Dependencies

  • mysql_async to provide Conn to run the store functions
  • tracing & tracing_subscriber to enable tracing and logging

Domain Application

The 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
}

Create Mulingo

The Application's create_mulingo need seven arguments:

  • owner: the owner of the item
  • ns: namespace of the item
  • lang_key: the language key, e.g.: en, zh_CN, ...
  • msg_key: the item key
  • msg: the item content
  • memo: the item memo, optional
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;
}

Fetch Mulingo

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;
}
Commit count: 0

cargo fmt