use of com.blade.jdbc.core.Take in project tale by otale.
the class PageController method index.
@Route(value = "", method = HttpMethod.GET)
public String index(Request request) {
Paginator<Contents> contentsPaginator = contentsService.getArticles(new Take(Contents.class).eq("type", Types.PAGE).page(1, TaleConst.MAX_POSTS, "created desc"));
request.attribute("articles", contentsPaginator);
return "admin/page_list";
}
use of com.blade.jdbc.core.Take in project tale by otale.
the class MetasServiceImpl method delete.
@Override
public void delete(int mid) {
Metas metas = activeRecord.byId(Metas.class, mid);
if (null != metas) {
String type = metas.getType();
String name = metas.getName();
activeRecord.delete(Metas.class, mid);
List<Relationships> rlist = activeRecord.list(new Take(Relationships.class).eq("mid", mid));
if (null != rlist) {
for (Relationships r : rlist) {
Contents contents = activeRecord.byId(Contents.class, r.getCid());
if (null != contents) {
boolean isUpdate = false;
Contents temp = new Contents();
temp.setCid(r.getCid());
if (type.equals(Types.CATEGORY)) {
temp.setCategories(reMeta(name, contents.getCategories()));
isUpdate = true;
}
if (type.equals(Types.TAG)) {
temp.setTags(reMeta(name, contents.getTags()));
isUpdate = true;
}
if (isUpdate) {
activeRecord.update(temp);
}
}
}
}
activeRecord.delete(new Take(Relationships.class).eq("mid", mid));
}
}
use of com.blade.jdbc.core.Take 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.blade.jdbc.core.Take in project tale by otale.
the class IndexController method feed.
/**
* feed页
*
* @return
*/
@Route(values = { "feed", "feed.xml" }, method = HttpMethod.GET)
public void feed(Response response) {
Paginator<Contents> contentsPaginator = contentsService.getArticles(new Take(Contents.class).eq("type", Types.ARTICLE).eq("status", Types.PUBLISH).eq("allow_feed", true).page(1, TaleConst.MAX_POSTS, "created desc"));
try {
String xml = TaleUtils.getRssXml(contentsPaginator.getList());
response.xml(xml);
} catch (Exception e) {
LOGGER.error("生成RSS失败", e);
}
}
use of com.blade.jdbc.core.Take in project tale by otale.
the class CommentsServiceImpl method getChildren.
/**
* 获取该评论下的追加评论
*
* @param coid
* @return
*/
private void getChildren(List<Comments> list, Integer coid) {
List<Comments> cms = activeRecord.list(new Take(Comments.class).eq("parent", coid).orderby("coid asc"));
if (null != cms) {
list.addAll(cms);
cms.forEach(c -> getChildren(list, c.getCoid()));
}
}
Aggregations