com.invms.x.services.basis.HtmlService Maven / Gradle / Ivy
The newest version!
package com.invms.x.services.basis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.invms.x.builders.ArgsBuilder;
import com.invms.x.entities.basis.IBasisEntity;
import com.invms.x.entities.basis.HtmlEntity;
import com.invms.x.filters.ConfigFilter;
import com.invms.x.models.basis.HtmlModel;
import com.invms.x.repositories.EntityRepository;
import com.invms.x.services.BaseService;
import com.invms.x.utils.ComUtils;
@ConfigFilter(code = HtmlService.BASE_CODE, name = "网页服务", sortIndex = HtmlService.BASE_SORT_INDEX, parentCode = IBasisEntity.BASE_CODE)
@Service
public class HtmlService extends BaseService {
public static final String BASE_CODE = IBasisEntity.BASE_CODE + "_html";
public static final long BASE_SORT_INDEX = IBasisEntity.BASE_SORT_INDEX + 9600;
@Autowired
private EntityRepository entityRepository;
@Autowired
private ConfigService configService;
@ConfigFilter(code = BASE_CODE + "_siteDescription", name = "站点描述", value = "X", sortIndex = BASE_SORT_INDEX + 1, parentCode = BASE_CODE)
public String getSiteDescription() throws Exception {
return configService.getConfigValue(String.class, BASE_CODE + "_siteDescription", null, "X");
}
@ConfigFilter(code = BASE_CODE + "_siteKeywords", name = "站点关键字", value = "X", sortIndex = BASE_SORT_INDEX + 2, parentCode = BASE_CODE)
public String getSiteKeywords() throws Exception {
return configService.getConfigValue(String.class, BASE_CODE + "_siteKeywords", null, "X");
}
public HtmlModel getHtmlModel(ArgsBuilder argsBuilder) throws Exception {
String code = argsBuilder.getValue(String.class, "code");
String name = argsBuilder.getValue(String.class, "name");
String fullName = argsBuilder.getValue(String.class, "fullName");
HtmlModel model = null;
if (!ComUtils.empty(code)) {
model = entityRepository.getResultByFields(HtmlModel.class, HtmlEntity.class, "code", code);
}
if (model == null) {
model = new HtmlModel();
model.setCode(code);
model.setName(name);
model.setFullName(fullName);
} else {
String temp = entityRepository.getFullNameByHierarchic(HtmlModel.class, HtmlEntity.class, model.getHierarchy(), "/");
model.setFullName(ComUtils.empty(temp) ? fullName : temp);
}
if (model.getDescription() == null) {
model.setDescription(getSiteDescription());
}
if (model.getKeywords() == null) {
model.setKeywords(getSiteKeywords());
}
return model;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy