1
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.CourseCategoryEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CourseCategoryDao extends MPJBaseMapper<CourseCategoryEntity> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.CourseEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CourseDao extends MPJBaseMapper<CourseEntity> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.CourseSociologyEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CourseSociologyDao extends MPJBaseMapper<CourseSociologyEntity> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.CourseToCategoryEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CourseToCategoryDao extends MPJBaseMapper<CourseToCategoryEntity> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.CourseToSociologyEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CourseToSociologyDao extends MPJBaseMapper<CourseToSociologyEntity> {
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("course_category")
|
||||
public class CourseCategoryEntity {
|
||||
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer pid;
|
||||
|
||||
private String uid;
|
||||
|
||||
private String title;
|
||||
|
||||
private Integer isLast;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@TableName("course")
|
||||
public class CourseEntity {
|
||||
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private String uid;
|
||||
|
||||
private String title;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("course_sociology")
|
||||
public class CourseSociologyEntity {
|
||||
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer pid;
|
||||
|
||||
private Integer isLast;
|
||||
|
||||
private String title;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("course_to_category")
|
||||
public class CourseToCategoryEntity {
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer courseId;
|
||||
|
||||
private Integer categoryId;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("course_to_sociology")
|
||||
public class CourseToSociologyEntity {
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer courseId;
|
||||
|
||||
private Integer sociologyId;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.peanut.modules.master.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.CourseEntity;
|
||||
import com.peanut.modules.master.service.CourseService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("masterCourse")
|
||||
@RequestMapping("master/course")
|
||||
public class CourseController {
|
||||
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
|
||||
@RequestMapping("/getCourseList")
|
||||
public R getCourseList(@RequestBody Map<String,Object> map){
|
||||
Page courseList = courseService.getCourseList(map);
|
||||
return R.ok().put("page",courseList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.CourseEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface CourseService extends IService<CourseEntity> {
|
||||
|
||||
Page getCourseList(Map<String ,Object> map);
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.*;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.master.service.CourseService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service("masterCourseService")
|
||||
public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> implements CourseService {
|
||||
@Autowired
|
||||
private CourseCategoryDao courseCategoryDao;
|
||||
@Autowired
|
||||
private CourseToCategoryDao courseToCategoryDao;
|
||||
@Autowired
|
||||
private CourseSociologyDao courseSociologyDao;
|
||||
@Autowired
|
||||
private CourseToSociologyDao courseToSociologyDao;
|
||||
|
||||
@Override
|
||||
public Page getCourseList(Map<String,Object> map) {
|
||||
Integer limit = Integer.valueOf(map.get("limit").toString());
|
||||
Integer page = Integer.valueOf(map.get("page").toString());
|
||||
LambdaQueryWrapper<CourseEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
if(map.get("type").toString().equals("1")){
|
||||
Integer categoryId = Integer.valueOf(map.get("categoryId").toString());
|
||||
List<Integer> collect;
|
||||
if(categoryId==0){
|
||||
LambdaQueryWrapper<CourseCategoryEntity> courseCategoryEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
courseCategoryEntityLambdaQueryWrapper.eq(CourseCategoryEntity::getIsLast,1);
|
||||
collect = courseCategoryDao.selectList(courseCategoryEntityLambdaQueryWrapper).stream().map(CourseCategoryEntity::getId).collect(Collectors.toList());
|
||||
}else{
|
||||
collect = this.categoryIds(categoryId);
|
||||
}
|
||||
if(collect.size()>0){
|
||||
List<Integer> collect1 = courseToCategoryDao.selectList(new LambdaQueryWrapper<CourseToCategoryEntity>().in(CourseToCategoryEntity::getCategoryId, collect)).stream().map(CourseToCategoryEntity::getCourseId).collect(Collectors.toList());
|
||||
wrapper.in(collect1.size()>0,CourseEntity::getId,collect1);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
} else if (map.get("type").toString().equals("2")) {
|
||||
Integer sociologyId = Integer.valueOf(map.get("sociologyId").toString());
|
||||
List<Integer> c;
|
||||
if(sociologyId==0){
|
||||
c = courseSociologyDao.selectList(new LambdaQueryWrapper<CourseSociologyEntity>().eq(CourseSociologyEntity::getIsLast,1)).stream().map(CourseSociologyEntity::getId).collect(Collectors.toList());
|
||||
}else{
|
||||
c = this.sociologyIds(sociologyId);
|
||||
}
|
||||
if(c.size()>0){
|
||||
List<Integer> collect = courseToSociologyDao.selectList(new LambdaQueryWrapper<CourseToSociologyEntity>().in(CourseToSociologyEntity::getSociologyId, c)).stream().map(CourseToSociologyEntity::getCourseId).collect(Collectors.toList());
|
||||
wrapper.in(collect.size()>0,CourseEntity::getId,collect);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
wrapper.like(CourseEntity::getTitle,map.get("keywords").toString());
|
||||
Page<CourseEntity> courseEntityPage = this.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
||||
|
||||
return courseEntityPage;
|
||||
}
|
||||
|
||||
private List<Integer> categoryIds(Integer id){
|
||||
ArrayList<Integer> integers = new ArrayList<>();
|
||||
CourseCategoryEntity courseCategoryEntity = courseCategoryDao.selectById(id);
|
||||
if(courseCategoryEntity.getIsLast()==1){
|
||||
integers.add(id);
|
||||
}else{
|
||||
List<CourseCategoryEntity> courseCategoryEntities = courseCategoryDao.selectList(new LambdaQueryWrapper<CourseCategoryEntity>().eq(CourseCategoryEntity::getPid, id));
|
||||
for (CourseCategoryEntity c : courseCategoryEntities ){
|
||||
List<Integer> integers1 = this.categoryIds(c.getId());
|
||||
integers.addAll(integers1);
|
||||
}
|
||||
}
|
||||
return integers;
|
||||
}
|
||||
|
||||
private List<Integer> sociologyIds(Integer id){
|
||||
ArrayList<Integer> integers = new ArrayList<>();
|
||||
CourseSociologyEntity courseSociologyEntity = courseSociologyDao.selectById(id);
|
||||
if(courseSociologyEntity.getIsLast()==1){
|
||||
integers.add(id);
|
||||
}else{
|
||||
List<CourseSociologyEntity> courseSociologyEntities = courseSociologyDao.selectList(new LambdaQueryWrapper<CourseSociologyEntity>().eq(CourseSociologyEntity::getPid, id));
|
||||
for (CourseSociologyEntity c : courseSociologyEntities ){
|
||||
List<Integer> integers1 = this.sociologyIds(c.getId());
|
||||
integers.addAll(integers1);
|
||||
}
|
||||
}
|
||||
return integers;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,11 @@
|
||||
package com.peanut.modules.medical.controller;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController("medicalCourse")
|
||||
@RequestMapping("medical/course")
|
||||
public class CourseController {
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RestController("sociologyCourse")
|
||||
@RequestMapping("sociology/course")
|
||||
public class CourseController {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user