完成团课查找功能
This commit is contained in:
+55
@@ -0,0 +1,55 @@
|
||||
package cn.novalon.gym.manage.db.converter;/*
|
||||
* @author:liwentao
|
||||
* @date:2026/4/26-04-26-13:18
|
||||
*/
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.novalon.gym.manage.db.entity.GroupCourseEntity;
|
||||
import cn.novalon.gym.manage.sys.core.domain.GroupCourse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class GroupCourseConverter {
|
||||
public GroupCourse toDomain(GroupCourseEntity entity){
|
||||
if(entity == null){
|
||||
return null;
|
||||
}
|
||||
GroupCourse groupCourse = new GroupCourse();
|
||||
BeanUtil.copyProperties(entity,groupCourse);
|
||||
log.info("转换bean,entity-domain:",groupCourse);
|
||||
return groupCourse;
|
||||
}
|
||||
|
||||
public GroupCourseEntity toEntity(GroupCourse domain){
|
||||
if(domain == null){
|
||||
return null;
|
||||
}
|
||||
GroupCourseEntity entity = new GroupCourseEntity();
|
||||
BeanUtil.copyProperties(domain,entity);
|
||||
log.info("转换bean,domain-entity:",entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<GroupCourse> toDomainList(List<GroupCourseEntity> entities){
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<GroupCourseEntity> toEntityList(List<GroupCourse> groupCourses){
|
||||
if (groupCourses == null) {
|
||||
return null;
|
||||
}
|
||||
return groupCourses.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.GroupCourseEntity;
|
||||
import cn.novalon.gym.manage.db.entity.SysUserEntity;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Repository
|
||||
public interface GroupCourseDao extends R2dbcRepository<GroupCourseEntity, Long> {
|
||||
|
||||
Mono<GroupCourseEntity> findByIdIsAndDeletedAtIsNull(Long id);
|
||||
|
||||
Flux<GroupCourseEntity> findAll();
|
||||
|
||||
Flux<GroupCourseEntity> findAll(Sort sort);
|
||||
|
||||
Flux<GroupCourseEntity> findAllByDeletedAtIsNull();
|
||||
|
||||
Flux<GroupCourseEntity> findAllByDeletedAtIsNull(Sort sort);
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author:liwentao
|
||||
* @date:2026/4/25-04-25-17:50
|
||||
* 团课预约记录表
|
||||
*/
|
||||
|
||||
@Table("group_course_booking")
|
||||
public class GroupCourseBookingEntity extends BaseEntity {
|
||||
|
||||
//团课id
|
||||
@Column("course_id")
|
||||
private Long courseId;
|
||||
|
||||
//用户id
|
||||
@Column("user_id")
|
||||
private Long userId;
|
||||
|
||||
//预约时间
|
||||
@Column("booking_time")
|
||||
private Date bookingTime;
|
||||
|
||||
//状态:0-已预约,1-已取消,2-已出席,3-缺席
|
||||
@Column("status")
|
||||
private Long status;
|
||||
//取消时间
|
||||
@Column("cancel_time")
|
||||
private Date cancelTime;
|
||||
|
||||
public Long getCourseId() {
|
||||
return courseId;
|
||||
}
|
||||
|
||||
public void setCourseId(Long courseId) {
|
||||
this.courseId = courseId;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Date getBookingTime() {
|
||||
return bookingTime;
|
||||
}
|
||||
|
||||
public void setBookingTime(Date bookingTime) {
|
||||
this.bookingTime = bookingTime;
|
||||
}
|
||||
|
||||
public Long getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Long status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getCancelTime() {
|
||||
return cancelTime;
|
||||
}
|
||||
|
||||
public void setCancelTime(Date cancelTime) {
|
||||
this.cancelTime = cancelTime;
|
||||
}
|
||||
}
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
/**
|
||||
* @author:liwentao
|
||||
* @date:2026/4/25-04-25-17:34
|
||||
* 团课表
|
||||
*/
|
||||
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@Table("group_course")
|
||||
public class GroupCourseEntity extends BaseEntity {
|
||||
|
||||
//课程名称
|
||||
@Column("course_name")
|
||||
private String courseName;
|
||||
|
||||
//教练id
|
||||
@Column("coach_id")
|
||||
private Long coachId;
|
||||
|
||||
//课程类型
|
||||
@Column("course_type")
|
||||
private Long courseType;
|
||||
|
||||
//开始时间
|
||||
@Column("start_time")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
//结束时间
|
||||
@Column("end_time")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
//最大参与人数
|
||||
@Column("max_members")
|
||||
private Integer maxMembers;
|
||||
|
||||
//当前参与人数
|
||||
@Column("current_members")
|
||||
private Integer currentMembers;
|
||||
|
||||
//课程状态:0-正常,1-已取消,2-已结束
|
||||
@Column("status")
|
||||
private Long status;
|
||||
|
||||
//上课地点
|
||||
@Column("location")
|
||||
private String location;
|
||||
|
||||
//封面图URL
|
||||
@Column("cover_image")
|
||||
private String coverImage;
|
||||
|
||||
//课程描述
|
||||
@Column("description")
|
||||
private String description;
|
||||
|
||||
public String getCourseName() {
|
||||
return courseName;
|
||||
}
|
||||
|
||||
public void setCourseName(String courseName) {
|
||||
this.courseName = courseName;
|
||||
}
|
||||
|
||||
public Long getCoachId() {
|
||||
return coachId;
|
||||
}
|
||||
|
||||
public void setCoachId(Long coachId) {
|
||||
this.coachId = coachId;
|
||||
}
|
||||
|
||||
public Long getCourseType() {
|
||||
return courseType;
|
||||
}
|
||||
|
||||
public void setCourseType(Long courseType) {
|
||||
this.courseType = courseType;
|
||||
}
|
||||
|
||||
public LocalDateTime getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(LocalDateTime startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(LocalDateTime endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public Integer getMaxMembers() {
|
||||
return maxMembers;
|
||||
}
|
||||
|
||||
public void setMaxMembers(Integer maxMembers) {
|
||||
this.maxMembers = maxMembers;
|
||||
}
|
||||
|
||||
public Integer getCurrentMembers() {
|
||||
return currentMembers;
|
||||
}
|
||||
|
||||
public void setCurrentMembers(Integer currentMembers) {
|
||||
this.currentMembers = currentMembers;
|
||||
}
|
||||
|
||||
public Long getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Long status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getCoverImage() {
|
||||
return coverImage;
|
||||
}
|
||||
|
||||
public void setCoverImage(String coverImage) {
|
||||
this.coverImage = coverImage;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.db.converter.GroupCourseConverter;
|
||||
import cn.novalon.gym.manage.db.dao.GroupCourseDao;
|
||||
import cn.novalon.gym.manage.sys.core.domain.GroupCourse;
|
||||
import cn.novalon.gym.manage.sys.core.repository.IGroupCourseRepository;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* @author:liwentao
|
||||
* @date:2026/4/26-04-26-14:16
|
||||
*/
|
||||
@Repository
|
||||
public class GroupCourseRepository implements IGroupCourseRepository {
|
||||
private final GroupCourseDao groupCourseDao;
|
||||
private final GroupCourseConverter groupCourseConverter;
|
||||
private final R2dbcEntityTemplate r2dbcEntityTemplate;
|
||||
|
||||
public GroupCourseRepository(GroupCourseDao groupCourseDao,GroupCourseConverter groupCourseConverter,
|
||||
R2dbcEntityTemplate r2dbcEntityTemplate){
|
||||
this.groupCourseDao = groupCourseDao;
|
||||
this.groupCourseConverter = groupCourseConverter;
|
||||
this.r2dbcEntityTemplate = r2dbcEntityTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<GroupCourse> findByIdAndDeletedAtIsNull(Long id) {
|
||||
return groupCourseDao.findByIdIsAndDeletedAtIsNull(id)
|
||||
.map(groupCourseConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourse> findAll() {
|
||||
return groupCourseDao.findAll()
|
||||
.map(groupCourseConverter::toDomain);
|
||||
}
|
||||
|
||||
public Flux<GroupCourse> findAll(Sort sort) {
|
||||
return groupCourseDao.findAll(sort)
|
||||
.map(groupCourseConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourse> findByDeletedAtIsNull() {
|
||||
return groupCourseDao.findAllByDeletedAtIsNull()
|
||||
.map(groupCourseConverter::toDomain);
|
||||
}
|
||||
|
||||
public Flux<GroupCourse> findByDeletedAtIsNull(Sort sort) {
|
||||
return groupCourseDao.findAllByDeletedAtIsNull(sort)
|
||||
.map(groupCourseConverter::toDomain);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user