POJO
- POJO(Plain Ordinary Java Object)
- POJO 专指只有 setter/getter/toString 的简单类,包括 DO/DTO/BO/VO
- Bean 就是符合规约的 POJO
AO(Application Object)
- AO(Application Object Service 层上 服用多个服务
- 例如一个 Controller 需要使用多Service 组装一个 AO
DTO
- DTO(Data Transfer Object)数据传输对象
- Controller 中使用接受参数 和返回值
@RestController
public class UserController {
@PostMapping("findUserList")
public AjaxJson findUserList(@RequestBody PageDTO pageDTO) {
// dto data translate 接受外部数据
UserTO param = new UserTO();
param.setPageNum(pageDTO.getPageNum());
param.setPageSize(pageDTO.getPageSize());
param.setUsername(pageDTO.getKeywords());
// to translate 传输对象传入到服务层
UserServiceImpl userService = new UserServiceImpl();
UserTO transfer = userService.findUserList(param);
// vo view 传回视图层
UserVO view = new UserVO();
view.setTransfer(transfer);
// 返回的形式
AjaxJson result = new AjaxJson();
result.addJson(view);
return result;
}
}
TO
- TO(Transfer Object)传输对象
- Service 中使用接受参数 和返回值
public class UserServiceImpl implements UserServices {
// DAO(Data Access Object) 数据访问对象 MpUserMapper就是一个DAO
@Resource
private MpUserMapper mpUserMapper;
@Resource
private MpUserInfoMapper mpUserInfoMapper;
@Override
public UserTO findUserList(UserTO transfer) {
// po persistent 持久化对象 通常对应一个数据表
// do domain 领域对象
UserPO user = new UserPO();
UserInfoPO userInfo = new UserInfoPO();
// bo business 业务对象 通常一个业务需要查询多个表 也就是多个 po
UserBO business = new UserBO();
business.setUser(user);
business.setUserInfo(userInfo);
List<UserBO> businesses = new ArrayList<>();
businesses.add(business);
// to transfer对象
transfer.setDataList(businesses);
return transfer;
}
}
标签:DO,DAO,DTO,transfer,Object,POJO,param,new,UserTO
From: https://www.cnblogs.com/guanchaoguo/p/17866767.html