src/main/java/com/yuanlrc/base/service/common/BlogService.java

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package com.yuanlrc.base.service.common;
/**
 * 后台公告操作service
 */

import com.yuanlrc.base.bean.PageBean;
import com.yuanlrc.base.dao.common.BlogDao;
import com.yuanlrc.base.entity.common.Blog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.*;
import org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.List;

/**
 * 公告Service
 */
@Service
public class BlogService {
	
	@Autowired
	private BlogDao blogDao;
	
	/**
	 * 公告添加/编辑
	 * @param blog
	 * @return
	 */
	public Blog save(Blog blog){
		return blogDao.save(blog);
	}
	
	/**
	 * 获取所有的公告列表
	 * @return
	 */
	public List<Blog> findAll(){
		return blogDao.findAll();
	}
	
	/**
	 * 分页按公告标题搜索公告列表
	 * @param Blog
	 * @param pageBean
	 * @return
	 */
	public PageBean<Blog> findList(Blog Blog,PageBean<Blog> pageBean){
		ExampleMatcher withMatcher = ExampleMatcher.matching().withMatcher("title", GenericPropertyMatchers.contains());
		withMatcher = withMatcher.withIgnorePaths("type","status");
		Example<Blog> example = Example.of(Blog, withMatcher);
		Pageable pageable = PageRequest.of(pageBean.getCurrentPage()-1, pageBean.getPageSize());
		Page<Blog> findAll = blogDao.findAll(example, pageable);
		pageBean.setContent(findAll.getContent());
后面还有 62 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。