Files
mdm/src/main/java/com/midm/model/system/HelpMessage.java
T

103 lines
2.5 KiB
Java

package com.midm.model.system;
import com.google.common.base.Strings;
import com.mitac.cell.db.DbObject;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@Document
public class HelpMessage {
@Id
private String code;
private DbObject message;
private DbObject options;
private String comment;
public HelpMessage() {
}
public HelpMessage(String code) {
this.setCode(code);
}
public HelpMessage(String code, String locale, String title, String desc, String comment) {
this.setCode(code);
this.setMessage(locale, title, desc);
this.setComment(comment);
}
public String getCode() {
return this.code;
}
public void setCode(String code) {
this.code = code;
}
public DbObject getMessage() {
if (this.message == null) {
this.message = new DbObject();
}
return this.message;
}
public void setMessages(DbObject messages) {
this.message = messages;
}
public void setMessage(String locale, String title, String desc) {
this.getMessage().append(locale, (new DbObject("title", title)).append("desc", this.message));
}
public String getTitle(String locale) {
return this.getMessage(locale).getString("title");
}
public DbObject getMessage(String locale) {
return this.getMessage().getDbObject(new String[]{Strings.isNullOrEmpty(locale) ? "en-US" : locale});
}
public String getDescription(String locale) {
return this.getMessage(locale).getString("desc");
}
public DbObject getOptions() {
if (this.options == null) {
this.options = new DbObject();
}
return this.options;
}
public DbObject getOptions(String category) {
Object categoryObject = this.getOptions().get(category);
if (categoryObject == null) {
categoryObject = new DbObject();
this.getOptions().put(category, categoryObject);
}
return (DbObject)categoryObject;
}
public void setOptions(DbObject options) {
this.options = options;
}
public void setOptions(String category, DbObject options) {
this.getOptions().put(category, options);
}
public void setOptions(String category, String key, String desc) {
this.getOptions(category).put(key, desc);
}
public String getComment() {
return this.comment;
}
public void setComment(String comment) {
this.comment = comment;
}
}