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 title = MapUtils.getString(params, "title");
|
||||||
String depIds = MapUtils.getString(params, "dep_ids");
|
String depIds = MapUtils.getString(params, "dep_ids");
|
||||||
String categoryIds = MapUtils.getString(params, "category_ids");
|
String categoryIds = MapUtils.getString(params, "category_ids");
|
||||||
|
Integer isRequired = MapUtils.getInteger(params, "is_requried");
|
||||||
|
|
||||||
CoursePaginateFiler filter = new CoursePaginateFiler();
|
CoursePaginateFiler filter = new CoursePaginateFiler();
|
||||||
filter.setTitle(title);
|
filter.setTitle(title);
|
||||||
@ -67,6 +68,7 @@ public class CourseController {
|
|||||||
filter.setSortAlgo(sortAlgo);
|
filter.setSortAlgo(sortAlgo);
|
||||||
filter.setCategoryIds(categoryIds);
|
filter.setCategoryIds(categoryIds);
|
||||||
filter.setDepIds(depIds);
|
filter.setDepIds(depIds);
|
||||||
|
filter.setIsRequired(isRequired);
|
||||||
|
|
||||||
PaginationResult<Course> result = courseService.paginate(page, size, filter);
|
PaginationResult<Course> result = courseService.paginate(page, size, filter);
|
||||||
|
|
||||||
@ -91,7 +93,14 @@ public class CourseController {
|
|||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Transactional
|
@Transactional
|
||||||
public JsonResponse store(@RequestBody @Validated CourseRequest req) throws ParseException {
|
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();
|
Date now = new Date();
|
||||||
|
|
||||||
@ -177,7 +186,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.getIsShow(), req.getCategoryIds(), req.getDepIds());
|
courseService.updateWithCategoryIdsAndDepIds(course, req.getTitle(), req.getThumb(), req.getIsRequired(), req.getIsShow(), req.getCategoryIds(), req.getDepIds());
|
||||||
return JsonResponse.success();
|
return JsonResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ 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;
|
||||||
|
|
||||||
@ -13,13 +12,14 @@ 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 {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
@ -39,6 +39,11 @@ public class Course implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer charge;
|
private Integer charge;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1:必修,0:选修
|
||||||
|
*/
|
||||||
|
private Integer isRequired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 课时数
|
* 课时数
|
||||||
*/
|
*/
|
||||||
@ -76,14 +81,15 @@ 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.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
|
&& (this.getIsRequired() == null ? other.getIsRequired() == null : this.getIsRequired().equals(other.getIsRequired()))
|
||||||
&& (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()))
|
&& (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
|
||||||
&& (this.getDeletedAt() == null ? other.getDeletedAt() == null : this.getDeletedAt().equals(other.getDeletedAt()));
|
&& (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()))
|
||||||
|
&& (this.getDeletedAt() == null ? other.getDeletedAt() == null : this.getDeletedAt().equals(other.getDeletedAt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -96,6 +102,7 @@ public class Course implements Serializable {
|
|||||||
result = prime * result + ((getCharge() == null) ? 0 : getCharge().hashCode());
|
result = prime * result + ((getCharge() == null) ? 0 : getCharge().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 + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
|
result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
|
||||||
result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
|
result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
|
||||||
result = prime * result + ((getDeletedAt() == null) ? 0 : getDeletedAt().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(", charge=").append(charge);
|
||||||
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(", createdAt=").append(createdAt);
|
sb.append(", createdAt=").append(createdAt);
|
||||||
sb.append(", updatedAt=").append(updatedAt);
|
sb.append(", updatedAt=").append(updatedAt);
|
||||||
sb.append(", deletedAt=").append(deletedAt);
|
sb.append(", deletedAt=").append(deletedAt);
|
||||||
|
@ -9,11 +9,11 @@ import xyz.playedu.api.types.paginate.CoursePaginateFiler;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tengteng
|
* @author tengteng
|
||||||
* @description 针对表【courses】的数据库操作Mapper
|
* @description 针对表【courses】的数据库操作Mapper
|
||||||
* @createDate 2023-02-24 14:48:38
|
* @createDate 2023-03-20 14:25:31
|
||||||
* @Entity xyz.playedu.api.domain.Course
|
* @Entity xyz.playedu.api.domain.Course
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface CourseMapper extends BaseMapper<Course> {
|
public interface CourseMapper extends BaseMapper<Course> {
|
||||||
|
|
||||||
@ -24,7 +24,6 @@ public interface CourseMapper extends BaseMapper<Course> {
|
|||||||
Long paginateCount(CoursePaginateFiler filer);
|
Long paginateCount(CoursePaginateFiler filer);
|
||||||
|
|
||||||
List<Course> openCoursesAndShow(Integer limit);
|
List<Course> openCoursesAndShow(Integer limit);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,10 @@ public class CourseRequest {
|
|||||||
@JsonProperty("is_show")
|
@JsonProperty("is_show")
|
||||||
private Integer isShow;
|
private Integer isShow;
|
||||||
|
|
||||||
|
@NotNull(message = "is_required参数不存在")
|
||||||
|
@JsonProperty("is_required")
|
||||||
|
private Integer isRequired;
|
||||||
|
|
||||||
@NotNull(message = "dep_ids参数不存在")
|
@NotNull(message = "dep_ids参数不存在")
|
||||||
@JsonProperty("dep_ids")
|
@JsonProperty("dep_ids")
|
||||||
private Integer[] depIds;
|
private Integer[] depIds;
|
||||||
|
@ -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 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);
|
void relateDepartments(Course course, Integer[] depIds);
|
||||||
|
|
||||||
|
@ -47,12 +47,13 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@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 course = new Course();
|
||||||
course.setTitle(title);
|
course.setTitle(title);
|
||||||
course.setThumb(thumb);
|
course.setThumb(thumb);
|
||||||
course.setIsShow(isShow);
|
course.setIsShow(isShow);
|
||||||
|
course.setIsRequired(isRequired);
|
||||||
course.setCreatedAt(new Date());
|
course.setCreatedAt(new Date());
|
||||||
course.setUpdatedAt(new Date());
|
course.setUpdatedAt(new Date());
|
||||||
save(course);
|
save(course);
|
||||||
@ -110,12 +111,13 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@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();
|
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);
|
||||||
|
|
||||||
updateById(newCourse);
|
updateById(newCourse);
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ public class CoursePaginateFiler {
|
|||||||
|
|
||||||
private String categoryIds;
|
private String categoryIds;
|
||||||
|
|
||||||
|
private Integer isRequired;
|
||||||
|
|
||||||
private String sortField;
|
private String sortField;
|
||||||
|
|
||||||
private String sortAlgo;
|
private String sortAlgo;
|
||||||
|
@ -5,22 +5,23 @@
|
|||||||
<mapper namespace="xyz.playedu.api.mapper.CourseMapper">
|
<mapper namespace="xyz.playedu.api.mapper.CourseMapper">
|
||||||
|
|
||||||
<resultMap id="BaseResultMap" type="xyz.playedu.api.domain.Course">
|
<resultMap id="BaseResultMap" type="xyz.playedu.api.domain.Course">
|
||||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||||
<result property="title" column="title" jdbcType="VARCHAR"/>
|
<result property="title" column="title" jdbcType="VARCHAR"/>
|
||||||
<result property="thumb" column="thumb" jdbcType="VARCHAR"/>
|
<result property="thumb" column="thumb" jdbcType="VARCHAR"/>
|
||||||
<result property="charge" column="charge" jdbcType="INTEGER"/>
|
<result property="charge" column="charge" jdbcType="INTEGER"/>
|
||||||
<result property="classHour" column="class_hour" jdbcType="INTEGER"/>
|
<result property="classHour" column="class_hour" jdbcType="INTEGER"/>
|
||||||
<result property="isShow" column="is_show" jdbcType="TINYINT"/>
|
<result property="isShow" column="is_show" jdbcType="TINYINT"/>
|
||||||
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
|
<result property="isRequired" column="is_required" jdbcType="TINYINT"/>
|
||||||
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
|
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
|
||||||
<result property="deletedAt" column="deleted_at" jdbcType="TIMESTAMP"/>
|
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
|
||||||
|
<result property="deletedAt" column="deleted_at" jdbcType="TIMESTAMP"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id
|
id,title,thumb,
|
||||||
,title,thumb,
|
|
||||||
charge,class_hour,is_show,
|
charge,class_hour,is_show,
|
||||||
created_at,updated_at,deleted_at
|
is_required,created_at,updated_at,
|
||||||
|
deleted_at
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="getCategoryCount" resultType="xyz.playedu.api.types.mapper.CourseCategoryCountMapper">
|
<select id="getCategoryCount" resultType="xyz.playedu.api.types.mapper.CourseCategoryCountMapper">
|
||||||
@ -78,6 +79,9 @@
|
|||||||
<if test="title != null and title != ''">
|
<if test="title != null and title != ''">
|
||||||
AND `courses`.`title` LIKE concat('%',#{title},'%')
|
AND `courses`.`title` LIKE concat('%',#{title},'%')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="isRequired != null">
|
||||||
|
AND `courses`.`is_required` = #{isRequired}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
|
||||||
<if test="sortAlgo == 'asc'">
|
<if test="sortAlgo == 'asc'">
|
||||||
@ -164,6 +168,9 @@
|
|||||||
<if test="title != null and title != ''">
|
<if test="title != null and title != ''">
|
||||||
AND `courses`.`title` LIKE concat('%',#{title},'%')
|
AND `courses`.`title` LIKE concat('%',#{title},'%')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="isRequired != null">
|
||||||
|
AND `courses`.`is_required` = #{isRequired}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
<select id="openCoursesAndShow" resultType="xyz.playedu.api.domain.Course">
|
<select id="openCoursesAndShow" resultType="xyz.playedu.api.domain.Course">
|
||||||
@ -172,6 +179,6 @@
|
|||||||
LEFT JOIN `course_department` ON `course_department`.`course_id` = `courses`.`id`
|
LEFT JOIN `course_department` ON `course_department`.`course_id` = `courses`.`id`
|
||||||
WHERE `course_department`.`course_id` IS NULL
|
WHERE `course_department`.`course_id` IS NULL
|
||||||
AND `courses`.`is_show` = 1
|
AND `courses`.`is_show` = 1
|
||||||
LIMIT #{limit}
|
LIMIT #{limit}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user