mirror of
https://gitee.com/coder-xiaomo/flashsale
synced 2025-09-13 23:41:39 +08:00
交易下单1(未完成)
This commit is contained in:
28
README.md
28
README.md
@@ -18,7 +18,7 @@
|
||||
| ----------------- | --------------------- | --------------------------------------- | ---------------------------------------- | ------------------------------- |
|
||||
| **Controller层** | | | | |
|
||||
| Controller | controller | 类 class | | controller.UserController |
|
||||
| View Object | controller/viewobject | 类 class | 将用户Model转化为可供UI使用的View Object | controller.UserController |
|
||||
| View Object (VO) | controller/viewobject | 类 class | 将用户Model转化为可供UI使用的View Object | controller.UserController |
|
||||
| | | | | |
|
||||
| **Service层** | 转换成业务模型 | | | |
|
||||
| Service | service | 接口 interface | | service.UserService |
|
||||
@@ -28,7 +28,7 @@
|
||||
| **Dao层** | 对数据库的映射 | | | |
|
||||
| Mapper | dao | 接口 interface | | dao.UserDOMapper |
|
||||
| Mapping | resources/mapping | Mapper接口实现类 | xml格式;SQL语句 | mapping/UserDOMapper.xml |
|
||||
| Data Object | dataobject | 类 class | | dataobject.UserDO |
|
||||
| Data Object (DO) | dataobject | 类 class | | dataobject.UserDO |
|
||||
| | | | | |
|
||||
| **其他** | | | | |
|
||||
| response | response | | 用于处理HTTP请求返回 | response.CommonReturnType |
|
||||
@@ -41,3 +41,27 @@
|
||||
| BusinessException | error | CommonError接口实现类 & 继承自Exception | | error.BusinessException |
|
||||
|
||||
**Tips:** Model与Data Object并非完全一一对应,例如UserModel是由ServiceImpl将UserDO和UserPasswordDO组装而成的。
|
||||
|
||||
|
||||
|
||||
代码构建顺序:
|
||||
|
||||
1. 创建Model模型(service/model)
|
||||
|
||||
2. 创建数据库中数据表
|
||||
|
||||
3. 使用mybatis-generator生成数据库映射文件(dao ; dataobject ; resources/mapping)
|
||||
|
||||
4. 创建Service接口(service)
|
||||
|
||||
5. 创建Service接口实现Impl(service/impl)(class打上 `Service` 标注;方法上打上 `@Transactional` 标签保证是在同一事务中)
|
||||
|
||||
6. 思考ServiceImpl中需要哪几步,并逐步实现
|
||||
|
||||
> - 如果需要修改自动生成的数据库语句,先改 resources/mapping 下的xml映射SQL语句,然后修改 dao 下的DOMapper接口
|
||||
>
|
||||
> - 可以用 `org.springframework.beans` 包中的 `BeanUtils.copyProperties` 进行DO转Model或Model转DO(要字段和类型完全一致的字段才能拷贝,其他不对应字段的需要手动设置)
|
||||
|
||||
7.
|
||||
|
||||
8. Service返回Controller前将DO
|
||||
|
Reference in New Issue
Block a user