Search in sources :

Example 1 with Options

use of com.tale.model.Options in project tale by otale.

the class OptionsServiceImpl method getOptions.

@Override
public Map<String, String> getOptions(String key) {
    Map<String, String> options = new HashMap<>();
    Take take = new Take(Options.class);
    if (StringKit.isNotBlank(key)) {
        take.like("name", key + "%");
    }
    List<Options> optionsList = activeRecord.list(take);
    if (null != optionsList) {
        optionsList.forEach(option -> options.put(option.getName(), option.getValue()));
    }
    return options;
}
Also used : Take(com.blade.jdbc.core.Take) Options(com.tale.model.Options) HashMap(java.util.HashMap)

Example 2 with Options

use of com.tale.model.Options in project tale by otale.

the class OptionsServiceImpl method saveOption.

@Override
public void saveOption(String key, String value) {
    if (StringKit.isNotBlank(key) && StringKit.isNotBlank(value)) {
        Options options = new Options();
        options.setName(key);
        int count = activeRecord.count(options);
        if (count == 0) {
            options.setValue(value);
            activeRecord.insert(options);
        } else {
            options.setValue(value);
            activeRecord.update(options);
        }
    }
}
Also used : Options(com.tale.model.Options)

Aggregations

Options (com.tale.model.Options)2 Take (com.blade.jdbc.core.Take)1 HashMap (java.util.HashMap)1