├── .gitignore ├── ddd-interface ├── ddd-api │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── application.yml │ │ │ └── init.sql │ │ │ └── java │ │ │ └── com │ │ │ └── ddd │ │ │ └── api │ │ │ ├── DDDFrameworkApiApplication.java │ │ │ ├── model │ │ │ ├── req │ │ │ │ ├── AuthorizeCreateReq.java │ │ │ │ └── AuthorizeUpdateReq.java │ │ │ └── vo │ │ │ │ └── UserAuthorizeVO.java │ │ │ ├── web │ │ │ └── AuthorizeController.java │ │ │ └── converter │ │ │ └── AuthorizeConverter.java │ ├── pom.xml │ └── ddd-api.iml └── ddd-task │ ├── pom.xml │ └── ddd-task.iml ├── ddd-domian ├── src │ └── main │ │ └── java │ │ └── com │ │ └── ddd │ │ └── domain │ │ ├── event │ │ ├── UserDeleteEvent.java │ │ ├── UserCreateEvent.java │ │ ├── UserUpdateEvent.java │ │ └── DomainEventPublisherImpl.java │ │ └── impl │ │ └── AuthorizeDomainServiceImpl.java ├── pom.xml └── ddd-domian.iml ├── ddd-infra ├── src │ └── main │ │ └── java │ │ └── com │ │ └── ddd │ │ └── infra │ │ ├── repository │ │ ├── mapper │ │ │ ├── RoleMapper.java │ │ │ ├── UserMapper.java │ │ │ └── UserRoleMapper.java │ │ ├── converter │ │ │ └── UserConverter.java │ │ └── impl │ │ │ └── UserRepositoryImpl.java │ │ └── config │ │ └── InfraCoreConfig.java ├── pom.xml └── ddd-infra.iml ├── ddd-common ├── ddd-common-domain │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── ddd │ │ │ └── domain │ │ │ ├── event │ │ │ ├── DomainEventPublisher.java │ │ │ └── BaseDomainEvent.java │ │ │ └── service │ │ │ └── AuthorizeDomainService.java │ ├── pom.xml │ └── ddd-common-domain.iml ├── ddd-common-infra │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── ddd │ │ │ └── infra │ │ │ ├── dto │ │ │ ├── UnitDTO.java │ │ │ ├── AddressDTO.java │ │ │ ├── RoleDTO.java │ │ │ └── UserRoleDTO.java │ │ │ ├── repository │ │ │ ├── mybatis │ │ │ │ └── entity │ │ │ │ │ ├── UserRolePO.java │ │ │ │ │ ├── RolePO.java │ │ │ │ │ ├── BaseUuidEntity.java │ │ │ │ │ └── UserPO.java │ │ │ └── UserRepository.java │ │ │ └── domain │ │ │ └── AuthorizeDO.java │ ├── pom.xml │ └── ddd-common-infra.iml ├── ddd-common-application │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── ddd │ │ │ └── applicaiton │ │ │ ├── dto │ │ │ ├── RoleInfoDTO.java │ │ │ └── UserRoleDTO.java │ │ │ └── service │ │ │ └── AuthrizeApplicationService.java │ ├── pom.xml │ └── ddd-common-application.iml └── ddd-common │ ├── src │ └── main │ │ └── java │ │ └── com │ │ └── ddd │ │ └── common │ │ ├── util │ │ ├── ValidationUtil.java │ │ └── GsonUtil.java │ │ ├── exception │ │ ├── ValidationException.java │ │ └── ServiceException.java │ │ └── result │ │ ├── PageResult.java │ │ ├── BaseResult.java │ │ ├── Page.java │ │ └── Result.java │ ├── pom.xml │ └── ddd-common.iml ├── ddd-application ├── pom.xml ├── src │ └── main │ │ └── java │ │ └── com │ │ └── ddd │ │ └── applicaiton │ │ ├── converter │ │ └── UserApplicationConverter.java │ │ └── impl │ │ └── AuthrizeApplicationServiceImpl.java └── ddd-application.iml ├── pom.xml ├── README.md └── ddd-framework.iml /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | -------------------------------------------------------------------------------- /ddd-interface/ddd-api/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8087 3 | 4 | spring: 5 | datasource: 6 | type: com.alibaba.druid.pool.DruidDataSource 7 | username: root 8 | password: 1234 9 | url: jdbc:mysql://127.0.0.1/study?characterEncoding=utf8 10 | driver-class-name: com.mysql.cj.jdbc.Driver -------------------------------------------------------------------------------- /ddd-domian/src/main/java/com/ddd/domain/event/UserDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package com.ddd.domain.event; 2 | 3 | /** 4 | * 用户删除领域事件 5 | * 6 | * @author louzai 7 | * @since 2021/11/20 8 | */ 9 | public class UserDeleteEvent extends BaseDomainEvent { 10 | public UserDeleteEvent(Long userId) { 11 | super(userId); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ddd-infra/src/main/java/com/ddd/infra/repository/mapper/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.repository.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.ddd.infra.repository.mybatis.entity.RolePO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | public interface RoleMapper extends BaseMapper { 8 | } 9 | -------------------------------------------------------------------------------- /ddd-infra/src/main/java/com/ddd/infra/repository/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.repository.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.ddd.infra.repository.mybatis.entity.UserPO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | public interface UserMapper extends BaseMapper { 8 | } 9 | -------------------------------------------------------------------------------- /ddd-infra/src/main/java/com/ddd/infra/repository/mapper/UserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.repository.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.ddd.infra.repository.mybatis.entity.UserRolePO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | public interface UserRoleMapper extends BaseMapper { 8 | } 9 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-domain/src/main/java/com/ddd/domain/event/DomainEventPublisher.java: -------------------------------------------------------------------------------- 1 | package com.ddd.domain.event; 2 | 3 | /** 4 | * 领域事件发布接口 5 | * 6 | * @author louzai 7 | * @since 2021/11/22 8 | */ 9 | public interface DomainEventPublisher { 10 | /** 11 | * 发布事件 12 | * 13 | * @param event 领域事件 14 | */ 15 | void publishEvent(BaseDomainEvent event); 16 | } 17 | -------------------------------------------------------------------------------- /ddd-domian/src/main/java/com/ddd/domain/event/UserCreateEvent.java: -------------------------------------------------------------------------------- 1 | package com.ddd.domain.event; 2 | 3 | import com.ddd.infra.domain.AuthorizeDO; 4 | 5 | /** 6 | * 用户新增领域事件 7 | * 8 | * @author louzai 9 | * @since 2021/11/20 10 | */ 11 | public class UserCreateEvent extends BaseDomainEvent { 12 | public UserCreateEvent(AuthorizeDO user) { 13 | super(user); 14 | } 15 | } -------------------------------------------------------------------------------- /ddd-domian/src/main/java/com/ddd/domain/event/UserUpdateEvent.java: -------------------------------------------------------------------------------- 1 | package com.ddd.domain.event; 2 | 3 | import com.ddd.infra.domain.AuthorizeDO; 4 | 5 | /** 6 | * 用户修改领域事件 7 | * 8 | * @author louzai 9 | * @since 2021/11/20 10 | */ 11 | public class UserUpdateEvent extends BaseDomainEvent { 12 | public UserUpdateEvent(AuthorizeDO user) { 13 | super(user); 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-domain/src/main/java/com/ddd/domain/service/AuthorizeDomainService.java: -------------------------------------------------------------------------------- 1 | package com.ddd.domain.service; 2 | 3 | import com.ddd.infra.domain.AuthorizeDO; 4 | 5 | /** 6 | * 用户授权 领域能力 7 | * 8 | * @author louzai 9 | * @since 2021/11/21 10 | */ 11 | public interface AuthorizeDomainService { 12 | /** 13 | * 设置单位信息 14 | * 15 | * @param user 16 | */ 17 | void associatedUnit(AuthorizeDO user); 18 | } 19 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-infra/src/main/java/com/ddd/infra/dto/UnitDTO.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.dto; 2 | 3 | import lombok.Data; 4 | import lombok.NoArgsConstructor; 5 | 6 | /** 7 | * 单位数据 8 | * 9 | * @author louzai 10 | * @since 2021/11/20 11 | */ 12 | @Data 13 | @NoArgsConstructor 14 | public class UnitDTO { 15 | /** 16 | * 单位id 17 | */ 18 | private Long unitId; 19 | 20 | /** 21 | * 单位名称 22 | */ 23 | private String unitName; 24 | } 25 | -------------------------------------------------------------------------------- /ddd-infra/src/main/java/com/ddd/infra/config/InfraCoreConfig.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.config; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * 对数据库的mapper加载 9 | * 10 | * @author louzai 11 | * @since 2021/11/20 12 | */ 13 | @Configuration 14 | @ComponentScan 15 | @MapperScan(value = "com.ddd.infra.repository.mapper") 16 | public class InfraCoreConfig { 17 | } 18 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-infra/src/main/java/com/ddd/infra/dto/AddressDTO.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.dto; 2 | 3 | import lombok.Data; 4 | import lombok.NoArgsConstructor; 5 | 6 | /** 7 | * 地址数据 8 | * 9 | * @author louzai 10 | * @since 2021/11/20 11 | */ 12 | @Data 13 | @NoArgsConstructor 14 | public class AddressDTO { 15 | /** 16 | * 省 17 | */ 18 | private String province; 19 | 20 | /** 21 | * 市 22 | */ 23 | private String city; 24 | 25 | /** 26 | * 区 27 | */ 28 | private String county; 29 | } 30 | -------------------------------------------------------------------------------- /ddd-domian/src/main/java/com/ddd/domain/impl/AuthorizeDomainServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.ddd.domain.impl; 2 | 3 | import com.ddd.domain.service.AuthorizeDomainService; 4 | import com.ddd.infra.domain.AuthorizeDO; 5 | import org.springframework.stereotype.Service; 6 | 7 | @Service 8 | public class AuthorizeDomainServiceImpl implements AuthorizeDomainService { 9 | @Override 10 | // 设置单位信息 11 | public void associatedUnit(AuthorizeDO authorizeDO) { 12 | String unitName = "武汉小米";// TODO: 通过第三方获取 13 | authorizeDO.getUnit().setUnitName(unitName); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-infra/src/main/java/com/ddd/infra/dto/RoleDTO.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.dto; 2 | 3 | import lombok.Data; 4 | import lombok.NoArgsConstructor; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | /** 9 | * 角色数据 10 | * 11 | * @author louzai 12 | * @since 2021/11/20 13 | */ 14 | @Data 15 | @NoArgsConstructor 16 | public class RoleDTO { 17 | 18 | /** 19 | * 角色id 20 | */ 21 | private Long roleId; 22 | 23 | /** 24 | * 角色名称 25 | */ 26 | private String name; 27 | 28 | /** 29 | * 角色code 30 | */ 31 | private String code; 32 | } 33 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-application/src/main/java/com/ddd/applicaiton/dto/RoleInfoDTO.java: -------------------------------------------------------------------------------- 1 | package com.ddd.applicaiton.dto; 2 | 3 | import lombok.Data; 4 | import lombok.NoArgsConstructor; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | /** 9 | * 角色数据 10 | * 11 | * @author louzai 12 | * @since 2021/11/20 13 | */ 14 | @Data 15 | @NoArgsConstructor 16 | public class RoleInfoDTO { 17 | 18 | /** 19 | * 角色id 20 | */ 21 | private Long roleId; 22 | 23 | /** 24 | * 角色名称 25 | */ 26 | private String name; 27 | 28 | /** 29 | * 角色code 30 | */ 31 | private String code; 32 | } 33 | -------------------------------------------------------------------------------- /ddd-common/ddd-common/src/main/java/com/ddd/common/util/ValidationUtil.java: -------------------------------------------------------------------------------- 1 | package com.ddd.common.util; 2 | 3 | import com.ddd.common.exception.ValidationException; 4 | 5 | /** 6 | * 校验工具类 7 | * 8 | * @author louzai 9 | * @since 2021/11/20 10 | */ 11 | public class ValidationUtil { 12 | 13 | public static void isTrue(boolean expect, String code, Object... params) { 14 | if (!expect) { 15 | throw ValidationException.of(code, params); 16 | } 17 | } 18 | 19 | public static void isFalse(boolean expect, String code, Object... params) { 20 | isTrue(!expect, code, params); 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /ddd-interface/ddd-api/src/main/java/com/ddd/api/DDDFrameworkApiApplication.java: -------------------------------------------------------------------------------- 1 | package com.ddd.api; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cache.annotation.EnableCaching; 6 | import org.springframework.context.annotation.ComponentScan; 7 | 8 | @EnableCaching 9 | @SpringBootApplication 10 | @ComponentScan(basePackages = {"com.ddd"}) 11 | public class DDDFrameworkApiApplication { 12 | public static void main(String[] args) { 13 | SpringApplication.run(DDDFrameworkApiApplication.class, args); 14 | } 15 | } -------------------------------------------------------------------------------- /ddd-interface/ddd-task/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | ddd-framework 7 | org.example 8 | 1.0-SNAPSHOT 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | ddd-task 14 | 15 | 16 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-application/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | ddd-framework 7 | org.example 8 | 1.0-SNAPSHOT 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | ddd-common-application 14 | 15 | 16 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-infra/src/main/java/com/ddd/infra/repository/mybatis/entity/UserRolePO.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.repository.mybatis.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.*; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 用户表 10 | * 11 | * @author louzai 12 | * @since 2021/11/20 13 | */ 14 | @Data 15 | @Builder 16 | @EqualsAndHashCode(callSuper = true) 17 | @NoArgsConstructor 18 | @AllArgsConstructor 19 | @TableName(value = "t_user_role", autoResultMap = true) 20 | public class UserRolePO extends BaseUuidEntity { 21 | 22 | /** 用户id */ 23 | private Long userId; 24 | 25 | /** 角色id */ 26 | private Long roleId; 27 | } 28 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-infra/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | ddd-framework 7 | org.example 8 | 1.0-SNAPSHOT 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | ddd-common-infra 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-infra/src/main/java/com/ddd/infra/dto/UserRoleDTO.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.dto; 2 | 3 | import lombok.Data; 4 | import lombok.NoArgsConstructor; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | /** 9 | * 用户角色数据 10 | * 11 | * @author louzai 12 | * @since 2021/11/20 13 | */ 14 | @Data 15 | @NoArgsConstructor 16 | public class UserRoleDTO { 17 | 18 | /** 19 | * 用户id 20 | */ 21 | private Long userId; 22 | 23 | /** 24 | * 角色id 25 | */ 26 | private Long roleId; 27 | 28 | /** 29 | * 创建时间 30 | */ 31 | private LocalDateTime createTime; 32 | 33 | /** 34 | * 修改时间 35 | */ 36 | private LocalDateTime updateTime; 37 | } 38 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-infra/src/main/java/com/ddd/infra/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.repository; 2 | 3 | import com.ddd.infra.domain.AuthorizeDO; 4 | 5 | /** 6 | * 用户领域仓储 7 | * 8 | * @author louzai 9 | * @since 2021/11/20 10 | */ 11 | public interface UserRepository { 12 | 13 | /** 14 | * 删除 15 | * 16 | * @param userId 17 | */ 18 | void delete(Long userId); 19 | 20 | /** 21 | * 查询 22 | * 23 | * @param userId 24 | * @return 25 | */ 26 | AuthorizeDO query(Long userId); 27 | 28 | /** 29 | * 保存 30 | * 31 | * @param user 32 | * @return 33 | */ 34 | AuthorizeDO save(AuthorizeDO user); 35 | } 36 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-infra/src/main/java/com/ddd/infra/repository/mybatis/entity/RolePO.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.repository.mybatis.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableLogic; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.*; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | * 用户表 13 | * 14 | * @author louzai 15 | * @since 2021/11/20 16 | */ 17 | @Data 18 | @EqualsAndHashCode(callSuper = true) 19 | @TableName(value = "t_role", autoResultMap = true) 20 | public class RolePO extends BaseUuidEntity { 21 | 22 | /** 角色名称 */ 23 | private String name; 24 | 25 | /** 角色code */ 26 | private String code; 27 | } 28 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-application/src/main/java/com/ddd/applicaiton/service/AuthrizeApplicationService.java: -------------------------------------------------------------------------------- 1 | package com.ddd.applicaiton.service; 2 | 3 | import com.ddd.applicaiton.dto.UserRoleDTO; 4 | 5 | public interface AuthrizeApplicationService { 6 | /** 7 | * 新建用户授权 8 | * 9 | * @param userRole 10 | */ 11 | void createUserAuthorize(UserRoleDTO userRole); 12 | 13 | /** 14 | * 查询用户授权 15 | * 16 | * @param userId 17 | */ 18 | UserRoleDTO queryUserAuthorize(Long userId); 19 | 20 | /** 21 | * 修改用户授权 22 | * 23 | * @param userRole 24 | */ 25 | void updateUserAuthorize(UserRoleDTO userRole); 26 | 27 | /** 28 | * 删除用户授权 29 | * 30 | * @param userId 31 | */ 32 | void deleteUserAuthorize(Long userId); 33 | } 34 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-domain/src/main/java/com/ddd/domain/event/BaseDomainEvent.java: -------------------------------------------------------------------------------- 1 | package com.ddd.domain.event; 2 | 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | import java.io.Serializable; 8 | import java.time.LocalDateTime; 9 | 10 | /** 11 | * 领域事件基类 12 | * 13 | * @author louzai 14 | * @since 2021/11/22 15 | */ 16 | @Getter 17 | @Setter 18 | @NoArgsConstructor 19 | public abstract class BaseDomainEvent implements Serializable { 20 | private static final long serialVersionUID = 1465328245048581896L; 21 | /** 22 | * 发生时间 23 | */ 24 | private LocalDateTime occurredOn; 25 | /** 26 | * 领域事件数据 27 | */ 28 | private T data; 29 | public BaseDomainEvent(T data) { 30 | this.data = data; 31 | this.occurredOn = LocalDateTime.now(); 32 | } 33 | } -------------------------------------------------------------------------------- /ddd-domian/src/main/java/com/ddd/domain/event/DomainEventPublisherImpl.java: -------------------------------------------------------------------------------- 1 | package com.ddd.domain.event; 2 | 3 | import com.ddd.common.util.GsonUtil; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.context.ApplicationEventPublisher; 7 | import org.springframework.stereotype.Component; 8 | 9 | /** 10 | * 领域事件发布实现类 11 | * 12 | * @author louzai 13 | * @since 2021/11/20 14 | */ 15 | @Component 16 | @Slf4j 17 | public class DomainEventPublisherImpl implements DomainEventPublisher { 18 | 19 | @Autowired 20 | private ApplicationEventPublisher applicationEventPublisher; 21 | 22 | @Override 23 | public void publishEvent(BaseDomainEvent event) { 24 | log.debug("发布事件,event:{}", GsonUtil.gsonToString(event)); 25 | applicationEventPublisher.publishEvent(event); 26 | } 27 | } -------------------------------------------------------------------------------- /ddd-common/ddd-common-infra/src/main/java/com/ddd/infra/repository/mybatis/entity/BaseUuidEntity.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.repository.mybatis.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableLogic; 6 | import lombok.Data; 7 | 8 | import java.time.LocalDateTime; 9 | 10 | /** 11 | * 基础表结构实体 12 | * 13 | * @author louzai 14 | * @since 2021/11/20 15 | */ 16 | @Data 17 | public class BaseUuidEntity { 18 | /** 19 | * 主键id 采用默认雪花算法 20 | */ 21 | @TableId 22 | private Long id; 23 | 24 | /** 25 | * 创建时间 26 | */ 27 | private LocalDateTime gmtCreate; 28 | 29 | /** 30 | * 修改时间 31 | */ 32 | private LocalDateTime gmtModified; 33 | 34 | /** 35 | * 是否删除,0位未删除 36 | */ 37 | @TableLogic(delval = "current_timestamp()") 38 | private Long deleted; 39 | } 40 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-domain/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | ddd-framework 7 | org.example 8 | 1.0-SNAPSHOT 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | ddd-common-domain 14 | 15 | 16 | org.example 17 | ddd-common-infra 18 | 1.0-SNAPSHOT 19 | compile 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /ddd-common/ddd-common/src/main/java/com/ddd/common/exception/ValidationException.java: -------------------------------------------------------------------------------- 1 | package com.ddd.common.exception; 2 | 3 | import lombok.EqualsAndHashCode; 4 | import lombok.Getter; 5 | 6 | /** 7 | * 校验 8 | * 9 | * @author louzai 10 | * @since 2021/11/20 11 | */ 12 | @EqualsAndHashCode(callSuper = true) 13 | public class ValidationException extends ServiceException { 14 | 15 | @Getter 16 | private Object[] params; 17 | 18 | public ValidationException(String message) { 19 | super(message); 20 | } 21 | 22 | public ValidationException(String message, Object[] params) { 23 | super(message); 24 | this.params = params; 25 | } 26 | 27 | public ValidationException(String code, String message, Object[] params) { 28 | super(code, message); 29 | this.params = params; 30 | } 31 | 32 | public static ValidationException of(String code, Object[] params) { 33 | return new ValidationException(code, null, params); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ddd-infra/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | ddd-framework 7 | org.example 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | ddd-infra 13 | 14 | 15 | org.example 16 | ddd-common-infra 17 | 1.0-SNAPSHOT 18 | compile 19 | 20 | 21 | org.example 22 | ddd-common 23 | 1.0-SNAPSHOT 24 | compile 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ddd-domian/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | ddd-framework 7 | org.example 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | ddd-domian 13 | 14 | 15 | org.example 16 | ddd-infra 17 | 1.0-SNAPSHOT 18 | compile 19 | 20 | 21 | org.example 22 | ddd-common-domain 23 | 1.0-SNAPSHOT 24 | compile 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /ddd-application/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | ddd-framework 7 | org.example 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | ddd-application 13 | 14 | 15 | org.example 16 | ddd-common-application 17 | 1.0-SNAPSHOT 18 | compile 19 | 20 | 21 | org.example 22 | ddd-domian 23 | 1.0-SNAPSHOT 24 | compile 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ddd-interface/ddd-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | ddd-framework 7 | org.example 8 | 1.0-SNAPSHOT 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | ddd-api 14 | 15 | 16 | org.example 17 | ddd-application 18 | 1.0-SNAPSHOT 19 | compile 20 | 21 | 22 | com.alibaba 23 | druid-spring-boot-starter 24 | 1.2.4 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ddd-interface/ddd-api/src/main/java/com/ddd/api/model/req/AuthorizeCreateReq.java: -------------------------------------------------------------------------------- 1 | package com.ddd.api.model.req; 2 | 3 | import com.ddd.applicaiton.dto.RoleInfoDTO; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.util.List; 8 | 9 | @Data 10 | @NoArgsConstructor 11 | public class AuthorizeCreateReq { 12 | /** 13 | * 用户ID 14 | */ 15 | private Long userId; 16 | 17 | /** 18 | * 角色ID列表 19 | */ 20 | private List roles; 21 | 22 | /** 23 | * 用户名 24 | */ 25 | private String userName; 26 | 27 | /** 28 | * 真是姓名 29 | */ 30 | private String realName; 31 | 32 | /** 33 | * 手机号 34 | */ 35 | private String phone; 36 | 37 | /** 38 | * 密码 39 | */ 40 | private String password; 41 | 42 | /** 43 | * 单位id 44 | */ 45 | private Long unitId; 46 | 47 | /** 48 | * 省 49 | */ 50 | private String province; 51 | 52 | /** 53 | * 市 54 | */ 55 | private String city; 56 | 57 | /** 58 | * 区 59 | */ 60 | private String county; 61 | } 62 | -------------------------------------------------------------------------------- /ddd-interface/ddd-api/src/main/java/com/ddd/api/model/req/AuthorizeUpdateReq.java: -------------------------------------------------------------------------------- 1 | package com.ddd.api.model.req; 2 | 3 | import com.ddd.applicaiton.dto.RoleInfoDTO; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.util.List; 8 | 9 | @Data 10 | @NoArgsConstructor 11 | public class AuthorizeUpdateReq { 12 | /** 13 | * 用户ID 14 | */ 15 | private Long userId; 16 | 17 | /** 18 | * 角色ID列表 19 | */ 20 | private List roles; 21 | 22 | /** 23 | * 用户名 24 | */ 25 | private String userName; 26 | 27 | /** 28 | * 真是姓名 29 | */ 30 | private String realName; 31 | 32 | /** 33 | * 手机号 34 | */ 35 | private String phone; 36 | 37 | /** 38 | * 密码 39 | */ 40 | private String password; 41 | 42 | /** 43 | * 单位id 44 | */ 45 | private Long unitId; 46 | 47 | /** 48 | * 省 49 | */ 50 | private String province; 51 | 52 | /** 53 | * 市 54 | */ 55 | private String city; 56 | 57 | /** 58 | * 区 59 | */ 60 | private String county; 61 | } 62 | -------------------------------------------------------------------------------- /ddd-interface/ddd-api/src/main/java/com/ddd/api/model/vo/UserAuthorizeVO.java: -------------------------------------------------------------------------------- 1 | package com.ddd.api.model.vo; 2 | 3 | import com.ddd.applicaiton.dto.RoleInfoDTO; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.util.List; 8 | 9 | @Data 10 | @NoArgsConstructor 11 | public class UserAuthorizeVO { 12 | /** 13 | * 用户ID 14 | */ 15 | private Long userId; 16 | 17 | /** 18 | * 角色ID列表 19 | */ 20 | private List roles; 21 | 22 | /** 23 | * 用户名 24 | */ 25 | private String userName; 26 | 27 | /** 28 | * 真是姓名 29 | */ 30 | private String realName; 31 | 32 | /** 33 | * 手机号 34 | */ 35 | private String phone; 36 | 37 | /** 38 | * 密码 39 | */ 40 | private String password; 41 | 42 | /** 43 | * 单位id 44 | */ 45 | private Long unitId; 46 | 47 | /** 48 | * 单位名称 49 | */ 50 | private String unitName; 51 | 52 | /** 53 | * 省 54 | */ 55 | private String province; 56 | 57 | /** 58 | * 市 59 | */ 60 | private String city; 61 | 62 | /** 63 | * 区 64 | */ 65 | private String county; 66 | } 67 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-infra/src/main/java/com/ddd/infra/domain/AuthorizeDO.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.domain; 2 | 3 | import com.ddd.infra.dto.AddressDTO; 4 | import com.ddd.infra.dto.RoleDTO; 5 | import com.ddd.infra.dto.UnitDTO; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Builder; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * 对身份授权(assign) 领域对象. 15 | * 16 | * @author louzai 17 | * @since 2021/11/20 18 | */ 19 | @Data 20 | @Builder 21 | @AllArgsConstructor 22 | @NoArgsConstructor 23 | public class AuthorizeDO { 24 | 25 | /** 26 | * 用户ID 27 | */ 28 | private Long userId; 29 | 30 | /** 31 | * 用户名 32 | */ 33 | private String userName; 34 | 35 | /** 36 | * 真是姓名 37 | */ 38 | private String realName; 39 | 40 | /** 41 | * 手机号 42 | */ 43 | private String phone; 44 | 45 | /** 46 | * 密码 47 | */ 48 | private String password; 49 | 50 | /** 51 | * 用户单位 52 | */ 53 | private UnitDTO unit; 54 | 55 | /** 56 | * 用户地址 57 | */ 58 | private AddressDTO address; 59 | 60 | /** 61 | * 用户角色 62 | */ 63 | private List roles; 64 | } 65 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-application/src/main/java/com/ddd/applicaiton/dto/UserRoleDTO.java: -------------------------------------------------------------------------------- 1 | package com.ddd.applicaiton.dto; 2 | 3 | import lombok.Data; 4 | import lombok.NoArgsConstructor; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 用户&角色数据 10 | * 11 | * @author louzai 12 | * @since 2021/11/22 13 | */ 14 | @Data 15 | @NoArgsConstructor 16 | public class UserRoleDTO { 17 | 18 | /** 19 | * 用户ID 20 | */ 21 | private Long userId; 22 | 23 | /** 24 | * 角色ID列表 25 | */ 26 | private List roles; 27 | 28 | /** 29 | * 用户名 30 | */ 31 | private String userName; 32 | 33 | /** 34 | * 真是姓名 35 | */ 36 | private String realName; 37 | 38 | /** 39 | * 手机号 40 | */ 41 | private String phone; 42 | 43 | /** 44 | * 密码 45 | */ 46 | private String password; 47 | 48 | /** 49 | * 单位id 50 | */ 51 | private Long unitId; 52 | 53 | /** 54 | * 单位名称 55 | */ 56 | private String unitName; 57 | 58 | /** 59 | * 省 60 | */ 61 | private String province; 62 | 63 | /** 64 | * 市 65 | */ 66 | private String city; 67 | 68 | /** 69 | * 区 70 | */ 71 | private String county; 72 | } 73 | -------------------------------------------------------------------------------- /ddd-common/ddd-common/src/main/java/com/ddd/common/result/PageResult.java: -------------------------------------------------------------------------------- 1 | package com.ddd.common.result; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 分页数据返回实体 11 | * 12 | * @author louzai 13 | * @since 2021/11/20 14 | */ 15 | @Data 16 | @EqualsAndHashCode(callSuper = true) 17 | public class PageResult extends BaseResult { 18 | 19 | private Long total; 20 | 21 | private List data; 22 | 23 | public PageResult() { 24 | } 25 | 26 | public static PageResult ok(Page result) { 27 | PageResult pageResult = new PageResult<>(); 28 | pageResult.setCode(CODE_SUCCESS); 29 | pageResult.setMessage(QUERY_SUCCESS); 30 | pageResult.setTotal(result.getTotal()); 31 | pageResult.setData(result.getRecords()); 32 | return pageResult; 33 | } 34 | 35 | public static PageResult ok(Long total,List data) { 36 | PageResult pageResult = new PageResult<>(); 37 | pageResult.setCode(CODE_SUCCESS); 38 | pageResult.setMessage(QUERY_SUCCESS); 39 | pageResult.setTotal(total); 40 | pageResult.setData(data); 41 | return pageResult; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-infra/src/main/java/com/ddd/infra/repository/mybatis/entity/UserPO.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.repository.mybatis.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.AllArgsConstructor; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | import lombok.ToString; 11 | 12 | import java.io.Serializable; 13 | 14 | /** 15 | * 用户表 16 | * 17 | * @author louzai 18 | * @since 2021/11/20 19 | */ 20 | @Data 21 | @TableName(value = "t_user") 22 | public class UserPO extends BaseUuidEntity { 23 | 24 | /** 25 | * 用户名 26 | * */ 27 | @TableField(value = "user_name") 28 | private String userName; 29 | 30 | /** 31 | * 真是姓名 32 | * */ 33 | private String realName; 34 | 35 | /** 36 | * 手机号 37 | * */ 38 | private String phone; 39 | 40 | /** 41 | * 密码 42 | * */ 43 | private String password; 44 | 45 | /** 46 | * 单位id 47 | * */ 48 | private Long unitId; 49 | 50 | /** 51 | * 单位名称 52 | * */ 53 | private String unitName; 54 | 55 | /** 56 | * 省 57 | */ 58 | private String province; 59 | 60 | /** 61 | * 市 62 | */ 63 | private String city; 64 | 65 | /** 66 | * 区 67 | */ 68 | private String county; 69 | } 70 | -------------------------------------------------------------------------------- /ddd-common/ddd-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | ddd-framework 7 | org.example 8 | 1.0-SNAPSHOT 9 | ../../pom.xml 10 | 11 | 4.0.0 12 | 13 | ddd-common 14 | 15 | 16 | 17 | com.google.code.gson 18 | gson 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-validation 23 | 24 | 25 | 26 | org.mapstruct 27 | 28 | mapstruct-jdk8 29 | 1.2.0.Final 30 | 31 | 32 | org.mapstruct 33 | mapstruct-processor 34 | 1.2.0.Final 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /ddd-common/ddd-common/src/main/java/com/ddd/common/result/BaseResult.java: -------------------------------------------------------------------------------- 1 | package com.ddd.common.result; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 基础返回实体 7 | * 8 | * @author louzai 9 | * @since 2021/11/20 10 | */ 11 | @Data 12 | public class BaseResult { 13 | /** 14 | * httpCode 15 | */ 16 | private Integer code; 17 | 18 | /** 19 | * 业务code 20 | */ 21 | private String errorCode; 22 | 23 | /** 24 | * 业务信息 25 | */ 26 | private String message; 27 | 28 | /** 29 | * 链路id 30 | */ 31 | private String traceId; 32 | 33 | public BaseResult() { 34 | } 35 | 36 | public BaseResult(Integer code, String message) { 37 | this.code = code; 38 | this.message = message; 39 | } 40 | 41 | public BaseResult(Integer code, String errorCode, String message) { 42 | this.code = code; 43 | this.errorCode = errorCode; 44 | this.message = message; 45 | } 46 | 47 | /** 48 | * 通用业务请求状态码 49 | */ 50 | public static final Integer CODE_SUCCESS = 200; 51 | public static final Integer CODE_SYSTEM_ERROR = 500; 52 | 53 | /** 54 | * 通用请求信息 55 | */ 56 | public static final String SYSTEM_ERROR = "系统错误"; 57 | public static final String MESSAGE_SUCCESS = "请求成功"; 58 | public static final String QUERY_SUCCESS = "查询成功"; 59 | public static final String INSERT_SUCCESS = "新增成功"; 60 | public static final String UPDATE_SUCCESS = "更新成功"; 61 | public static final String DELETE_SUCCESS = "删除成功"; 62 | public static final String IMPORT_SUCCESS = "导入成功"; 63 | public static final String EXPORT_SUCCESS = "导出成功"; 64 | public static final String DOWNLOAD_SUCCESS = "下载成功"; 65 | 66 | } 67 | 68 | 69 | -------------------------------------------------------------------------------- /ddd-common/ddd-common/src/main/java/com/ddd/common/result/Page.java: -------------------------------------------------------------------------------- 1 | package com.ddd.common.result; 2 | 3 | import com.baomidou.mybatisplus.core.metadata.OrderItem; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | import java.util.Iterator; 8 | import java.util.List; 9 | import java.util.Spliterator; 10 | import java.util.function.Consumer; 11 | import java.util.function.Function; 12 | 13 | /** 14 | * 分页实体 15 | * 16 | * @author louzai 17 | * @since 2021/11/20 18 | */ 19 | @Data 20 | @EqualsAndHashCode(callSuper = true) 21 | public class Page extends com.baomidou.mybatisplus.extension.plugins.pagination.Page implements Iterable { 22 | 23 | @Override 24 | public Iterator iterator() { 25 | return getRecords().iterator(); 26 | } 27 | 28 | @Override 29 | public void forEach(Consumer action) { 30 | getRecords().forEach(action); 31 | } 32 | 33 | @Override 34 | public Spliterator spliterator() { 35 | return getRecords().spliterator(); 36 | } 37 | 38 | @Override 39 | public Page convert(Function mapper) { 40 | return (Page) super.convert(mapper); 41 | } 42 | 43 | @Override 44 | public long getCurrent() { 45 | return super.getCurrent(); 46 | } 47 | 48 | /** 49 | * 反序列化的时候需要用到 50 | */ 51 | public void setOffset(Long offset) { 52 | setCurrent(offset/getSize()+1); 53 | } 54 | 55 | @Override 56 | public long getSize() { 57 | return super.getSize(); 58 | } 59 | 60 | /** 61 | * 反序列化的时候需要用到 62 | */ 63 | public void setLimit(Long limit) { 64 | setSize(limit); 65 | } 66 | 67 | @Override 68 | public List getOrders() { 69 | return super.getOrders(); 70 | } 71 | 72 | @Override 73 | public boolean isSearchCount() { 74 | return super.isSearchCount(); 75 | } 76 | } 77 | 78 | -------------------------------------------------------------------------------- /ddd-common/ddd-common/src/main/java/com/ddd/common/result/Result.java: -------------------------------------------------------------------------------- 1 | package com.ddd.common.result; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | /** 7 | * 返回实体 8 | * 9 | * @author louzai 10 | * @since 2021/11/20 11 | */ 12 | @Data 13 | @EqualsAndHashCode(callSuper = true) 14 | public class Result extends BaseResult { 15 | 16 | private T data; 17 | 18 | public Result() { 19 | } 20 | 21 | public Result(Integer code, String message, T data) { 22 | super(code, message); 23 | this.data = data; 24 | } 25 | 26 | public Result(Integer code, String errorCode, String message, T data) { 27 | super(code, errorCode, message); 28 | this.data = data; 29 | } 30 | 31 | public boolean success() { 32 | return CODE_SUCCESS.equals(getCode()); 33 | } 34 | 35 | public boolean systemFail() { 36 | return CODE_SYSTEM_ERROR.equals(getCode()); 37 | } 38 | 39 | public static Result ok() { 40 | return new Result<>(CODE_SUCCESS, "", null); 41 | } 42 | 43 | public static Result ok(String message) { 44 | return new Result<>(CODE_SUCCESS, message, null); 45 | } 46 | 47 | public static Result success(T data) { 48 | return new Result<>(CODE_SUCCESS, MESSAGE_SUCCESS, data); 49 | } 50 | 51 | public static Result success(T data, String message) { 52 | return new Result<>(CODE_SUCCESS, message, data); 53 | } 54 | 55 | public static Result error(String message) { 56 | return Result.error(CODE_SYSTEM_ERROR, null, message, null); 57 | } 58 | 59 | public static Result error(String errorCode, String message) { 60 | return Result.error(CODE_SYSTEM_ERROR, errorCode, message, null); 61 | } 62 | 63 | public static Result error(Integer code, String errorCode, String message, Object data) { 64 | return new Result<>(code, errorCode, message, data); 65 | } 66 | 67 | } 68 | 69 | -------------------------------------------------------------------------------- /ddd-common/ddd-common/src/main/java/com/ddd/common/exception/ServiceException.java: -------------------------------------------------------------------------------- 1 | package com.ddd.common.exception; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | /** 7 | * 系统统一根异常 8 | * 9 | * @author louzai 10 | * @since 2021/11/20 11 | */ 12 | @Data 13 | @EqualsAndHashCode(callSuper = true) 14 | public class ServiceException extends RuntimeException { 15 | 16 | private static final long serialVersionUID = 430933593095358673L; 17 | 18 | private String errorMessage; 19 | 20 | private String errorCode; 21 | 22 | /** 23 | * 构造新实例。 24 | */ 25 | public ServiceException() { 26 | super(); 27 | } 28 | 29 | /** 30 | * 用给定的异常信息构造新实例。 31 | * @param errorMessage 异常信息。 32 | */ 33 | public ServiceException(String errorMessage) { 34 | super((String)null); 35 | this.errorMessage = errorMessage; 36 | } 37 | 38 | /** 39 | * 用表示异常原因的对象构造新实例。 40 | * @param cause 异常原因。 41 | */ 42 | public ServiceException(Throwable cause) { 43 | super(null, cause); 44 | } 45 | 46 | /** 47 | * 用异常消息和表示异常原因的对象构造新实例。 48 | * @param errorMessage 异常信息。 49 | * @param cause 异常原因。 50 | */ 51 | public ServiceException(String errorMessage, Throwable cause) { 52 | super(null, cause); 53 | this.errorMessage = errorMessage; 54 | } 55 | 56 | /** 57 | * 用异常消息和表示异常原因及其他信息的对象构造新实例。 58 | * @param errorMessage 异常信息。 59 | * @param errorCode 错误代码。 60 | * @param cause 异常原因。 61 | */ 62 | public ServiceException(String errorMessage, String errorCode, Throwable cause) { 63 | this(errorMessage, cause); 64 | this.errorCode = errorCode; 65 | } 66 | 67 | /** 68 | * 返回异常信息。 69 | * @return 异常信息。 70 | */ 71 | public String getErrorMessage() { 72 | return errorMessage; 73 | } 74 | 75 | /** 76 | * 返回错误代码的字符串表示。 77 | * @return 错误代码的字符串表示。 78 | */ 79 | public String getErrorCode() { 80 | return errorCode; 81 | } 82 | 83 | @Override 84 | public String getMessage() { 85 | return getErrorMessage(); 86 | } 87 | 88 | public ServiceException(String code, String message) { 89 | super(message); 90 | this.errorCode = code; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /ddd-interface/ddd-api/src/main/resources/init.sql: -------------------------------------------------------------------------------- 1 | create table t_user_role ( 2 | id bigint auto_increment comment '主键id' primary key, 3 | user_id bigint not null comment '用户id', 4 | role_id bigint not null comment '角色id', 5 | gmt_create datetime default CURRENT_TIMESTAMP not null comment '创建时间', 6 | gmt_modified datetime default CURRENT_TIMESTAMP not null comment '修改时间', 7 | deleted bigint default 0 not null comment '是否已删除' 8 | )comment '用户角色关联表' charset = utf8; 9 | 10 | create table t_user 11 | ( 12 | id bigint auto_increment comment '主键' primary key, 13 | user_name varchar(64) null comment '用户名', 14 | password varchar(255) null comment '密码', 15 | real_name varchar(64) null comment '真实姓名', 16 | phone bigint null comment '手机号', 17 | province varchar(64) null comment '用户名', 18 | city varchar(64) null comment '用户名', 19 | county varchar(64) null comment '用户名', 20 | unit_id bigint null comment '单位id', 21 | unit_name varchar(64) null comment '单位名称', 22 | gmt_create datetime default CURRENT_TIMESTAMP not null comment '创建时间', 23 | gmt_modified datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', 24 | deleted bigint default 0 not null comment '是否删除,非0为已删除' 25 | )comment '用户表' collate = utf8_bin; 26 | 27 | create table t_role 28 | ( 29 | id bigint auto_increment comment '主键' primary key, 30 | name varchar(256) not null comment '名称', 31 | code varchar(64) null comment '角色code', 32 | gmt_create datetime default CURRENT_TIMESTAMP not null comment '创建时间', 33 | gmt_modified datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', 34 | deleted bigint default 0 not null comment '是否已删除' 35 | )comment '角色表' charset = utf8; 36 | 37 | INSERT INTO t_role (id, name, code, gmt_create, gmt_modified, deleted) VALUES (1, '超级管理员', 'super_admin', '2021-09-10 19:27:55', '2021-09-10 19:27:55', 0); 38 | INSERT INTO t_role (id, name, code, gmt_create, gmt_modified, deleted) VALUES (2, '管理员', 'admin', '2021-09-10 19:27:55', '2021-09-10 19:27:55', 0); 39 | INSERT INTO t_role (id, name, code, gmt_create, gmt_modified, deleted) VALUES (3, '普通用户', 'user', '2021-09-10 19:27:56', '2021-09-10 19:27:56', 0); -------------------------------------------------------------------------------- /ddd-interface/ddd-api/src/main/java/com/ddd/api/web/AuthorizeController.java: -------------------------------------------------------------------------------- 1 | package com.ddd.api.web; 2 | 3 | import com.ddd.api.converter.AuthorizeConverter; 4 | import com.ddd.api.model.req.AuthorizeCreateReq; 5 | import com.ddd.api.model.req.AuthorizeUpdateReq; 6 | import com.ddd.api.model.vo.UserAuthorizeVO; 7 | import com.ddd.applicaiton.dto.UserRoleDTO; 8 | import com.ddd.applicaiton.service.AuthrizeApplicationService; 9 | import com.ddd.common.result.BaseResult; 10 | import com.ddd.common.result.Result; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.web.bind.annotation.*; 13 | 14 | /** 15 | * 用户管理web接口 16 | * 17 | * @author louzai 18 | * @since 2021/11/22 19 | */ 20 | @RestController 21 | @RequestMapping("/api/user") 22 | public class AuthorizeController { 23 | 24 | @Autowired 25 | private AuthorizeConverter authorizeConverter; 26 | 27 | @Autowired 28 | private AuthrizeApplicationService authrizeApplicationService; 29 | 30 | /** 31 | * 测试URL:http://127.0.0.1:8087/api/user?userId=xxx 32 | */ 33 | @GetMapping("/query") 34 | public Result query(@RequestParam("userId") Long userId){ 35 | UserRoleDTO userRoleDTO = authrizeApplicationService.queryUserAuthorize(userId); 36 | Result result = new Result<>(); 37 | result.setData(authorizeConverter.toVO(userRoleDTO)); 38 | result.setCode(BaseResult.CODE_SUCCESS); 39 | return result; 40 | } 41 | 42 | /** 43 | * 测试URL:http://127.0.0.1:8087/api/user/delete?userId=xxx 44 | */ 45 | @PostMapping("/delete") 46 | public Result delete(@RequestParam("userId") Long userId){ 47 | authrizeApplicationService.deleteUserAuthorize(userId); 48 | return Result.ok(BaseResult.DELETE_SUCCESS); 49 | } 50 | 51 | /** 52 | * 测试URL:http://127.0.0.1:8087/api/user/save 53 | * Post Body:{"userName":"louzai","realName":"楼","phone":13123676844,"password":"***","unitId":2,"province":"湖北省","city":"鄂州市","county":"葛店开发区","roles":[{"roleId":2}]} 54 | */ 55 | @PostMapping("/save") 56 | public Result create(@RequestBody AuthorizeCreateReq authorizeCreateReq){ 57 | authrizeApplicationService.createUserAuthorize(authorizeConverter.toDTO(authorizeCreateReq)); 58 | return Result.ok(BaseResult.INSERT_SUCCESS); 59 | } 60 | 61 | /** 62 | * 测试URL:http://127.0.0.1:8087/api/user/update 63 | * Post Body:{"userId":1,"userName":"louzai","realName":"louzai-realname","phone":123,"roles":[{"roleId":2}]} 64 | */ 65 | @PostMapping("/update") 66 | public Result update(@RequestBody AuthorizeUpdateReq authorizeUpdateReq){ 67 | authrizeApplicationService.updateUserAuthorize(authorizeConverter.toDTO(authorizeUpdateReq)); 68 | return Result.ok(BaseResult.UPDATE_SUCCESS); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /ddd-infra/src/main/java/com/ddd/infra/repository/converter/UserConverter.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.repository.converter; 2 | 3 | import com.ddd.infra.domain.AuthorizeDO; 4 | import com.ddd.infra.dto.AddressDTO; 5 | import com.ddd.infra.dto.RoleDTO; 6 | import com.ddd.infra.dto.UnitDTO; 7 | import com.ddd.infra.repository.mybatis.entity.RolePO; 8 | import com.ddd.infra.repository.mybatis.entity.UserPO; 9 | import com.ddd.infra.repository.mybatis.entity.UserRolePO; 10 | import org.mapstruct.Mapper; 11 | import org.springframework.beans.BeanUtils; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.stream.Collectors; 16 | 17 | /** 18 | * UserPo转换器 19 | * 20 | * @author louzai 21 | * @since 2021/11/20 22 | */ 23 | @Mapper(componentModel = "spring") 24 | public interface UserConverter { 25 | 26 | default AuthorizeDO toAuthorizeDo(UserPO userPo, List roles) { 27 | AuthorizeDO authorizeDO = new AuthorizeDO(); 28 | authorizeDO.setUserId(userPo.getId()); 29 | authorizeDO.setUserName(userPo.getUserName()); 30 | authorizeDO.setRealName(userPo.getRealName()); 31 | authorizeDO.setPhone(userPo.getPhone()); 32 | authorizeDO.setPassword(userPo.getPassword()); 33 | 34 | UnitDTO unitDTO = new UnitDTO(); 35 | unitDTO.setUnitId(userPo.getUnitId()); 36 | unitDTO.setUnitName(userPo.getUnitName()); 37 | 38 | AddressDTO addressDTO = new AddressDTO(); 39 | addressDTO.setCity(userPo.getCity()); 40 | addressDTO.setCounty(userPo.getCounty()); 41 | addressDTO.setProvince(userPo.getProvince()); 42 | 43 | authorizeDO.setUnit(unitDTO); 44 | authorizeDO.setAddress(addressDTO); 45 | 46 | List roleDTOList = new ArrayList<>(); 47 | roles.stream().forEach(e -> { 48 | RoleDTO roleDTO = new RoleDTO(); 49 | roleDTO.setRoleId(e.getId()); 50 | roleDTO.setCode(e.getCode()); 51 | roleDTO.setName(e.getName()); 52 | roleDTOList.add(roleDTO); 53 | }); 54 | authorizeDO.setRoles(roleDTOList); 55 | return authorizeDO; 56 | } 57 | 58 | default UserPO toUserPo(AuthorizeDO user){ 59 | UserPO userPo = new UserPO(); 60 | BeanUtils.copyProperties(user,userPo); 61 | userPo.setId(user.getUserId()); 62 | userPo.setCity(user.getAddress().getCity()); 63 | userPo.setCounty(user.getAddress().getCounty()); 64 | userPo.setProvince(user.getAddress().getProvince()); 65 | userPo.setUnitId(user.getUnit().getUnitId()); 66 | userPo.setUnitName(user.getUnit().getUnitName()); 67 | return userPo; 68 | } 69 | 70 | default List toUserRolePo(AuthorizeDO user){ 71 | return user.getRoles().stream() 72 | .map(e-> new UserRolePO(user.getUserId(),e.getRoleId())) 73 | .collect(Collectors.toList()); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /ddd-interface/ddd-api/src/main/java/com/ddd/api/converter/AuthorizeConverter.java: -------------------------------------------------------------------------------- 1 | package com.ddd.api.converter; 2 | 3 | import com.ddd.api.model.req.AuthorizeCreateReq; 4 | import com.ddd.api.model.req.AuthorizeUpdateReq; 5 | import com.ddd.api.model.vo.UserAuthorizeVO; 6 | import com.ddd.applicaiton.dto.UserRoleDTO; 7 | import org.mapstruct.Mapper; 8 | 9 | /** 10 | * UserVO转换器 11 | * 12 | * @author louzai 13 | * @since 2021/11/20 14 | */ 15 | @Mapper(componentModel = "spring") 16 | public interface AuthorizeConverter { 17 | 18 | // 这里很奇怪,通过mapstruce转换失败,一直找不到原因,就直接先手动赋值吧 19 | default UserRoleDTO toDTO(AuthorizeCreateReq authorizeCreateReq) { 20 | UserRoleDTO userRoleDTO = new UserRoleDTO(); 21 | userRoleDTO.setUserId(authorizeCreateReq.getUserId()); 22 | userRoleDTO.setRoles(authorizeCreateReq.getRoles()); 23 | userRoleDTO.setUserName(authorizeCreateReq.getUserName()); 24 | userRoleDTO.setRealName(authorizeCreateReq.getRealName()); 25 | userRoleDTO.setPhone(authorizeCreateReq.getPhone()); 26 | userRoleDTO.setPassword(authorizeCreateReq.getPassword()); 27 | userRoleDTO.setUnitId(authorizeCreateReq.getUnitId()); 28 | userRoleDTO.setProvince(authorizeCreateReq.getProvince()); 29 | userRoleDTO.setCity(authorizeCreateReq.getCity()); 30 | userRoleDTO.setCounty(authorizeCreateReq.getCounty()); 31 | return userRoleDTO; 32 | } 33 | 34 | // 这里很奇怪,通过mapstruce转换失败,一直找不到原因,就直接先手动赋值吧 35 | default UserRoleDTO toDTO(AuthorizeUpdateReq authorizeUpdateReq) { 36 | UserRoleDTO userRoleDTO = new UserRoleDTO(); 37 | userRoleDTO.setUserId(authorizeUpdateReq.getUserId()); 38 | userRoleDTO.setRoles(authorizeUpdateReq.getRoles()); 39 | userRoleDTO.setUserName(authorizeUpdateReq.getUserName()); 40 | userRoleDTO.setRealName(authorizeUpdateReq.getRealName()); 41 | userRoleDTO.setPhone(authorizeUpdateReq.getPhone()); 42 | userRoleDTO.setPassword(authorizeUpdateReq.getPassword()); 43 | userRoleDTO.setUnitId(authorizeUpdateReq.getUnitId()); 44 | userRoleDTO.setProvince(authorizeUpdateReq.getProvince()); 45 | userRoleDTO.setCity(authorizeUpdateReq.getCity()); 46 | userRoleDTO.setCounty(authorizeUpdateReq.getCounty()); 47 | return userRoleDTO; 48 | } 49 | 50 | // 这里很奇怪,通过mapstruce转换失败,一直找不到原因,就直接先手动赋值吧 51 | default UserAuthorizeVO toVO(UserRoleDTO userRoleDTO) { 52 | UserAuthorizeVO userAuthorizeVO = new UserAuthorizeVO(); 53 | userAuthorizeVO.setUserId(userRoleDTO.getUserId()); 54 | userAuthorizeVO.setRoles(userRoleDTO.getRoles()); 55 | userAuthorizeVO.setUserName(userRoleDTO.getUserName()); 56 | userAuthorizeVO.setRealName(userRoleDTO.getRealName()); 57 | userAuthorizeVO.setPhone(userRoleDTO.getPhone()); 58 | userAuthorizeVO.setPassword(userRoleDTO.getPassword()); 59 | userAuthorizeVO.setUnitId(userRoleDTO.getUnitId()); 60 | userAuthorizeVO.setUnitName(userRoleDTO.getUnitName()); 61 | userAuthorizeVO.setProvince(userRoleDTO.getProvince()); 62 | userAuthorizeVO.setCity(userRoleDTO.getCity()); 63 | userAuthorizeVO.setCounty(userRoleDTO.getCounty()); 64 | return userAuthorizeVO; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /ddd-application/src/main/java/com/ddd/applicaiton/converter/UserApplicationConverter.java: -------------------------------------------------------------------------------- 1 | package com.ddd.applicaiton.converter; 2 | 3 | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; 4 | import com.ddd.applicaiton.dto.RoleInfoDTO; 5 | import com.ddd.applicaiton.dto.UserRoleDTO; 6 | import com.ddd.infra.domain.AuthorizeDO; 7 | import com.ddd.infra.dto.AddressDTO; 8 | import com.ddd.infra.dto.RoleDTO; 9 | import com.ddd.infra.dto.UnitDTO; 10 | import org.mapstruct.Mapper; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * UserDo转换器 17 | * 18 | * @author louzai 19 | * @since 2021/11/20 20 | */ 21 | @Mapper(componentModel = "spring") 22 | public interface UserApplicationConverter { 23 | 24 | RoleDTO toRoleDTO(RoleInfoDTO roleDTO); 25 | 26 | RoleInfoDTO toRoleInfoDTO(RoleDTO roleDTO); 27 | 28 | default AuthorizeDO toAuthorizeDo(UserRoleDTO userRoleDTO) { 29 | AuthorizeDO authorizeDO = new AuthorizeDO(); 30 | 31 | authorizeDO.setUserId(userRoleDTO.getUserId()); 32 | authorizeDO.setUserName(userRoleDTO.getUserName()); 33 | authorizeDO.setRealName(userRoleDTO.getRealName()); 34 | authorizeDO.setPhone(userRoleDTO.getPhone()); 35 | authorizeDO.setPassword(userRoleDTO.getPassword()); 36 | 37 | UnitDTO unitDTO = new UnitDTO(); 38 | unitDTO.setUnitId(userRoleDTO.getUnitId()); 39 | unitDTO.setUnitName(userRoleDTO.getUnitName()); 40 | 41 | AddressDTO addressDTO = new AddressDTO(); 42 | addressDTO.setCity(userRoleDTO.getCity()); 43 | addressDTO.setCounty(userRoleDTO.getCounty()); 44 | addressDTO.setProvince(userRoleDTO.getProvince()); 45 | 46 | authorizeDO.setUnit(unitDTO); 47 | authorizeDO.setAddress(addressDTO); 48 | 49 | List roleDTOList = new ArrayList<>(); 50 | if (!CollectionUtils.isEmpty(userRoleDTO.getRoles())) { 51 | userRoleDTO.getRoles().parallelStream().forEach(roleInfoDTO -> { 52 | roleDTOList.add(toRoleDTO(roleInfoDTO)); 53 | }); 54 | } 55 | authorizeDO.setRoles(roleDTOList); 56 | return authorizeDO; 57 | } 58 | 59 | default UserRoleDTO toAuthorizeDTO(AuthorizeDO authorizeDO) { 60 | UserRoleDTO userRoleDTO = new UserRoleDTO(); 61 | userRoleDTO.setUserId(authorizeDO.getUserId()); 62 | userRoleDTO.setUserName(authorizeDO.getUserName()); 63 | userRoleDTO.setRealName(authorizeDO.getRealName()); 64 | userRoleDTO.setPhone(authorizeDO.getPhone()); 65 | userRoleDTO.setPassword(authorizeDO.getPassword()); 66 | userRoleDTO.setUnitId(authorizeDO.getUnit().getUnitId()); 67 | userRoleDTO.setUnitName(authorizeDO.getUnit().getUnitName()); 68 | userRoleDTO.setCity(authorizeDO.getAddress().getCity()); 69 | userRoleDTO.setCounty(authorizeDO.getAddress().getCounty()); 70 | userRoleDTO.setProvince(authorizeDO.getAddress().getProvince()); 71 | 72 | List roleInfoDTOList = new ArrayList<>(); 73 | authorizeDO.getRoles().parallelStream().forEach(roleDTO -> { 74 | roleInfoDTOList.add(toRoleInfoDTO(roleDTO)); 75 | }); 76 | userRoleDTO.setRoles(roleInfoDTOList); 77 | return userRoleDTO; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /ddd-infra/src/main/java/com/ddd/infra/repository/impl/UserRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package com.ddd.infra.repository.impl; 2 | 3 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; 4 | import com.ddd.infra.domain.AuthorizeDO; 5 | import com.ddd.infra.repository.UserRepository; 6 | import com.ddd.infra.repository.converter.UserConverter; 7 | import com.ddd.infra.repository.mapper.RoleMapper; 8 | import com.ddd.infra.repository.mapper.UserMapper; 9 | import com.ddd.infra.repository.mapper.UserRoleMapper; 10 | import com.ddd.infra.repository.mybatis.entity.RolePO; 11 | import com.ddd.infra.repository.mybatis.entity.UserPO; 12 | import com.ddd.infra.repository.mybatis.entity.UserRolePO; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.stereotype.Repository; 15 | import org.springframework.util.CollectionUtils; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | import java.util.Objects; 20 | import java.util.stream.Collectors; 21 | 22 | /** 23 | * 用户领域仓储 24 | * 25 | * @author louzai 26 | * @since 2021/11/21 27 | */ 28 | @Repository 29 | public class UserRepositoryImpl implements UserRepository { 30 | 31 | @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") 32 | @Autowired 33 | private UserMapper userMapper; 34 | 35 | @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") 36 | @Autowired 37 | private RoleMapper roleMapper; 38 | 39 | @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") 40 | @Autowired 41 | private UserRoleMapper userRoleMapper; 42 | 43 | @Autowired 44 | private UserConverter userConverter; 45 | 46 | @Override 47 | public void delete(Long userId) { 48 | userRoleMapper.delete(Wrappers.lambdaQuery() 49 | .eq(UserRolePO::getUserId, userId)); 50 | userMapper.deleteById(userId); 51 | } 52 | 53 | @Override 54 | public AuthorizeDO query(Long userId) { 55 | UserPO user = userMapper.selectById(userId); 56 | if(Objects.isNull(user)){ 57 | return null; 58 | } 59 | List userRoles = userRoleMapper.selectList(Wrappers.lambdaQuery() 60 | .eq(UserRolePO::getUserId, userId) 61 | .select(UserRolePO::getRoleId)); 62 | List roleIds = CollectionUtils.isEmpty(userRoles)? new ArrayList<>() : userRoles.stream() 63 | .map(UserRolePO::getRoleId) 64 | .collect(Collectors.toList()); 65 | List roles = roleMapper.selectBatchIds(roleIds); 66 | AuthorizeDO authorizeDO = userConverter.toAuthorizeDo(user, roles); 67 | return authorizeDO; 68 | 69 | } 70 | 71 | @Override 72 | public AuthorizeDO save(AuthorizeDO user) { 73 | UserPO userPo = userConverter.toUserPo(user); 74 | if(Objects.isNull(user.getUserId())){ 75 | userMapper.insert(userPo); 76 | user.setUserId(userPo.getId()); 77 | } else { 78 | userMapper.updateById(userPo); 79 | userRoleMapper.delete(Wrappers.lambdaQuery() 80 | .eq(UserRolePO::getUserId, user.getUserId())); 81 | } 82 | List userRolePos = userConverter.toUserRolePo(user); 83 | userRolePos.forEach(userRoleMapper::insert); 84 | return this.query(user.getUserId()); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /ddd-application/src/main/java/com/ddd/applicaiton/impl/AuthrizeApplicationServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.ddd.applicaiton.impl; 2 | 3 | import com.ddd.applicaiton.converter.UserApplicationConverter; 4 | import com.ddd.applicaiton.dto.UserRoleDTO; 5 | import com.ddd.applicaiton.service.AuthrizeApplicationService; 6 | import com.ddd.common.exception.ValidationException; 7 | import com.ddd.common.util.ValidationUtil; 8 | import com.ddd.domain.event.DomainEventPublisher; 9 | import com.ddd.domain.event.UserCreateEvent; 10 | import com.ddd.domain.event.UserDeleteEvent; 11 | import com.ddd.domain.event.UserUpdateEvent; 12 | import com.ddd.domain.service.AuthorizeDomainService; 13 | import com.ddd.infra.domain.AuthorizeDO; 14 | import com.ddd.infra.repository.UserRepository; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.stereotype.Service; 17 | import org.springframework.transaction.annotation.Transactional; 18 | import org.springframework.util.ObjectUtils; 19 | 20 | import java.util.Objects; 21 | 22 | /** 23 | * 应用服务 24 | * 25 | * @author louzai 26 | * @since 2021/11/22 27 | */ 28 | @Service 29 | public class AuthrizeApplicationServiceImpl implements AuthrizeApplicationService { 30 | 31 | @Autowired 32 | UserRepository userRepository; 33 | 34 | @Autowired 35 | AuthorizeDomainService authorizeDomainService; 36 | 37 | @Autowired 38 | DomainEventPublisher domainEventPublisher; 39 | 40 | @Autowired 41 | UserApplicationConverter userApplicationConverter; 42 | 43 | @Override 44 | @Transactional(rollbackFor = Exception.class) 45 | public void createUserAuthorize(UserRoleDTO userRoleDTO){ 46 | // DTO转为DO 47 | AuthorizeDO authorizeDO = userApplicationConverter.toAuthorizeDo(userRoleDTO); 48 | // 关联单位单位信息 49 | authorizeDomainService.associatedUnit(authorizeDO); 50 | // 存储用户 51 | AuthorizeDO saveAuthorizeDO = userRepository.save(authorizeDO); 52 | // 发布用户新建的领域事件 53 | domainEventPublisher.publishEvent(new UserCreateEvent(saveAuthorizeDO)); 54 | } 55 | 56 | @Override 57 | public UserRoleDTO queryUserAuthorize(Long userId) { 58 | // 查询用户授权领域数据 59 | AuthorizeDO authorizeDO = userRepository.query(userId); 60 | if (Objects.isNull(authorizeDO)) { 61 | throw ValidationException.of("UserId is not exist.", null); 62 | } 63 | // DO转DTO 64 | return userApplicationConverter.toAuthorizeDTO(authorizeDO); 65 | } 66 | 67 | @Override 68 | @Transactional(rollbackFor = Exception.class) 69 | public void updateUserAuthorize(UserRoleDTO userRoleDTO) { 70 | // 先校验用户是否存在【应用服务仅允许此种判断,抛出错误情况,即为参数校验,不允许实际业务逻辑处理】 71 | ValidationUtil.isTrue(Objects.nonNull(userRepository.query(userRoleDTO.getUserId())), "UserId is not exist."); 72 | // DTO转为DO 73 | AuthorizeDO authorizeDO = userApplicationConverter.toAuthorizeDo(userRoleDTO); 74 | // 设置单位信息 75 | authorizeDomainService.associatedUnit(authorizeDO); 76 | // 存储用户 77 | AuthorizeDO saveAuthorizeDO = userRepository.save(authorizeDO); 78 | // 发布用户修改的领域事件 79 | domainEventPublisher.publishEvent(new UserUpdateEvent(saveAuthorizeDO)); 80 | } 81 | 82 | @Override 83 | @Transactional(rollbackFor = Exception.class) 84 | public void deleteUserAuthorize(Long userId) { 85 | // 根据用户id删除用户聚合 86 | userRepository.delete(userId); 87 | // 发布用户删除领域事件 88 | domainEventPublisher.publishEvent(new UserDeleteEvent(userId)); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /ddd-common/ddd-common/src/main/java/com/ddd/common/util/GsonUtil.java: -------------------------------------------------------------------------------- 1 | package com.ddd.common.util; 2 | 3 | import com.google.gson.*; 4 | import com.google.gson.reflect.TypeToken; 5 | 6 | import java.time.LocalDate; 7 | import java.time.LocalDateTime; 8 | import java.time.ZoneId; 9 | import java.time.format.DateTimeFormatter; 10 | import java.util.Date; 11 | import java.util.List; 12 | import java.util.Map; 13 | import java.util.Objects; 14 | 15 | public class GsonUtil { 16 | 17 | private static Gson gson = null; 18 | 19 | static { 20 | if (Objects.isNull(gson)) { 21 | gson = new GsonBuilder() 22 | .registerTypeAdapter(LocalDateTime.class, (JsonDeserializer) (json, type, jsonDeserializationContext) -> { 23 | String datetime = json.getAsJsonPrimitive().getAsString(); 24 | return LocalDateTime.parse(datetime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); 25 | }) 26 | .registerTypeAdapter(LocalDate.class, (JsonDeserializer) (json, type, jsonDeserializationContext) -> { 27 | String datetime = json.getAsJsonPrimitive().getAsString(); 28 | return LocalDate.parse(datetime, DateTimeFormatter.ofPattern("yyyy-MM-dd")); 29 | }) 30 | .registerTypeAdapter(Date.class, (JsonDeserializer) (json, type, jsonDeserializationContext) -> { 31 | String datetime = json.getAsJsonPrimitive().getAsString(); 32 | LocalDateTime localDateTime = LocalDateTime.parse(datetime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); 33 | return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); 34 | }) 35 | .registerTypeAdapter(LocalDateTime.class, (JsonSerializer) (src, typeOfSrc, context) -> new JsonPrimitive(src.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) 36 | .registerTypeAdapter(LocalDate.class, (JsonSerializer) (src, typeOfSrc, context) -> new JsonPrimitive(src.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))) 37 | .registerTypeAdapter(Date.class, (JsonSerializer) (src, typeOfSrc, context) -> { 38 | LocalDateTime localDateTime = LocalDateTime.ofInstant(src.toInstant(), ZoneId.systemDefault()); 39 | return new JsonPrimitive(localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); 40 | }) 41 | .create(); 42 | } 43 | } 44 | 45 | public GsonUtil() { 46 | } 47 | 48 | /** 49 | * 将object对象转成json字符串 50 | * 51 | * @param object 52 | * @return 53 | */ 54 | public static String gsonToString(Object object) { 55 | String gsonString = null; 56 | if (gson != null) { 57 | gsonString = gson.toJson(object); 58 | } 59 | return gsonString; 60 | } 61 | 62 | /** 63 | * 将gsonString转成泛型bean 64 | * 65 | * @param gsonString 66 | * @param cls 67 | * @return 68 | */ 69 | public static T gsonToBean(String gsonString, Class cls) { 70 | T t = null; 71 | if (gson != null) { 72 | t = gson.fromJson(gsonString, cls); 73 | } 74 | return t; 75 | } 76 | 77 | /** 78 | * 转成list 79 | * 泛型在编译期类型被擦除导致报错 80 | * @param gsonString 81 | * @param cls 82 | * @return 83 | */ 84 | public static List gsonToList(String gsonString, Class cls) { 85 | List list = null; 86 | if (gson != null) { 87 | list = gson.fromJson(gsonString, TypeToken.getParameterized(List.class,cls).getType()); 88 | } 89 | return list; 90 | } 91 | 92 | /** 93 | * 转成list中有map的 94 | * 95 | * @param gsonString 96 | * @return 97 | */ 98 | public static List> gsonToListMaps(String gsonString) { 99 | List> list = null; 100 | if (gson != null) { 101 | list = gson.fromJson(gsonString, 102 | new TypeToken>>() { 103 | }.getType()); 104 | } 105 | return list; 106 | } 107 | 108 | 109 | /** 110 | * 转成map的 111 | * 112 | * @param gsonString 113 | * @return 114 | */ 115 | public static Map gsonToMaps(String gsonString) { 116 | Map map = null; 117 | if (gson != null) { 118 | map = gson.fromJson(gsonString, new TypeToken>() { 119 | }.getType()); 120 | } 121 | return map; 122 | } 123 | 124 | /** 125 | * 把一个bean(或者其他的字符串什么的)转成json 126 | * @param object 127 | * @return 128 | */ 129 | public static String beanToJson(Object object){ 130 | return gson.toJson(object); 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 2.3.11.RELEASE 10 | 11 | 12 | 13 | 4.0.0 14 | 15 | org.example 16 | ddd-framework 17 | pom 18 | 1.0-SNAPSHOT 19 | 20 | 21 | 22 | ddd-application 23 | ddd-domian 24 | ddd-infra 25 | ddd-interface/ddd-api 26 | ddd-interface/ddd-task 27 | ddd-common/ddd-common 28 | ddd-common/ddd-common-application 29 | ddd-common/ddd-common-infra 30 | ddd-common/ddd-common-domain 31 | 32 | 33 | 34 | 35 | UTF-8 36 | UTF-8 37 | 1.8 38 | 3.4.1 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-web 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-starter-test 54 | test 55 | 56 | 57 | 59 | 60 | com.baomidou 61 | mybatis-plus-boot-starter 62 | ${mybatis-plus.version} 63 | 64 | 65 | com.baomidou 66 | mybatis-plus-generator 67 | ${mybatis-plus.version} 68 | 69 | 70 | 71 | 72 | mysql 73 | mysql-connector-java 74 | 8.0.11 75 | 76 | 77 | 78 | 79 | org.projectlombok 80 | lombok 81 | 1.16.10 82 | 83 | 84 | 85 | 86 | 87 | dev 88 | 89 | dev 90 | 91 | 92 | 93 | prod 94 | 95 | prod 96 | 97 | 98 | true 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | src/main/resources 107 | true 108 | 109 | config/** 110 | templates/** 111 | 112 | 113 | 114 | src/main/resources/config/${env} 115 | true 116 | 117 | 118 | src/main/resources/templates 119 | templates 120 | 121 | 122 | 123 | 124 | 125 | org.apache.maven.plugins 126 | maven-compiler-plugin 127 | 3.5.1 128 | 129 | 1.8 130 | 1.8 131 | 132 | 133 | 134 | org.apache.maven.plugins 135 | maven-source-plugin 136 | 3.2.1 137 | 138 | 139 | attach-sources 140 | 141 | jar 142 | 143 | 144 | 145 | 146 | 147 | org.apache.maven.plugins 148 | maven-resources-plugin 149 | 150 | 151 | xls 152 | xlsx 153 | doc 154 | docx 155 | 156 | 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ddd-framework 2 | DDD脚手架 3 | 4 | ## 为何编写此脚手架 5 | 6 | - 解决编写过程式和事务代码,造成后期维护逻辑混乱、维护成本高的痛点; 7 | - 抛弃MVC框架,拥抱更适合复杂业务的开发框架; 8 | - 将DDD落地,通过脚手架的改变,推动DDD思想的讨论学习发芽 9 | 10 | ## 此脚手架坚持的原则 11 | 12 | - 以领域驱动(DDD)设计为基础,分层清楚,做默认规范 13 | 14 | ## 为何要强制分层 15 | 16 | - 高内聚低耦合,提高各个层次间的复用性,减少模块间接口的复杂程度 17 | - 各个层次中的变化不影响其上层和下层 18 | - 层次分明便于mock和查找问题,各个层次间异常处理机制可控 19 | 20 | ## 项目结构 21 | ``` 22 | ./ddd-application // 应用层 23 | ├── pom.xml 24 | └── src 25 | └── main 26 | └── java 27 | └── com 28 | └── ddd 29 | └── applicaiton 30 | ├── converter 31 | │   └── UserApplicationConverter.java // 类型转换器 32 | └── impl 33 | └── AuthrizeApplicationServiceImpl.java // 业务逻辑 34 | ./ddd-common 35 | ├── ddd-common // 通用类库 36 | │ ├── pom.xml 37 | │   └── src 38 | │   └── main 39 | │   └── java 40 | │   └── com 41 | │   └── ddd 42 | │   └── common 43 | │   ├── exception // 异常 44 | │   │   ├── ServiceException.java 45 | │   │   └── ValidationException.java 46 | │   ├── result // 返回结果集 47 | │ │ ├── BaseResult.javar 48 | │ │ ├── Page.java 49 | │   │   ├── PageResult.java 50 | │   │   └── Result.java 51 | │   └── util // 通用工具 52 | │   ├── GsonUtil.java 53 | │   └── ValidationUtil.java 54 | ├── ddd-common-application // 业务层通用模块 55 | │ ├── pom.xml 56 | │   └── src 57 | │   └── main 58 | │   └── java 59 | │   └── com 60 | │   └── ddd 61 | │   └── applicaiton 62 | │   ├── dto // DTO 63 | │   │   ├── RoleInfoDTO.java 64 | │   │   └── UserRoleDTO.java 65 | │ └── servic // 业务接口 66 | │ └── AuthrizeApplicationService.java 67 | ├── ddd-common-domain 68 | │   ├── pom.xml 69 | │   └── src 70 | │   └── main 71 | │   └── java 72 | │   └── com 73 | │   └── ddd 74 | │   └── domain 75 | │ ├── event // 领域事件 76 | │ │ ├── BaseDomainEvent.java 77 | │   │   └── DomainEventPublisher.java 78 | │ └── service // 领域接口 79 | │ └── AuthorizeDomainService.java 80 | └── ddd-common-infra 81 | ├── pom.xml 82 | └── src 83 | └── main 84 | └── java 85 | └── com 86 | └── ddd 87 | └── infra 88 | ├── domain // DO 89 | │ └── AuthorizeDO.java 90 | ├── dto 91 | │   ├── AddressDTO.java 92 | │   ├── RoleDTO.java 93 | │   ├── UnitDTO.java 94 | │   └── UserRoleDTO.java 95 | └── repository 96 | ├── UserRepository.java // 领域仓库 97 | └── mybatis 98 | └── entity // PO 99 | ├── BaseUuidEntity.java 100 | ├── RolePO.java 101 | ├── UserPO.java 102 | └── UserRolePO.java 103 | ./ddd-domian // 领域层 104 | ├── pom.xml 105 | └── src 106 | └── main 107 | └── java 108 | └── com 109 | └── ddd 110 | └── domain 111 | ├── event // 领域事件 112 | │ ├── DomainEventPublisherImpl.java 113 | │   ├── UserCreateEvent.java 114 | │   ├── UserDeleteEvent.java 115 | │   └── UserUpdateEvent.java 116 | └── impl // 领域逻辑 117 | └── AuthorizeDomainServiceImpl.java 118 | ./ddd-infra // 基础服务层 119 | ├── pom.xml 120 | └── src 121 | └── main 122 | └── java 123 | └── com 124 | └── ddd 125 | └── infra 126 | ├── config 127 | │ └── InfraCoreConfig.java // 扫描Mapper文件 128 | └── repository 129 | ├── converter 130 | │ └── UserConverter.java // 类型转换器 131 | ├── impl 132 | │   └── UserRepositoryImpl.java 133 | └── mapper 134 | ├── RoleMapper.java 135 | ├── UserMapper.java 136 | └── UserRoleMapper.java 137 | ./ddd-interface 138 | ├── ddd-api // 用户接口层 139 | │ ├── pom.xml 140 | │   └── src 141 | │   └── main 142 | │   ├── java 143 | │   │   └── com 144 | │   │   └── ddd 145 | │   │   └── api 146 | │ │ ├── DDDFrameworkApiApplication.java // 启动入口 147 | │ │ ├── converter 148 | │   │   │   └── AuthorizeConverter.java // 类型转换器 149 | │   │   ├── model 150 | │ │ │ ├── req // 入参 req 151 | │ │ │ │ ├── AuthorizeCreateReq.java 152 | │   │   │   │   └── AuthorizeUpdateReq.java 153 | │ │ │ └── vo // 输出 VO 154 | │ │ │ └── UserAuthorizeVO.java 155 | │   │   └── web // API 156 | │   │   └── AuthorizeController.java 157 | │ └── resources // 系统配置 158 | │ ├── application.yml 159 | │ └── resources // Sql文件 160 | │   └── init.sql 161 | └── ddd-task 162 | └── pom.xml 163 | ./pom.xml 164 | ``` 165 | 166 | ## 功能测试 167 | ### 1. 新建库表 168 | - 通过文件"ddd-interface/ddd-api/src/main/resources/init.sql"新建库表。 169 | 170 | ### 2. 修改SQL配置 171 | - 修改"ddd-interface/ddd-api/src/main/resources/application.yml"的数据库配置。 172 | 173 | ### 3. 启动服务 174 | - 直接启动服务即可。 175 | 176 | ### 4. 测试用例 177 | 178 | - 请求URL:http://127.0.0.1:8087/api/user/save 179 | - Post body:{"userName":"louzai","realName":"楼","phone":13123676844,"password":"***","unitId":2,"province":"湖北省","city":"鄂州市","county":"葛店开发区","roles":[{"roleId":2}]} 180 | - 更多测试用例详见"AuthorizeController.java" 181 | 182 | ## 维护者 183 | 184 | 楼仔(微信公众号"楼仔进阶之路") 185 | -------------------------------------------------------------------------------- /ddd-framework.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /ddd-interface/ddd-task/ddd-task.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-infra/ddd-common-infra.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-application/ddd-common-application.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /ddd-common/ddd-common-domain/ddd-common-domain.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /ddd-common/ddd-common/ddd-common.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /ddd-infra/ddd-infra.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /ddd-domian/ddd-domian.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /ddd-application/ddd-application.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /ddd-interface/ddd-api/ddd-api.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | --------------------------------------------------------------------------------