当前位置: 首页>>代码示例>>Java>>正文


Java Criteria.andOperator方法代码示例

本文整理汇总了Java中org.springframework.data.mongodb.core.query.Criteria.andOperator方法的典型用法代码示例。如果您正苦于以下问题:Java Criteria.andOperator方法的具体用法?Java Criteria.andOperator怎么用?Java Criteria.andOperator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.data.mongodb.core.query.Criteria的用法示例。


在下文中一共展示了Criteria.andOperator方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMyRepositoryPosts

import org.springframework.data.mongodb.core.query.Criteria; //导入方法依赖的package包/类
/** 자기가 진행중인 저장소의 글을 검색함.
 * @param privateAndMassageTags
 * @param search
 * @param sort
 * @param page
 * @param size
 * @return
 */
public List<Post> getMyRepositoryPosts(List<String> privateAndMassageTags, String search, 
		String sort, int page,int size) {
	Criteria criteria = new Criteria();

	criteria.and("tags").in(privateAndMassageTags);

	if (search != null)
		criteria.andOperator(new Criteria().orOperator(
				Criteria.where("title").regex(search),
				Criteria.where("content").regex(search)));

	this.filter(criteria, sort);

	Query query = new Query(criteria);
	query.with(new PageRequest(page - 1, size));

	this.sorting(query, sort);
	return mongoTemplate.find(query, Post.class);
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:28,代码来源:PostDao.java

示例2: countMyPosts

import org.springframework.data.mongodb.core.query.Criteria; //导入方法依赖的package包/类
/** 자신의 글 숫자를 셈 (자기가 보낸 쪽지는 제외).
 * @param publicTags
 * @param privateAndMassageTags
 * @param writer
 * @param search
 * @param sort
 * @return
 */
public long countMyPosts(List<String> publicTags,List<String> privateAndMassageTags, Weaver writer, 
		String search, String sort) {
	Criteria criteria = new Criteria();

	if(privateAndMassageTags != null)
		criteria.orOperator(Criteria.where("writer").is(writer).and("kind").ne(3),
				Criteria.where("tags").in(privateAndMassageTags));
	else
		criteria.orOperator(Criteria.where("writer").is(writer).and("kind").ne(3));

	if (search != null)
		criteria.andOperator(new Criteria().orOperator(
				Criteria.where("title").regex(search),
				Criteria.where("content").regex(search)));

	if (publicTags != null)
		criteria.and("tags").all(publicTags);

	this.filter(criteria, sort);

	return mongoTemplate.count(new Query(criteria), Post.class);
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:31,代码来源:PostDao.java

示例3: countPostsAsPrivateTags

import org.springframework.data.mongodb.core.query.Criteria; //导入方法依赖的package包/类
/**  저장소 태그를 이용하여 글을 파악하고 셈
 * @param privateAndMassageTags
 * @param search
 * @param writer
 * @param sort
 * @return
 */
public long countPostsAsPrivateTags(List<String> privateAndMassageTags, String search, Weaver writer,String sort) {
	Criteria criteria = new Criteria();

	criteria.and("kind").is(2).and("tags")
	.all(privateAndMassageTags); // 비밀 글 가져오기

	if (writer != null)
		criteria.and("writer").is(writer);

	if (search != null)
		criteria.andOperator(criteria.orOperator(new Criteria("title").regex(search),
				new Criteria("content").regex(search)));

	this.filter(criteria, sort);

	return mongoTemplate.count(new Query(criteria), Post.class);
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:25,代码来源:PostDao.java

示例4: getPostsAsPrivateTags

import org.springframework.data.mongodb.core.query.Criteria; //导入方法依赖的package包/类
/** 저장소 태그를 이용하여 글을 검색함
 * @param privateAndMassageTags
 * @param search
 * @param writer
 * @param sort
 * @param page
 * @param size
 * @return
 */
public List<Post> getPostsAsPrivateTags(List<String> privateAndMassageTags, String search, Weaver writer,
		String sort, int page, int size) {

	Criteria criteria = new Criteria();

	criteria.and("kind").is(2).and("tags")
	.all(privateAndMassageTags); // 일반 일반글을 불러옴;

	if (writer != null)
		criteria.and("writer").is(writer);

	if (search != null)
		criteria.andOperator(criteria.orOperator(new Criteria("title").regex(search),
				new Criteria("content").regex(search)));

	this.filter(criteria, sort);

	Query query = new Query(criteria);
	query.with(new PageRequest(page - 1, size));

	this.sorting(query, sort);
	return mongoTemplate.find(query, Post.class);
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:33,代码来源:PostDao.java

示例5: countPostsAsMassageTag

import org.springframework.data.mongodb.core.query.Criteria; //导入方法依赖的package包/类
/** 메세지 태그를 이용하여 글을 검색하고 셈
 * @param userTags
 * @param search
 * @param writer
 * @param my
 * @param sort
 * @return
 */
public long countPostsAsMassageTag(String massageTag, String search, Weaver writer,
		boolean my, String sort) {
	Criteria criteria;
	if (my) // 유저가 test1라면 $test1 하나만 들어왔을때
		criteria = new Criteria().orOperator(
				Criteria.where("kind").is(3).and("tags").in(massageTag),
				Criteria.where("kind").is(3).and("writer")
				.is(writer));
	else  // 유저가 test1고 $test2 하나만 들어왔을때
	{
		String orderWeaverName = massageTag.substring(1);
		criteria = new Criteria().orOperator(
				Criteria.where("kind").is(3).and("writer") // test1이 test2에게 보낸 것
				.is(writer).and("tags").in(massageTag),
				Criteria.where("kind").is(3).and("writer.id") // test2가 test1에게 보낸 쪽지
				.is(orderWeaverName).and("tags").in("$"+writer.getId()));
	}
	if (search != null)
		criteria.andOperator(new Criteria().orOperator(
				Criteria.where("title").regex(search),
				Criteria.where("content").regex(search)));

	this.filter(criteria, sort);
	return mongoTemplate.count(new Query(criteria), Post.class);
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:34,代码来源:PostDao.java

示例6: countPostsAsWriter

import org.springframework.data.mongodb.core.query.Criteria; //导入方法依赖的package包/类
/** 로그인한 회원이 다른 사용자의 글을 검색할때 숫자를 셈.
 * @param publicTags
 * @param loginWeaverprivateAndMassageTags
 * @param writer
 * @param loginWeaver
 * @param search
 * @param sort
 * @return
 */
public long countPostsAsWriter(
		List<String> publicTags, List<String> loginWeaverprivateAndMassageTags,
		Weaver writer, Weaver loginWeaver, String search, String sort) {
	Criteria criteria = new Criteria();

	criteria.orOperator(
			Criteria.where("kind").is(1).and("writer").is(writer),
			Criteria.where("tags").in(loginWeaverprivateAndMassageTags)
			.and("writer").is(writer));

	if (search != null)
		criteria.andOperator(new Criteria().orOperator(
				Criteria.where("title").regex(search),
				Criteria.where("content").regex(search)));

	if (publicTags != null)
		criteria.and("tags").all(publicTags);

	this.filter(criteria, sort);

	return mongoTemplate.count(new Query(criteria), Post.class);
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:32,代码来源:PostDao.java

示例7: getMyPosts

import org.springframework.data.mongodb.core.query.Criteria; //导入方法依赖的package包/类
/** 자기글과 자기한테 온 메세지를 검색함.(자기가 보낸 쪽지는 제외)
 * @param publicTags
 * @param privateAndMassageTags
 * @param writer
 * @param search
 * @param sort
 * @param page
 * @param size
 * @return
 */
public List<Post> getMyPosts(List<String> publicTags,List<String> privateAndMassageTags,  Weaver writer, String search,
		String sort, int page, int size) {
	Criteria criteria = new Criteria();

	if(privateAndMassageTags != null)
		criteria.orOperator(Criteria.where("writer").is(writer).and("kind").ne(3),
				Criteria.where("tags").in(privateAndMassageTags));
	else
		criteria.orOperator(Criteria.where("writer").is(writer).and("kind").ne(3));
	if (search != null)
		criteria.andOperator(new Criteria().orOperator(
				Criteria.where("title").regex(search),
				Criteria.where("content").regex(search)));

	if (publicTags != null)
		criteria.and("tags").all(publicTags);

	this.filter(criteria, sort);

	Query query = new Query(criteria);
	query.with(new PageRequest(page - 1, size));

	this.sorting(query, sort);
	return mongoTemplate.find(query, Post.class);
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:36,代码来源:PostDao.java

示例8: createQueryByMap

import org.springframework.data.mongodb.core.query.Criteria; //导入方法依赖的package包/类
/**************************** 私有方法 *******************************/

	@SuppressWarnings("unchecked")
	private <R> QueryWraper<R> createQueryByMap(Map<Object, Object> map, Class<R> resultType, String orderBy) {
		Criteria criteriaLink = new Criteria();
		for (Entry<Object, Object> entry : map.entrySet()) {
			Object key = entry.getKey();
			Object value = entry.getValue();
			if (value instanceof AbstractExpression) {
				Criteria criteria = ((AbstractExpression) value).buildMongoCriteria(key);
				criteriaLink.andOperator(criteria);
			} else {
				String name = key.toString();
				criteriaLink.and(name).is(value);
			}
		}
		Query query = new Query(criteriaLink);
		if (!StringUtils.isEmpty(orderBy)) {
			query.with(MongoQueryFormHelper.getSort(orderBy));
		}
		return new QueryWraper<R>(query, (Class<R>) entityClass);
	}
 
开发者ID:szsucok,项目名称:sucok-framework,代码行数:23,代码来源:MongoGenericDao.java

示例9: getPostsAsMassageTag

import org.springframework.data.mongodb.core.query.Criteria; //导入方法依赖的package包/类
/** 메세지 태그를 이용하여 글을 검색
 * @param userTags
 * @param search
 * @param writer
 * @param my
 * @param sort
 * @param page
 * @param size
 * @return
 */
public List<Post> getPostsAsMassageTag(
		String massageTag, String search,Weaver writer, 
		boolean my, String sort, int page, int size) {
	Criteria criteria;
	if (my) // 유저가 test1라면 $test1 하나만 들어왔을때
		criteria = new Criteria().orOperator(
				Criteria.where("kind").is(3).and("tags").in(massageTag),
				Criteria.where("kind").is(3).and("writer")
				.is(writer));
	else  // 유저가 test1고 $test2 하나만 들어왔을때
	{
		String orderWeaverName = massageTag.substring(1);
		criteria = new Criteria().orOperator(
				Criteria.where("kind").is(3).and("writer") // test1이 test2에게 보낸 것
				.is(writer).and("tags").in(massageTag),
				Criteria.where("kind").is(3).and("writer.id") // test2가 test1에게 보낸 쪽지
				.is(orderWeaverName).and("tags").in("$"+writer.getId()));
	}
	if (search != null)
		criteria.andOperator(new Criteria().orOperator(
				Criteria.where("title").regex(search),
				Criteria.where("content").regex(search)));

	this.filter(criteria, sort);

	Query query = new Query(criteria);
	query.with(new PageRequest(page - 1, size));
	this.sorting(query, sort);

	return mongoTemplate.find(query, Post.class);
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:42,代码来源:PostDao.java

示例10: countPostsWhenLogin

import org.springframework.data.mongodb.core.query.Criteria; //导入方法依赖的package包/类
/** 로그인한 회원이 글을 검색할때 숫자를 셈.
 * @param publicTags
 * @param privateAndMassageTags
 * @param writer
 * @param search
 * @param sort
 * @return
 */
public long countPostsWhenLogin(List<String> publicTags, List<String> privateAndMassageTags,
		Weaver writer, String search, String sort) {
	Criteria criteria = new Criteria();


	if(privateAndMassageTags != null)
		criteria.orOperator(Criteria.where("kind").is(1),
				Criteria.where("writer").is(writer),
				Criteria.where("tags").in(privateAndMassageTags));

	else
		criteria.orOperator(Criteria.where("kind").is(1),
				Criteria.where("writer").is(writer));

	if (search != null)
		criteria.andOperator(new Criteria().orOperator(
				Criteria.where("title").regex(search),
				Criteria.where("content").regex(search)));

	if (publicTags != null)
		criteria.and("tags").all(publicTags);

	this.filter(criteria, sort);

	return mongoTemplate.count(new Query(criteria), Post.class);
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:35,代码来源:PostDao.java

示例11: getPostsWhenLogin

import org.springframework.data.mongodb.core.query.Criteria; //导入方法依赖的package包/类
/** 로그인한 회원이 글을 검색함.
 * @param publicTags
 * @param privateAndMassageTags
 * @param writer
 * @param search
 * @param sort
 * @param page
 * @param size
 * @return
 */
public List<Post> getPostsWhenLogin(
		List<String> publicTags, List<String> privateAndMassageTags,
		Weaver writer, String search, String sort, int page, int size) {

	Criteria criteria = new Criteria();

	if(privateAndMassageTags != null)
		criteria.orOperator(Criteria.where("kind").is(1),
				Criteria.where("writer").is(writer),
				Criteria.where("tags").in(privateAndMassageTags));
	else
		criteria.orOperator(Criteria.where("kind").is(1),
				Criteria.where("writer").is(writer));

	if (search != null)
		criteria.andOperator(new Criteria().orOperator(
				Criteria.where("title").regex(search),
				Criteria.where("content").regex(search)));

	if (publicTags != null)
		criteria.and("tags").all(publicTags);

	this.filter(criteria, sort);

	Query query = new Query(criteria);

	query.with(new PageRequest(page - 1, size));

	this.sorting(query, sort);
	return mongoTemplate.find(query, Post.class);
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:42,代码来源:PostDao.java

示例12: getPostsAsWriter

import org.springframework.data.mongodb.core.query.Criteria; //导入方法依赖的package包/类
/** 로그인한 회원이 다른 사용자의 글을 검색함.
 * @param publicTags
 * @param loginWeaverprivateAndMassageTags
 * @param writer
 * @param loginWeaver
 * @param search
 * @param sort
 * @param page
 * @param size
 * @return
 */
public List<Post> getPostsAsWriter(
		List<String> publicTags, List<String> loginWeaverprivateAndMassageTags,
		Weaver writer, Weaver loginWeaver, String search, String sort,
		int page, int size) {
	Criteria criteria = new Criteria();
	criteria.orOperator(
			Criteria.where("kind").is(1).and("writer").is(writer), //다른 사용자의 일반글.
			Criteria.where("tags").in(loginWeaverprivateAndMassageTags) //로그인한 회원의 태그를 기반으로 다른 사용자의 글을 검색.
			.and("writer").is(writer));

	if (search != null)
		criteria.andOperator(new Criteria().orOperator(
				Criteria.where("title").regex(search),
				Criteria.where("content").regex(search)));

	if (publicTags != null)
		criteria.and("tags").all(publicTags);

	this.filter(criteria, sort);

	Query query = new Query(criteria);
	query.with(new PageRequest(page - 1, size));

	this.sorting(query, sort);
	return mongoTemplate.find(query, Post.class);
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:38,代码来源:PostDao.java

示例13: countMyRepositoryPosts

import org.springframework.data.mongodb.core.query.Criteria; //导入方法依赖的package包/类
/** // 자기가 진행중인 저장소 글 숫자를 셈.
 * @param privateAndMassageTags
 * @param search
 * @param sort
 * @return
 */
public long countMyRepositoryPosts(List<String> privateAndMassageTags, String search, String sort) {
	Criteria criteria = new Criteria();

	criteria.and("tags").in(privateAndMassageTags);

	if (search != null)
		criteria.andOperator(new Criteria().orOperator(
				Criteria.where("title").regex(search),
				Criteria.where("content").regex(search)));

	this.filter(criteria, sort);

	return mongoTemplate.count(new Query(criteria), Post.class);
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:21,代码来源:PostDao.java

示例14: customerTitles

import org.springframework.data.mongodb.core.query.Criteria; //导入方法依赖的package包/类
/**
 *
 * @Description: 查询任务
 * @param
 * @return  List<PageData>
 * @throws Exception
 * @Data: 2017/3/2 下午4:47
 *
 */
@RequestMapping(value = "/customerTitles")
public PageData customerTitles(@RequestBody PageData pd){
	String handlerId=pd.getString("HANDLER_ID");
	if(StringUtils.isNotBlank(handlerId)){

		Calendar queryTime = Calendar.getInstance();
		queryTime.setTime(new Date());
		queryTime.add(Calendar.SECOND,titleIdTimeOut*-1);


		//查询所有未结束的消息
		Criteria criteria = new Criteria();
		criteria.andOperator(Criteria.where("HANDLER_ID").is(handlerId),Criteria.where("STATUS").is("1"),Criteria.where("CHANGE_TIME").gte(queryTime.getTime()));
		Query query = new Query(criteria);
		List<PageData> allTitle=mongoTemplate.find(query,PageData.class,"IM_TITLE");

		String handlerRedis=String.join("_",customerCounter,"HANDLER",handlerId);
		if(!redisTemplate.hasKey(handlerRedis)){
			return WebResult.requestFailed(401,"本客服以及下线!",null);
		}
		//客服人员上次更新时间
		Date updateDate=(Date) redisTemplate.opsForValue().get(handlerRedis);
		Date now=new Date();

		List<PageData> newTitle=new ArrayList<>();
		List<PageData> oldTitle=new ArrayList<>();
		for(PageData title:allTitle){
			String titleId=title.getString("TITLE_ID");
			if(redisTemplate.hasKey(String.join("_",customerCounter,titleId))){
				//查询新消息
				PageData contentPd=new PageData();
				contentPd.put("TITLE_ID",titleId);
				contentPd.put("STARTTIME",updateDate);
				contentPd.put("ENDTIME",now);
				contentPd.put("TITLE_TYPE","1");
				List<PageData> contentList=loopContent(contentPd);
				title.put("CONTENTLIST",contentList);

				//区分新旧回话
				Date changeTime=(Date)title.get("CHANGE_TIME");
				if(changeTime.compareTo(updateDate)>0){
					newTitle.add(title);
				}else{
					oldTitle.add(title);
				}
			}else{
				//关闭回话
				Criteria updCriteria = new Criteria();
				updCriteria.orOperator(Criteria.where("TITLE_ID").is(pd.get("TITLE_ID")));
				mongoTemplate.updateFirst(new Query(updCriteria), Update.update("STATUS","0"),"IM_TITLE");
			}
		}
		PageData retPd=new PageData();
		retPd.put("NEWTITLE",newTitle);
		retPd.put("OLDTITLE",oldTitle);
		retPd.put("IMGSERVER",imageServerUrl);

		//更新客服时间
		pd.put("_id",false);
		pd.put("_id",handlerId);
		pd.put("CHANGE_TIME",new Date());
		pd.put("CHANGE_UID",pd.getString("HANDLER_ID"));
		mongoTemplate.save(pd,"IM_INCUSTOMER");
		redisTemplate.opsForValue().set(handlerRedis, now, handlerTimeOut, TimeUnit.SECONDS);
		return WebResult.requestSuccess(retPd);
	}else{
		return WebResult.requestFailed(504,"参数错误",null);
	}
}
 
开发者ID:noseparte,项目名称:Spring-Boot-Server,代码行数:79,代码来源:AppCustomerRestful.java


注:本文中的org.springframework.data.mongodb.core.query.Criteria.andOperator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。