|
@@ -1,30 +1,24 @@
|
|
package com.management.platform.controller;
|
|
package com.management.platform.controller;
|
|
|
|
|
|
-
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.management.platform.entity.CourseInfo;
|
|
import com.management.platform.entity.CourseInfo;
|
|
-import com.management.platform.entity.User;
|
|
|
|
|
|
+import com.management.platform.entity.CourseType;
|
|
import com.management.platform.entity.dto.CourseInfoDto;
|
|
import com.management.platform.entity.dto.CourseInfoDto;
|
|
|
|
+import com.management.platform.mapper.CourseTypeMapper;
|
|
import com.management.platform.service.CourseInfoService;
|
|
import com.management.platform.service.CourseInfoService;
|
|
import com.management.platform.service.UserService;
|
|
import com.management.platform.service.UserService;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
-
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
-
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
-import java.io.File;
|
|
|
|
-import java.io.FileOutputStream;
|
|
|
|
-import java.io.InputStream;
|
|
|
|
-import java.io.OutputStream;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
-import java.util.UUID;
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -44,6 +38,8 @@ public class CourseInfoController {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private CourseInfoService courseInfoService ;
|
|
private CourseInfoService courseInfoService ;
|
|
|
|
+ @Autowired
|
|
|
|
+ private CourseTypeMapper courseTypeMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -55,11 +51,11 @@ public class CourseInfoController {
|
|
@RequestMapping(value="/saveOrUpdate")
|
|
@RequestMapping(value="/saveOrUpdate")
|
|
public HttpRespMsg saveOrUpdate(CourseInfo courseInfo, HttpServletRequest request) {
|
|
public HttpRespMsg saveOrUpdate(CourseInfo courseInfo, HttpServletRequest request) {
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
- String token = request.getHeader("Token");
|
|
|
|
- User user = userService.getById(token);
|
|
|
|
|
|
+// String token = request.getHeader("Token");
|
|
|
|
+// User user = userService.getById(token);
|
|
//新增
|
|
//新增
|
|
if (courseInfo.getId() == null) {
|
|
if (courseInfo.getId() == null) {
|
|
- courseInfo.setCompanyId(user.getCompanyId());
|
|
|
|
|
|
+// courseInfo.setCompanyId(user.getCompanyId());
|
|
courseInfoService.save(courseInfo);
|
|
courseInfoService.save(courseInfo);
|
|
}
|
|
}
|
|
//修改
|
|
//修改
|
|
@@ -103,16 +99,25 @@ public class CourseInfoController {
|
|
public HttpRespMsg list(CourseInfoDto courseInfoDto) {
|
|
public HttpRespMsg list(CourseInfoDto courseInfoDto) {
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
QueryWrapper<CourseInfo> wrapper = new QueryWrapper<>();
|
|
QueryWrapper<CourseInfo> wrapper = new QueryWrapper<>();
|
|
|
|
+ List<CourseType> courseTypeList = courseTypeMapper.selectList(new QueryWrapper<CourseType>());
|
|
if(StringUtils.isNotEmpty(courseInfoDto.getCourseName())){
|
|
if(StringUtils.isNotEmpty(courseInfoDto.getCourseName())){
|
|
wrapper.like("course_name", courseInfoDto.getCourseName());
|
|
wrapper.like("course_name", courseInfoDto.getCourseName());
|
|
}
|
|
}
|
|
- if (StringUtils.isNotEmpty(courseInfoDto.getCourseName())){
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(courseInfoDto.getCourseInstructor())){
|
|
wrapper.like("course_instructor", courseInfoDto.getCourseInstructor());
|
|
wrapper.like("course_instructor", courseInfoDto.getCourseInstructor());
|
|
}
|
|
}
|
|
if(courseInfoDto.getCourseType()!=null){
|
|
if(courseInfoDto.getCourseType()!=null){
|
|
- wrapper.eq("course_type", courseInfoDto.getCourseType());
|
|
|
|
|
|
+ wrapper.eq("course_type_id", courseInfoDto.getCourseType());
|
|
}
|
|
}
|
|
IPage<CourseInfo> page = courseInfoService.page(new Page<CourseInfo>(courseInfoDto.getPage(), courseInfoDto.getSize()), wrapper);
|
|
IPage<CourseInfo> page = courseInfoService.page(new Page<CourseInfo>(courseInfoDto.getPage(), courseInfoDto.getSize()), wrapper);
|
|
|
|
+ //设置每条数据的courseTypeName
|
|
|
|
+ for (CourseInfo courseInfo : page.getRecords()) {
|
|
|
|
+ for (CourseType courseType : courseTypeList) {
|
|
|
|
+ if (courseInfo.getCourseTypeId().equals(courseType.getId())) {
|
|
|
|
+ courseInfo.setCourseTypeName(courseType.getTypeName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
map.put("records", page.getRecords());
|
|
map.put("records", page.getRecords());
|
|
map.put("total", page.getTotal());
|
|
map.put("total", page.getTotal());
|