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;
    // 
}

猜你喜欢

转载自blog.csdn.net/yjw1007020425/article/details/80222556