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;
}
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);
}
}
}