课程增加简介字段

This commit is contained in:
none 2023-03-21 15:03:21 +08:00
parent 57535a2ce7
commit a2a1206ec7
5 changed files with 33 additions and 19 deletions

View File

@ -96,6 +96,7 @@ public class CourseController {
Course course = courseService.createWithCategoryIdsAndDepIds( Course course = courseService.createWithCategoryIdsAndDepIds(
req.getTitle(), req.getTitle(),
req.getThumb(), req.getThumb(),
req.getShortDesc(),
req.getIsRequired(), req.getIsRequired(),
req.getIsShow(), req.getIsShow(),
req.getCategoryIds(), req.getCategoryIds(),
@ -186,7 +187,7 @@ public class CourseController {
@Transactional @Transactional
public JsonResponse update(@PathVariable(name = "id") Integer id, @RequestBody @Validated CourseRequest req) throws NotFoundException { public JsonResponse update(@PathVariable(name = "id") Integer id, @RequestBody @Validated CourseRequest req) throws NotFoundException {
Course course = courseService.findOrFail(id); 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(); return JsonResponse.success();
} }

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
@ -12,10 +13,9 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data; import lombok.Data;
/** /**
*
* @TableName courses * @TableName courses
*/ */
@TableName(value ="courses") @TableName(value = "courses")
@Data @Data
public class Course implements Serializable { public class Course implements Serializable {
/** /**
@ -39,6 +39,12 @@ public class Course implements Serializable {
*/ */
private Integer charge; private Integer charge;
/**
* 课程简介
*/
@JsonProperty("short_desc")
private String shortDesc;
/** /**
* 1:必修,0:选修 * 1:必修,0:选修
*/ */
@ -81,15 +87,16 @@ public class Course implements Serializable {
} }
Course other = (Course) that; Course other = (Course) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle())) && (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
&& (this.getThumb() == null ? other.getThumb() == null : this.getThumb().equals(other.getThumb())) && (this.getThumb() == null ? other.getThumb() == null : this.getThumb().equals(other.getThumb()))
&& (this.getCharge() == null ? other.getCharge() == null : this.getCharge().equals(other.getCharge())) && (this.getCharge() == null ? other.getCharge() == null : this.getCharge().equals(other.getCharge()))
&& (this.getClassHour() == null ? other.getClassHour() == null : this.getClassHour().equals(other.getClassHour())) && (this.getClassHour() == null ? other.getClassHour() == null : this.getClassHour().equals(other.getClassHour()))
&& (this.getIsShow() == null ? other.getIsShow() == null : this.getIsShow().equals(other.getIsShow())) && (this.getIsShow() == null ? other.getIsShow() == null : this.getIsShow().equals(other.getIsShow()))
&& (this.getIsRequired() == null ? other.getIsRequired() == null : this.getIsRequired().equals(other.getIsRequired())) && (this.getIsRequired() == null ? other.getIsRequired() == null : this.getIsRequired().equals(other.getIsRequired()))
&& (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt())) && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
&& (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt())) && (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()))
&& (this.getDeletedAt() == null ? other.getDeletedAt() == null : this.getDeletedAt().equals(other.getDeletedAt())); && (this.getDeletedAt() == null ? other.getDeletedAt() == null : this.getDeletedAt().equals(other.getDeletedAt()))
&& (this.getShortDesc() == null ? other.getShortDesc() == null : this.getShortDesc().equals(other.getShortDesc()));
} }
@Override @Override
@ -100,6 +107,7 @@ public class Course implements Serializable {
result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode()); result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
result = prime * result + ((getThumb() == null) ? 0 : getThumb().hashCode()); result = prime * result + ((getThumb() == null) ? 0 : getThumb().hashCode());
result = prime * result + ((getCharge() == null) ? 0 : getCharge().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 + ((getClassHour() == null) ? 0 : getClassHour().hashCode());
result = prime * result + ((getIsShow() == null) ? 0 : getIsShow().hashCode()); result = prime * result + ((getIsShow() == null) ? 0 : getIsShow().hashCode());
result = prime * result + ((getIsRequired() == null) ? 0 : getIsRequired().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(", title=").append(title);
sb.append(", thumb=").append(thumb); sb.append(", thumb=").append(thumb);
sb.append(", charge=").append(charge); sb.append(", charge=").append(charge);
sb.append(", shortDesc=").append(shortDesc);
sb.append(", classHour=").append(classHour); sb.append(", classHour=").append(classHour);
sb.append(", isShow=").append(isShow); sb.append(", isShow=").append(isShow);
sb.append(", isRequired=").append(isRequired); sb.append(", isRequired=").append(isRequired);

View File

@ -15,14 +15,16 @@ import java.util.Map;
@Data @Data
public class CourseRequest { public class CourseRequest {
@NotNull(message = "title参数不存在")
@NotBlank(message = "请输入课程标题") @NotBlank(message = "请输入课程标题")
private String title; private String title;
@NotNull(message = "thumb参数不存在")
@NotBlank(message = "请上传课程封面") @NotBlank(message = "请上传课程封面")
private String thumb; private String thumb;
@NotBlank(message = "请填写课程简介")
@JsonProperty("short_desc")
private String shortDesc;
@NotNull(message = "is_show参数不存在") @NotNull(message = "is_show参数不存在")
@JsonProperty("is_show") @JsonProperty("is_show")
private Integer isShow; private Integer isShow;

View File

@ -18,9 +18,9 @@ public interface CourseService extends IService<Course> {
PaginationResult<Course> paginate(int page, int size, CoursePaginateFiler filter); 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); void relateDepartments(Course course, Integer[] depIds);

View File

@ -47,11 +47,12 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
@Override @Override
@Transactional @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 course = new Course();
course.setTitle(title); course.setTitle(title);
course.setThumb(thumb); course.setThumb(thumb);
course.setShortDesc(shortDesc);
course.setIsShow(isShow); course.setIsShow(isShow);
course.setIsRequired(isRequired); course.setIsRequired(isRequired);
course.setCreatedAt(new Date()); course.setCreatedAt(new Date());
@ -111,13 +112,14 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
@Override @Override
@Transactional @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(); Course newCourse = new Course();
newCourse.setId(course.getId()); newCourse.setId(course.getId());
newCourse.setTitle(title); newCourse.setTitle(title);
newCourse.setThumb(thumb); newCourse.setThumb(thumb);
newCourse.setIsShow(isShow); newCourse.setIsShow(isShow);
newCourse.setIsRequired(isRequired); newCourse.setIsRequired(isRequired);
newCourse.setShortDesc(shortDesc);
updateById(newCourse); updateById(newCourse);