将团课相关代码迁移至gym-GroupCourse模块
This commit is contained in:
-55
@@ -1,55 +0,0 @@
|
||||
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
@@ -1,23 +0,0 @@
|
||||
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
@@ -1,75 +0,0 @@
|
||||
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
@@ -1,148 +0,0 @@
|
||||
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
@@ -1,57 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
-146
@@ -1,146 +0,0 @@
|
||||
package cn.novalon.gym.manage.sys.core.domain;
|
||||
/**
|
||||
* @author:liwentao
|
||||
* @date:2026/4/26-04-26-13:20
|
||||
*/
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
@Schema(description = "")
|
||||
public class GroupCourse extends BaseDomain{
|
||||
|
||||
//课程名称
|
||||
@Schema(description = "团课名", example = "Push-up")
|
||||
private String courseName;
|
||||
|
||||
//教练id
|
||||
@Schema(description = "教练id", example = "1")
|
||||
private Long coachId;
|
||||
|
||||
//课程类型
|
||||
@Schema(description = "课程类型", example = "1")
|
||||
private Long courseType;
|
||||
|
||||
//开始时间
|
||||
@Schema(description = "开始时间", example = "2026-01-01")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
//结束时间
|
||||
@Schema(description = "结束时间", example = "2026-01-02")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
//最大参与人数
|
||||
@Schema(description = "最大参与人数", example = "20")
|
||||
private Integer maxMembers;
|
||||
|
||||
//当前参与人数
|
||||
@Schema(description = "当前参与人数", example = "2")
|
||||
private Integer currentMembers;
|
||||
|
||||
//课程状态:0-正常,1-已取消,2-已结束
|
||||
@Schema(description = "课程状态", example = "0")
|
||||
private Long status;
|
||||
|
||||
//上课地点
|
||||
@Schema(description = "上课地点", example = "龙泉驿区幸福路")
|
||||
private String location;
|
||||
|
||||
//封面图URL
|
||||
@Schema(description = "封面图URL", example = "https://12345.com")
|
||||
private String coverImage;
|
||||
|
||||
//课程描述
|
||||
@Schema(description = "课程描述", example = "从入门到入土")
|
||||
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;
|
||||
}
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
package cn.novalon.gym.manage.sys.core.repository;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.GroupCourse;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface IGroupCourseRepository {
|
||||
Mono<GroupCourse> findByIdAndDeletedAtIsNull(Long id);
|
||||
Flux<GroupCourse> findAll();
|
||||
Flux<GroupCourse> findAll(Sort sort);
|
||||
Flux<GroupCourse> findByDeletedAtIsNull();
|
||||
Flux<GroupCourse> findByDeletedAtIsNull(Sort sort);
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
package cn.novalon.gym.manage.sys.core.service;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.GroupCourse;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface IGroupCourseService {
|
||||
Mono<GroupCourse> findById(Long id);
|
||||
Flux<GroupCourse> findAll();
|
||||
Flux<GroupCourse> findAll(boolean includeDeleted);
|
||||
}
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
package cn.novalon.gym.manage.sys.core.service.impl;
|
||||
|
||||
import cn.novalon.gym.manage.sys.audit.service.IAuditLogService;
|
||||
import cn.novalon.gym.manage.sys.core.domain.GroupCourse;
|
||||
import cn.novalon.gym.manage.sys.core.repository.IGroupCourseRepository;
|
||||
import cn.novalon.gym.manage.sys.core.service.IGroupCourseService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* @author:liwentao
|
||||
* @date:2026/4/26-04-26-14:12
|
||||
*/
|
||||
@Service
|
||||
public class GroupCourseService implements IGroupCourseService {
|
||||
private final IGroupCourseRepository groupCourseRepository;
|
||||
private final IAuditLogService auditLogService;
|
||||
public GroupCourseService(IGroupCourseRepository groupCourseRepository, IAuditLogService auditLogService){
|
||||
this.groupCourseRepository = groupCourseRepository;
|
||||
this.auditLogService = auditLogService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<GroupCourse> findById(Long id) {
|
||||
return groupCourseRepository.findByIdAndDeletedAtIsNull(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourse> findAll() {
|
||||
return groupCourseRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourse> findAll(boolean includeDeleted) {
|
||||
if(includeDeleted){
|
||||
return groupCourseRepository.findAll();
|
||||
}else{
|
||||
return groupCourseRepository.findByDeletedAtIsNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
package cn.novalon.gym.manage.sys.handler.groupCourse;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.GroupCourse;
|
||||
import cn.novalon.gym.manage.sys.core.service.IGroupCourseService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Validator;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* @author:liwentao
|
||||
* @date:2026/4/26-04-26-14:30
|
||||
*/
|
||||
@Component
|
||||
@Tag(name="团课管理",description = "团课相关操作")
|
||||
public class GroupCourseHandler {
|
||||
private final IGroupCourseService groupCourseService;
|
||||
private final Validator validator;
|
||||
public GroupCourseHandler(IGroupCourseService groupCourseService,Validator validator){
|
||||
this.groupCourseService = groupCourseService;
|
||||
this.validator = validator;
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有用户", description = "获取系统中所有用户列表")
|
||||
public Mono<ServerResponse> getAllGroupCourse(ServerRequest request){
|
||||
boolean includeDeleted = Boolean.valueOf(request.queryParam("includeDeleted").orElse("false"));
|
||||
return ServerResponse.ok()
|
||||
.body(groupCourseService.findAll(includeDeleted), GroupCourse.class);
|
||||
}
|
||||
|
||||
public Mono<ServerResponse> getGroupCourseById(ServerRequest request){
|
||||
Long id = Long.valueOf(request.pathVariable("id"));
|
||||
return groupCourseService.findById(id)
|
||||
.flatMap(groupCourse -> ServerResponse.ok().bodyValue(groupCourse))
|
||||
.switchIfEmpty(ServerResponse.notFound().build());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user