Ver Fonte

category

常忠宇 há 1 ano atrás
pai
commit
8e5fbd3cf6

+ 6 - 0
common/src/main/java/com/koobietech/eas/common/constant/EnumType.java

@@ -0,0 +1,6 @@
+package com.koobietech.eas.common.constant;
+
+public enum EnumType {
+
+
+}

+ 89 - 0
controller/src/main/java/com/koobietech/eas/controller/EasEduCategoryController.java

@@ -0,0 +1,89 @@
+package com.koobietech.eas.controller;
+
+import com.koobietech.eas.common.result.JsonResult;
+import com.koobietech.eas.mbg.model.EasEduCategory;
+import com.koobietech.eas.service.EasEduCategoryService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@Tag(name = "课程分类控制器")
+public class EasEduCategoryController {
+
+    @Resource
+    EasEduCategoryService easEduCategoryService;
+
+    /**
+     * 添加
+     * @param easEduCategory
+     * @return
+     */
+    @PostMapping(value = "/addEasEduCategory")
+    @Operation(summary = "添加课程" , description = "用于演示添加课程")
+    public JsonResult addEasEduCategory(@RequestBody EasEduCategory easEduCategory ){
+        int add = easEduCategoryService.addEasEduCategory( easEduCategory );
+        System.out.println( add );
+        return JsonResult.ok("添加成功");
+    }
+
+    /**
+     * 更新
+     * @param easEduCategory
+     * @return
+     */
+    @PostMapping(value = "/updateEasEduCategory")
+    @Operation(summary = "课程更新" , description = "用于演示课程更新")
+    public JsonResult updateEasEduCategory(@RequestBody EasEduCategory easEduCategory){
+        int i = easEduCategoryService.updateEasEduCategory( easEduCategory );
+        if (i > 0){
+            return JsonResult.ok();
+        }else {
+            return JsonResult.fail();
+        }
+    }
+
+    /**
+     * 根据 Id 删除
+     * @param easEduCategory
+     * @return
+     */
+    @GetMapping(value = "/deleteById")
+    @Operation(summary = "根据Id删除课程" , description = "用于演示根据Id删除课程")
+    public JsonResult deleteById(@RequestBody EasEduCategory easEduCategory){
+        int i = easEduCategoryService.deleteById(easEduCategory.getId());
+        if (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){
+        EasEduCategory easEduCategory = easEduCategoryService.selectById(id);
+        System.out.println(easEduCategory);
+        return JsonResult.data( easEduCategory );
+    }
+
+    /**
+     * 查询全部课程
+     * @return
+     */
+    @GetMapping(value = "/selectAll")
+    @Operation(summary = "查询全部课程" , description = "用于演示查询全部课程")
+    public JsonResult selectAll(){
+        List<EasEduCategory> easEduCategories = easEduCategoryService.selectAll();
+        return JsonResult.data( easEduCategories );
+    }
+}

+ 21 - 0
service/src/main/java/com/koobietech/eas/service/EasEduCategoryService.java

@@ -0,0 +1,21 @@
+package com.koobietech.eas.service;
+
+import com.koobietech.eas.mbg.model.EasEduCategory;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+public interface EasEduCategoryService {
+
+    int addEasEduCategory( EasEduCategory easEduCategory );
+
+    int updateEasEduCategory( EasEduCategory easEduCategory );
+
+    int deleteById(int id);
+
+    @Select("SELECT * FROM eas_edu_category")
+    EasEduCategory selectById( Integer id );
+
+    List<EasEduCategory> selectAll();
+
+}

+ 41 - 0
service/src/main/java/com/koobietech/eas/service/impl/EasEduCategoryServiceImpl.java

@@ -0,0 +1,41 @@
+package com.koobietech.eas.service.impl;
+
+import com.koobietech.eas.mbg.mapper.EasEduCategoryMapper;
+import com.koobietech.eas.mbg.model.EasEduCategory;
+import com.koobietech.eas.service.EasEduCategoryService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+public class EasEduCategoryServiceImpl implements EasEduCategoryService {
+
+    @Resource
+    EasEduCategoryMapper easEduCategoryMapper;
+
+    @Override
+    public int addEasEduCategory(EasEduCategory easEduCategory) {
+       return  easEduCategoryMapper.insert(easEduCategory);
+    }
+
+    @Override
+    public int updateEasEduCategory(EasEduCategory easEduCategory) {
+        return easEduCategoryMapper.updateByPrimaryKey( easEduCategory );
+    }
+
+    @Override
+    public int deleteById(int id) {
+        return easEduCategoryMapper.deleteByPrimaryKey( id );
+    }
+
+    @Override
+    public EasEduCategory selectById(Integer id) {
+        return easEduCategoryMapper.selectByPrimaryKey( id );
+    }
+
+    @Override
+    public List<EasEduCategory> selectAll() {
+        return easEduCategoryMapper.selectByExample(null);
+    }
+}