公共字典模块

sodo-common-dict

在项目开发中,经常需要存储个别配置,或者是零碎的统计信息等 ... 为了节省建表并提供service层的功夫,common-dict提供了可依赖即用的公用模块。

1. 在Maven的Pom.xml中引入sodo-common-dict项目

<dependency>
    <groupId>com.shuodao</groupId>
    <artifactId>sodo-common-dict</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

2.继承Controller提供配置页面

public class DictConfigCongroller extends CommonDictionaryBaseController{

    @PostConstruct
    public void init(){
        dictionaryManager.addPage("sysConfig", "平台配置")
            .group("支付宝配置")
            .configString(SystemConfig.KEY_ALI_PAY_SELLER_ACCOUNT, "aliPaySellerAccount")
            .configString(SystemConfig.KEY_ALI_PAY_PARTNER, "aliPayPartner")
            .configString(SystemConfig.KEY_ALI_PAY_SECURITY_KEY, "aliPaySecurityKey")
            .configText(SystemConfig.KEY_ALI_PAY_PRIVATE_KEY, "aliPayPrivateKey")
            .configText(SystemConfig.KEY_ALI_PAY_PUBLIC_KEY, "aliPayPublicKey")
            .group("系统配置")
            .configString(SystemConfig.KEY_RECEPTION_APP_KEY, "客服AppKey")
            .configSelect(SystemConfig.KEY_THEME_DIR, "主题风格", "", ThemeEnum.values())
            .endFormGroup()
            .configSwitch(SystemConfig.KEY_HOME_SWITCH, "HomeSwith模式", false)
            .endFormGroup()
            .configSwitch(SystemConfig.KEY_SUBDOMAIN_REQUIRED, "公司简称必填", false);
    }

    @Override
    protected Belong belong() {
        return $.BELONG.ADMIN;
    }
}

3.使用字典配置

//in java 
CommonDictionaryManager.getInstance().get(NAMESPACE, key);

//in ftl
<#assign dictVal = dict("belong", "key") />
Copyright © Sodo Tech 2014-2018 all right reserved,powered by Gitbook最后更新: 2017-12-21 15:40

results matching ""

    No results matching ""