Search in sources :

Example 1 with Take

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";
}
Also used : Take(com.blade.jdbc.core.Take) Contents(com.tale.model.Contents)

Example 2 with Take

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));
    }
}
Also used : Take(com.blade.jdbc.core.Take) Metas(com.tale.model.Metas) Relationships(com.tale.model.Relationships) Contents(com.tale.model.Contents)

Example 3 with Take

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;
}
Also used : Take(com.blade.jdbc.core.Take) Options(com.tale.model.Options) HashMap(java.util.HashMap)

Example 4 with Take

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);
    }
}
Also used : Take(com.blade.jdbc.core.Take) Contents(com.tale.model.Contents) TipException(com.tale.exception.TipException)

Example 5 with Take

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()));
    }
}
Also used : Take(com.blade.jdbc.core.Take) Comments(com.tale.model.Comments)

Aggregations

Take (com.blade.jdbc.core.Take)15 Contents (com.tale.model.Contents)7 TipException (com.tale.exception.TipException)4 Comments (com.tale.model.Comments)3 Metas (com.tale.model.Metas)3 Relationships (com.tale.model.Relationships)2 Users (com.tale.model.Users)2 Paginator (com.blade.jdbc.model.Paginator)1 Route (com.blade.mvc.annotation.Route)1 Comment (com.tale.dto.Comment)1 Options (com.tale.model.Options)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1