lml200701158 / ddd-framework Goto Github PK
View Code? Open in Web Editor NEWDDD框架
DDD框架
这个东西不需要你手动实现,写上接口,然后maven重新打包,运行就会自动生成实现类
`package com.ddd.api.converter;
import com.ddd.api.model.req.AuthorizeCreateReq;
import com.ddd.api.model.req.AuthorizeUpdateReq;
import com.ddd.api.model.vo.UserAuthorizeVO;
import com.ddd.applicaiton.dto.UserRoleDTO;
import org.mapstruct.Mapper;
/**
UserVO转换器
@author louzai
@SInCE 2021/11/20
*/
@Mapper(componentModel = "spring")
public interface AuthorizeConverter {
/**
/**
/**
这是自动生成实现类的代码
`package com.ddd.api.converter;
import com.ddd.api.model.req.AuthorizeCreateReq;
import com.ddd.api.model.req.AuthorizeUpdateReq;
import com.ddd.api.model.vo.UserAuthorizeVO;
import com.ddd.applicaiton.dto.RoleInfoDTO;
import com.ddd.applicaiton.dto.UserRoleDTO;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Generated;
import org.springframework.stereotype.Component;
@generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2023-10-28T10:54:06+0800",
comments = "version: 1.5.2.Final, compiler: javac, environment: Java 1.8.0_351 (Oracle Corporation)"
)
@component
public class AuthorizeConverterImpl implements AuthorizeConverter {
@Override
public UserRoleDTO toDTO(AuthorizeCreateReq authorizeCreateReq) {
if ( authorizeCreateReq == null ) {
return null;
}
UserRoleDTO userRoleDTO = new UserRoleDTO();
userRoleDTO.setUserId( authorizeCreateReq.getUserId() );
List<RoleInfoDTO> list = authorizeCreateReq.getRoles();
if ( list != null ) {
userRoleDTO.setRoles( new ArrayList<RoleInfoDTO>( list ) );
}
userRoleDTO.setUserName( authorizeCreateReq.getUserName() );
userRoleDTO.setRealName( authorizeCreateReq.getRealName() );
userRoleDTO.setPhone( authorizeCreateReq.getPhone() );
userRoleDTO.setPassword( authorizeCreateReq.getPassword() );
userRoleDTO.setUnitId( authorizeCreateReq.getUnitId() );
userRoleDTO.setProvince( authorizeCreateReq.getProvince() );
userRoleDTO.setCity( authorizeCreateReq.getCity() );
userRoleDTO.setCounty( authorizeCreateReq.getCounty() );
return userRoleDTO;
}
@Override
public UserRoleDTO toDTO(AuthorizeUpdateReq authorizeUpdateReq) {
if ( authorizeUpdateReq == null ) {
return null;
}
UserRoleDTO userRoleDTO = new UserRoleDTO();
userRoleDTO.setUserId( authorizeUpdateReq.getUserId() );
List<RoleInfoDTO> list = authorizeUpdateReq.getRoles();
if ( list != null ) {
userRoleDTO.setRoles( new ArrayList<RoleInfoDTO>( list ) );
}
userRoleDTO.setUserName( authorizeUpdateReq.getUserName() );
userRoleDTO.setRealName( authorizeUpdateReq.getRealName() );
userRoleDTO.setPhone( authorizeUpdateReq.getPhone() );
userRoleDTO.setPassword( authorizeUpdateReq.getPassword() );
userRoleDTO.setUnitId( authorizeUpdateReq.getUnitId() );
userRoleDTO.setProvince( authorizeUpdateReq.getProvince() );
userRoleDTO.setCity( authorizeUpdateReq.getCity() );
userRoleDTO.setCounty( authorizeUpdateReq.getCounty() );
return userRoleDTO;
}
@Override
public UserAuthorizeVO toVO(UserRoleDTO userRoleDTO) {
if ( userRoleDTO == null ) {
return null;
}
UserAuthorizeVO userAuthorizeVO = new UserAuthorizeVO();
userAuthorizeVO.setUserId( userRoleDTO.getUserId() );
List<RoleInfoDTO> list = userRoleDTO.getRoles();
if ( list != null ) {
userAuthorizeVO.setRoles( new ArrayList<RoleInfoDTO>( list ) );
}
userAuthorizeVO.setUserName( userRoleDTO.getUserName() );
userAuthorizeVO.setRealName( userRoleDTO.getRealName() );
userAuthorizeVO.setPhone( userRoleDTO.getPhone() );
userAuthorizeVO.setPassword( userRoleDTO.getPassword() );
userAuthorizeVO.setUnitId( userRoleDTO.getUnitId() );
userAuthorizeVO.setUnitName( userRoleDTO.getUnitName() );
userAuthorizeVO.setProvince( userRoleDTO.getProvince() );
userAuthorizeVO.setCity( userRoleDTO.getCity() );
userAuthorizeVO.setCounty( userRoleDTO.getCounty() );
return userAuthorizeVO;
}
}`
ddd-domian --> ddd-domain
刚学习完极客时间的《DDD实战课》,然后看到本仓库demo中,应用层调用了仓储接口的save方法,按照严格分层理论,是否将这个保存操作放到领域层中,然后应用层调用这个领域层的保存方法会更好?
我理解DDD推荐领域对象只暴露关键字段和领域方法,状态的变化通过构造函数或者领域方法来完成。
java17+springboot3.0.9,按照配置@componentscan(basePackages = {"com.ddd"})启动,
直接报错一堆,坑太多了,好不容易解决环境问题,直接按照测试case查询一下
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ddd.infra.repository.mapper.UserMapper.selectById
求楼主解惑,谢谢。
看了下代码一个DTO、VO、DO 的转换都3次,效率上会比MVC低很多,不知道各位如何看待?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.