mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-13 21:56:57 +08:00
线上课增加必修课、选修课属性
This commit is contained in:
parent
48a1597998
commit
1fdbc2fdca
@ -60,6 +60,7 @@ public class CourseController {
|
||||
String title = MapUtils.getString(params, "title");
|
||||
String depIds = MapUtils.getString(params, "dep_ids");
|
||||
String categoryIds = MapUtils.getString(params, "category_ids");
|
||||
Integer isRequired = MapUtils.getInteger(params, "is_requried");
|
||||
|
||||
CoursePaginateFiler filter = new CoursePaginateFiler();
|
||||
filter.setTitle(title);
|
||||
@ -67,6 +68,7 @@ public class CourseController {
|
||||
filter.setSortAlgo(sortAlgo);
|
||||
filter.setCategoryIds(categoryIds);
|
||||
filter.setDepIds(depIds);
|
||||
filter.setIsRequired(isRequired);
|
||||
|
||||
PaginationResult<Course> result = courseService.paginate(page, size, filter);
|
||||
|
||||
@ -91,7 +93,14 @@ public class CourseController {
|
||||
@PostMapping("/create")
|
||||
@Transactional
|
||||
public JsonResponse store(@RequestBody @Validated CourseRequest req) throws ParseException {
|
||||
Course course = courseService.createWithCategoryIdsAndDepIds(req.getTitle(), req.getThumb(), req.getIsShow(), req.getCategoryIds(), req.getDepIds());
|
||||
Course course = courseService.createWithCategoryIdsAndDepIds(
|
||||
req.getTitle(),
|
||||
req.getThumb(),
|
||||
req.getIsRequired(),
|
||||
req.getIsShow(),
|
||||
req.getCategoryIds(),
|
||||
req.getDepIds()
|
||||
);
|
||||
|
||||
Date now = new Date();
|
||||
|
||||
@ -177,7 +186,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.getIsShow(), req.getCategoryIds(), req.getDepIds());
|
||||
courseService.updateWithCategoryIdsAndDepIds(course, req.getTitle(), req.getThumb(), req.getIsRequired(), req.getIsShow(), req.getCategoryIds(), req.getDepIds());
|
||||
return JsonResponse.success();
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ 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;
|
||||
|
||||
@ -13,9 +12,10 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName courses
|
||||
*/
|
||||
@TableName(value = "courses")
|
||||
@TableName(value ="courses")
|
||||
@Data
|
||||
public class Course implements Serializable {
|
||||
/**
|
||||
@ -39,6 +39,11 @@ public class Course implements Serializable {
|
||||
*/
|
||||
private Integer charge;
|
||||
|
||||
/**
|
||||
* 1:必修,0:选修
|
||||
*/
|
||||
private Integer isRequired;
|
||||
|
||||
/**
|
||||
* 课时数
|
||||
*/
|
||||
@ -81,6 +86,7 @@ public class Course implements Serializable {
|
||||
&& (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()));
|
||||
@ -96,6 +102,7 @@ public class Course implements Serializable {
|
||||
result = prime * result + ((getCharge() == null) ? 0 : getCharge().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());
|
||||
result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
|
||||
result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
|
||||
result = prime * result + ((getDeletedAt() == null) ? 0 : getDeletedAt().hashCode());
|
||||
@ -114,6 +121,7 @@ public class Course implements Serializable {
|
||||
sb.append(", charge=").append(charge);
|
||||
sb.append(", classHour=").append(classHour);
|
||||
sb.append(", isShow=").append(isShow);
|
||||
sb.append(", isRequired=").append(isRequired);
|
||||
sb.append(", createdAt=").append(createdAt);
|
||||
sb.append(", updatedAt=").append(updatedAt);
|
||||
sb.append(", deletedAt=").append(deletedAt);
|
||||
|
@ -9,11 +9,11 @@ import xyz.playedu.api.types.paginate.CoursePaginateFiler;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
* @description 针对表【courses】的数据库操作Mapper
|
||||
* @createDate 2023-02-24 14:48:38
|
||||
* @Entity xyz.playedu.api.domain.Course
|
||||
*/
|
||||
* @author tengteng
|
||||
* @description 针对表【courses】的数据库操作Mapper
|
||||
* @createDate 2023-03-20 14:25:31
|
||||
* @Entity xyz.playedu.api.domain.Course
|
||||
*/
|
||||
@Mapper
|
||||
public interface CourseMapper extends BaseMapper<Course> {
|
||||
|
||||
@ -24,7 +24,6 @@ public interface CourseMapper extends BaseMapper<Course> {
|
||||
Long paginateCount(CoursePaginateFiler filer);
|
||||
|
||||
List<Course> openCoursesAndShow(Integer limit);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,6 +27,10 @@ public class CourseRequest {
|
||||
@JsonProperty("is_show")
|
||||
private Integer isShow;
|
||||
|
||||
@NotNull(message = "is_required参数不存在")
|
||||
@JsonProperty("is_required")
|
||||
private Integer isRequired;
|
||||
|
||||
@NotNull(message = "dep_ids参数不存在")
|
||||
@JsonProperty("dep_ids")
|
||||
private Integer[] depIds;
|
||||
|
@ -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 isShow, Integer[] categoryIds, Integer[] depIds);
|
||||
Course createWithCategoryIdsAndDepIds(String title, String thumb, Integer isRequired, Integer isShow, Integer[] categoryIds, Integer[] depIds);
|
||||
|
||||
void updateWithCategoryIdsAndDepIds(Course course, String title, String thumb, Integer isShow, Integer[] categoryIds, Integer[] depIds);
|
||||
void updateWithCategoryIdsAndDepIds(Course course, String title, String thumb, Integer isRequired, Integer isShow, Integer[] categoryIds, Integer[] depIds);
|
||||
|
||||
void relateDepartments(Course course, Integer[] depIds);
|
||||
|
||||
|
@ -47,12 +47,13 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Course createWithCategoryIdsAndDepIds(String title, String thumb, Integer isShow, Integer[] categoryIds, Integer[] depIds) {
|
||||
public Course createWithCategoryIdsAndDepIds(String title, String thumb, Integer isRequired, Integer isShow, Integer[] categoryIds, Integer[] depIds) {
|
||||
// 创建课程
|
||||
Course course = new Course();
|
||||
course.setTitle(title);
|
||||
course.setThumb(thumb);
|
||||
course.setIsShow(isShow);
|
||||
course.setIsRequired(isRequired);
|
||||
course.setCreatedAt(new Date());
|
||||
course.setUpdatedAt(new Date());
|
||||
save(course);
|
||||
@ -110,12 +111,13 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateWithCategoryIdsAndDepIds(Course course, String title, String thumb, Integer isShow, Integer[] categoryIds, Integer[] depIds) {
|
||||
public void updateWithCategoryIdsAndDepIds(Course course, String title, String thumb, 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);
|
||||
|
||||
updateById(newCourse);
|
||||
|
||||
|
@ -15,6 +15,8 @@ public class CoursePaginateFiler {
|
||||
|
||||
private String categoryIds;
|
||||
|
||||
private Integer isRequired;
|
||||
|
||||
private String sortField;
|
||||
|
||||
private String sortAlgo;
|
||||
|
@ -11,16 +11,17 @@
|
||||
<result property="charge" column="charge" jdbcType="INTEGER"/>
|
||||
<result property="classHour" column="class_hour" jdbcType="INTEGER"/>
|
||||
<result property="isShow" column="is_show" jdbcType="TINYINT"/>
|
||||
<result property="isRequired" column="is_required" jdbcType="TINYINT"/>
|
||||
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
|
||||
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
|
||||
<result property="deletedAt" column="deleted_at" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id
|
||||
,title,thumb,
|
||||
id,title,thumb,
|
||||
charge,class_hour,is_show,
|
||||
created_at,updated_at,deleted_at
|
||||
is_required,created_at,updated_at,
|
||||
deleted_at
|
||||
</sql>
|
||||
|
||||
<select id="getCategoryCount" resultType="xyz.playedu.api.types.mapper.CourseCategoryCountMapper">
|
||||
@ -78,6 +79,9 @@
|
||||
<if test="title != null and title != ''">
|
||||
AND `courses`.`title` LIKE concat('%',#{title},'%')
|
||||
</if>
|
||||
<if test="isRequired != null">
|
||||
AND `courses`.`is_required` = #{isRequired}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
<if test="sortAlgo == 'asc'">
|
||||
@ -164,6 +168,9 @@
|
||||
<if test="title != null and title != ''">
|
||||
AND `courses`.`title` LIKE concat('%',#{title},'%')
|
||||
</if>
|
||||
<if test="isRequired != null">
|
||||
AND `courses`.`is_required` = #{isRequired}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="openCoursesAndShow" resultType="xyz.playedu.api.domain.Course">
|
||||
|
Loading…
x
Reference in New Issue
Block a user