我正在使用spring数据mongoDB进行spring启动应用程序。我有一个公共类,它包含所有公共属性,而我的其他类扩展它,以便我在其中具有这些公共属性。
$return = '';
foreach ($getallaffiliates as $theaffiliate) {
$user_id = get_userdata( $theaffiliate->user_id );
$userfirstname = $user_id->first_name;
$userlastname = $user_id->last_name;
$totalreferrals = $theaffiliate->referrals;
$affiliate_id = $theaffiliate->affiliate_id;
$getaffreferrals = $wpdb->get_results( "SELECT `date` FROM `wp_affiliate_wp_referrals` WHERE `affiliate_id` = $affiliate_id AND `date` >= '$current_year-$current_month-01:00:00:00' AND `date` < '$current_year-$current_month-$lastday:23:59:59' ORDER BY `wp_affiliate_wp_referrals`.`referral_id` ASC");//Get all referrals by affiliate id
$closerstring = $userfirstname." | This Month's Sales: ".count($getaffreferrals)."<br>";
if(!empty($getaffreferrals)){
$return_array.= $closerstring;
}
}
return $return_array;
现在当我在我的另一个类中扩展这个类时,如
@Getter
@Setter
@EntityListeners({AuditingEntityListener.class})
public abstract class AbstractAuditEntity implements Serializable {
@CreatedBy
@NotNull
private Long createdBy;
@LastModifiedBy
@NotNull
private Long updatedBy;
@CreatedDate
@NotNull
private Instant createdDate;
@LastModifiedDate
@NotNull
private Instant updatedDate;
}
在mongo数据库中创建的文档与我的类名相同,即&#34; ConsumerEntity&#34;,如何让@Document(collection =&#34; consumer&#34;)工作,以便在我的mongo数据库集合名称反映为&#34; consumer&#34;。谢谢