|
@@ -0,0 +1,95 @@
|
|
|
+package com.management.platform.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.management.platform.entity.CourseInfo;
|
|
|
+import com.management.platform.entity.CourseType;
|
|
|
+import com.management.platform.entity.dto.CourseInfoDto;
|
|
|
+import com.management.platform.service.CourseInfoService;
|
|
|
+import com.management.platform.service.CourseTypeService;
|
|
|
+import com.management.platform.util.HttpRespMsg;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 前端控制器
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author Seyason
|
|
|
+ * @since 2025-04-14
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/course-type")
|
|
|
+public class CourseTypeController {
|
|
|
+ @Resource
|
|
|
+ private CourseTypeService courseTypeService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private CourseInfoService courseInfoService;
|
|
|
+ /**
|
|
|
+ * 保存或修改
|
|
|
+ * @param courseType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value="/saveOrUpdate")
|
|
|
+ public HttpRespMsg saveOrUpdate(CourseType courseType) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ if(StringUtils.isEmpty(courseType.getTypeName())){
|
|
|
+ httpRespMsg.setError("类型名称不能为空!");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ if (courseType.getId() == null) {
|
|
|
+ int count = courseTypeService.count(new QueryWrapper<CourseType>().eq("type_name", courseType.getTypeName()));
|
|
|
+ if(count > 0){
|
|
|
+ httpRespMsg.setError("类型名称重复!");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ int count = courseTypeService.count(new QueryWrapper<CourseType>()
|
|
|
+ .eq("type_name", courseType.getTypeName())
|
|
|
+ .ne("id", courseType.getId()));
|
|
|
+ if(count > 0){
|
|
|
+ httpRespMsg.setError("类型名称重复!");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ courseTypeService.saveOrUpdate(courseType);
|
|
|
+ return httpRespMsg;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除类型
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value="/delete")
|
|
|
+ public HttpRespMsg delete(Integer id) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ int count = courseInfoService.count(new QueryWrapper<CourseInfo>().eq("course_type_id", id));
|
|
|
+ if(count > 0){
|
|
|
+ httpRespMsg.setError("有课程类型为当前类型,不能删除!");
|
|
|
+ return httpRespMsg;
|
|
|
+ }else {
|
|
|
+ courseTypeService.removeById(id);
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value="/typeList")
|
|
|
+ public HttpRespMsg typeList() {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ List<CourseType> courseTypeList = courseTypeService.list();
|
|
|
+ httpRespMsg.setData(courseTypeList);
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|