超星网站开发实战答案,建设银行网站会员怎么注册,2003 建设网站,网站设置高度文章目录一.需求分析二.课程分类查询介绍三.数据结构四.数据格式五.数据模型六.Api接口七.服务器端1.Dao1#xff09;定义mapper2#xff09;定义mapper映射文件2.Service3.Controller八.接口测试一.需求分析
用户操作流程如下#xff1a; 1、用户进入“我的课程”页面定义mapper2定义mapper映射文件2.Service3.Controller八.接口测试一.需求分析
用户操作流程如下 1、用户进入“我的课程”页面点击“新增课程”进入新增课程页面 2、填写课程信息选择课程分类、课程等级、学习模式等。 3、信息填写完毕点击“提交”课程添加成功或课程添加失败并提示失败原因。 需要解决的是在新增页面上输入的信息 1、课程分类 多级分类需要方便用户去选择。 2、课程等级、学习模式等这些选项建议是可以配置的
二.课程分类查询介绍
在新增课程界面需要选择课程所属分类 分类信息是整个项目非常重要的信息课程即商品分类信息设置的好坏直接影响用户访问量。 分类信息在哪里应用 1、首页分类导航 2、课程的归属地 添加课程时要选择课程的所属分类。
三.数据结构
分类表category的结构如下
四.数据格式
在添加课程时需要选择课程所属的分类因此需要定义课程分类查询接口。 接口格式要根据前端需要的数据格式来定义前端展示课程分类使用elemenet-ui的cascader级联选择器组件。 数据格式例子如下
[{value: zhinan,label: 指南,children: [{value: shejiyuanze,label: 设计原则,children: [{value: yizhi,label: 一致}, {value: fankui,label: 反馈}, {value: xiaolv,label: 效率}, {value: kekong,label: 可控}]}]}
]五.数据模型
定义category的模型 文件位置xcEduService01\xc-framework-model\src\main\java\com\xuecheng\framework\domain\course\Category.java
Data
ToString
Entity
Table(namecategory)
GenericGenerator(name jpa‐assigned, strategy assigned)
public class Category implements Serializable {private static final long serialVersionUID ‐906357110051689484L;IdGeneratedValue(generator jpa‐assigned)Column(length 32)private String id;private String name;private String label;private String parentid;private String isshow;private Integer orderby;private String isleaf;
}定义数据返回格式 文件位置xcEduService01\xc-framework-model\src\main\java\com\xuecheng\framework\domain\course\ext\CategoryNode.java
Data
ToString
public class CategoryNode extends Category {ListCategoryNode children;
}六.Api接口
文件位置C:\Users\fxd\Desktop\java\21微服务教育网学成在线\07-课程管理实战\代码\xcEduService01\xc-service-api\src\main\java\com\xuecheng\api\course\CategoryControllerApi.java
package com.xuecheng.api.web.controller.api.course;
import com.xuecheng.framework.domain.course.ext.CategoryNode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
Api(value 课程分类管理,description 课程分类管理,tags {课程分类管理})
public interface CategoryControllerApi {ApiOperation(查询分类)public CategoryNode findList();
}七.服务器端
1.Dao
1定义mapper
文件位置xcEduService01\xc-service-manage-course\src\main\java\com\xuecheng\manage_course\dao\CategoryMapper.java
Mapper
public interface CategoryMapper {//查询分类public CategoryNode selectList();
}2定义mapper映射文件
采用表的自连接方式输出树型结果集。 文件位置xcEduService01\xc-service-manage-course\src\main\resources\com\xuecheng\manage_course\dao\CategoryMapper.xml
?xml version1.0 encodingUTF‐8 ?
!DOCTYPE mapper PUBLIC ‐//mybatis.org//DTD Mapper 3.0//EN http://mybatis.org/dtd/mybatis‐3‐
mapper.dtd
mapper namespacecom.xuecheng.manage_course.dao.CategoryMapper resultMap typecom.xuecheng.framework.domain.course.ext.CategoryNode idcategoryMap id propertyid columnone_id/result propertyname columnone_name/result propertylabel columnone_label/result propertyisshow columnone_isshow/result propertyisleaf columnone_isleaf/result propertyorderby columnone_orderby/result propertyparentid columnone_parentid/collection propertychildren ofTypecom.xuecheng.framework.domain.course.ext.CategoryNodeid propertyid columntwo_id/result propertyname columntwo_name/result propertylabel columntwo_label/result propertyisshow columntwo_isshow/result propertyisleaf columntwo_isleaf/result propertyorderby columntwo_orderby/result propertyparentid columntwo_parentid/collection propertychildren ofTypecom.xuecheng.framework.domain.course.ext.CategoryNodeid propertyid columnthree_id/result propertyname columnthree_name/result propertylabel columnthree_label/result propertyisshow columnthree_isshow/result propertyisleaf columnthree_isleaf/result propertyorderby columnthree_orderby/result propertyparentid columnthree_parentid//collection/collection/resultMapselect idselectList resultMapcategoryMap SELECTa.id one_id,a.name one_name,a.label one_label,a.isshow one_isshow,a.isleaf one_isleaf,a.orderby one_orderby,a.parentid one_parentid,b.id two_id,b.name two_name,b.label two_label,b.isshow two_isshow,b.isleaf two_isleaf,b.orderby two_orderby,b.parentid two_parentid,c.id three_id,c.name three_name,c.label three_label,c.isshow three_isshow,c.isleaf three_isleaf,c.orderby three_orderby,c.parentid three_parentidFROMcategory a LEFT JOIN category bON a.id b.parentidLEFT JOIN category cON b.id c.parentidWHERE a.parentid 0ORDER BY a.orderby,b.orderby,c.orderby/select
/mapper2.Service
文件位置xcEduService01\xc-service-manage-course\src\main\java\com\xuecheng\manage_course\service\CategoryService.java
Service
public class CategoryService {AutowiredCategoryMapper categoryMapper;//查询分类public CategoryNode findList(){return categoryMapper.selectList();}
}3.Controller
文件位置xcEduService01\xc-service-manage-course\src\main\java\com\xuecheng\manage_course\controller\CategoryController.java
RestController
RequestMapping(/category)
public class CategoryController implements CategoryControllerApi {AutowiredCategoryService categoryService;OverrideGetMapping(/list)public CategoryNode findList() {return categoryService.findList();}
}八.接口测试
接口描述如下
使用swagger-ui或postman测试接口