當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。