diff --git a/src/main/java/com/dl/officialsite/common/enums/CodeEnums.java b/src/main/java/com/dl/officialsite/common/enums/CodeEnums.java index 49f9120a..4223cdb6 100644 --- a/src/main/java/com/dl/officialsite/common/enums/CodeEnums.java +++ b/src/main/java/com/dl/officialsite/common/enums/CodeEnums.java @@ -44,6 +44,7 @@ public enum CodeEnums { APPLY_REPEAT("1024", "apply repeat"), NOT_FOUND_BOUNTY("1025", "not found bounty"), + NOT_FOUND_COURSE("1026", "not found course"), // distribute ID_NEED_EMPTY("6000", "Id need empty"), diff --git a/src/main/java/com/dl/officialsite/course/Course.java b/src/main/java/com/dl/officialsite/course/Course.java new file mode 100644 index 00000000..0af8dd67 --- /dev/null +++ b/src/main/java/com/dl/officialsite/course/Course.java @@ -0,0 +1,61 @@ +package com.dl.officialsite.course; + +import lombok.Data; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EntityListeners; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +@Data +@Entity +@EntityListeners(AuditingEntityListener.class) +@Table(name = "course") +public class Course { + /** + * create table course + * ( + * id bigint auto_increment + * primary key, + * course_name varchar(255) null comment '课程名称', + * remark varchar(1024) null comment '课程简介', + * cooperate_community varchar(100) null comment '合作社区', + * creator varchar(64) null comment '创建者', + * updater varchar(64) null comment '更新者', + * create_time bigint null comment '创建时间', + * update_time bigint null comment '更新时间', + * status int null comment '状态,0:进行中,1:已结束' + * ) + * comment '课程表'; + */ + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + //课程名称 + private String courseName; + //课程简介 + private String remark; + //合作社区 + private String cooperateCommunity; + //创建者 + private String creator; + //更新者 + private String updater; + //创建时间 + @CreatedDate + @Column(updatable = false) + private Long createTime; + //更新时间 + @LastModifiedDate + @Column( updatable = false ,nullable = false) + private Long updateTime; + //状态,0:进行中,1:已结束 + private Integer status; +} diff --git a/src/main/java/com/dl/officialsite/course/CourseController.java b/src/main/java/com/dl/officialsite/course/CourseController.java new file mode 100644 index 00000000..08b0d484 --- /dev/null +++ b/src/main/java/com/dl/officialsite/course/CourseController.java @@ -0,0 +1,69 @@ +package com.dl.officialsite.course; + +import com.dl.officialsite.common.base.BaseResponse; +import com.dl.officialsite.course.vo.CourseAddVo; +import com.dl.officialsite.course.vo.CourseQueryVo; +import com.dl.officialsite.course.vo.CourseSearchVo; +import com.dl.officialsite.course.vo.CourseUpdateVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @Description + * @Author xiaoming + * @Date 2024/9/12 7:37 PM + **/ +@RestController +@RequestMapping("/course") +@Slf4j +public class CourseController { + + @Resource + private CourseService courseService; + + + @PostMapping("/add") + public BaseResponse add(@RequestBody CourseAddVo courseAddVo, @RequestParam String address) { + return BaseResponse.successWithData(courseService.add(courseAddVo, address)); + } + + @PostMapping("/update") + public BaseResponse update(@RequestBody CourseUpdateVo courseUpdateVo, @RequestParam String address) { + courseService.update(courseUpdateVo, address); + return BaseResponse.successWithData(null); + } + + @PostMapping("/detail") + public BaseResponse detail(@RequestParam Long id, @RequestParam(defaultValue = "1") Integer pageNumber, + @RequestParam(defaultValue = "10") Integer pageSize) { + Pageable pageable = PageRequest.of(pageNumber - 1, pageSize, Sort.by(Sort.Direction.DESC, "createTime")); + return BaseResponse.successWithData(courseService.detail(id, pageable)); + } + + @PostMapping("/list") + public BaseResponse list( + @RequestParam(defaultValue = "1") Integer pageNumber, + @RequestParam(defaultValue = "10") Integer pageSize) { + Pageable pageable = PageRequest.of(pageNumber - 1, pageSize, Sort.by(Sort.Direction.DESC, "createTime")); + CourseSearchVo courseSearchVo = new CourseSearchVo(); + Page page = courseService.search(courseSearchVo, pageable); + return BaseResponse.successWithData(page); + } + + @PostMapping("/delete") + public BaseResponse delete(@RequestParam Long id, @RequestParam String address) { + courseService.delete(id); + return BaseResponse.successWithData(null); + } + +} diff --git a/src/main/java/com/dl/officialsite/course/CourseRepository.java b/src/main/java/com/dl/officialsite/course/CourseRepository.java new file mode 100644 index 00000000..05a43a01 --- /dev/null +++ b/src/main/java/com/dl/officialsite/course/CourseRepository.java @@ -0,0 +1,11 @@ +package com.dl.officialsite.course; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + + +public interface CourseRepository extends JpaRepository, JpaSpecificationExecutor { + + + +} diff --git a/src/main/java/com/dl/officialsite/course/CourseService.java b/src/main/java/com/dl/officialsite/course/CourseService.java new file mode 100644 index 00000000..55fe6e72 --- /dev/null +++ b/src/main/java/com/dl/officialsite/course/CourseService.java @@ -0,0 +1,136 @@ +package com.dl.officialsite.course; + +import cn.hutool.core.collection.CollUtil; +import com.dl.officialsite.common.enums.CodeEnums; +import com.dl.officialsite.common.exception.BizException; +import com.dl.officialsite.course.constant.CourseStatusEnums; +import com.dl.officialsite.course.vo.CourseAddVo; +import com.dl.officialsite.course.vo.CourseQueryVo; +import com.dl.officialsite.course.vo.CourseSearchVo; +import com.dl.officialsite.course.vo.CourseUpdateVo; +import com.dl.officialsite.sharing.Share; +import com.dl.officialsite.sharing.SharingRepository; +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; +import javax.persistence.criteria.Predicate; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +import static com.dl.officialsite.common.enums.CodeEnums.NOT_FOUND_COURSE; + +/** + * @Description + * @Author xiaoming + * @Date 2024/9/12 7:32 PM + **/ +@Service +@Slf4j +public class CourseService { + + @Resource + private CourseRepository courseRepository; + @Resource + private SharingRepository sharingRepository; + public Course add(CourseAddVo courseAddVo, String address) { + Course course = new Course(); + BeanUtils.copyProperties(courseAddVo, course); + course.setCreator(address); + course.setUpdater(address); + course.setStatus(CourseStatusEnums.ING.getCode()); + courseRepository.save(course); + Long courseId = course.getId(); + + List shareIdList = courseAddVo.getShareIdList(); + shareIdList.forEach(shareId -> { + Share share = sharingRepository.findById(shareId).orElseThrow(() -> new BizException(CodeEnums.SHARING_NOT_FOUND.getCode(), CodeEnums.SHARING_NOT_FOUND.getMsg())); + share.setCourseId(courseId); + sharingRepository.save(share); + }); + return course; + } + + @Transactional(rollbackFor = Exception.class) + public void update(CourseUpdateVo courseUpdateVo, String address) { + Long courseId = courseUpdateVo.getId(); + Course course = courseRepository.findById(courseUpdateVo.getId()).orElseThrow(() -> new BizException(NOT_FOUND_COURSE.getCode(), NOT_FOUND_COURSE.getMsg())); + BeanUtils.copyProperties(courseUpdateVo, course); + course.setUpdater(address); + courseRepository.save(course); + + List shareIdList = courseUpdateVo.getShareIdList(); + //先将分享的课程id设置为null + List oldShareList = sharingRepository.findByCourseId(courseId); + List oldIdList = oldShareList.stream().map(Share::getId).collect(Collectors.toList()); + if(CollUtil.isNotEmpty(oldShareList)){ + Collection subtract = CollUtil.subtract(oldIdList, shareIdList); + if(CollUtil.isNotEmpty(subtract)){ + sharingRepository.updateCourseIdToNull(Lists.newArrayList(subtract)); + } + } + //设置新的分享课程id + shareIdList.forEach(shareId -> { + Share share = sharingRepository.findById(shareId).orElseThrow(() -> new BizException(CodeEnums.SHARING_NOT_FOUND.getCode(), CodeEnums.SHARING_NOT_FOUND.getMsg())); + share.setCourseId(courseId); + sharingRepository.save(share); + }); + } + + public Page search(CourseSearchVo courseSearchVo, Pageable pageable) { + Page all = courseRepository.findAll((root, query, criteriaBuilder) -> { + List predicates = new ArrayList<>(); + if (StringUtils.isNotBlank(courseSearchVo.getCourseName())) { + predicates.add(criteriaBuilder.like(root.get("courseName"), "%" + courseSearchVo.getCourseName() + "%")); + } + if (StringUtils.isNotBlank(courseSearchVo.getRemark())) { + predicates.add(criteriaBuilder.like(root.get("remark"), "%" + courseSearchVo.getRemark() + "%")); + } + if (StringUtils.isNotBlank(courseSearchVo.getCooperateCommunity())) { + predicates.add(criteriaBuilder.like(root.get("cooperateCommunity"), "%" + courseSearchVo.getCooperateCommunity() + "%")); + } + if (courseSearchVo.getStatus() != null) { + predicates.add(criteriaBuilder.equal(root.get("status"), courseSearchVo.getStatus())); + } + return criteriaBuilder.and(predicates.toArray(new Predicate[0])); + }, pageable); + return all.map(course -> { + CourseQueryVo courseQueryVo = new CourseQueryVo(); + BeanUtils.copyProperties(course, courseQueryVo); + return courseQueryVo; + }); + } + + public CourseQueryVo detail(Long id, Pageable pageable) { + Course course = courseRepository.findById(id).orElseThrow(() -> new BizException(NOT_FOUND_COURSE.getCode(), NOT_FOUND_COURSE.getMsg())); + CourseQueryVo courseQueryVo = new CourseQueryVo(); + BeanUtils.copyProperties(course, courseQueryVo); + //通过courseId分页查找share + Page all = sharingRepository.findAll((root, query, criteriaBuilder) -> { + List predicates = new ArrayList<>(); + predicates.add(criteriaBuilder.equal(root.get("courseId"), id)); + return criteriaBuilder.and(predicates.toArray(new Predicate[0])); + }, pageable); + courseQueryVo.setSharePage(all); + return courseQueryVo; + } + + public void delete(Long id) { + Course course = courseRepository.findById(id).orElseThrow(() -> new BizException(NOT_FOUND_COURSE.getCode(), NOT_FOUND_COURSE.getMsg())); + courseRepository.delete(course); + + //先将分享的课程id设置为null + List oldShareList = sharingRepository.findByCourseId(id); + List oldIdList = oldShareList.stream().map(Share::getId).collect(Collectors.toList()); + if(CollUtil.isNotEmpty(oldShareList)){ + sharingRepository.updateCourseIdToNull(oldIdList); + } + } +} diff --git a/src/main/java/com/dl/officialsite/course/constant/CourseStatusEnums.java b/src/main/java/com/dl/officialsite/course/constant/CourseStatusEnums.java new file mode 100644 index 00000000..f690cb70 --- /dev/null +++ b/src/main/java/com/dl/officialsite/course/constant/CourseStatusEnums.java @@ -0,0 +1,24 @@ +package com.dl.officialsite.course.constant; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Description + * @Author xiaoming + * @Date 2024/9/12 7:40 PM + **/ +@Getter +@AllArgsConstructor +public enum CourseStatusEnums { + /** + * 状态,0:进行中,1:已结束 + */ + ING(0, "进行中"), + END(1, "已结束"); + + + private int code; + + private String message; +} diff --git a/src/main/java/com/dl/officialsite/course/vo/CourseAddVo.java b/src/main/java/com/dl/officialsite/course/vo/CourseAddVo.java new file mode 100644 index 00000000..0df7ac69 --- /dev/null +++ b/src/main/java/com/dl/officialsite/course/vo/CourseAddVo.java @@ -0,0 +1,26 @@ +package com.dl.officialsite.course.vo; + +import lombok.Data; + +import java.util.List; + +/** + * @Description + * @Author xiaoming + * @Date 2024/9/12 7:35 PM + **/ +@Data +public class CourseAddVo { + + //课程名称 + private String courseName; + //课程简介 + private String remark; + //合作社区 + private String cooperateCommunity; + + /** + * 分享id列表 + */ + private List shareIdList; +} diff --git a/src/main/java/com/dl/officialsite/course/vo/CourseQueryVo.java b/src/main/java/com/dl/officialsite/course/vo/CourseQueryVo.java new file mode 100644 index 00000000..5de14668 --- /dev/null +++ b/src/main/java/com/dl/officialsite/course/vo/CourseQueryVo.java @@ -0,0 +1,40 @@ +package com.dl.officialsite.course.vo; + +import com.dl.officialsite.sharing.Share; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; +import org.springframework.data.domain.Page; + +/** + * @Description + * @Author xiaoming + * @Date 2024/9/12 7:50 PM + **/ +@Data +public class CourseQueryVo { + +// @JsonSerialize(using = ToStringSerializer.class) + private Long id; + //课程名称 + private String courseName; + //课程简介 + private String remark; + //合作社区 + private String cooperateCommunity; + //创建者 + private String creator; + //更新者 + private String updater; + //创建时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Long createTime; + //更新时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Long updateTime; +// //状态,0:进行中,1:已结束 +// private Integer status; + + private Page sharePage; +} diff --git a/src/main/java/com/dl/officialsite/course/vo/CourseSearchVo.java b/src/main/java/com/dl/officialsite/course/vo/CourseSearchVo.java new file mode 100644 index 00000000..78b28272 --- /dev/null +++ b/src/main/java/com/dl/officialsite/course/vo/CourseSearchVo.java @@ -0,0 +1,21 @@ +package com.dl.officialsite.course.vo; + +import lombok.Data; + +/** + * @Description + * @Author xiaoming + * @Date 2024/9/12 7:48 PM + **/ +@Data +public class CourseSearchVo { + + //课程名称 + private String courseName; + //课程简介 + private String remark; + //合作社区 + private String cooperateCommunity; + //课程状态 + private Integer status; +} diff --git a/src/main/java/com/dl/officialsite/course/vo/CourseUpdateVo.java b/src/main/java/com/dl/officialsite/course/vo/CourseUpdateVo.java new file mode 100644 index 00000000..2bab51af --- /dev/null +++ b/src/main/java/com/dl/officialsite/course/vo/CourseUpdateVo.java @@ -0,0 +1,33 @@ +package com.dl.officialsite.course.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; + +import java.util.List; + +/** + * @Description + * @Author xiaoming + * @Date 2024/9/12 7:44 PM + **/ +@Data +public class CourseUpdateVo { + + +// @JsonSerialize(using = ToStringSerializer.class) + private Long id; + //课程名称 + private String courseName; + //课程简介 + private String remark; + //合作社区 + private String cooperateCommunity; +// //课程状态 +// private Integer status; + + /** + * 分享id列表 + */ + private List shareIdList; +} diff --git a/src/main/java/com/dl/officialsite/login/filter/LoginFilter.java b/src/main/java/com/dl/officialsite/login/filter/LoginFilter.java index 65ae66c2..6eb0dafa 100644 --- a/src/main/java/com/dl/officialsite/login/filter/LoginFilter.java +++ b/src/main/java/com/dl/officialsite/login/filter/LoginFilter.java @@ -71,6 +71,8 @@ public class LoginFilter extends OncePerRequestFilter { add("/share/search"); add("/share/query"); add("/sponsors/all"); + add("/course/detail"); + add("/course/list"); }} ; private Set noAddrCheckApis = new HashSet() {{ diff --git a/src/main/java/com/dl/officialsite/sharing/Share.java b/src/main/java/com/dl/officialsite/sharing/Share.java index 485b5c11..428d5ea6 100644 --- a/src/main/java/com/dl/officialsite/sharing/Share.java +++ b/src/main/java/com/dl/officialsite/sharing/Share.java @@ -139,6 +139,12 @@ public class Share { @Column(name = "tag") private String tag; + /** + * 课程Id + */ + @Column(name = "course_id") + private Long courseId; + @CreatedDate @Column(updatable = false) private Long createTime; diff --git a/src/main/java/com/dl/officialsite/sharing/ShareCourseController.java b/src/main/java/com/dl/officialsite/sharing/ShareCourseController.java new file mode 100644 index 00000000..2fa04b2b --- /dev/null +++ b/src/main/java/com/dl/officialsite/sharing/ShareCourseController.java @@ -0,0 +1,40 @@ +package com.dl.officialsite.sharing; + +import com.dl.officialsite.common.base.BaseResponse; +import com.dl.officialsite.sharing.model.req.CourseShareAddReq; +import com.dl.officialsite.sharing.model.req.CourseShareDeleteReq; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @Description + * @Author xiaoming + * @Date 2024/9/13 7:57 AM + **/ +@RestController +@RequestMapping("/shareCourse") +@Slf4j +@Deprecated +public class ShareCourseController { + + @Resource + private ShareCourseService shareCourseService; + + @PostMapping("/addOrModify") + public BaseResponse addOrModifyShareCourse(@RequestBody CourseShareAddReq courseShareAddReq, @RequestParam String address) { + shareCourseService.addShareCourse(courseShareAddReq); + return BaseResponse.successWithData(null); + } + + @PostMapping("/delete") + public BaseResponse deleteShareCourse(@RequestBody CourseShareDeleteReq courseShareDeleteReq, @RequestParam String address) { + shareCourseService.deleteShareCourse(courseShareDeleteReq); + return BaseResponse.successWithData(null); + } +} diff --git a/src/main/java/com/dl/officialsite/sharing/ShareCourseService.java b/src/main/java/com/dl/officialsite/sharing/ShareCourseService.java new file mode 100644 index 00000000..20207101 --- /dev/null +++ b/src/main/java/com/dl/officialsite/sharing/ShareCourseService.java @@ -0,0 +1,47 @@ +package com.dl.officialsite.sharing; + +import cn.hutool.core.collection.CollUtil; +import com.dl.officialsite.common.enums.CodeEnums; +import com.dl.officialsite.common.exception.BizException; +import com.dl.officialsite.sharing.model.req.CourseShareAddReq; +import com.dl.officialsite.sharing.model.req.CourseShareDeleteReq; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Description + * @Author xiaoming + * @Date 2024/9/13 8:02 AM + **/ +@Service +@Slf4j +public class ShareCourseService { + + @Resource + private SharingRepository sharingRepository; + + public void addShareCourse(CourseShareAddReq courseShareAddReq){ + List shareIdList = courseShareAddReq.getShareIdList(); + Long courseId = courseShareAddReq.getCourseId(); + //先将分享的课程id设置为null + List oldShareList = sharingRepository.findByCourseId(courseId); + List oldIdList = oldShareList.stream().map(Share::getId).collect(Collectors.toList()); + if(CollUtil.isNotEmpty(oldShareList)){ + sharingRepository.updateCourseIdToNull(oldIdList); + } + shareIdList.forEach(shareId -> { + Share share = sharingRepository.findById(shareId).orElseThrow(() -> new BizException(CodeEnums.SHARING_NOT_FOUND.getCode(), CodeEnums.SHARING_NOT_FOUND.getMsg())); + share.setCourseId(courseId); + sharingRepository.save(share); + }); + } + + public void deleteShareCourse(CourseShareDeleteReq courseShareDeleteReq){ + Long shareId = courseShareDeleteReq.getShareId(); + sharingRepository.findById(shareId).orElseThrow(() -> new BizException(CodeEnums.SHARING_NOT_FOUND.getCode(), CodeEnums.SHARING_NOT_FOUND.getMsg())); + sharingRepository.updateCourseIdToNull(shareId); + } +} diff --git a/src/main/java/com/dl/officialsite/sharing/SharingRepository.java b/src/main/java/com/dl/officialsite/sharing/SharingRepository.java index e86589ba..8af8f4d2 100644 --- a/src/main/java/com/dl/officialsite/sharing/SharingRepository.java +++ b/src/main/java/com/dl/officialsite/sharing/SharingRepository.java @@ -5,9 +5,12 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import javax.transaction.Transactional; + public interface SharingRepository extends JpaRepository, JpaSpecificationExecutor { @Query(value = "select * from share limit :offset, :limit", nativeQuery = true) @@ -33,4 +36,21 @@ List findAllSharesByUidPaged(@Param("memberAddress") String memberAddress @Query(value = "SELECT presenter, COUNT(*) AS shareCount FROM share GROUP BY presenter ORDER" + " BY shareCount DESC LIMIT :rankNumber" ,nativeQuery = true) List findTopGroups(@Param("rankNumber") Integer rankNumber); + + //通过id将share表中的courseId字段置为null + @Modifying + @Transactional + @Query("update Share s set s.courseId = null where s.id = :id") + void updateCourseIdToNull(@Param("id") Long id); + + + //通过idList将share表中的courseId字段置为null + @Modifying + @Transactional + @Query("update Share s set s.courseId = null where s.id in :idList") + void updateCourseIdToNull(@Param("idList") List idList); + + //通过courseId查询share表中的数据 + @Query(value = "select * from share s where s.course_id = :courseId", nativeQuery = true) + List findByCourseId(Long courseId); } diff --git a/src/main/java/com/dl/officialsite/sharing/SharingService.java b/src/main/java/com/dl/officialsite/sharing/SharingService.java index b48b7416..5432b39c 100644 --- a/src/main/java/com/dl/officialsite/sharing/SharingService.java +++ b/src/main/java/com/dl/officialsite/sharing/SharingService.java @@ -124,6 +124,7 @@ public void updateSharing(UpdateSharingReq req, String address) { sharing.setBilibiliLink(req.getBilibiliLink()); sharing.setYoutubeLink(req.getYoutubeLink()); sharing.setTag(req.getTag()); + sharing.setCourseId(req.getCourseId()); this.sharingRepository.save(sharing); /* SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); diff --git a/src/main/java/com/dl/officialsite/sharing/model/req/CourseShareAddReq.java b/src/main/java/com/dl/officialsite/sharing/model/req/CourseShareAddReq.java new file mode 100644 index 00000000..d4d10274 --- /dev/null +++ b/src/main/java/com/dl/officialsite/sharing/model/req/CourseShareAddReq.java @@ -0,0 +1,27 @@ +package com.dl.officialsite.sharing.model.req; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; + +import java.util.List; + +/** + * @Description + * @Author xiaoming + * @Date 2024/9/13 7:59 AM + **/ +@Data +public class CourseShareAddReq { + + /** + * 课程id + */ +// @JsonSerialize(using = ToStringSerializer.class) + private Long courseId; + + /** + * 分享id列表 + */ + private List shareIdList; +} diff --git a/src/main/java/com/dl/officialsite/sharing/model/req/CourseShareDeleteReq.java b/src/main/java/com/dl/officialsite/sharing/model/req/CourseShareDeleteReq.java new file mode 100644 index 00000000..b4d877a3 --- /dev/null +++ b/src/main/java/com/dl/officialsite/sharing/model/req/CourseShareDeleteReq.java @@ -0,0 +1,17 @@ +package com.dl.officialsite.sharing.model.req; + +import lombok.Data; + +/** + * @Description + * @Author xiaoming + * @Date 2024/9/13 7:59 AM + **/ +@Data +public class CourseShareDeleteReq { + + /** + * 分享id列表 + */ + private Long shareId; +} diff --git a/src/main/java/com/dl/officialsite/sharing/model/req/UpdateSharingReq.java b/src/main/java/com/dl/officialsite/sharing/model/req/UpdateSharingReq.java index 7db99258..259f3349 100644 --- a/src/main/java/com/dl/officialsite/sharing/model/req/UpdateSharingReq.java +++ b/src/main/java/com/dl/officialsite/sharing/model/req/UpdateSharingReq.java @@ -5,6 +5,8 @@ import java.util.Date; import lombok.Data; +import javax.persistence.Column; + @Data public class UpdateSharingReq { @@ -78,4 +80,9 @@ public class UpdateSharingReq { * tag */ private String tag; + + /** + * 课程Id + */ + private Long courseId; }