|
@@ -0,0 +1,114 @@
|
|
|
+package com.koobietech.eas.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.koobietech.eas.common.constant.Disabled;
|
|
|
+import com.koobietech.eas.common.result.JsonPageResult;
|
|
|
+import com.koobietech.eas.common.result.JsonResult;
|
|
|
+import com.koobietech.eas.common.result.PageData;
|
|
|
+import com.koobietech.eas.mbg.model.EasEduCategory;
|
|
|
+import com.koobietech.eas.mbg.model.EasEduSubjects;
|
|
|
+import com.koobietech.eas.service.EasEduSubjectsService;
|
|
|
+import io.swagger.v3.core.util.Json;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@Tag(name = "课程控制器")
|
|
|
+@RequestMapping("/subject")
|
|
|
+public class EasEduSubjectsController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ EasEduSubjectsService easEduSubjectsService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加课程
|
|
|
+ * @param easEduSubjects
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/addSubject")
|
|
|
+ @Operation(summary = "添加课程" , description = "用于添加课程")
|
|
|
+ public JsonResult addSubject( @RequestBody EasEduSubjects easEduSubjects){
|
|
|
+ int addSubject = easEduSubjectsService.addSubject(easEduSubjects);
|
|
|
+ System.out.println(addSubject);
|
|
|
+ return JsonResult.ok("添加成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改课程
|
|
|
+ * @param easEduSubjects
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/updateSubjects")
|
|
|
+ @Operation(summary = "修改课程" , description = "用于修改课程")
|
|
|
+ public JsonResult updateSubjects( @RequestBody EasEduSubjects easEduSubjects){
|
|
|
+ int update_i = easEduSubjectsService.updateSubjects(easEduSubjects);
|
|
|
+ if (update_i > 0){
|
|
|
+ return JsonResult.ok();
|
|
|
+ }else {
|
|
|
+ return JsonResult.fail();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除课程
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @DeleteMapping(value = "/deleteSubjects/{id}")
|
|
|
+ @Operation(summary = "删除课程",description = "用于删除课程")
|
|
|
+ public JsonResult deleteSubjects(@PathVariable Integer id){
|
|
|
+ int delete_i = easEduSubjectsService.deleteSubjects(id);
|
|
|
+ if (delete_i > 0){
|
|
|
+ return JsonResult.ok();
|
|
|
+ }else {
|
|
|
+ return JsonResult.fail();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据 id 进行查询
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/selectById")
|
|
|
+ @Operation(summary = "id查询课程" ,description = "根据id查询课程")
|
|
|
+ public JsonResult selectById(Integer id){
|
|
|
+ EasEduSubjects easEduSubjects = easEduSubjectsService.selectById(id);
|
|
|
+ System.out.println(
|
|
|
+ Disabled.valueOf(easEduSubjects.getDisabled())
|
|
|
+ );
|
|
|
+ return JsonResult.data( easEduSubjects );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询所有课程及其信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/selectAll")
|
|
|
+ @Operation(summary = "查询所有课程",description = "用于查询所有课程")
|
|
|
+ public JsonResult selectAll(){
|
|
|
+ List<EasEduSubjects> easEduSubjects = easEduSubjectsService.selectAll();
|
|
|
+ return JsonResult.data( easEduSubjects );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过条件查询课程
|
|
|
+ * @param easEduSubjects
|
|
|
+ * @param pageNum
|
|
|
+ * @param pageSize
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/selectByCondition")
|
|
|
+ @Operation(summary = "根据条件进行查询课程", description = "用于根据条件查询课程")
|
|
|
+ public JsonPageResult selectByCondition(@RequestBody EasEduSubjects easEduSubjects,
|
|
|
+ @RequestParam Integer pageNum, @RequestParam Integer pageSize) {
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ PageData pageData = easEduSubjectsService.selectByCondition(easEduSubjects);
|
|
|
+ return JsonPageResult.data( pageData );
|
|
|
+ }
|
|
|
+}
|