Search in sources :

Example 16 with Blog

use of com.duan.blogos.entity.blog.Blog in project BlogSystem by DuanJiaNing.

the class BloggerStatisticsServiceImpl method getBloggerStatistics.

@Override
public ResultBean<BloggerStatisticsDTO> getBloggerStatistics(int bloggerId) {
    int blogCount = blogDao.countBlogByBloggerId(bloggerId, BlogStatusEnum.PUBLIC.getCode());
    List<Blog> blogs = blogDao.listAllWordCountByBloggerId(bloggerId, BlogStatusEnum.PUBLIC.getCode());
    int wordCountSum = blogs.stream().mapToInt(Blog::getWordCount).sum();
    int likeCount = blogs.stream().mapToInt(Blog::getId).map(statisticsDao::getLikeCount).sum();
    int likeGiveCount = likeDao.countLikeByLikerId(bloggerId);
    int categoryCount = categoryDao.countByBloggerId(bloggerId);
    int labelCount = labelDao.countByBloggerId(bloggerId);
    int collectCount = collectDao.countByCollectorId(bloggerId);
    int collectedCount = blogs.stream().mapToInt(Blog::getId).map(statisticsDao::getCollectCount).sum();
    int linkCount = linkDao.countLinkByBloggerId(bloggerId);
    BloggerStatisticsDTO dto = dataFillingManager.bloggerStatisticToDTO(blogCount, wordCountSum, likeCount, likeGiveCount, categoryCount, labelCount, collectCount, collectedCount, linkCount);
    return new ResultBean<>(dto);
}
Also used : BloggerStatisticsDTO(com.duan.blogos.dto.blogger.BloggerStatisticsDTO) Blog(com.duan.blogos.entity.blog.Blog) ResultBean(com.duan.blogos.restful.ResultBean)

Example 17 with Blog

use of com.duan.blogos.entity.blog.Blog in project BlogSystem by DuanJiaNing.

the class BlogDaoTest method insert.

@Test
public void insert() {
    String content = "Statement 是 Java 执行数据库操作的一个重要接口,用于在已经建立数据库连接的基础上,向数据库发送要执行的SQL语句。Statement对象,用于执行不带参数的简单SQL语句。\n" + "用于执行静态 SQL 语句并返回它所生成结果的对象。\n" + "在默认情况下,同一时间每个 Statement 对象在只能打开一个 ResultSet 对象。因此,如果读取一个 ResultSet 对象与读取另一个交叉,则这两个对象必须是由不同的 Statement 对象生成的。如果存在某个语句的打开的当前 ResultSet 对象,则 Statement 接口中的所有执行方法都会隐式关闭它。\n" + "Statement 对象用于将 SQL 语句发送到数据库中。实际上有三种 Statement 对象,它们都作为在给定连接上执行 SQL 语句的包容器:Statement、PreparedStatement(它从 Statement 继承而来)和 CallableStatement(它从 PreparedStatement 继承而来)。它们都专用于发送特定类型的 SQL 语句: Statement 对象用于执行不带参数的简单 SQL 语句;PreparedStatement 对象用于执行带或不带 IN 参数的预编译 SQL 语句;CallableStatement 对象用于执行对数据库已存在的存储过程的调用。\n" + "Statement 接口提供了执行语句和获取结果的基本方法。PreparedStatement 接口添加了处理 IN 参数的方法;而 CallableStatement 添加了处理 OUT 参数的方法。";
    Blog blog = new Blog();
    blog.setBloggerId(3);
    blog.setCategoryIds("5");
    blog.setLabelIds("5");
    blog.setTitle("Statement-1");
    blog.setContent(content);
    blog.setSummary("用于执行静态 SQL");
    blog.setWordCount(content.length());
    blog.setKeyWords("Statement SQL");
    // blog.setState();
    P.out(blogDao.insert(blog));
}
Also used : Blog(com.duan.blogos.entity.blog.Blog) Test(org.junit.Test) BaseTest(com.duan.blogos.BaseTest)

Aggregations

Blog (com.duan.blogos.entity.blog.Blog)17 ResultBean (com.duan.blogos.restful.ResultBean)6 BlogCategory (com.duan.blogos.entity.blog.BlogCategory)5 BlogStatistics (com.duan.blogos.entity.blog.BlogStatistics)5 LuceneException (com.duan.blogos.exception.internal.LuceneException)4 SQLException (com.duan.blogos.exception.internal.SQLException)4 IOException (java.io.IOException)4 BlogLabel (com.duan.blogos.entity.blog.BlogLabel)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 BaseTest (com.duan.blogos.BaseTest)2 BlogListItemDTO (com.duan.blogos.dto.blogger.BlogListItemDTO)2 BloggerStatisticsDTO (com.duan.blogos.dto.blogger.BloggerStatisticsDTO)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 Test (org.junit.Test)2 BlogCategoryDao (com.duan.blogos.dao.blog.BlogCategoryDao)1 BlogStatisticsDao (com.duan.blogos.dao.blog.BlogStatisticsDao)1 BloggerPictureDao (com.duan.blogos.dao.blogger.BloggerPictureDao)1 BlogListItemDTO (com.duan.blogos.dto.blog.BlogListItemDTO)1 BlogMainContentDTO (com.duan.blogos.dto.blog.BlogMainContentDTO)1