From e765002e8314d6a0f0e2266313988a26079b6245 Mon Sep 17 00:00:00 2001
From: SKYID <2569982966@qq.com>
Date: Mon, 25 Jan 2021 11:22:47 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=A0=B9=E6=8D=AE?=
=?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=B1=BB=E5=9E=8B=E6=9F=A5=E8=AF=A2=E7=9A=84?=
=?UTF-8?q?=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/resources/mapper/CourseMapper.xml | 8 +-------
src/test/java/com/letoy/study/dao/CourseMapperTest.java | 2 +-
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/src/main/resources/mapper/CourseMapper.xml b/src/main/resources/mapper/CourseMapper.xml
index a764fa9..1a62dc3 100644
--- a/src/main/resources/mapper/CourseMapper.xml
+++ b/src/main/resources/mapper/CourseMapper.xml
@@ -30,13 +30,7 @@
select *
from course_info
where 1=1
-
-
-
-
- and course_type=#{courseType}
-
-
+
and course_type=#{courseType}
diff --git a/src/test/java/com/letoy/study/dao/CourseMapperTest.java b/src/test/java/com/letoy/study/dao/CourseMapperTest.java
index f8d36bc..ee0c7bc 100644
--- a/src/test/java/com/letoy/study/dao/CourseMapperTest.java
+++ b/src/test/java/com/letoy/study/dao/CourseMapperTest.java
@@ -94,7 +94,7 @@ public class CourseMapperTest {
@Test
public void findAllCourseInfoByCourseType() {
- ListcourseInfoList = courseMapper.findAllCourseInfoByCourseType("后端基础课程");
+ ListcourseInfoList = courseMapper.findAllCourseInfoByCourseType("");
for (CourseInfo attribute : courseInfoList){
System.out.println(attribute.getCourseId());
--
Gitee
From 8fb12b9f6d5d380447e8ff6dce171ed9f8f64699 Mon Sep 17 00:00:00 2001
From: SKYID <2569982966@qq.com>
Date: Mon, 25 Jan 2021 16:26:38 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../study/controller/CourseController.java | 48 ++++++++++
.../com/letoy/study/dao/CourseMapper.java | 1 +
.../letoy/study/service/CourseService.java | 21 ++++
.../service/implement/CourseServiceImpl.java | 95 +++++++++++++++++++
src/main/resources/mapper/CourseMapper.xml | 8 +-
src/main/resources/mybatis-config.xml | 4 +
.../com/letoy/study/dao/CourseMapperTest.java | 26 ++---
7 files changed, 183 insertions(+), 20 deletions(-)
create mode 100644 src/main/java/com/letoy/study/controller/CourseController.java
create mode 100644 src/main/java/com/letoy/study/service/CourseService.java
create mode 100644 src/main/java/com/letoy/study/service/implement/CourseServiceImpl.java
diff --git a/src/main/java/com/letoy/study/controller/CourseController.java b/src/main/java/com/letoy/study/controller/CourseController.java
new file mode 100644
index 0000000..31cecef
--- /dev/null
+++ b/src/main/java/com/letoy/study/controller/CourseController.java
@@ -0,0 +1,48 @@
+package com.letoy.study.controller;
+
+import com.letoy.study.entity.CourseInfo;
+import com.letoy.study.service.CourseService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+
+/**
+ * @program:letoy-study-java
+ * @author: WeiHaoL
+ * @Time: 2021/1/25 下午3:16
+ */
+
+@RestController
+public class CourseController {
+
+ @Resource
+ CourseService courseService;
+
+ @PostMapping("/course/releaseCourse")
+ @ApiOperation(value = "发布课程信息", notes = "发布课程信息")
+ public HashMap releaseCourse(CourseInfo courseInfo){
+
+ return courseService.releaseCourse(courseInfo);
+ }
+
+ @PostMapping("/course/deleteCourse")
+ @ApiOperation(value = "删除课程信息", notes = "删除课程信息")
+ public HashMap deleteCourse(CourseInfo courseInfo){
+
+ return courseService.deleteCourse(courseInfo);
+ }
+
+ @PostMapping("/course/findAllCourseInfo")
+ @ApiOperation(value = "查询课程信息", notes = "查询课程信息")
+ public HashMap findAllCourseInfo(String courseType){
+
+ if (courseType != null) {
+ return courseService.findAllCourseInfo(courseType);
+ }
+ return courseService.findAllCourseInfo();
+ }
+
+}
diff --git a/src/main/java/com/letoy/study/dao/CourseMapper.java b/src/main/java/com/letoy/study/dao/CourseMapper.java
index 65594a7..dd506bd 100644
--- a/src/main/java/com/letoy/study/dao/CourseMapper.java
+++ b/src/main/java/com/letoy/study/dao/CourseMapper.java
@@ -2,6 +2,7 @@ package com.letoy.study.dao;
import com.letoy.study.entity.CourseInfo;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
diff --git a/src/main/java/com/letoy/study/service/CourseService.java b/src/main/java/com/letoy/study/service/CourseService.java
new file mode 100644
index 0000000..8422bdd
--- /dev/null
+++ b/src/main/java/com/letoy/study/service/CourseService.java
@@ -0,0 +1,21 @@
+package com.letoy.study.service;
+
+import com.letoy.study.entity.CourseInfo;
+
+import java.util.HashMap;
+
+/**
+ * @program:letoy-study-java
+ * @author: WeiHaoL
+ * @Time: 2021/1/25 上午11:27
+ */
+public interface CourseService {
+
+ HashMap releaseCourse(CourseInfo courseInfo);
+
+ HashMap deleteCourse(CourseInfo courseInfo);
+
+ HashMap findAllCourseInfo();
+
+ HashMap findAllCourseInfo(String courseType);
+}
diff --git a/src/main/java/com/letoy/study/service/implement/CourseServiceImpl.java b/src/main/java/com/letoy/study/service/implement/CourseServiceImpl.java
new file mode 100644
index 0000000..94813cd
--- /dev/null
+++ b/src/main/java/com/letoy/study/service/implement/CourseServiceImpl.java
@@ -0,0 +1,95 @@
+package com.letoy.study.service.implement;
+
+import com.letoy.study.dao.CourseMapper;
+import com.letoy.study.entity.CourseInfo;
+import com.letoy.study.service.CourseService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+
+
+import static com.letoy.study.utils.Constants.FAIL;
+import static com.letoy.study.utils.Constants.SUCCESS;
+
+/**
+ * @program:letoy-study-java
+ * @author: WeiHaoL
+ * @Time: 2021/1/25 下午3:04
+ */
+@Service
+public class CourseServiceImpl implements CourseService {
+
+ @Resource
+ CourseMapper courseMapper;
+
+
+
+
+ @Override
+ public HashMap releaseCourse(CourseInfo courseInfo) {
+
+ HashMap hashMap = new HashMap<>();
+ int i = courseMapper.releaseCourse(courseInfo);
+ if (i == 0) {
+ hashMap.put("status", FAIL);
+ hashMap.put("msg", "发布失败");
+ return hashMap;
+ }
+ hashMap.put("status", SUCCESS);
+ hashMap.put("msg", "发布成功");
+ return hashMap;
+ }
+
+ @Override
+ public HashMap deleteCourse(CourseInfo courseInfo) {
+
+ HashMap hashMap = new HashMap<>();
+
+ int i = courseMapper.deleteCourse(courseInfo);
+ if (i == 0) {
+ hashMap.put("status", FAIL);
+ hashMap.put("msg", "删除失败");
+ return hashMap;
+ }
+ hashMap.put("status", SUCCESS);
+ hashMap.put("msg", "删除成功");
+ return hashMap;
+ }
+
+ @Override
+ public HashMap findAllCourseInfo() {
+
+ HashMap hashMap = new HashMap<>();
+
+ List allCourseInfoByCourseType = courseMapper.findAllCourseInfoByCourseType("");
+
+ if (allCourseInfoByCourseType == null) {
+ hashMap.put("status", FAIL);
+ hashMap.put("msg", "查询失败");
+ return hashMap;
+ }
+ hashMap.put("status", SUCCESS);
+ hashMap.put("msg", "查询成功");
+ hashMap.put("data", allCourseInfoByCourseType);
+ return hashMap;
+ }
+
+ @Override
+ public HashMap findAllCourseInfo(String courseType) {
+ HashMap hashMap = new HashMap<>();
+
+ List allCourseInfoByCourseType = courseMapper.findAllCourseInfoByCourseType(courseType);
+
+ if (allCourseInfoByCourseType == null) {
+ hashMap.put("status", FAIL);
+ hashMap.put("msg", "查询失败");
+ return hashMap;
+ }
+ hashMap.put("status", SUCCESS);
+ hashMap.put("msg", "查询成功");
+ hashMap.put("data", allCourseInfoByCourseType);
+ return hashMap;
+ }
+}
diff --git a/src/main/resources/mapper/CourseMapper.xml b/src/main/resources/mapper/CourseMapper.xml
index 1a62dc3..3d6d3dd 100644
--- a/src/main/resources/mapper/CourseMapper.xml
+++ b/src/main/resources/mapper/CourseMapper.xml
@@ -17,20 +17,20 @@
-
+
delete from course_info
- where course_id =#{courseId}
+ where course_id =#{courseId} and user_id=#{userId}
-