youhang kecheng信息

master
you hang 6 months ago committed by youahng
parent 90201ce300
commit fef6a5762e
  1. 32
      src/main/java/com/teaching/backend/common/PageRequest.java
  2. 18
      src/main/java/com/teaching/backend/constant/CommonConstant.java
  3. 28
      src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java
  4. 22
      src/main/java/com/teaching/backend/model/dto/favour/courseFavour/CourseFavourQueryRequest.java
  5. 72
      src/main/java/com/teaching/backend/model/vo/favour/CourseFavourDetailVO.java
  6. 18
      src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java
  7. 39
      src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java
  8. 1
      src/main/resources/application.properties
  9. 11
      src/main/resources/application.yml

@ -0,0 +1,32 @@
package com.teaching.backend.common;
import com.teaching.backend.constant.CommonConstant;
import lombok.Data;
/**
* 分页请求
*/
@Data
public class PageRequest {
/**
* 当前页号
*/
private int current = 1;
/**
* 页面大小
*/
private int pageSize = 10;
/**
* 排序字段
*/
private String sortField;
/**
* 排序顺序默认升序
*/
private String sortOrder = CommonConstant.SORT_ORDER_ASC;
}

@ -0,0 +1,18 @@
package com.teaching.backend.constant;
/**
* 通用常量
*/
public interface CommonConstant {
/**
* 升序
*/
String SORT_ORDER_ASC = "ascend";
/**
* 降序
*/
String SORT_ORDER_DESC = " descend";
}

@ -1,5 +1,7 @@
package com.teaching.backend.controller.favour;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
@ -9,9 +11,17 @@ import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourAddRequest;
import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourAllRequest;
import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourListRequest;
import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourQueryRequest;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.favour.SeCourseFavour;
import com.teaching.backend.model.vo.CoursesVO;
import com.teaching.backend.model.vo.favour.CourseFavourDetailVO;
import com.teaching.backend.service.courses.ICoursesService;
import com.teaching.backend.service.favour.SeCourseFavourService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@ -106,5 +116,23 @@ public class SeCourseFavourController {
return ResultUtils.success(result);
}
/**
* 分页获取列表仅管理员
*
* @return
*/
@PostMapping("/list/page")
public BaseResponse<Page<CourseFavourDetailVO>> listPostByPage(@RequestBody CourseFavourQueryRequest courseFavourQueryRequest) {
long current = courseFavourQueryRequest.getCurrent();
long size = courseFavourQueryRequest.getPageSize();
String userId = courseFavourQueryRequest.getUserId();
List<String> ids = seCourseFavourService.courseList(userId);
QueryWrapper<Courses> courseQueryWrapper = new QueryWrapper<>();
courseQueryWrapper.in("id", ids);
Page<CourseFavourDetailVO> courseFavourDetailVOPage = seCourseFavourService.listCourseFavourByPage(new Page<>(current, size), courseQueryWrapper);
return ResultUtils.success(courseFavourDetailVOPage);
}
}

@ -0,0 +1,22 @@
package com.teaching.backend.model.dto.favour.courseFavour;
import com.teaching.backend.common.PageRequest;
import com.teaching.backend.constant.CommonConstant;
import lombok.Data;
import java.io.Serializable;
/**
* 课程点赞请求
*/
@Data
public class CourseFavourQueryRequest extends PageRequest implements Serializable {
/**
* 用户 id
*/
private String userId;
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,72 @@
package com.teaching.backend.model.vo.favour;
import com.baomidou.mybatisplus.annotation.TableName;
import com.teaching.backend.model.entity.courses.Courses;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import java.math.BigDecimal;
/**
* @Author:youhang
* @Date:2024-06-03-11:18
* @Description:
*/
@TableName(value = "courses")
@Data
public class CourseFavourDetailVO {
/**
* 内部编号
*/
private String id;
/**
* 课程封面
*/
private String img;
/**
* 课程名称
*/
private String name;
/**
* 教师id
*/
@ApiModelProperty("教师id")
private String teacher;
/**
* 课程学分
*/
@ApiModelProperty(value = "课程学分", required = true)
private BigDecimal credit;
/**
* 课程学时
*/
@ApiModelProperty(value = "课程学时", required = true)
private Integer classhours;
/**
* 对象转包装类
*
* @param course
* @return
*/
public static CourseFavourDetailVO objToVo(Courses course) {
if (course == null) {
return null;
}
CourseFavourDetailVO courseFavourDetailVO = new CourseFavourDetailVO();
BeanUtils.copyProperties(course, courseFavourDetailVO);
return courseFavourDetailVO;
}
}

@ -1,7 +1,16 @@
package com.teaching.backend.service.favour;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourQueryRequest;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.favour.SeCourseFavour;
import com.teaching.backend.model.vo.favour.CourseFavourDetailVO;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@ -48,4 +57,13 @@ public interface SeCourseFavourService extends IService<SeCourseFavour> {
*/
List<String> courseList(String userId);
/**
* 某个用户课程列表全部信息
*
* @param page
* @param queryWrapper
* @return
*/
public Page<CourseFavourDetailVO> listCourseFavourByPage(Page<Courses> page, Wrapper<Courses> queryWrapper);
}

@ -1,21 +1,37 @@
package com.teaching.backend.service.impl.favour;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.favour.SeCourseFavourMapper;
import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourQueryRequest;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.favour.SeCourseFavour;
import com.teaching.backend.model.entity.favour.SeKnowFavour;
import com.teaching.backend.model.entity.favour.SeResourceFavour;
import com.teaching.backend.model.vo.CoursesVO;
import com.teaching.backend.model.vo.favour.CourseFavourDetailVO;
import com.teaching.backend.service.courses.ICoursesService;
import com.teaching.backend.service.favour.SeCourseFavourService;
import com.teaching.backend.service.favour.SeKnowFavourService;
import com.teaching.backend.service.favour.SeResourceFavourService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@ -37,6 +53,9 @@ public class SeCourseFavourServiceImpl extends ServiceImpl<SeCourseFavourMapper,
@Resource
SeKnowFavourService seKnowFavourService;
@Autowired
ICoursesService coursesService;
@Override
public boolean doCourseFavour(String courseId, String userId) {
@ -119,5 +138,25 @@ public class SeCourseFavourServiceImpl extends ServiceImpl<SeCourseFavourMapper,
return list;
}
@Override
public Page<CourseFavourDetailVO> listCourseFavourByPage(Page<Courses> page, Wrapper<Courses> queryWrapper) {
Page<Courses> coursePage = coursesService.page(page, queryWrapper);
Page<CourseFavourDetailVO> courseFavourVOPage = new Page<>(coursePage.getCurrent(), coursePage.getSize(), coursePage.getTotal());
List<Courses> courseFavourList = coursePage.getRecords();
//若数据为空,直接返回
if (CollUtil.isEmpty(courseFavourList)) {
return courseFavourVOPage;
}
//过滤字段
List<CourseFavourDetailVO> courseFavourDetailVOList = new ArrayList<>();
for (int i = 0; i < courseFavourList.size(); i++) {
CourseFavourDetailVO courseFavourDetailVO = new CourseFavourDetailVO();
BeanUtils.copyProperties(courseFavourList.get(i), courseFavourDetailVO);
courseFavourDetailVOList.add(courseFavourDetailVO);
}
courseFavourVOPage.setRecords(courseFavourDetailVOList);
return courseFavourVOPage;
}
}

@ -2,3 +2,4 @@ teaching-backend.img.path=C:\\Users\\jian\\Desktop\\cc\\teaching-backend\\src\\m
teaching-backend.video.path=C:\\Users\\jian\\Desktop\\cc\\teaching-backend\\src\\main\\resources\\static\\video\\
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB

@ -19,3 +19,14 @@ mybatis:
- classpath*:com/**/mapper/*.xml
# 接口文档配置
knife4j:
enable: true
openapi:
title: "111"
version: 1.0
group:
default:
api-rule: package
api-rule-resources:
- com.teaching.backend.controller

Loading…
Cancel
Save