feat: add CheckinRecord entity and repository
This commit is contained in:
@@ -0,0 +1,54 @@
|
|||||||
|
package com.gym.manage.domain.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
import org.springframework.data.relational.core.mapping.Column;
|
||||||
|
import org.springframework.data.relational.core.mapping.Table;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Table("checkin_record")
|
||||||
|
public class CheckinRecord {
|
||||||
|
@Id
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column("tenant_id")
|
||||||
|
private Long tenantId;
|
||||||
|
|
||||||
|
@Column("store_id")
|
||||||
|
private Long storeId;
|
||||||
|
|
||||||
|
@Column("member_id")
|
||||||
|
private Long memberId;
|
||||||
|
|
||||||
|
@Column("checkin_type")
|
||||||
|
private String checkinType;
|
||||||
|
|
||||||
|
@Column("checkin_time")
|
||||||
|
private LocalDateTime checkinTime;
|
||||||
|
|
||||||
|
@Column("checkout_time")
|
||||||
|
private LocalDateTime checkoutTime;
|
||||||
|
|
||||||
|
@Column("device_id")
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
@Column("device_type")
|
||||||
|
private String deviceType;
|
||||||
|
|
||||||
|
@Column("status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Column("remark")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Column("created_at")
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
|
@Column("updated_at")
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
|
||||||
|
@Column("deleted_at")
|
||||||
|
private LocalDateTime deletedAt;
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.gym.manage.domain.repository;
|
||||||
|
|
||||||
|
import com.gym.manage.domain.entity.CheckinRecord;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.r2dbc.repository.Query;
|
||||||
|
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface CheckinRecordRepository extends R2dbcRepository<CheckinRecord, Long> {
|
||||||
|
|
||||||
|
Mono<CheckinRecord> findByIdAndDeletedAtIsNull(Long id);
|
||||||
|
|
||||||
|
Flux<CheckinRecord> findByMemberIdAndDeletedAtIsNull(Long memberId, Pageable pageable);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM checkin_record WHERE member_id = :memberId " +
|
||||||
|
"AND DATE(checkin_time) = DATE(:date) AND deleted_at IS NULL " +
|
||||||
|
"ORDER BY checkin_time DESC LIMIT 1")
|
||||||
|
Mono<CheckinRecord> findLatestByMemberIdAndDate(Long memberId, LocalDateTime date);
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(*) FROM checkin_record WHERE member_id = :memberId " +
|
||||||
|
"AND checkin_time >= :startTime AND checkin_time <= :endTime AND deleted_at IS NULL")
|
||||||
|
Mono<Long> countByMemberIdAndTimeRange(Long memberId, LocalDateTime startTime, LocalDateTime endTime);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user