mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-10 20:04:06 +08:00
课程增加简介字段
This commit is contained in:
parent
57535a2ce7
commit
a2a1206ec7
@ -96,6 +96,7 @@ public class CourseController {
|
||||
Course course = courseService.createWithCategoryIdsAndDepIds(
|
||||
req.getTitle(),
|
||||
req.getThumb(),
|
||||
req.getShortDesc(),
|
||||
req.getIsRequired(),
|
||||
req.getIsShow(),
|
||||
req.getCategoryIds(),
|
||||
@ -186,7 +187,7 @@ public class CourseController {
|
||||
@Transactional
|
||||
public JsonResponse update(@PathVariable(name = "id") Integer id, @RequestBody @Validated CourseRequest req) throws NotFoundException {
|
||||
Course course = courseService.findOrFail(id);
|
||||
courseService.updateWithCategoryIdsAndDepIds(course, req.getTitle(), req.getThumb(), req.getIsRequired(), req.getIsShow(), req.getCategoryIds(), req.getDepIds());
|
||||
courseService.updateWithCategoryIdsAndDepIds(course, req.getTitle(), req.getThumb(), req.getShortDesc(), req.getIsRequired(), req.getIsShow(), req.getCategoryIds(), req.getDepIds());
|
||||
return JsonResponse.success();
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@ -12,14 +13,13 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName courses
|
||||
*/
|
||||
@TableName(value ="courses")
|
||||
@TableName(value = "courses")
|
||||
@Data
|
||||
public class Course implements Serializable {
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@ -39,6 +39,12 @@ public class Course implements Serializable {
|
||||
*/
|
||||
private Integer charge;
|
||||
|
||||
/**
|
||||
* 课程简介
|
||||
*/
|
||||
@JsonProperty("short_desc")
|
||||
private String shortDesc;
|
||||
|
||||
/**
|
||||
* 1:必修,0:选修
|
||||
*/
|
||||
@ -81,15 +87,16 @@ public class Course implements Serializable {
|
||||
}
|
||||
Course other = (Course) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
|
||||
&& (this.getThumb() == null ? other.getThumb() == null : this.getThumb().equals(other.getThumb()))
|
||||
&& (this.getCharge() == null ? other.getCharge() == null : this.getCharge().equals(other.getCharge()))
|
||||
&& (this.getClassHour() == null ? other.getClassHour() == null : this.getClassHour().equals(other.getClassHour()))
|
||||
&& (this.getIsShow() == null ? other.getIsShow() == null : this.getIsShow().equals(other.getIsShow()))
|
||||
&& (this.getIsRequired() == null ? other.getIsRequired() == null : this.getIsRequired().equals(other.getIsRequired()))
|
||||
&& (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
|
||||
&& (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()))
|
||||
&& (this.getDeletedAt() == null ? other.getDeletedAt() == null : this.getDeletedAt().equals(other.getDeletedAt()));
|
||||
&& (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
|
||||
&& (this.getThumb() == null ? other.getThumb() == null : this.getThumb().equals(other.getThumb()))
|
||||
&& (this.getCharge() == null ? other.getCharge() == null : this.getCharge().equals(other.getCharge()))
|
||||
&& (this.getClassHour() == null ? other.getClassHour() == null : this.getClassHour().equals(other.getClassHour()))
|
||||
&& (this.getIsShow() == null ? other.getIsShow() == null : this.getIsShow().equals(other.getIsShow()))
|
||||
&& (this.getIsRequired() == null ? other.getIsRequired() == null : this.getIsRequired().equals(other.getIsRequired()))
|
||||
&& (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
|
||||
&& (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()))
|
||||
&& (this.getDeletedAt() == null ? other.getDeletedAt() == null : this.getDeletedAt().equals(other.getDeletedAt()))
|
||||
&& (this.getShortDesc() == null ? other.getShortDesc() == null : this.getShortDesc().equals(other.getShortDesc()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -100,6 +107,7 @@ public class Course implements Serializable {
|
||||
result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
|
||||
result = prime * result + ((getThumb() == null) ? 0 : getThumb().hashCode());
|
||||
result = prime * result + ((getCharge() == null) ? 0 : getCharge().hashCode());
|
||||
result = prime * result + ((getShortDesc() == null) ? 0 : getShortDesc().hashCode());
|
||||
result = prime * result + ((getClassHour() == null) ? 0 : getClassHour().hashCode());
|
||||
result = prime * result + ((getIsShow() == null) ? 0 : getIsShow().hashCode());
|
||||
result = prime * result + ((getIsRequired() == null) ? 0 : getIsRequired().hashCode());
|
||||
@ -119,6 +127,7 @@ public class Course implements Serializable {
|
||||
sb.append(", title=").append(title);
|
||||
sb.append(", thumb=").append(thumb);
|
||||
sb.append(", charge=").append(charge);
|
||||
sb.append(", shortDesc=").append(shortDesc);
|
||||
sb.append(", classHour=").append(classHour);
|
||||
sb.append(", isShow=").append(isShow);
|
||||
sb.append(", isRequired=").append(isRequired);
|
||||
|
@ -15,14 +15,16 @@ import java.util.Map;
|
||||
@Data
|
||||
public class CourseRequest {
|
||||
|
||||
@NotNull(message = "title参数不存在")
|
||||
@NotBlank(message = "请输入课程标题")
|
||||
private String title;
|
||||
|
||||
@NotNull(message = "thumb参数不存在")
|
||||
@NotBlank(message = "请上传课程封面")
|
||||
private String thumb;
|
||||
|
||||
@NotBlank(message = "请填写课程简介")
|
||||
@JsonProperty("short_desc")
|
||||
private String shortDesc;
|
||||
|
||||
@NotNull(message = "is_show参数不存在")
|
||||
@JsonProperty("is_show")
|
||||
private Integer isShow;
|
||||
|
@ -18,9 +18,9 @@ public interface CourseService extends IService<Course> {
|
||||
|
||||
PaginationResult<Course> paginate(int page, int size, CoursePaginateFiler filter);
|
||||
|
||||
Course createWithCategoryIdsAndDepIds(String title, String thumb, Integer isRequired, Integer isShow, Integer[] categoryIds, Integer[] depIds);
|
||||
Course createWithCategoryIdsAndDepIds(String title, String thumb, String shortDesc, Integer isRequired, Integer isShow, Integer[] categoryIds, Integer[] depIds);
|
||||
|
||||
void updateWithCategoryIdsAndDepIds(Course course, String title, String thumb, Integer isRequired, Integer isShow, Integer[] categoryIds, Integer[] depIds);
|
||||
void updateWithCategoryIdsAndDepIds(Course course, String title, String thumb, String shortDesc, Integer isRequired, Integer isShow, Integer[] categoryIds, Integer[] depIds);
|
||||
|
||||
void relateDepartments(Course course, Integer[] depIds);
|
||||
|
||||
|
@ -47,11 +47,12 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Course createWithCategoryIdsAndDepIds(String title, String thumb, Integer isRequired, Integer isShow, Integer[] categoryIds, Integer[] depIds) {
|
||||
public Course createWithCategoryIdsAndDepIds(String title, String thumb, String shortDesc, Integer isRequired, Integer isShow, Integer[] categoryIds, Integer[] depIds) {
|
||||
// 创建课程
|
||||
Course course = new Course();
|
||||
course.setTitle(title);
|
||||
course.setThumb(thumb);
|
||||
course.setShortDesc(shortDesc);
|
||||
course.setIsShow(isShow);
|
||||
course.setIsRequired(isRequired);
|
||||
course.setCreatedAt(new Date());
|
||||
@ -111,13 +112,14 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateWithCategoryIdsAndDepIds(Course course, String title, String thumb, Integer isRequired, Integer isShow, Integer[] categoryIds, Integer[] depIds) {
|
||||
public void updateWithCategoryIdsAndDepIds(Course course, String title, String thumb, String shortDesc, Integer isRequired, Integer isShow, Integer[] categoryIds, Integer[] depIds) {
|
||||
Course newCourse = new Course();
|
||||
newCourse.setId(course.getId());
|
||||
newCourse.setTitle(title);
|
||||
newCourse.setThumb(thumb);
|
||||
newCourse.setIsShow(isShow);
|
||||
newCourse.setIsRequired(isRequired);
|
||||
newCourse.setShortDesc(shortDesc);
|
||||
|
||||
updateById(newCourse);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user