1. 程式人生 > >java操作mongodb指定集合及索引建立spring boot

java操作mongodb指定集合及索引建立spring boot

package com.paic.aims.farmer.farmerinfo.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.mapping.Document;

import
java.io.Serializable; /** * @author * 2018/3/28. * 三農資訊 */ /*指定集合*/ @Document(collection = "AIMS_INFORMATION") @ApiModel(value = "APP端返回三農資訊列表實體類") /* 建立索引,提高查詢速度 */ @CompoundIndexes( { @CompoundIndex(name = "publishDate_informationId",def = "{'publishDate':-1,'informationId':1}"
) }) public class InformationAppListModel implements Serializable{ /**主鍵ID**/ @ApiModelProperty(value = "id", example = "") private String informationId; /**資訊標題**/ @ApiModelProperty(value = "資訊標題", example = "") private String informationTitle; /**摘要**/ @ApiModelProperty
(value = "摘要", example = "") private String publishAbstract; /**封面圖片id**/ @ApiModelProperty(value = "封面圖片id", example = "") private Date publishDate; // }