mirror of https://github.com/halo-dev/halo
Add data type property into ThemeSetting entity
parent
5922158cb4
commit
8a8d55eae1
|
@ -5,6 +5,7 @@ import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import org.hibernate.annotations.SQLDelete;
|
import org.hibernate.annotations.SQLDelete;
|
||||||
import org.hibernate.annotations.Where;
|
import org.hibernate.annotations.Where;
|
||||||
|
import run.halo.app.model.enums.DataType;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
@ -45,4 +46,17 @@ public class ThemeSetting extends BaseEntity {
|
||||||
@Column(name = "theme_id", columnDefinition = "varchar(255) not null")
|
@Column(name = "theme_id", columnDefinition = "varchar(255) not null")
|
||||||
private String themeId;
|
private String themeId;
|
||||||
|
|
||||||
|
@Column(name = "data_type", columnDefinition = "int default 0")
|
||||||
|
private DataType type;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void prePersist() {
|
||||||
|
super.prePersist();
|
||||||
|
|
||||||
|
id = null;
|
||||||
|
|
||||||
|
if (type == null) {
|
||||||
|
type = DataType.STRING;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package run.halo.app.model.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data type enum.
|
||||||
|
*
|
||||||
|
* @author johnniang
|
||||||
|
* @date 4/9/19
|
||||||
|
*/
|
||||||
|
public enum DataType implements ValueEnum<Integer> {
|
||||||
|
|
||||||
|
STRING(0),
|
||||||
|
|
||||||
|
LONG(1),
|
||||||
|
|
||||||
|
DOUBLE(2),
|
||||||
|
|
||||||
|
BOOL(3);
|
||||||
|
|
||||||
|
private Integer value;
|
||||||
|
|
||||||
|
DataType(Integer value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package run.halo.app.model.enums.converter;
|
||||||
|
|
||||||
|
import run.halo.app.model.enums.DataType;
|
||||||
|
|
||||||
|
import javax.persistence.Converter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data type converter.
|
||||||
|
*
|
||||||
|
* @author johnniang
|
||||||
|
* @date 4/10/19
|
||||||
|
*/
|
||||||
|
@Converter(autoApply = true)
|
||||||
|
public class DataTypeConverter extends AbstractConverter<DataType, Integer> {
|
||||||
|
|
||||||
|
public DataTypeConverter() {
|
||||||
|
super(DataType.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -297,6 +297,9 @@ public class ThemeServiceImpl implements ThemeService {
|
||||||
// Set the activated theme id
|
// Set the activated theme id
|
||||||
setActivatedThemeId(themeId);
|
setActivatedThemeId(themeId);
|
||||||
|
|
||||||
|
// Clear the cache
|
||||||
|
cacheStore.delete(THEMES_CACHE_KEY);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO Refactor here in the future
|
// TODO Refactor here in the future
|
||||||
configuration.setSharedVariable("themeName", themeId);
|
configuration.setSharedVariable("themeName", themeId);
|
||||||
|
|
Loading…
Reference in New Issue