1. jpa

eg1

public interface CouponInfoRepository extends MongoRepository<CouponInfo, String>{

/**
* 跟进优惠券类型ID查找卷码
* @param couponId 优惠券类型ID
* @return 列表
*/
List<CouponInfo> findByCouponId(String couponId);
}
List<CouponInfo> couponInfos = couponInfoRepository.findByCouponId(couponId);


2.spting data MongoTemplate

eg1:

Criteria criteria = new Criteria();
criteria.and("couponState").is(EnumCouponState.PUBLISH);
TypedAggregation typedAggregation = TypedAggregation.newAggregation(Coupon.class, Arrays.asList(
TypedAggregation.match(criteria),
TypedAggregation.group("brandName")));
AggregationResults<Map> aggregationResults = mongoTemplate.aggregate(typedAggregation, Map.class);

eg2:
Original original = mongoTemplate.findById("600fe698fececf417c47acea", Original.class);
@Getter
@Setter
@ToString(callSuper = true)
@Document(collection = "original")
@EqualsAndHashCode(callSuper = true)
@CompoundIndexes({
@CompoundIndex(name = "tenantId_1_updateTime_1", def = "{'tenantId':1, 'updateTime':1}", background = true),
@CompoundIndex(name = "tenantId_1_originalId_1", def = "{'tenantId':1, 'originalId':1}", unique = true, background = true)
})
public class Original extends BaseClue {

/** 活动ID */
private String activityId;

/** 原始线索业务ID */
private String originalId;

/** 归集结果 */
private GroupResultEnum groupResult;

/** 扩展标记 */
private String mark;

/** 询底价:试驾时间 */
private Date driveTime;
}





相关文章:

  • 2022-01-18
  • 2021-11-15
  • 2021-10-17
  • 2022-02-07
  • 2022-01-30
  • 2021-07-15
  • 2021-09-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2021-08-04
  • 2021-09-06
相关资源
相似解决方案