├── common-file
├── common-file-core
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── spring.factories
│ │ │ └── java
│ │ │ └── org
│ │ │ └── originit
│ │ │ └── common
│ │ │ └── file
│ │ │ ├── entity
│ │ │ ├── ContextInfo.java
│ │ │ ├── UploadConfig.java
│ │ │ ├── UploadResult.java
│ │ │ └── FileInfo.java
│ │ │ ├── FileUploaderDeprecated.java
│ │ │ ├── ChunkFileManager.java
│ │ │ ├── FileFilter.java
│ │ │ ├── AbstractSimpleFileUploadStrategy.java
│ │ │ ├── FileUploadStrategy.java
│ │ │ ├── property
│ │ │ └── FileProperties.java
│ │ │ ├── impl
│ │ │ ├── SimpleFileUploader.java
│ │ │ └── DefaultFileFilter.java
│ │ │ ├── FileManager.java
│ │ │ ├── config
│ │ │ └── FileAutoConfiguration.java
│ │ │ └── AbstractFileUploader.java
│ ├── config.puml
│ ├── file-design.puml
│ └── pom.xml
├── common-disk-file-starter
│ ├── src
│ │ ├── test
│ │ │ ├── resources
│ │ │ │ └── application.yml
│ │ │ └── java
│ │ │ │ └── org
│ │ │ │ └── originit
│ │ │ │ └── file
│ │ │ │ └── disk
│ │ │ │ ├── DiskFileApplication.java
│ │ │ │ └── CommonDiskFileStarterApplicationTests.java
│ │ └── main
│ │ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── spring.factories
│ │ │ └── java
│ │ │ └── org
│ │ │ └── originit
│ │ │ └── file
│ │ │ └── disk
│ │ │ ├── property
│ │ │ └── UploadConfig.java
│ │ │ ├── config
│ │ │ └── DiskFileAutoConfiguration.java
│ │ │ └── uploader
│ │ │ └── DiskFileManager.java
│ └── pom.xml
└── pom.xml
├── common
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── originit
│ │ │ │ └── common
│ │ │ │ ├── validator
│ │ │ │ ├── group
│ │ │ │ │ ├── CreateGroup.java
│ │ │ │ │ ├── SearchGroup.java
│ │ │ │ │ └── UpdateGroup.java
│ │ │ │ ├── info
│ │ │ │ │ └── ParameterInvalidItem.java
│ │ │ │ ├── EnumValueValidator.java
│ │ │ │ └── annotation
│ │ │ │ │ └── EnumValue.java
│ │ │ │ ├── exception
│ │ │ │ └── NoTokenFoundException.java
│ │ │ │ ├── constant
│ │ │ │ └── CommonConstant.java
│ │ │ │ ├── param
│ │ │ │ └── anno
│ │ │ │ │ ├── BodyField.java
│ │ │ │ │ └── BodyFieldArgResolver.java
│ │ │ │ ├── utils
│ │ │ │ ├── BeanField.java
│ │ │ │ ├── NumberUtil.java
│ │ │ │ ├── BeanStrategy.java
│ │ │ │ ├── ExceptionUtil.java
│ │ │ │ ├── SpringUtil.java
│ │ │ │ ├── IpUtil.java
│ │ │ │ ├── RequestContextHolderUtil.java
│ │ │ │ ├── CommonUtil.java
│ │ │ │ ├── CookieUtil.java
│ │ │ │ ├── SecurityUtil.java
│ │ │ │ ├── PropertiesUtil.java
│ │ │ │ ├── HttpUtil.java
│ │ │ │ ├── DateUtil.java
│ │ │ │ ├── ResourceUtil.java
│ │ │ │ ├── StringUtil.java
│ │ │ │ └── EncryptUtil.java
│ │ │ │ ├── page
│ │ │ │ ├── PageParam.java
│ │ │ │ └── PageVO.java
│ │ │ │ └── config
│ │ │ │ └── CommonAutoConfiguration.java
│ │ └── resources
│ │ │ └── META-INF
│ │ │ └── spring.factories
│ └── test
│ │ └── java
│ │ └── com
│ │ └── originit
│ │ └── common
│ │ └── JSONTest.java
├── .gitignore
└── pom.xml
├── demo
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── application.yml
│ │ └── java
│ │ │ └── org
│ │ │ └── originit
│ │ │ └── demo
│ │ │ ├── exception
│ │ │ └── UserNotFoundException.java
│ │ │ └── DemoApp.java
│ └── test
│ │ └── java
│ │ └── org
│ │ └── originit
│ │ └── demo
│ │ └── DemoAppTest.java
└── pom.xml
├── common-mybatis-crud
├── src
│ ├── test
│ │ ├── resources
│ │ │ ├── sql
│ │ │ │ ├── test-dataload.sql
│ │ │ │ ├── blog-derby.properties
│ │ │ │ └── test-schema.sql
│ │ │ ├── jdbc.properties
│ │ │ ├── spring-mybatis.xml
│ │ │ └── MapperConfig.xml
│ │ ├── kotlin
│ │ │ └── org
│ │ │ │ └── originit
│ │ │ │ └── crud
│ │ │ │ ├── mapper
│ │ │ │ ├── UserMapper.kt
│ │ │ │ └── UserMapperTest.kt
│ │ │ │ └── BaseDataTest.java
│ │ └── java
│ │ │ └── org
│ │ │ └── originit
│ │ │ └── crud
│ │ │ └── pojo
│ │ │ └── User.java
│ └── main
│ │ └── kotlin
│ │ └── org
│ │ └── originit
│ │ └── crud
│ │ ├── enums
│ │ └── KeyGeneratorPolicy.kt
│ │ ├── anno
│ │ ├── LogicDelete.kt
│ │ ├── Id.kt
│ │ ├── TableName.kt
│ │ ├── Column.kt
│ │ └── KeyGenerator.kt
│ │ ├── util
│ │ ├── StrUtil.kt
│ │ └── SQLUtils.kt
│ │ ├── key
│ │ └── IdGenerator.kt
│ │ ├── provider
│ │ ├── impl
│ │ │ ├── SelectByIdSQLProvider.kt
│ │ │ ├── DeleteSQLProvider.kt
│ │ │ ├── UpdateSQLProvider.kt
│ │ │ ├── SelectListSQLProvider.kt
│ │ │ └── InsertSQLProvider.kt
│ │ └── BaseSQLProvider.kt
│ │ ├── mapper
│ │ └── CrudMapper.kt
│ │ ├── meta
│ │ └── MetaCache.kt
│ │ └── factory
│ │ └── MapperProxyFactoryBean.kt
└── .gitignore
├── common-web-starter
├── src
│ └── main
│ │ ├── resources
│ │ └── META-INF
│ │ │ └── spring.factories
│ │ └── java
│ │ └── org
│ │ └── originit
│ │ └── web
│ │ ├── exception
│ │ └── DefaultResultGenerator.java
│ │ └── config
│ │ └── WebConfig.java
├── .gitignore
└── pom.xml
├── common-logger-starter
├── src
│ └── main
│ │ ├── resources
│ │ └── META-INF
│ │ │ └── spring.factories
│ │ └── java
│ │ └── com
│ │ └── originit
│ │ └── logger
│ │ ├── enums
│ │ └── HeaderConstants.java
│ │ ├── property
│ │ └── LogProperty.java
│ │ ├── annotation
│ │ ├── NoLog.java
│ │ └── Log.java
│ │ └── config
│ │ └── LoggerAutoConfiguration.java
├── .gitignore
└── pom.xml
├── .idea
├── vcs.xml
├── .gitignore
├── inspectionProfiles
│ └── Project_Default.xml
└── jarRepositories.xml
├── common-response-starter
├── src
│ └── main
│ │ ├── resources
│ │ └── META-INF
│ │ │ └── spring.factories
│ │ └── java
│ │ └── com
│ │ └── originit
│ │ └── response
│ │ ├── success
│ │ ├── SuccessCodeAcquirer.java
│ │ └── DefaultSuccessCodeAcquirer.java
│ │ ├── constant
│ │ └── Const.java
│ │ ├── result
│ │ ├── SimpleData.java
│ │ ├── Result.java
│ │ └── PlatformResult.java
│ │ ├── anotation
│ │ ├── OriginResponse.java
│ │ └── ResponseResult.java
│ │ ├── property
│ │ └── ResponseProperty.java
│ │ ├── config
│ │ └── ResponseAutoConfiguration.java
│ │ ├── handler
│ │ └── ResponseResultHandler.java
│ │ └── interceptor
│ │ └── ResponseResultInterceptor.java
├── .gitignore
└── pom.xml
├── common-user-service
├── src
│ └── main
│ │ └── java
│ │ └── org
│ │ └── originit
│ │ └── common
│ │ └── userservice
│ │ ├── callback
│ │ ├── RegisterUserCallback.java
│ │ └── LoginUserCallback.java
│ │ ├── entity
│ │ └── ILoginUser.java
│ │ └── web
│ │ └── UserController.java
├── .gitignore
└── pom.xml
├── common-exception-starter
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── spring.factories
│ │ └── java
│ │ │ └── org
│ │ │ └── originit
│ │ │ └── exception
│ │ │ ├── result
│ │ │ └── ExceptionResultGenerator.java
│ │ │ ├── log
│ │ │ ├── ExceptionLogger.java
│ │ │ └── DefaultExceptionLogger.java
│ │ │ ├── config
│ │ │ └── ExceptionAutoConfiguration.java
│ │ │ ├── BusinessException.java
│ │ │ └── enums
│ │ │ └── InnerResultCode.java
│ └── test
│ │ └── java
│ │ └── org
│ │ └── originit
│ │ └── AppTest.java
├── .gitignore
└── pom.xml
├── entity2table
├── entity2table-core
│ ├── src
│ │ ├── main
│ │ │ ├── java
│ │ │ │ └── org
│ │ │ │ │ └── originit
│ │ │ │ │ └── et
│ │ │ │ │ ├── entity
│ │ │ │ │ ├── Id.java
│ │ │ │ │ ├── Table.java
│ │ │ │ │ └── Column.java
│ │ │ │ │ ├── converter
│ │ │ │ │ ├── DefaultTypeConverter.java
│ │ │ │ │ ├── impl
│ │ │ │ │ │ ├── DefaultLongTypeConverter.java
│ │ │ │ │ │ ├── DefaultIntegerTypeConverter.java
│ │ │ │ │ │ ├── DefaultLocalDateTypeConverter.java
│ │ │ │ │ │ ├── DefaultLocalDateTimeTypeConverter.java
│ │ │ │ │ │ └── DefaultStringTypeConverter.java
│ │ │ │ │ └── TypeConverter.java
│ │ │ │ │ ├── executor
│ │ │ │ │ ├── ConvertExecutor.java
│ │ │ │ │ └── impl
│ │ │ │ │ │ └── SimpleConvertExecutor.java
│ │ │ │ │ ├── jdbc
│ │ │ │ │ └── JDBCType.java
│ │ │ │ │ ├── anno
│ │ │ │ │ └── Comment.java
│ │ │ │ │ ├── config
│ │ │ │ │ └── ConvertConfig.java
│ │ │ │ │ ├── info
│ │ │ │ │ ├── AbstractModelTableInfoAcquirer.java
│ │ │ │ │ ├── impl
│ │ │ │ │ │ ├── JPAModelTableInfoAcquirer.java
│ │ │ │ │ │ └── JPAColumnInfoAcquirer.java
│ │ │ │ │ ├── ModelTableInfoAcquirer.java
│ │ │ │ │ ├── ColumnInfoAcquirer.java
│ │ │ │ │ └── AbstractColumnInfoAcquirer.java
│ │ │ │ │ └── util
│ │ │ │ │ └── TemplateUtil.java
│ │ │ └── resources
│ │ │ │ ├── META-INF
│ │ │ │ └── services
│ │ │ │ │ └── org.originit.et.converter.TypeConverter
│ │ │ │ └── template
│ │ │ │ └── table
│ │ │ │ └── create.ftl
│ │ └── test
│ │ │ └── java
│ │ │ └── org
│ │ │ └── originit
│ │ │ └── et
│ │ │ ├── executor
│ │ │ └── AbstractConvertExecutorTest.java
│ │ │ └── entity
│ │ │ └── AppUser.java
│ ├── .gitignore
│ └── pom.xml
├── .gitignore
├── mp2table_acquirer
│ ├── .gitignore
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── org
│ │ │ └── originit
│ │ │ └── et
│ │ │ └── mp
│ │ │ ├── MPModelTableInfoAcquirer.java
│ │ │ └── MPColumnInfoAcquirer.java
│ └── pom.xml
└── pom.xml
├── common-mybatis-crud.iml
└── .gitignore
/common-file/common-file-core/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/common-file/common-disk-file-starter/src/test/resources/application.yml:
--------------------------------------------------------------------------------
1 | common:
2 | file:
3 | disk:
4 | root-path: E:\\
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/validator/group/CreateGroup.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.validator.group;
2 |
3 | public interface CreateGroup {
4 | }
5 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/validator/group/SearchGroup.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.validator.group;
2 |
3 | public interface SearchGroup {
4 | }
5 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/validator/group/UpdateGroup.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.validator.group;
2 |
3 | public interface UpdateGroup {
4 | }
5 |
--------------------------------------------------------------------------------
/demo/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8081
3 |
4 | common:
5 | response:
6 | success-code: 300
7 | logger:
8 | log-get: false
9 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/test/resources/sql/test-dataload.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO t_user (id, name, age) VALUES (1,'xxc', 24);
2 | INSERT INTO t_user (id, name, age) VALUES (2,'zss', 25);
--------------------------------------------------------------------------------
/common-web-starter/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | # Auto Configure
2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
3 | org.originit.web.config.WebConfig
--------------------------------------------------------------------------------
/common-mybatis-crud/src/test/resources/jdbc.properties:
--------------------------------------------------------------------------------
1 | jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
2 | jdbc.url=jdbc:derby:memory:admin;create=true
3 | jdbc.username=
4 | jdbc.password=
--------------------------------------------------------------------------------
/common/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | # Auto Configure
2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
3 | com.originit.common.config.CommonAutoConfiguration
--------------------------------------------------------------------------------
/common-logger-starter/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | # Auto Configure
2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
3 | com.originit.logger.config.LoggerAutoConfiguration
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/test/kotlin/org/originit/crud/mapper/UserMapper.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.mapper
2 |
3 | import org.originit.crud.pojo.User
4 |
5 | interface UserMapper:CrudMapper {
6 | }
--------------------------------------------------------------------------------
/common-response-starter/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | # Auto Configure
2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
3 | com.originit.response.config.ResponseAutoConfiguration
--------------------------------------------------------------------------------
/common-user-service/src/main/java/org/originit/common/userservice/callback/RegisterUserCallback.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.userservice.callback;
2 |
3 | public interface RegisterUserCallback {
4 | }
5 |
--------------------------------------------------------------------------------
/common-exception-starter/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | # Auto Configure
2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
3 | org.originit.exception.config.ExceptionAutoConfiguration
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/enums/KeyGeneratorPolicy.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.enums
2 |
3 | enum class KeyGeneratorPolicy {
4 |
5 | AUTO(),
6 | UUID(),
7 | NONE();
8 |
9 | }
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Datasource local storage ignored files
5 | /dataSources/
6 | /dataSources.local.xml
7 | # Editor-based HTTP Client requests
8 | /httpRequests/
9 |
--------------------------------------------------------------------------------
/common-file/common-disk-file-starter/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | # Auto Configure
2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
3 | org.originit.file.disk.config.DiskFileAutoConfiguration
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/anno/LogicDelete.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.anno
2 |
3 | @Retention(AnnotationRetention.RUNTIME)
4 | @Target(AnnotationTarget.FIELD)
5 | annotation class LogicDelete
6 |
--------------------------------------------------------------------------------
/common-response-starter/src/main/java/com/originit/response/success/SuccessCodeAcquirer.java:
--------------------------------------------------------------------------------
1 | package com.originit.response.success;
2 |
3 | public interface SuccessCodeAcquirer {
4 |
5 | Integer getSuccessCode();
6 | }
7 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/anno/Id.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.anno
2 |
3 | @Retention(AnnotationRetention.RUNTIME)
4 | @Target(AnnotationTarget.FIELD)
5 | annotation class Id(val value: String = "")
6 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/exception/NoTokenFoundException.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.exception;
2 |
3 | /**
4 | * 无法在请求中获取token异常
5 | */
6 | public class NoTokenFoundException extends RuntimeException{
7 | }
8 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/entity/Id.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.entity;
2 |
3 | import lombok.Data;
4 |
5 | @Data
6 | public class Id extends Column{
7 |
8 | private Boolean auto;
9 | }
10 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/constant/CommonConstant.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.constant;
2 |
3 | public interface CommonConstant {
4 |
5 | int CODE_SUCCESS = 200;
6 |
7 | String MSG_SUCCESS = "success";
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/converter/DefaultTypeConverter.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.converter;
2 |
3 | /**
4 | * 默认的类型转换器
5 | * @author xxc
6 | */
7 | public interface DefaultTypeConverter extends TypeConverter{
8 | }
9 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/anno/TableName.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.anno
2 |
3 | @Retention(AnnotationRetention.RUNTIME)
4 | @Target(AnnotationTarget.TYPE, AnnotationTarget.CLASS)
5 | annotation class TableName(val value: String)
6 |
--------------------------------------------------------------------------------
/common-logger-starter/src/main/java/com/originit/logger/enums/HeaderConstants.java:
--------------------------------------------------------------------------------
1 | package com.originit.logger.enums;
2 |
3 | public interface HeaderConstants {
4 | String CALL_SOURCE = "call-source";
5 | String API_VERSION = "api-version";
6 | String APP_VERSION = "app-version";
7 | }
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/entity/ContextInfo.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file.entity;
2 |
3 | import lombok.Data;
4 |
5 | @Data
6 | public class ContextInfo {
7 |
8 | private String suffix;
9 |
10 | private Boolean isImg;
11 | }
12 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/util/StrUtil.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.util
2 |
3 | import java.util.*
4 |
5 | fun String.camelCaseToUnderscores(): String {
6 | val regex = Regex("([a-z])([A-Z])")
7 | return replace(regex, "$1_$2").lowercase(Locale.getDefault())
8 | }
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/executor/ConvertExecutor.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.executor;
2 |
3 | /**
4 | * @author xxc
5 | */
6 | public interface ConvertExecutor {
7 |
8 | /**
9 | * 执行模型到表的转换
10 | */
11 | void execute();
12 | }
13 |
--------------------------------------------------------------------------------
/common-exception-starter/src/main/java/org/originit/exception/result/ExceptionResultGenerator.java:
--------------------------------------------------------------------------------
1 | package org.originit.exception.result;
2 |
3 | /**
4 | * 当出现异常时如何返回
5 | */
6 | public interface ExceptionResultGenerator {
7 |
8 | Object generate(String msg,Integer code);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/anno/Column.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.anno
2 |
3 | @Retention(AnnotationRetention.RUNTIME)
4 | @Target(AnnotationTarget.FIELD)
5 | /**
6 | * value 数据库列名
7 | */
8 | annotation class Column(val value: String, val updateIfNull: Boolean = false)
9 |
--------------------------------------------------------------------------------
/common-user-service/src/main/java/org/originit/common/userservice/entity/ILoginUser.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.userservice.entity;
2 |
3 | /**
4 | * 登录的用户信息
5 | */
6 | public interface ILoginUser {
7 |
8 | String getLoginUserName();
9 |
10 | String getLoginPassword();
11 | }
12 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/jdbc/JDBCType.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.jdbc;
2 |
3 | /**
4 | * 数据库类型
5 | * @author xxc
6 | */
7 | public enum JDBCType {
8 | CHAR,VARCHAR,TIMESTAMP, DATE, DATETIME,BIGINT,INT,BIT,DECIMAL,DOUBLE,TINYINT,BOOLEAN,YEAR;
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/common-response-starter/src/main/java/com/originit/response/constant/Const.java:
--------------------------------------------------------------------------------
1 | package com.originit.response.constant;
2 | public interface Const {
3 | String RESPONSE_RESULT = "response-result";
4 |
5 | /**
6 | * 请求头中如果api-style不为空时不封装结果
7 | */
8 | String HEADER_API_STYLE = "api-style";
9 | }
10 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/anno/KeyGenerator.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.anno
2 |
3 | import org.originit.crud.enums.KeyGeneratorPolicy
4 |
5 | @Retention(AnnotationRetention.RUNTIME)
6 | @Target(AnnotationTarget.FIELD)
7 | annotation class KeyGenerator (val value:KeyGeneratorPolicy = KeyGeneratorPolicy.AUTO)
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/key/IdGenerator.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.key
2 |
3 | import java.util.UUID
4 |
5 | interface IdGenerator {
6 |
7 | fun next():String
8 | }
9 |
10 | object UUIDGenerator:IdGenerator {
11 | override fun next(): String {
12 | return UUID.randomUUID().toString().replace("-", "")
13 | }
14 | }
--------------------------------------------------------------------------------
/demo/src/main/java/org/originit/demo/exception/UserNotFoundException.java:
--------------------------------------------------------------------------------
1 | package org.originit.demo.exception;
2 |
3 | import org.originit.exception.BusinessException;
4 |
5 | public class UserNotFoundException extends BusinessException {
6 |
7 | public UserNotFoundException(String message, Integer code) {
8 | super(message, code);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/param/anno/BodyField.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.param.anno;
2 |
3 | import java.lang.annotation.*;
4 |
5 | /**
6 | * @author xxc
7 | */
8 | @Target({ElementType.PARAMETER})
9 | @Retention(RetentionPolicy.RUNTIME)
10 | @Documented
11 | public @interface BodyField {
12 |
13 | public String value() default "";
14 | }
15 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/anno/Comment.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.anno;
2 |
3 | import java.lang.annotation.*;
4 |
5 | /**
6 | * 注释
7 | * @author xxc
8 | */
9 | @Target({ElementType.TYPE, ElementType.FIELD})
10 | @Retention(RetentionPolicy.RUNTIME)
11 | @Documented
12 | public @interface Comment {
13 | public String value();
14 | }
15 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/resources/META-INF/services/org.originit.et.converter.TypeConverter:
--------------------------------------------------------------------------------
1 | org.originit.et.converter.impl.DefaultIntegerTypeConverter
2 | org.originit.et.converter.impl.DefaultLocalDateTimeTypeConverter
3 | org.originit.et.converter.impl.DefaultLocalDateTypeConverter
4 | org.originit.et.converter.impl.DefaultStringTypeConverter
5 | org.originit.et.converter.impl.DefaultLongTypeConverter
--------------------------------------------------------------------------------
/common-file/common-disk-file-starter/src/main/java/org/originit/file/disk/property/UploadConfig.java:
--------------------------------------------------------------------------------
1 | package org.originit.file.disk.property;
2 |
3 |
4 | import lombok.Data;
5 | import org.springframework.boot.context.properties.ConfigurationProperties;
6 |
7 | @ConfigurationProperties(prefix = "common.file.disk")
8 | @Data
9 | public class UploadConfig {
10 |
11 | private String rootPath;
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/common-user-service/src/main/java/org/originit/common/userservice/callback/LoginUserCallback.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.userservice.callback;
2 |
3 | import org.originit.common.userservice.entity.ILoginUser;
4 |
5 | import javax.servlet.http.HttpServletRequest;
6 |
7 | /**
8 | * 获取登录用户的回调
9 | */
10 | public interface LoginUserCallback {
11 |
12 | ILoginUser getLoginUser(HttpServletRequest request);
13 | }
14 |
--------------------------------------------------------------------------------
/common-file/common-file-core/config.puml:
--------------------------------------------------------------------------------
1 | @startyaml
2 | doe: "a deer, a female deer"
3 | ray: "a drop of golden sun"
4 | pi: 3.14159
5 | xmas: true
6 | french-hens: 3
7 | calling-birds:
8 | - huey
9 | - dewey
10 | - louie
11 | - fred
12 | xmas-fifth-day:
13 | calling-birds: four
14 | french-hens: 3
15 | golden-rings: 5
16 | partridges:
17 | count: 1
18 | location: "a pear tree"
19 | turtle-doves: two
20 | @endyaml
--------------------------------------------------------------------------------
/common-response-starter/src/main/java/com/originit/response/result/SimpleData.java:
--------------------------------------------------------------------------------
1 | package com.originit.response.result;
2 |
3 | import lombok.Data;
4 |
5 | @Data
6 | public class SimpleData {
7 |
8 | private T data;
9 |
10 | SimpleData(T data) {
11 | this.data = data;
12 | }
13 |
14 | public static SimpleData of(D data) {
15 | return new SimpleData<>(data);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/common-exception-starter/src/test/java/org/originit/AppTest.java:
--------------------------------------------------------------------------------
1 | package org.originit;
2 |
3 | import static org.junit.Assert.assertTrue;
4 |
5 | import org.junit.Test;
6 |
7 | /**
8 | * Unit test for simple App.
9 | */
10 | public class AppTest
11 | {
12 | /**
13 | * Rigorous Test :-)
14 | */
15 | @Test
16 | public void shouldAnswerWithTrue()
17 | {
18 | assertTrue( true );
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/common/src/test/java/com/originit/common/JSONTest.java:
--------------------------------------------------------------------------------
1 | package com.originit.common;
2 |
3 | import cn.hutool.json.JSON;
4 | import cn.hutool.json.JSONUtil;
5 | import org.junit.Test;
6 |
7 | public class JSONTest {
8 | @Test
9 | public void test1() {
10 | final JSON parse = JSONUtil.parse("{\"name\":\"xxc\",\"age\":24,\"wifi\":{\"name\":\"zss\",\"age\":25}}");
11 | System.out.println(parse);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/common-response-starter/src/main/java/com/originit/response/result/Result.java:
--------------------------------------------------------------------------------
1 | package com.originit.response.result;
2 |
3 | import java.io.Serializable;
4 | import java.util.Map;
5 |
6 | /**
7 | * 全局响应对象
8 | * @author xxc、
9 | */
10 |
11 | public abstract class Result implements Serializable{
12 |
13 | public Result() {}
14 | /**
15 | * 成功情况下的Result
16 | * @param data 数据
17 | */
18 | public Result(Object data){ }
19 | }
20 |
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/entity/UploadConfig.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 |
9 | @Data
10 | @Builder
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | public class UploadConfig {
14 |
15 | private String module;
16 |
17 | private String tag;
18 | }
19 |
--------------------------------------------------------------------------------
/common-logger-starter/src/main/java/com/originit/logger/property/LogProperty.java:
--------------------------------------------------------------------------------
1 | package com.originit.logger.property;
2 |
3 | import lombok.Data;
4 | import org.springframework.boot.context.properties.ConfigurationProperties;
5 |
6 | @ConfigurationProperties("common.logger")
7 | @Data
8 | public class LogProperty {
9 |
10 | private boolean logGet = true;
11 |
12 | private boolean enable = true;
13 |
14 | private boolean debug = false;
15 | }
16 |
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/entity/UploadResult.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file.entity;
2 |
3 | import lombok.Data;
4 |
5 | @Data
6 | public class UploadResult {
7 |
8 | private String path;
9 |
10 | public static UploadResult success(String path){
11 | final UploadResult uploadResult = new UploadResult();
12 | uploadResult.setPath(path);
13 | return uploadResult;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/common-file/common-disk-file-starter/src/test/java/org/originit/file/disk/DiskFileApplication.java:
--------------------------------------------------------------------------------
1 | package org.originit.file.disk;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class DiskFileApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(DiskFileApplication.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/FileUploaderDeprecated.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file;
2 |
3 | import org.originit.common.file.entity.FileInfo;
4 | import org.originit.common.file.entity.UploadConfig;
5 | import org.originit.common.file.entity.UploadResult;
6 |
7 | /**
8 | * 文件上传器
9 | */
10 | @Deprecated
11 | public interface FileUploaderDeprecated {
12 |
13 | UploadResult upload(FileInfo file, UploadConfig config);
14 |
15 | }
--------------------------------------------------------------------------------
/common-response-starter/src/main/java/com/originit/response/anotation/OriginResponse.java:
--------------------------------------------------------------------------------
1 | package com.originit.response.anotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * 标记为不被拦截
10 | */
11 | @Target({ElementType.TYPE,ElementType.METHOD})
12 | @Retention(RetentionPolicy.RUNTIME)
13 | public @interface OriginResponse {
14 | }
--------------------------------------------------------------------------------
/common-web-starter/src/main/java/org/originit/web/exception/DefaultResultGenerator.java:
--------------------------------------------------------------------------------
1 | package org.originit.web.exception;
2 |
3 |
4 | import com.originit.response.result.PlatformResult;
5 | import org.originit.exception.result.ExceptionResultGenerator;
6 | public class DefaultResultGenerator implements ExceptionResultGenerator {
7 |
8 | @Override
9 | public Object generate(String msg, Integer code) {
10 | return PlatformResult.fail(code, msg);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/common-response-starter/src/main/java/com/originit/response/property/ResponseProperty.java:
--------------------------------------------------------------------------------
1 | package com.originit.response.property;
2 |
3 | import lombok.Data;
4 | import org.springframework.boot.context.properties.ConfigurationProperties;
5 |
6 | /**
7 | * @author xxc
8 | */
9 | @ConfigurationProperties(prefix = "common.response")
10 | @Data
11 | public class ResponseProperty {
12 |
13 | // 是否启用
14 | private Boolean enable = true;
15 |
16 | private Integer successCode = 1;
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/ChunkFileManager.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file;
2 |
3 | import org.springframework.web.multipart.MultipartFile;
4 |
5 | public interface ChunkFileManager {
6 |
7 | boolean checkChunkFile(String path, String chunk, String chunkSize);
8 |
9 | void uploadChunkFile(String path, String chunk, String chunkSize, MultipartFile file);
10 |
11 | void mergeChunkFile(String path, String chunk, String chunkSize, String fileName);
12 | }
13 |
--------------------------------------------------------------------------------
/common-logger-starter/src/main/java/com/originit/logger/annotation/NoLog.java:
--------------------------------------------------------------------------------
1 | package com.originit.logger.annotation;
2 |
3 | /**
4 | * 不打印日志
5 | */
6 |
7 | import java.lang.annotation.ElementType;
8 | import java.lang.annotation.Retention;
9 | import java.lang.annotation.RetentionPolicy;
10 | import java.lang.annotation.Target;
11 |
12 | /**
13 | * 标注所标注的类或方法不打印日志
14 | * @author xxc、
15 | */
16 | @Target({ElementType.TYPE,ElementType.METHOD})
17 | @Retention(RetentionPolicy.RUNTIME)
18 | public @interface NoLog {
19 | }
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/converter/impl/DefaultLongTypeConverter.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.converter.impl;
2 |
3 | import org.originit.et.converter.DefaultTypeConverter;
4 | import org.originit.et.jdbc.JDBCType;
5 |
6 | public class DefaultLongTypeConverter implements DefaultTypeConverter {
7 | @Override
8 | public Class> javaType() {
9 | return Long.class;
10 | }
11 |
12 | @Override
13 | public JDBCType jdbcType() {
14 | return JDBCType.BIGINT;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/converter/impl/DefaultIntegerTypeConverter.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.converter.impl;
2 |
3 | import org.originit.et.converter.DefaultTypeConverter;
4 | import org.originit.et.jdbc.JDBCType;
5 |
6 | public class DefaultIntegerTypeConverter implements DefaultTypeConverter {
7 | @Override
8 | public Class> javaType() {
9 | return Integer.class;
10 | }
11 |
12 | @Override
13 | public JDBCType jdbcType() {
14 | return JDBCType.INT;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/BeanField.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | import java.lang.reflect.Field;
4 |
5 | public class BeanField {
6 | private String columnName;
7 | private Field field;
8 |
9 | public String getColumnName() {
10 | return columnName;
11 | }
12 | public void setColumnName(String columnName) {
13 | this.columnName = columnName;
14 | }
15 | public Field getField() {
16 | return field;
17 | }
18 | public void setField(Field field) {
19 | this.field = field;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/entity/Table.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * 表格实体
12 | */
13 | @Data
14 | @AllArgsConstructor
15 | @NoArgsConstructor
16 | @Builder
17 | public class Table {
18 |
19 | private String name;
20 |
21 | private List columns;
22 |
23 | private Id id;
24 |
25 | private String comment;
26 | }
27 |
--------------------------------------------------------------------------------
/common-logger-starter/src/main/java/com/originit/logger/annotation/Log.java:
--------------------------------------------------------------------------------
1 | package com.originit.logger.annotation;
2 |
3 | /**
4 | * 添加该注解的类或方法会打印参数以及响应的日志
5 | */
6 |
7 | import java.lang.annotation.ElementType;
8 | import java.lang.annotation.Retention;
9 | import java.lang.annotation.RetentionPolicy;
10 | import java.lang.annotation.Target;
11 |
12 | /**
13 | * 标志所标注的类的所有方法打印日志,如果有不需要打印的可以使用{@link NoLog}注解标注
14 | * 标注所在的方法打印日志
15 | */
16 | @Target({ElementType.TYPE,ElementType.METHOD})
17 | @Retention(RetentionPolicy.RUNTIME)
18 | public @interface Log {
19 | }
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/converter/impl/DefaultLocalDateTypeConverter.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.converter.impl;
2 |
3 | import org.originit.et.converter.DefaultTypeConverter;
4 | import org.originit.et.jdbc.JDBCType;
5 |
6 | import java.time.LocalDate;
7 |
8 | public class DefaultLocalDateTypeConverter implements DefaultTypeConverter {
9 | @Override
10 | public Class> javaType() {
11 | return LocalDate.class;
12 | }
13 |
14 | @Override
15 | public JDBCType jdbcType() {
16 | return JDBCType.DATE;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/entity/Column.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | /**
9 | * 表的列
10 | */
11 | @Data
12 | @Builder
13 | @AllArgsConstructor
14 | @NoArgsConstructor
15 | public class Column {
16 |
17 | private String name;
18 |
19 | private String type;
20 |
21 | private Integer length;
22 |
23 | private boolean unique;
24 |
25 | private boolean notNull;
26 |
27 | private String comment;
28 | }
29 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/converter/impl/DefaultLocalDateTimeTypeConverter.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.converter.impl;
2 |
3 | import org.originit.et.converter.DefaultTypeConverter;
4 | import org.originit.et.jdbc.JDBCType;
5 |
6 | import java.time.LocalDateTime;
7 |
8 | public class DefaultLocalDateTimeTypeConverter implements DefaultTypeConverter {
9 | @Override
10 | public Class> javaType() {
11 | return LocalDateTime.class;
12 | }
13 |
14 | @Override
15 | public JDBCType jdbcType() {
16 | return JDBCType.DATETIME;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/common-exception-starter/src/main/java/org/originit/exception/log/ExceptionLogger.java:
--------------------------------------------------------------------------------
1 | package org.originit.exception.log;
2 |
3 | import org.originit.exception.BusinessException;
4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
5 |
6 | @ConditionalOnClass
7 | public interface ExceptionLogger {
8 |
9 | /**
10 | * 打印常规异常的信息
11 | * @param e 常规异常
12 | */
13 | void logException(Exception e);
14 |
15 | /**
16 | * 打印业务异常的信息
17 | * @param businessException 业务异常
18 | */
19 | void logBusinessException(BusinessException businessException);
20 | }
21 |
--------------------------------------------------------------------------------
/common-response-starter/src/main/java/com/originit/response/success/DefaultSuccessCodeAcquirer.java:
--------------------------------------------------------------------------------
1 | package com.originit.response.success;
2 |
3 | import com.originit.response.property.ResponseProperty;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.beans.factory.annotation.Value;
6 |
7 | public class DefaultSuccessCodeAcquirer implements SuccessCodeAcquirer{
8 |
9 | @Autowired
10 | ResponseProperty responseProperty;
11 |
12 | @Override
13 | public Integer getSuccessCode() {
14 | return responseProperty.getSuccessCode();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/common-file/common-disk-file-starter/src/main/java/org/originit/file/disk/config/DiskFileAutoConfiguration.java:
--------------------------------------------------------------------------------
1 | package org.originit.file.disk.config;
2 |
3 | import org.originit.file.disk.property.UploadConfig;
4 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
5 | import org.springframework.context.annotation.ComponentScan;
6 | import org.springframework.context.annotation.Configuration;
7 |
8 | @EnableConfigurationProperties({UploadConfig.class})
9 | @Configuration
10 | @ComponentScan(basePackages = "org.originit.file.disk")
11 | public class DiskFileAutoConfiguration {
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/converter/TypeConverter.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.converter;
2 |
3 | import org.originit.et.jdbc.JDBCType;
4 |
5 | /**
6 | * 类型映射器,将java类型转换为sql类型
7 | * @author xxc
8 | */
9 | public interface TypeConverter {
10 |
11 | /**
12 | * java类型
13 | * @return
14 | */
15 | Class> javaType();
16 |
17 | /**
18 | * 数据库类型
19 | * @return
20 | */
21 | JDBCType jdbcType();
22 |
23 | /**
24 | * 默认长度
25 | * @return
26 | */
27 | default Integer defaultLength() {
28 | return null;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/entity/FileInfo.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file.entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Getter;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.io.InputStream;
9 |
10 | @Getter
11 | @Builder
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | public class FileInfo {
15 |
16 | private String name;
17 |
18 | private String originalFileName;
19 |
20 | private String contentType;
21 |
22 | private Boolean isEmpty;
23 |
24 | private long size;
25 |
26 | private InputStream inputStream;
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/common/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/FileFilter.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file;
2 |
3 | import org.originit.common.file.entity.ContextInfo;
4 | import org.originit.common.file.entity.FileInfo;
5 | import org.originit.common.file.entity.UploadConfig;
6 |
7 | /**
8 | * 文件过滤器,排除掉不符合条件的类
9 | */
10 | public interface FileFilter {
11 |
12 | String SUPPORT_ALL_IMAGES = "*";
13 |
14 | /**
15 | * 过滤不合法的文件
16 | *
17 | * @param file 上传的文件
18 | * @param config 文件相关配置
19 | * @param info
20 | * @return 是否合法
21 | */
22 | void doFilter(FileInfo file, UploadConfig config, ContextInfo info);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/entity2table/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/common-logger-starter/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/common-mybatis-crud/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/common-user-service/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/common-web-starter/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/common-exception-starter/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/common-response-starter/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/validator/info/ParameterInvalidItem.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.validator.info;
2 |
3 | public class ParameterInvalidItem {
4 | private String fieldName;
5 | private String message;
6 |
7 | public ParameterInvalidItem() {
8 | }
9 |
10 | public String getFieldName() {
11 | return this.fieldName;
12 | }
13 |
14 | public void setFieldName(String fieldName) {
15 | this.fieldName = fieldName;
16 | }
17 |
18 | public String getMessage() {
19 | return this.message;
20 | }
21 |
22 | public void setMessage(String message) {
23 | this.message = message;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/converter/impl/DefaultStringTypeConverter.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.converter.impl;
2 |
3 | import org.originit.et.converter.DefaultTypeConverter;
4 | import org.originit.et.jdbc.JDBCType;
5 |
6 | /**
7 | * @author xxc
8 | */
9 | public class DefaultStringTypeConverter implements DefaultTypeConverter {
10 | @Override
11 | public Class> javaType() {
12 | return String.class;
13 | }
14 |
15 | @Override
16 | public JDBCType jdbcType() {
17 | return JDBCType.VARCHAR;
18 | }
19 |
20 | @Override
21 | public Integer defaultLength() {
22 | return 1000;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/common-mybatis-crud.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
--------------------------------------------------------------------------------
/common-response-starter/src/main/java/com/originit/response/anotation/ResponseResult.java:
--------------------------------------------------------------------------------
1 | package com.originit.response.anotation;
2 |
3 | import com.originit.response.result.PlatformResult;
4 | import com.originit.response.result.Result;
5 |
6 | import java.lang.annotation.ElementType;
7 | import java.lang.annotation.Retention;
8 | import java.lang.annotation.RetentionPolicy;
9 | import java.lang.annotation.Target;
10 |
11 | /**
12 | * 用于声明Controller使用哪个响应类,默认是PlatformResult
13 | * @author xxc、
14 | */
15 | @Target({ElementType.TYPE})
16 | @Retention(RetentionPolicy.RUNTIME)
17 | public@interface ResponseResult{
18 | Class extends Result> value() default PlatformResult.class;
19 | }
20 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/entity2table/mp2table_acquirer/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/common-exception-starter/src/main/java/org/originit/exception/log/DefaultExceptionLogger.java:
--------------------------------------------------------------------------------
1 | package org.originit.exception.log;
2 |
3 | import com.originit.common.utils.ExceptionUtil;
4 | import lombok.extern.slf4j.Slf4j;
5 | import org.originit.exception.BusinessException;
6 |
7 | /**
8 | * 默认的异常堆栈打印
9 | * @author xxc
10 | */
11 | @Slf4j
12 | public class DefaultExceptionLogger implements ExceptionLogger{
13 |
14 |
15 | @Override
16 | public void logException(Exception e) {
17 | log.error(ExceptionUtil.buildErrorMessage(e));
18 | }
19 |
20 | @Override
21 | public void logBusinessException(BusinessException businessException) {
22 | log.info(ExceptionUtil.buildErrorMessage(businessException));
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/resources/template/table/create.ftl:
--------------------------------------------------------------------------------
1 | CREATE TABLE IF NOT EXISTS ${model.name}(
2 | <#if model.id??>
3 | `${model.id.name}` ${model.id.type}<#if model.id.length??>(${model.id.length?c})#if> <#if model.id.notNull??> NOT NULL #if> PRIMARY KEY <#if model.id.auto> AUTO_INCREMENT #if><#if (model.columns?size>0)>,#if>
4 | #if>
5 | <#if model.columns??>
6 | <#list model.columns as column>
7 | `${column.name}` ${column.type}<#if column.length??>(${column.length?c})#if><#if column.notNull??> NOT NULL #if><#if column.comment??> COMMENT '${column.comment}'#if><#if column_has_next>,#if>
8 | #list>
9 | #if>
10 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='${model.comment?default("")}';
11 |
12 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/util/SQLUtils.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.util
2 |
3 | import org.apache.ibatis.jdbc.SQL
4 | import org.originit.crud.meta.ClassMetaInfo
5 | import org.originit.crud.meta.FieldMetaInfo
6 |
7 | class SQLUtils {
8 |
9 | companion object {
10 |
11 | fun conditions(sql: SQL, params: MutableMap, metaInfo: ClassMetaInfo): SQL {
12 | val conditions = metaInfo.fields.filter { params.containsKey(it.fieldName) }.map {
13 | "${it.columnName}=#{${it.fieldName}}"
14 | }
15 |
16 | for ((_, condition) in conditions.withIndex()) {
17 | sql.WHERE(condition)
18 | }
19 | return sql
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/provider/impl/SelectByIdSQLProvider.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.provider.impl
2 |
3 | import org.apache.ibatis.jdbc.SQL
4 | import org.originit.crud.meta.ClassMetaInfo
5 | import org.originit.crud.provider.BaseSQLProvider
6 |
7 | class SelectByIdSQLProvider: BaseSQLProvider() {
8 | override fun buildSql(params: MutableMap, metaInfo: ClassMetaInfo): String {
9 | // 我想要mapperType上的泛型
10 | val tableName = metaInfo.tableName
11 | val sql = SQL()
12 | sql.SELECT("*").FROM(tableName).WHERE("${metaInfo.idColumn}=#{${metaInfo.idField}}")
13 | if (metaInfo.logicField != null) {
14 | sql.WHERE("${metaInfo.logicColumn}=1")
15 | }
16 | return sql.toString()
17 | }
18 | }
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/provider/impl/DeleteSQLProvider.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.provider.impl
2 |
3 | import org.apache.ibatis.jdbc.SQL
4 | import org.originit.crud.meta.ClassMetaInfo
5 | import org.originit.crud.provider.BaseSQLProvider
6 | import org.originit.crud.util.SQLUtils
7 |
8 | class DeleteSQLProvider: BaseSQLProvider() {
9 | override fun buildSql(params: MutableMap, metaInfo: ClassMetaInfo): String {
10 | val sql = SQL()
11 | if (metaInfo.logicField == null) {
12 | sql.DELETE_FROM(metaInfo.tableName)
13 | } else {
14 | sql.UPDATE(metaInfo.tableName).SET("${metaInfo.logicColumn}=0")
15 | }
16 | SQLUtils.conditions(sql, params, metaInfo)
17 | return sql.toString()
18 | }
19 | }
--------------------------------------------------------------------------------
/common-web-starter/src/main/java/org/originit/web/config/WebConfig.java:
--------------------------------------------------------------------------------
1 | package org.originit.web.config;
2 |
3 | import org.originit.exception.result.ExceptionResultGenerator;
4 | import org.originit.web.exception.DefaultResultGenerator;
5 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.ComponentScan;
8 | import org.springframework.context.annotation.Configuration;
9 | @Configuration
10 | public class WebConfig {
11 |
12 | /**
13 | * 默认的异常返回,使用PlatformResult
14 | * @return
15 | */
16 | @Bean
17 | @ConditionalOnMissingBean(ExceptionResultGenerator.class)
18 | public ExceptionResultGenerator exceptionResultGenerator() {
19 | return new DefaultResultGenerator();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/test/resources/sql/blog-derby.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2009-2012 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 | driver=org.apache.derby.jdbc.EmbeddedDriver
18 | url=jdbc:derby:memory:admin;create=true
19 | username=
20 | password=
--------------------------------------------------------------------------------
/common-file/common-disk-file-starter/src/test/java/org/originit/file/disk/CommonDiskFileStarterApplicationTests.java:
--------------------------------------------------------------------------------
1 | package org.originit.file.disk;
2 |
3 | import cn.hutool.core.io.FileUtil;
4 | import org.junit.jupiter.api.Assertions;
5 | import org.junit.jupiter.api.Test;
6 | import org.originit.common.file.FileManager;
7 | import org.originit.common.file.entity.FileInfo;
8 | import org.originit.common.file.entity.UploadResult;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.boot.test.context.SpringBootTest;
11 |
12 | import java.io.FileInputStream;
13 | import java.io.FileNotFoundException;
14 |
15 | @SpringBootTest
16 | class CommonDiskFileStarterApplicationTests {
17 |
18 | @Autowired
19 | FileManager uploader;
20 |
21 | @Test
22 | void contextLoads() throws FileNotFoundException {
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/page/PageParam.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.page;
2 |
3 | import lombok.Data;
4 |
5 |
6 | /**
7 | * 分页参数
8 | * @author xxc
9 | */
10 | @Data
11 | public class PageParam {
12 |
13 | private Long size;
14 |
15 | private Long page;
16 |
17 | public static long defaultPage = 1;
18 |
19 | public static long defaultSize = 20;
20 |
21 |
22 | public static PageParam nonNullDefault(Long page,Long size,PageParam param) {
23 | if (param != null) {
24 | return param;
25 | }
26 | final PageParam pageParam = new PageParam();
27 | pageParam.setPage(page);
28 | pageParam.setSize(size);
29 | return pageParam;
30 | }
31 |
32 | public static PageParam nonNullDefault(PageParam param) {
33 | return nonNullDefault(defaultPage,defaultSize,param);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/provider/impl/UpdateSQLProvider.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.provider.impl
2 |
3 | import org.apache.ibatis.jdbc.SQL
4 | import org.originit.crud.meta.ClassMetaInfo
5 | import org.originit.crud.provider.BaseSQLProvider
6 | import org.originit.crud.util.SQLUtils
7 |
8 | class UpdateSQLProvider : BaseSQLProvider() {
9 | override fun buildSql(params: MutableMap, metaInfo: ClassMetaInfo): String {
10 | val sql = SQL()
11 |
12 | sql.UPDATE(metaInfo.tableName)
13 | val sets = metaInfo.fields.filter { it.updateIfNull
14 | || params.containsKey(it.fieldName) }
15 | .joinToString(",") {
16 | "${it.columnName}=#{${it.fieldName}}"
17 | }
18 | sql.SET(sets)
19 | sql.WHERE("${metaInfo.idColumn}=#{${metaInfo.idField}}")
20 | return sql.toString()
21 | }
22 |
23 | }
--------------------------------------------------------------------------------
/common-exception-starter/src/main/java/org/originit/exception/config/ExceptionAutoConfiguration.java:
--------------------------------------------------------------------------------
1 | package org.originit.exception.config;
2 |
3 | import org.originit.exception.handler.CommonExceptionHandler;
4 | import org.originit.exception.log.DefaultExceptionLogger;
5 | import org.originit.exception.log.ExceptionLogger;
6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.context.annotation.Configuration;
9 | import org.springframework.context.annotation.Import;
10 |
11 | /**
12 | * @author xxc
13 | */
14 | @Configuration
15 | @Import({CommonExceptionHandler.class})
16 | public class ExceptionAutoConfiguration {
17 |
18 |
19 | @Bean
20 | @ConditionalOnMissingBean(ExceptionLogger.class)
21 | public ExceptionLogger defaultExceptionLogger() {
22 | return new DefaultExceptionLogger();
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/config/ConvertConfig.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.config;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * @author xxc
12 | */
13 | @Data
14 | @Builder
15 | @AllArgsConstructor
16 | @NoArgsConstructor
17 | public class ConvertConfig {
18 |
19 | /**
20 | * 实体类所在的包的包名
21 | */
22 | private List packageNames;
23 |
24 | /**
25 | * 表对应实体类的类名
26 | */
27 | private List tableClassNames;
28 |
29 | /**
30 | * 表信息获取器
31 | */
32 | private String tableInfoAcquirerClassName;
33 |
34 |
35 | private String columnInfoAcquirerClassName;
36 |
37 | /**
38 | * 数据库相关配置
39 | */
40 | private String url;
41 |
42 | private String username;
43 |
44 | private String password;
45 | }
46 |
--------------------------------------------------------------------------------
/common-response-starter/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | web-common
7 | org.originit
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | common-response-starter
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-starter-web
18 |
19 |
20 | common
21 | org.originit
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/common-logger-starter/src/main/java/com/originit/logger/config/LoggerAutoConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.originit.logger.config;
2 |
3 |
4 | import com.originit.logger.handler.LoggerAspect;
5 | import com.originit.logger.property.LogProperty;
6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
8 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
9 | import org.springframework.context.annotation.Bean;
10 | import org.springframework.context.annotation.Configuration;
11 |
12 | @Configuration
13 | @ConditionalOnProperty(prefix = "common.logger",name = "enable",havingValue = "true",matchIfMissing = true)
14 | @EnableConfigurationProperties(LogProperty.class)
15 | public class LoggerAutoConfiguration {
16 |
17 | @Bean
18 | public LoggerAspect loggerAspect (LogProperty property) {
19 | return new LoggerAspect(property);
20 | }
21 | }
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/provider/impl/SelectListSQLProvider.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.provider.impl
2 |
3 | import org.apache.ibatis.builder.SqlSourceBuilder
4 | import org.apache.ibatis.jdbc.SQL
5 | import org.apache.ibatis.jdbc.SqlBuilder
6 | import org.originit.crud.meta.ClassMetaInfo
7 | import org.originit.crud.provider.BaseSQLProvider
8 | import org.originit.crud.util.SQLUtils
9 |
10 | class SelectListSQLProvider: BaseSQLProvider() {
11 | override fun buildSql(params: MutableMap, metaInfo: ClassMetaInfo): String {
12 | val sql = SQL()
13 | sql.SELECT("*").FROM(metaInfo.tableName)
14 | SQLUtils.conditions(sql, params, metaInfo)
15 | if (params.containsKey(metaInfo.idField)) {
16 | sql.WHERE("${metaInfo.idColumn}=#{${metaInfo.idField}}")
17 | }
18 | if (metaInfo.logicField != null) {
19 | sql.WHERE("${metaInfo.logicColumn}=1")
20 | }
21 | return sql.toString()
22 | }
23 | }
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/AbstractSimpleFileUploadStrategy.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file;
2 |
3 | import org.originit.common.file.entity.FileInfo;
4 | import org.originit.common.file.entity.UploadConfig;
5 | import org.originit.common.file.entity.UploadResult;
6 |
7 | /**
8 | * @author xxc
9 | */
10 | public abstract class AbstractSimpleFileUploadStrategy implements FileUploadStrategy {
11 |
12 | @Override
13 | public UploadResult uploadImage(FileInfo file, UploadConfig config) {
14 | return justUpload(file,config);
15 | }
16 |
17 | @Override
18 | public UploadResult uploadFile(FileInfo file, UploadConfig config) {
19 | return justUpload(file,config);
20 | }
21 |
22 | @Override
23 | public UploadResult uploadBigFile(FileInfo file, UploadConfig config) {
24 | return justUpload(file,config);
25 | }
26 |
27 | protected abstract UploadResult justUpload(FileInfo file, UploadConfig config);
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/test/java/org/originit/et/executor/AbstractConvertExecutorTest.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.executor;
2 |
3 |
4 | import org.junit.Test;
5 | import org.originit.et.config.ConvertConfig;
6 | import org.originit.et.executor.impl.SimpleConvertExecutor;
7 |
8 | import java.util.ArrayList;
9 |
10 | public class AbstractConvertExecutorTest {
11 |
12 | @Test
13 | public void testTypeMap() {
14 | final ArrayList packages = new ArrayList<>();
15 | packages.add("org.originit.et.entity");
16 | final ConvertConfig convertConfig = ConvertConfig.builder().packageNames(packages)
17 | .url("jdbc:mysql://localhost:3306/sc_post?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false")
18 | .password("root")
19 | .username("root").build();
20 | final ConvertExecutor convertExecutor = new SimpleConvertExecutor(convertConfig);
21 | convertExecutor.execute();
22 |
23 | }
24 | }
--------------------------------------------------------------------------------
/common-mybatis-crud/src/test/resources/sql/test-schema.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2009-2012 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- http://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE t_user (
18 | id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
19 | name VARCHAR(255) NOT NULL,
20 | age int NOT NULL,
21 | is_del int not null default 1,
22 | PRIMARY KEY (id)
23 | );
24 |
25 |
26 |
--------------------------------------------------------------------------------
/common-user-service/src/main/java/org/originit/common/userservice/web/UserController.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.userservice.web;
2 |
3 | import com.originit.response.anotation.ResponseResult;
4 | import org.originit.common.userservice.callback.LoginUserCallback;
5 | import org.originit.common.userservice.entity.ILoginUser;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.web.bind.annotation.*;
8 |
9 | import javax.servlet.http.HttpServletRequest;
10 |
11 | /**
12 | * @author xxc
13 | */
14 | @RestController
15 | @ResponseResult
16 | @RequestMapping("/user")
17 | public class UserController {
18 |
19 | @Autowired
20 | LoginUserCallback loginUserCallback;
21 |
22 | @PostMapping("/login")
23 | public void login(HttpServletRequest request) {
24 | final ILoginUser loginUser = loginUserCallback.getLoginUser(request);
25 | }
26 |
27 | @PostMapping("/register")
28 | public void registerUser(HttpServletRequest request) {
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/test/java/org/originit/et/entity/AppUser.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.entity;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 |
6 | import javax.persistence.GeneratedValue;
7 | import javax.persistence.GenerationType;
8 | import javax.persistence.Id;
9 | import javax.persistence.Table;
10 | import java.io.Serializable;
11 | import java.time.LocalDateTime;
12 |
13 | /**
14 | *
15 | * 小程序用户表
16 | *
17 | *
18 | * @author macro
19 | * @since 2023-03-29
20 | */
21 | @Getter
22 | @Setter
23 | @Table(name = "app_user")
24 | public class AppUser implements Serializable {
25 |
26 | private static final long serialVersionUID = 1L;
27 |
28 | @Id
29 | @GeneratedValue(strategy = GenerationType.AUTO)
30 | private Long id;
31 |
32 | private String nickname;
33 |
34 | private String unionId;
35 |
36 | private String wxOpenId;
37 |
38 | private String phone;
39 |
40 | private Integer schoolId;
41 |
42 | private LocalDateTime createTime;
43 |
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/NumberUtil.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | import java.util.Date;
4 | import java.util.Random;
5 |
6 | public class NumberUtil {
7 |
8 | /**
9 | * 生成编号
10 | * @param number 生成的编号位数
11 | * @return 返回生成的随机数
12 | */
13 | public static long randomNo(int number){
14 | double rate1 = Math.pow(10,number-1);
15 | double rate2 = rate1*9;
16 | long rate3 = (long)rate1*10;
17 | Random random = new Random();
18 | double tmp= random.nextDouble()*rate2+rate1;
19 | long no = Math.round(tmp)%rate3;
20 | return no;
21 | }
22 |
23 | private static int seq = 0;//序列
24 | private static final int LIMIT = 100000;//上限
25 | private static Date date = new Date();
26 | //根据时间生成唯一编码(考虑并发)
27 | public static synchronized long timeUinqueNumber(){
28 | if (seq > LIMIT) seq = 0;
29 | date.setTime(System.currentTimeMillis());
30 | String str = String.format("%1$tY%1$tm%1$td%1$tk%1$tM%1$tS%2$05d", date, seq++);
31 | return Long.parseLong(str);
32 | }
33 |
34 | }
35 |
36 |
37 |
--------------------------------------------------------------------------------
/entity2table/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | web-common
7 | org.originit
8 | 1.0-SNAPSHOT
9 |
10 | pom
11 |
12 | entity2table-core
13 | mp2table_acquirer
14 |
15 | 4.0.0
16 |
17 | entity2table
18 |
19 | entity2table
20 |
21 | http://www.example.com
22 |
23 |
24 | UTF-8
25 | 1.8
26 | 1.8
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/BeanStrategy.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | import org.springframework.beans.BeanWrapper;
4 | import org.springframework.beans.BeanWrapperImpl;
5 |
6 | import java.util.HashSet;
7 | import java.util.Set;
8 |
9 |
10 | /**
11 | * @author xxc
12 | */
13 | public class BeanStrategy {
14 |
15 | /**
16 | * 返回实体的所有非 null 字段
17 | * @param source
18 | * @return
19 | */
20 | public static String[] getNullPropertyNames (Object source) {
21 | if (source == null) {
22 | return new String[0];
23 | }
24 | final BeanWrapper src = new BeanWrapperImpl(source);
25 | java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();
26 |
27 | Set emptyNames = new HashSet<>();
28 | for(java.beans.PropertyDescriptor pd : pds) {
29 | Object srcValue = src.getPropertyValue(pd.getName());
30 | if (srcValue == null) emptyNames.add(pd.getName());
31 | }
32 | String[] result = new String[emptyNames.size()];
33 | return emptyNames.toArray(result);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/common-web-starter/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | org.originit
6 | web-common
7 | 1.0-SNAPSHOT
8 |
9 |
10 | common-web-starter
11 | jar
12 |
13 | common-web-starter
14 | http://maven.apache.org
15 |
16 |
17 | UTF-8
18 |
19 |
20 |
21 |
22 | org.originit
23 | common-exception-starter
24 |
25 |
26 | org.originit
27 | common-response-starter
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/mapper/CrudMapper.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.mapper
2 |
3 | import org.apache.ibatis.annotations.DeleteProvider
4 | import org.apache.ibatis.annotations.InsertProvider
5 | import org.apache.ibatis.annotations.Param
6 | import org.apache.ibatis.annotations.SelectProvider
7 | import org.apache.ibatis.annotations.Update
8 | import org.apache.ibatis.annotations.UpdateProvider
9 | import org.originit.crud.provider.impl.*
10 | /**
11 | * 如何去代理掉这个呢?
12 | */
13 | interface CrudMapper {
14 |
15 | @InsertProvider(type = InsertSQLProvider::class, method = "invoke")
16 | fun insert(entity: Type): Int
17 |
18 | @UpdateProvider(type = UpdateSQLProvider::class, method = "invoke")
19 | fun updateById(entity: Type?): Int
20 | @SelectProvider(type = SelectByIdSQLProvider::class, method = "invoke")
21 | fun getById(@Param("id") id: ID): Type?
22 |
23 | @SelectProvider(type = SelectListSQLProvider::class, method = "invoke")
24 | fun list(entity: Type?): List
25 |
26 | @DeleteProvider(type = DeleteSQLProvider::class, method = "invoke")
27 | fun delete(entity: Type?): Int
28 | }
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/validator/EnumValueValidator.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.validator;
2 |
3 | import com.originit.common.validator.annotation.EnumValue;
4 | import org.springframework.stereotype.Component;
5 |
6 | import javax.validation.ConstraintValidator;
7 | import javax.validation.ConstraintValidatorContext;
8 |
9 | @Component
10 | public class EnumValueValidator implements ConstraintValidator {
11 |
12 | private String[] strValues;
13 | private int[] intValues;
14 |
15 | @Override
16 | public void initialize(EnumValue constraintAnnotation) {
17 | strValues = constraintAnnotation.strValues();
18 | intValues = constraintAnnotation.intValues();
19 | }
20 |
21 | @Override
22 | public boolean isValid(Object value, ConstraintValidatorContext context ) {
23 | if(value instanceof String) {
24 | for (String s:strValues) {
25 | if(s.equals(value)){
26 | return true;
27 | }
28 | }
29 | }else if(value instanceof Integer){
30 | for (Integer s:intValues) {
31 | if(s==value){
32 | return true;
33 | }
34 | }
35 | }
36 | return false;
37 |
38 | }
39 |
40 |
41 |
42 | }
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/info/AbstractModelTableInfoAcquirer.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.info;
2 |
3 | import cn.hutool.core.util.ClassUtil;
4 | import org.originit.et.entity.Column;
5 |
6 | import java.lang.reflect.Field;
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | /**
11 | * @author xxc
12 | */
13 | public abstract class AbstractModelTableInfoAcquirer implements ModelTableInfoAcquirer{
14 |
15 | protected final ColumnInfoAcquirer columnInfoAcquirer;
16 |
17 | public AbstractModelTableInfoAcquirer(ColumnInfoAcquirer columnInfoAcquirer) {
18 | this.columnInfoAcquirer = columnInfoAcquirer;
19 | }
20 |
21 | @Override
22 | public List getColumns(Class> c) {
23 | List columns = new ArrayList<>();
24 | final Field[] declaredFields = ClassUtil.getDeclaredFields(c);
25 | for (Field declaredField : declaredFields) {
26 | if (columnInfoAcquirer.isTableField(declaredField)) {
27 | columns.add(columnInfoAcquirer.getColumn(declaredField));
28 | }
29 | }
30 | return columns;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/ExceptionUtil.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | public class ExceptionUtil {
4 |
5 | //打印异常堆栈信息
6 | public static String getStackTraceString(Throwable ex){//(Exception ex) {
7 | StackTraceElement[] traceElements = ex.getStackTrace();
8 |
9 | StringBuilder traceBuilder = new StringBuilder();
10 |
11 | if (traceElements != null && traceElements.length > 0) {
12 | for (StackTraceElement traceElement : traceElements) {
13 | traceBuilder.append(traceElement.toString());
14 | traceBuilder.append("\n");
15 | }
16 | }
17 |
18 | return traceBuilder.toString();
19 | }
20 |
21 | //构造异常堆栈信息
22 | public static String buildErrorMessage(Exception ex) {
23 |
24 | String result;
25 | String stackTrace = getStackTraceString(ex);
26 | String exceptionType = ex.toString();
27 | String exceptionMessage = ex.getMessage();
28 |
29 | result = String.format("%s : %s \r\n %s", exceptionType, exceptionMessage, stackTrace);
30 |
31 | return result;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/SpringUtil.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | import org.springframework.beans.BeansException;
4 | import org.springframework.context.ApplicationContext;
5 | import org.springframework.context.ApplicationContextAware;
6 | import org.springframework.stereotype.Component;
7 |
8 | /**
9 | * @Description Spring上下文工具类
10 | * @Author Sans
11 | * @CreateTime 2019/6/17 13:40
12 | */
13 | @Component
14 | public class SpringUtil implements ApplicationContextAware {
15 | private static ApplicationContext context;
16 | /**
17 | * Spring在bean初始化后会判断是不是ApplicationContextAware的子类
18 | * 如果该类是,setApplicationContext()方法,会将容器中ApplicationContext作为参数传入进去
19 | * @Author Sans
20 | * @CreateTime 2019/6/17 16:58
21 | */
22 | @Override
23 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
24 | context = applicationContext;
25 | }
26 | /**
27 | * 通过Name返回指定的Bean
28 | * @Author Sans
29 | * @CreateTime 2019/6/17 16:03
30 | */
31 | public static T getBean(Class beanClass) {
32 | return context.getBean(beanClass);
33 | }
34 | }
--------------------------------------------------------------------------------
/demo/src/main/java/org/originit/demo/DemoApp.java:
--------------------------------------------------------------------------------
1 | package org.originit.demo;
2 |
3 | import com.originit.logger.annotation.Log;
4 | import com.originit.response.anotation.ResponseResult;
5 | import com.originit.response.result.SimpleData;
6 | import org.originit.demo.exception.UserNotFoundException;
7 | import org.springframework.boot.SpringApplication;
8 | import org.springframework.boot.autoconfigure.SpringBootApplication;
9 | import org.springframework.web.bind.annotation.RequestMapping;
10 | import org.springframework.web.bind.annotation.RequestParam;
11 | import org.springframework.web.bind.annotation.RestController;
12 | import org.springframework.web.servlet.mvc.method.annotation.DeferredResultMethodReturnValueHandler;
13 |
14 | @SpringBootApplication
15 | @RestController
16 | @ResponseResult
17 | @Log
18 | public class DemoApp {
19 |
20 | public static void main(String[] args) {
21 | SpringApplication.run(DemoApp.class,args);
22 | }
23 |
24 | @RequestMapping("/hello")
25 | public SimpleData sayHello(@RequestParam Boolean error) {
26 | if (error) {
27 | throw new UserNotFoundException( "用户找不到了", 10001);
28 | }
29 | return SimpleData.of("hahah");
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/FileUploadStrategy.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file;
2 |
3 | import org.originit.common.file.entity.FileInfo;
4 | import org.originit.common.file.entity.UploadConfig;
5 | import org.originit.common.file.entity.UploadResult;
6 |
7 | public interface FileUploadStrategy {
8 |
9 | long BIG_SIZE_GLOBAL = -1;
10 |
11 | /**
12 | * 上传图片
13 | * @param file 文件相关信息
14 | * @param config 上传相关配置
15 | * @return 上传结果
16 | */
17 | UploadResult uploadImage(FileInfo file, UploadConfig config);
18 |
19 |
20 | /**
21 | * 上传普通文件
22 | * @param file 文件相关信息
23 | * @param config 上传相关配置
24 | * @return 上传结果
25 | */
26 | UploadResult uploadFile(FileInfo file,UploadConfig config);
27 |
28 | /**
29 | * 上传大文件
30 | * @param file 文件相关信息
31 | * @param config 上传相关配置
32 | * @return 上传结果
33 | */
34 | UploadResult uploadBigFile(FileInfo file,UploadConfig config);
35 |
36 | /**
37 | * 唯一文件上传策略值
38 | * @return 当前上传策略名称
39 | */
40 | String getType();
41 |
42 | /**
43 | * 区分大文件的大小
44 | * @return 默认是使用全局配置
45 | */
46 | default long getBigSize() {
47 | return BIG_SIZE_GLOBAL;
48 | }
49 | }
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/property/FileProperties.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file.property;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 | import lombok.ToString;
6 | import org.springframework.boot.context.properties.ConfigurationProperties;
7 |
8 | import java.util.List;
9 | import java.util.Set;
10 | import java.util.stream.Collectors;
11 |
12 | @ToString
13 | @ConfigurationProperties("common.file")
14 | public class FileProperties {
15 |
16 | /**
17 | * 大尺寸文件的界限
18 | */
19 | @Getter
20 | @Setter
21 | private long bigSize = 10 * 1024 * 1024;
22 |
23 | /**
24 | * 图片最大大小
25 | */
26 | @Getter
27 | @Setter
28 | private long imageMaxSize = 8 * 1024 * 1024;
29 |
30 | /**
31 | * 支持的图片类型
32 | */
33 | @Setter
34 | private List supportImgs;
35 |
36 | private Set supportImgSet;
37 |
38 | private boolean handled = false;
39 |
40 | public Set getSupportImgs() {
41 | if (!handled && supportImgs != null && !supportImgs.isEmpty()) {
42 | supportImgSet = supportImgs.stream().map(String::toLowerCase).collect(Collectors.toSet());
43 | handled = true;
44 | }
45 | return supportImgSet;
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/IpUtil.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | import cn.hutool.json.JSONUtil;
4 | import lombok.extern.slf4j.Slf4j;
5 |
6 | import java.io.BufferedReader;
7 | import java.io.InputStreamReader;
8 | import java.net.HttpURLConnection;
9 | import java.net.URL;
10 |
11 | @Slf4j
12 | public class IpUtil {
13 |
14 | /**
15 | * 获取本地的公网ip
16 | * @return IP地址
17 | */
18 | public static String getLocalIP() {
19 | String ip = "http://pv.sohu.com/cityjson?ie=utf-8";
20 |
21 | String inputLine = "";
22 | String read = "";
23 | try {
24 | URL url = new URL(ip);
25 | HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
26 | BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
27 | while ((read = in.readLine()) != null) {
28 | inputLine += read;
29 | }
30 | } catch (Exception e) {
31 | e.printStackTrace();
32 | }
33 | inputLine = inputLine.substring(inputLine.indexOf('{') - 1,inputLine.length() - 1);
34 | ip = (String) JSONUtil.parseObj(inputLine).get("cip");
35 | log.info("若无法显示经理图片,请看这里是否与服务器ip一致: {}",ip);
36 | return ip;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/meta/MetaCache.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.meta
2 |
3 | import org.originit.crud.enums.KeyGeneratorPolicy
4 | import org.springframework.util.IdGenerator
5 | import javax.crypto.KeyGenerator
6 |
7 |
8 | class FieldMetaInfo(var fieldName: String? = null,
9 | var columnName: String? = null,
10 | var primary: Boolean = false,
11 | var updateIfNull: Boolean = false) {
12 | }
13 | class ClassMetaInfo(var tableName: String? = null,
14 | var entityClass: Class<*>? = null,
15 | var idField: String? = null,
16 | var idColumn: String? = null,
17 | var logicField: String? = null,
18 | var logicColumn: String? = null,
19 | var idGenerator: KeyGeneratorPolicy = KeyGeneratorPolicy.NONE,
20 | var fields: MutableList = mutableListOf()
21 | ) {
22 | }
23 |
24 | object MetaCache {
25 |
26 | private val cache: MutableMap,ClassMetaInfo> = mutableMapOf()
27 |
28 | fun getCache(clazz: Class<*>): ClassMetaInfo? {
29 | return cache[clazz]
30 | }
31 |
32 | fun putCache(mapperType: Class<*>, classMetaInfo: ClassMetaInfo) {
33 | cache[mapperType] = classMetaInfo
34 | }
35 | }
--------------------------------------------------------------------------------
/common-logger-starter/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | web-common
6 | org.originit
7 | 1.0-SNAPSHOT
8 |
9 | 4.0.0
10 |
11 | common-logger-starter
12 |
13 | common-logger-starter
14 |
15 | http://www.example.com
16 |
17 |
18 | UTF-8
19 | 1.8
20 | 1.8
21 |
22 |
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-starter-aop
27 |
28 |
29 | common
30 | org.originit
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/provider/impl/InsertSQLProvider.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.provider.impl
2 |
3 | import org.apache.ibatis.jdbc.SQL
4 | import org.originit.crud.enums.KeyGeneratorPolicy
5 | import org.originit.crud.key.UUIDGenerator
6 | import org.originit.crud.meta.ClassMetaInfo
7 | import org.originit.crud.provider.BaseSQLProvider
8 |
9 | class InsertSQLProvider: BaseSQLProvider() {
10 | override fun buildSql(params: MutableMap, metaInfo: ClassMetaInfo): String {
11 | val sql = SQL()
12 | metaInfo.idGenerator
13 | var fields = if (metaInfo.idGenerator == KeyGeneratorPolicy.AUTO) metaInfo.fields.filter { it.primary.not() }
14 | else metaInfo.fields
15 | fields = fields.filter {
16 | it.primary || params.containsKey(it.fieldName)
17 | }
18 | if (metaInfo.idGenerator === KeyGeneratorPolicy.UUID && metaInfo.idField != null) {
19 | params[metaInfo.idField!!] = UUIDGenerator.next()
20 | }
21 | val columns = fields.filter { params.containsKey(it.fieldName) }
22 | .map { it.columnName }.joinToString(",")
23 | val values = fields
24 | .joinToString(",") { "#{${it.fieldName}}" }
25 | sql.INSERT_INTO(metaInfo.tableName).VALUES(columns, values)
26 | return sql.toString()
27 | }
28 | }
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/validator/annotation/EnumValue.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.validator.annotation;
2 |
3 | import com.originit.common.validator.EnumValueValidator;
4 |
5 | import javax.validation.Constraint;
6 | import javax.validation.Payload;
7 | import java.lang.annotation.Documented;
8 | import java.lang.annotation.Retention;
9 | import java.lang.annotation.Target;
10 |
11 | import static java.lang.annotation.ElementType.*;
12 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
13 |
14 | /**
15 | * @author xxc、
16 | */
17 | @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
18 | @Retention(RUNTIME)
19 | @Documented
20 | @Constraint(validatedBy = {EnumValueValidator.class})
21 | public @interface EnumValue {
22 |
23 | /**
24 | * 默认错误消息
25 | */
26 | String message() default "必须为指定值";
27 |
28 | /**
29 | * 字符串的值
30 | */
31 | String[] strValues() default {};
32 |
33 | /**
34 | * int值
35 | */
36 | int[] intValues() default {};
37 |
38 | //分组
39 | Class>[] groups() default {};
40 |
41 | //负载
42 | Class extends Payload>[] payload() default {};
43 |
44 | //指定多个时使用
45 | @Target({FIELD, METHOD, PARAMETER, ANNOTATION_TYPE})
46 | @Retention(RUNTIME)
47 | @Documented
48 | @interface List {
49 | EnumValue[] value();
50 | }
51 | }
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/RequestContextHolderUtil.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | import org.springframework.web.context.ContextLoader;
4 | import org.springframework.web.context.request.RequestContextHolder;
5 | import org.springframework.web.context.request.ServletRequestAttributes;
6 |
7 | import javax.servlet.ServletContext;
8 | import javax.servlet.http.HttpServletRequest;
9 | import javax.servlet.http.HttpServletResponse;
10 | import javax.servlet.http.HttpSession;
11 |
12 | /**
13 | * @author xxc、
14 | */
15 | public class RequestContextHolderUtil {
16 |
17 | public static HttpServletRequest getRequest() {
18 | return getRequestAttributes().getRequest();
19 | }
20 |
21 | public static HttpServletResponse getResponse() {
22 | return getRequestAttributes().getResponse();
23 | }
24 |
25 | public static HttpSession getSession() {
26 | return getRequest().getSession();
27 | }
28 |
29 | public static ServletRequestAttributes getRequestAttributes() {
30 | return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes());
31 | }
32 |
33 | public static ServletContext getServletContext() {
34 | return ContextLoader.getCurrentWebApplicationContext().getServletContext();
35 | }
36 |
37 | }
--------------------------------------------------------------------------------
/common-mybatis-crud/src/test/kotlin/org/originit/crud/mapper/UserMapperTest.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.mapper
2 |
3 | import org.apache.ibatis.io.Resources
4 | import org.apache.ibatis.session.Configuration
5 | import org.apache.ibatis.session.SqlSessionFactory
6 | import org.apache.ibatis.session.SqlSessionFactoryBuilder
7 | import org.junit.Assert
8 | import org.junit.Before
9 | import org.junit.Test
10 | import org.originit.crud.BaseDataTest
11 | import org.originit.crud.pojo.User
12 | import org.springframework.context.support.ClassPathXmlApplicationContext
13 |
14 | class UserMapperTest: BaseDataTest() {
15 |
16 | @Before
17 | fun setUp() {
18 | createBlogDataSource()
19 | }
20 |
21 | @Test
22 | fun testSelectById() {
23 | val app = ClassPathXmlApplicationContext("spring-mybatis.xml")
24 | val userMapper = app.getBean(UserMapper::class.java)
25 | // 从SqlSessionFactory中获取UserMapper
26 | userMapper.delete(User(1))
27 | Assert.assertNull(userMapper.getById(1))
28 | userMapper.insert(User(3, "gj", 26))
29 | Assert.assertNotNull(userMapper.getById(3))
30 | Assert.assertEquals(userMapper.getById(3), User(3, "gj", 26))
31 | userMapper.updateById(User(2, "xxc"))
32 | val gj = userMapper.getById(2)
33 | Assert.assertEquals(gj, User(2, "xxc", gj!!.age))
34 | val user = userMapper.list(null)
35 | Assert.assertEquals(user.size, 2)
36 | }
37 | }
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/config/CommonAutoConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.config;
2 |
3 | import com.originit.common.param.anno.BodyFieldArgResolver;
4 | import com.originit.common.utils.SpringUtil;
5 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 | import org.springframework.web.method.support.HandlerMethodArgumentResolver;
9 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
10 |
11 | import java.util.List;
12 |
13 | @Configuration
14 | public class CommonAutoConfiguration implements WebMvcConfigurer {
15 |
16 | @Bean
17 | @ConditionalOnProperty(name = "common.mvc.bodyField", matchIfMissing = true, havingValue = "true")
18 | public BodyFieldArgResolver bodyFieldArgResolver() {
19 | return new BodyFieldArgResolver();
20 | }
21 |
22 | @Override
23 | public void addArgumentResolvers(List resolvers) {
24 | final BodyFieldArgResolver bodyFieldArgResolver = bodyFieldArgResolver();
25 | if (bodyFieldArgResolver != null) {
26 | resolvers.add(bodyFieldArgResolver);
27 | }
28 | WebMvcConfigurer.super.addArgumentResolvers(resolvers);
29 | }
30 |
31 | @Bean
32 | public SpringUtil springUtil() {
33 | return new SpringUtil();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/demo/src/test/java/org/originit/demo/DemoAppTest.java:
--------------------------------------------------------------------------------
1 | package org.originit.demo;
2 |
3 | import cn.hutool.json.JSONUtil;
4 | import org.junit.Before;
5 | import org.junit.Test;
6 | import org.junit.runner.RunWith;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.boot.test.context.SpringBootTest;
9 | import org.springframework.http.MediaType;
10 | import org.springframework.test.context.junit4.SpringRunner;
11 | import org.springframework.test.context.web.WebAppConfiguration;
12 | import org.springframework.test.web.servlet.MockMvc;
13 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
14 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
15 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
16 | import org.springframework.web.context.WebApplicationContext;
17 |
18 | import java.util.ArrayList;
19 | import java.util.HashMap;
20 | import java.util.List;
21 |
22 | @SpringBootTest
23 | @RunWith(SpringRunner.class)
24 | @WebAppConfiguration
25 | public class DemoAppTest {
26 |
27 | private MockMvc mockMvc;
28 | @Autowired
29 | private WebApplicationContext webApplicationContext;
30 | @Before
31 | public void setup() {
32 | // 实例化方式一
33 | // mockMvc = MockMvcBuilders.standaloneSetup(new HelloWorldController()).build();
34 | // 实例化方式二
35 | mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/impl/SimpleFileUploader.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file.impl;
2 |
3 | import com.originit.common.utils.StringUtil;
4 | import org.originit.common.file.AbstractFileUploader;
5 | import org.originit.common.file.FileUploadStrategy;
6 | import org.originit.common.file.entity.ContextInfo;
7 | import org.originit.common.file.entity.FileInfo;
8 | import org.originit.common.file.entity.UploadConfig;
9 | import org.originit.common.file.entity.UploadResult;
10 | import org.originit.common.file.property.FileProperties;
11 |
12 | /**
13 | * @author xxc
14 | */
15 | public class SimpleFileUploader extends AbstractFileUploader {
16 |
17 | FileProperties properties;
18 |
19 | public SimpleFileUploader(FileProperties fileProperties) {
20 | this.properties = fileProperties;
21 | }
22 |
23 | @Override
24 | protected UploadResult onUpload(FileUploadStrategy strategy, FileInfo file, UploadConfig config, ContextInfo info) {
25 | String suffix = info.getSuffix();
26 | Boolean isImg = info.getIsImg();
27 | if (!StringUtil.isEmpty(suffix)) {
28 | if (isImg) {
29 | return strategy.uploadImage(file,config);
30 | }
31 | }
32 | if (file.getSize() >= properties.getBigSize()) {
33 | return strategy.uploadBigFile(file, config);
34 | } else {
35 | return strategy.uploadFile(file, config);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/provider/BaseSQLProvider.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.provider
2 |
3 | import org.apache.ibatis.builder.annotation.ProviderContext
4 | import org.apache.ibatis.reflection.SystemMetaObject
5 | import org.originit.crud.meta.ClassMetaInfo
6 | import org.originit.crud.meta.MetaCache
7 |
8 | abstract class BaseSQLProvider {
9 |
10 |
11 | fun invoke(params: Any?, providerContext: ProviderContext): String {
12 | val paramsMap: MutableMap = if (params != null && params is MutableMap<*, *>) {
13 | params as MutableMap
14 | } else {
15 | val m = mutableMapOf()
16 | if (params != null) {
17 | for (declaredField in params::class.java.declaredFields) {
18 | val metaObject = SystemMetaObject.forObject(params)
19 | if (metaObject.getValue(declaredField.name) != null)
20 | m[declaredField.name] = metaObject.getValue(declaredField.name)
21 | }
22 | }
23 | m
24 | }
25 | var classMetaInfo: ClassMetaInfo = MetaCache.getCache(providerContext.mapperType)
26 | ?: throw IllegalStateException("Mapper类未被解析:${providerContext.mapperType.name}")
27 | val sql = buildSql(paramsMap, classMetaInfo)
28 | return sql
29 | }
30 |
31 |
32 | abstract fun buildSql(params: MutableMap, metaInfo: ClassMetaInfo): String
33 | }
--------------------------------------------------------------------------------
/common-response-starter/src/main/java/com/originit/response/result/PlatformResult.java:
--------------------------------------------------------------------------------
1 | package com.originit.response.result;
2 |
3 |
4 | import com.originit.common.constant.CommonConstant;
5 | import com.originit.common.utils.SpringUtil;
6 | import com.originit.response.success.SuccessCodeAcquirer;
7 | import lombok.AllArgsConstructor;
8 | import lombok.Data;
9 | import lombok.EqualsAndHashCode;
10 |
11 | /**
12 | * 通用响应
13 | * @author xxc
14 | */
15 | @EqualsAndHashCode(callSuper = true)
16 | @Data
17 | @AllArgsConstructor
18 | public class PlatformResult extends Result{
19 |
20 | private Integer code;
21 | private String msg;
22 | private T data;
23 |
24 | public PlatformResult(T data) {
25 | this.code = SpringUtil.getBean(SuccessCodeAcquirer.class).getSuccessCode();
26 | this.data = data;
27 | }
28 |
29 |
30 |
31 | public static PlatformResult success(T data, String msg) {
32 | return new PlatformResult<>(SpringUtil.getBean(SuccessCodeAcquirer.class).getSuccessCode(),msg,data);
33 | }
34 |
35 | public static PlatformResult success(T data) {
36 | return new PlatformResult(SpringUtil.getBean(SuccessCodeAcquirer.class).getSuccessCode(),"success",data);
37 | }
38 |
39 | public static PlatformResult fail (Integer code,String msg,T data) {
40 | return new PlatformResult(code,msg,data);
41 | }
42 |
43 | public static PlatformResult fail (Integer code,String msg) {
44 | return new PlatformResult(code,msg,null);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/CommonUtil.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.io.IOException;
7 | import java.util.List;
8 | import java.util.UUID;
9 |
10 | public class CommonUtil {
11 |
12 | public static String getUID(){
13 | return UUID.randomUUID().toString().replace("-", "");
14 | }
15 |
16 | public static String stringCap(String str){
17 | return str.substring(0,1).toLowerCase() + str.substring(1);
18 | }
19 |
20 | public static byte[][] toArray(List list){
21 | byte[][] bytes = new byte[list.size()][];
22 | for(int i = 0; i < list.size() ;i++){
23 | bytes[i] = list.get(i);
24 | }
25 | return bytes;
26 | }
27 |
28 | public static byte[] getFileBytes(File file) {
29 | byte[] ret = null;
30 | try {
31 | if (file == null) {
32 | return null;
33 | }
34 | FileInputStream in = new FileInputStream(file);
35 | ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
36 | byte[] b = new byte[4096];
37 | int n;
38 | while ((n = in.read(b)) != -1) {
39 | out.write(b, 0, n);
40 | }
41 | in.close();
42 | out.close();
43 | ret = out.toByteArray();
44 | } catch (IOException e) {
45 | e.printStackTrace();
46 | }
47 | return ret;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/common-exception-starter/src/main/java/org/originit/exception/BusinessException.java:
--------------------------------------------------------------------------------
1 | package org.originit.exception;
2 |
3 | import lombok.Data;
4 | import lombok.EqualsAndHashCode;
5 |
6 | /**
7 | * @author zhumaer
8 | * @desc 业务异常类
9 | * @since 9/18/2017 3:00 PM
10 | */
11 | @Data
12 | public class BusinessException extends RuntimeException {
13 |
14 | protected Integer code;
15 |
16 | protected Object data;
17 |
18 |
19 | public BusinessException(Integer code, Object data) {
20 | this.code = code;
21 | this.data = data;
22 | }
23 |
24 | public BusinessException(String message, Integer code) {
25 | super(message);
26 | this.code = code;
27 | }
28 |
29 | public BusinessException(String message, Integer code, Object data) {
30 | super(message);
31 | this.code = code;
32 | this.data = data;
33 | }
34 |
35 | public BusinessException(String message, Throwable cause, Integer code, Object data) {
36 | super(message, cause);
37 | this.code = code;
38 | this.data = data;
39 | }
40 |
41 | public BusinessException(Throwable cause, Integer code, Object data) {
42 | super(cause);
43 | this.code = code;
44 | this.data = data;
45 | }
46 |
47 | public BusinessException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, Integer code, Object data) {
48 | super(message, cause, enableSuppression, writableStackTrace);
49 | this.code = code;
50 | this.data = data;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/common-file/common-file-core/file-design.puml:
--------------------------------------------------------------------------------
1 | @startuml
2 | 'https://plantuml.com/class-diagram
3 |
4 | class UploadConfig {
5 | String model;
6 | }
7 |
8 | class UploadResult {
9 | String path;
10 |
11 | Integer type;
12 | }
13 |
14 | class FileInfo {
15 |
16 | String name;
17 |
18 | String originalFileName;
19 |
20 | String contentType;
21 |
22 | Boolean isEmpty;
23 |
24 | long size;
25 |
26 | InputStream inputStream;
27 |
28 | }
29 |
30 |
31 | interface FileUploadStrategy {
32 | UploadResult uploadImage(FileInfo file,UploadConfig config);
33 |
34 | UploadResult uploadFile(FileInfo file,UploadConfig config);
35 |
36 | UploadResult uploadBigFile(FileInfo file,UploadConfig config);
37 |
38 | String getType();
39 | }
40 | interface FileFilter {
41 | boolean doFilter(FileInfo file,UploadConfig config);
42 | }
43 |
44 | interface FileUploader {
45 |
46 | UploadResult upload(FileInfo file,UploadConfig config);
47 |
48 | }
49 |
50 | abstract class AbstractSimpleFileUploadStrategy implements FileUploadStrategy{
51 | # {abstract} UploadResult justUpload(FileInfo file,UploadConfig config);
52 | }
53 |
54 | abstract class AbstractFileUploader implements FileUploader{
55 | # FileFilter filter;
56 | # FileUploadStrategy strategy;
57 |
58 | + void setStrategy(FileUploadStrategy strategy);
59 | + void setFilter(FileFilter filter);
60 |
61 | # UploadResult onUpload(FileUploadStrategy addStrategy,FileInfo file,UploadConfig config);
62 | }
63 |
64 | FileUploadStrategy o-- AbstractFileUploader
65 | FileFilter *-- AbstractFileUploader
66 | @enduml
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/impl/DefaultFileFilter.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file.impl;
2 |
3 | import org.originit.common.file.FileFilter;
4 | import org.originit.common.file.entity.ContextInfo;
5 | import org.originit.common.file.entity.FileInfo;
6 | import org.originit.common.file.entity.UploadConfig;
7 | import org.originit.common.file.property.FileProperties;
8 |
9 | /**
10 | * 默认的过滤器
11 | * @author xxc
12 | */
13 | public class DefaultFileFilter implements FileFilter {
14 |
15 | FileProperties properties;
16 |
17 | public DefaultFileFilter(FileProperties properties) {
18 | this.properties = properties;
19 | }
20 |
21 | @Override
22 | public void doFilter(FileInfo file, UploadConfig config, ContextInfo info) {
23 | String suffix = info.getSuffix();
24 | if (info.getIsImg()) {
25 | if (properties.getSupportImgs() != null && !properties.getSupportImgs().isEmpty()) {
26 | boolean isSupportAll = properties.getSupportImgs().size() == 1 && properties.getSupportImgs().contains(FileFilter.SUPPORT_ALL_IMAGES);
27 | if (!isSupportAll && !properties.getSupportImgs().contains(suffix.toLowerCase())) {
28 | throw new IllegalArgumentException("不支持图片类型" + suffix + "!");
29 | } else if(file.getSize() > properties.getImageMaxSize()) {
30 | throw new IllegalArgumentException("图片尺寸太大!!");
31 | }
32 | } else {
33 | throw new IllegalArgumentException("不支持图片文件!");
34 | }
35 | }
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/page/PageVO.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.page;
2 |
3 | import lombok.Data;
4 | import org.springframework.util.Assert;
5 |
6 | import java.util.List;
7 | import java.util.function.Function;
8 | import java.util.stream.Collectors;
9 |
10 | /**
11 | * @author xxc
12 | */
13 | @Data
14 | public class PageVO {
15 |
16 | private List list;
17 |
18 | private Long total;
19 |
20 | private Long current;
21 |
22 | private Long size;
23 |
24 |
25 | public static PageVO of(List pageList,Long total,Long current) {
26 | return of(pageList,total,current,t -> t);
27 | }
28 |
29 |
30 |
31 | public static PageVO of(List pageList, Long total, Long current, Function convertor) {
32 | Assert.notNull(convertor,"转换器不能为空");
33 | return create(pageList.stream().map(convertor).collect(Collectors.toList()),total,current,null);
34 | }
35 |
36 | public static PageVO empty() {
37 | return create(null,0L,1L,15L);
38 | }
39 |
40 | public static PageVO empty(long size) {
41 | return create(null,0L,1L,size);
42 | }
43 |
44 | public static PageVO create (List list,Long total,Long current,Long size) {
45 | final PageVO objectPageVO = new PageVO<>();
46 | objectPageVO.size = size;
47 | objectPageVO.current = current;
48 | objectPageVO.total = total;
49 | objectPageVO.list = list;
50 | if (objectPageVO.total == 0L) {
51 | objectPageVO.current = 1L;
52 | }
53 | return objectPageVO;
54 | }
55 |
56 |
57 | }
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/FileManager.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file;
2 |
3 | import org.originit.common.file.entity.FileInfo;
4 | import org.originit.common.file.entity.UploadConfig;
5 | import org.originit.common.file.entity.UploadResult;
6 | import org.springframework.web.multipart.MultipartFile;
7 |
8 | import java.io.File;
9 | import java.io.IOException;
10 |
11 | public interface FileManager {
12 | UploadResult upload(FileInfo fileInfo, UploadConfig config);
13 |
14 | default UploadResult upload(FileInfo fileInfo) {
15 | return this.upload(fileInfo, null);
16 | }
17 |
18 | default UploadResult upload(MultipartFile multipartFile, UploadConfig config) {
19 | try {
20 | return this.upload(FileInfo.builder().size(multipartFile.getSize()).name(multipartFile.getName())
21 | .inputStream(multipartFile.getInputStream())
22 | .contentType(multipartFile.getContentType())
23 | .isEmpty(multipartFile.isEmpty())
24 | .originalFileName(multipartFile.getOriginalFilename())
25 | .build(), config);
26 | } catch (IOException e) {
27 | throw new RuntimeException(e);
28 | }
29 | }
30 |
31 | default UploadResult upload(MultipartFile multipartFile) {
32 | return this.upload(multipartFile, null);
33 | }
34 |
35 | /**
36 | * 获取文件
37 | * @param path 文件code
38 | * @return
39 | */
40 | File getFile(String path);
41 |
42 | /**
43 | * 删除文件
44 | * @param path
45 | */
46 | void deleteFile(String path);
47 | }
48 |
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/config/FileAutoConfiguration.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file.config;
2 |
3 | import org.originit.common.file.FileFilter;
4 | import org.originit.common.file.FileUploadStrategy;
5 | import org.originit.common.file.FileUploaderDeprecated;
6 | import org.originit.common.file.impl.DefaultFileFilter;
7 | import org.originit.common.file.impl.SimpleFileUploader;
8 | import org.originit.common.file.property.FileProperties;
9 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
10 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
11 | import org.springframework.context.annotation.Bean;
12 | import org.springframework.context.annotation.ComponentScan;
13 |
14 | /**
15 | * @author xxc
16 | */
17 | //@Configuration
18 | @EnableConfigurationProperties({FileProperties.class})
19 | @ComponentScan("org.originit.common.file")
20 | public class FileAutoConfiguration {
21 |
22 | @Bean
23 | @ConditionalOnMissingBean(FileFilter.class)
24 | public FileFilter defaultFileFilter(FileProperties fileProperties) {
25 | return new DefaultFileFilter(fileProperties);
26 | }
27 |
28 | @Bean
29 | @ConditionalOnMissingBean(FileUploaderDeprecated.class)
30 | public FileUploaderDeprecated defaultFileUploader(FileProperties fileProperties, FileUploadStrategy strategy, FileFilter filter) {
31 | final SimpleFileUploader simpleFileUploader = new SimpleFileUploader(fileProperties);
32 | simpleFileUploader.setFilter(filter);
33 | simpleFileUploader.setStrategy(strategy);
34 | return simpleFileUploader;
35 | }
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/common-exception-starter/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | web-common
7 | org.originit
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | common-exception-starter
13 | 2.0
14 | common-exception-starter
15 |
16 | http://www.example.com
17 |
18 |
19 | UTF-8
20 | 1.8
21 | 1.8
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 | provided
29 |
30 |
31 | org.originit
32 | common
33 |
34 |
35 | junit
36 | junit
37 | test
38 |
39 |
40 | org.originit
41 | common
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/CookieUtil.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | import javax.servlet.http.Cookie;
4 | import javax.servlet.http.HttpServletRequest;
5 | import javax.servlet.http.HttpServletResponse;
6 |
7 | public class CookieUtil {
8 |
9 | public static final String WEIXIN_OPENID = "_weixin_openid_";
10 |
11 | public static Cookie addCookie(HttpServletResponse response, String cookieName, String value, Integer maxAge, String domain) {
12 | return addCookie(response, cookieName, value, maxAge, domain, "/");
13 | }
14 |
15 | public static Cookie addCookie(HttpServletResponse response, String cookieName, String value, Integer maxAge, String domain, String path) {
16 | Cookie cookie = new Cookie(cookieName,value);
17 | cookie.setMaxAge(maxAge);
18 | cookie.setDomain(domain);
19 | cookie.setPath(path);
20 | response.addCookie(cookie);
21 | return cookie;
22 | }
23 |
24 | // 获取 cookie
25 | public static String getCookie(HttpServletRequest request, String cookieName) {
26 | Cookie[] cookies = request.getCookies();
27 | if (cookies != null) {
28 | for (Cookie cookie : cookies) {
29 | if (cookieName.equalsIgnoreCase(cookie.getName())) {
30 | return cookie.getValue();
31 | }
32 | }
33 | }
34 | return null;
35 | }
36 |
37 | // 删除 cookie
38 | public static void delCookie(HttpServletResponse response, String cookieName) {
39 | Cookie cookie = new Cookie(cookieName,null);
40 | cookie.setMaxAge(0);
41 | cookie.setPath("/");
42 | response.addCookie(cookie);
43 | }
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/info/impl/JPAModelTableInfoAcquirer.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.info.impl;
2 |
3 | import cn.hutool.core.annotation.AnnotationUtil;
4 | import cn.hutool.core.util.StrUtil;
5 | import org.originit.et.anno.Comment;
6 | import org.originit.et.info.AbstractModelTableInfoAcquirer;
7 | import org.originit.et.info.ColumnInfoAcquirer;
8 |
9 | import javax.persistence.Table;
10 |
11 | /**
12 | * @author xxc
13 | */
14 | public class JPAModelTableInfoAcquirer extends AbstractModelTableInfoAcquirer {
15 |
16 | public JPAModelTableInfoAcquirer(ColumnInfoAcquirer columnInfoAcquirer) {
17 | super(columnInfoAcquirer);
18 | }
19 |
20 | @Override
21 | public void isTable(Class> c) {
22 | final Table table = AnnotationUtil.getAnnotation(c, Table.class);
23 | if (table == null) {
24 | throw new IllegalArgumentException(c.getName() + " must annotated with javax.persistence.Table to specify table name!");
25 | }
26 | if (table.name() == null || StrUtil.isBlank(table.name())) {
27 | throw new IllegalArgumentException(" table name can't be empty or null," + c.getName() + " must annotated with javax.persistence.Table to specify table name!");
28 | }
29 | }
30 |
31 | @Override
32 | public String getTableName(Class> c) {
33 | final Table annotation = AnnotationUtil.getAnnotation(c, Table.class);
34 | return annotation.name();
35 | }
36 |
37 | @Override
38 | public String getComment(Class> c) {
39 | final Comment annotation = c.getAnnotation(Comment.class);
40 | if (annotation != null) {
41 | return annotation.value();
42 | }
43 | return null;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/entity2table/mp2table_acquirer/src/main/java/org/originit/et/mp/MPModelTableInfoAcquirer.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.mp;
2 |
3 | import cn.hutool.core.annotation.AnnotationUtil;
4 | import cn.hutool.core.util.StrUtil;
5 | import com.baomidou.mybatisplus.annotation.TableName;
6 | import io.swagger.annotations.ApiModel;
7 | import org.originit.et.info.AbstractModelTableInfoAcquirer;
8 | import org.originit.et.info.ColumnInfoAcquirer;
9 |
10 | /**
11 | * @author xxc
12 | */
13 | public class MPModelTableInfoAcquirer extends AbstractModelTableInfoAcquirer {
14 |
15 | public MPModelTableInfoAcquirer(ColumnInfoAcquirer columnInfoAcquirer) {
16 | super(columnInfoAcquirer);
17 | }
18 |
19 | @Override
20 | public void isTable(Class> c) {
21 | final TableName table = AnnotationUtil.getAnnotation(c, TableName.class);
22 | if (table == null) {
23 | throw new IllegalArgumentException(c.getName() + " must annotated with javax.persistence.Table to specify table name!");
24 | }
25 | if (table.value() == null || StrUtil.isBlank(table.value())) {
26 | throw new IllegalArgumentException(" table name can't be empty or null," + c.getName() + " must annotated with javax.persistence.Table to specify table name!");
27 | }
28 | }
29 |
30 | @Override
31 | public String getTableName(Class> c) {
32 | final TableName annotation = AnnotationUtil.getAnnotation(c, TableName.class);
33 | return annotation.value();
34 | }
35 |
36 | @Override
37 | public String getComment(Class> c) {
38 | final ApiModel annotation = c.getAnnotation(ApiModel.class);
39 | if (annotation != null) {
40 | return annotation.description();
41 | }
42 | return null;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/executor/impl/SimpleConvertExecutor.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.executor.impl;
2 |
3 | import cn.hutool.db.ds.simple.SimpleDataSource;
4 | import lombok.extern.slf4j.Slf4j;
5 | import org.originit.et.config.ConvertConfig;
6 | import org.originit.et.entity.Table;
7 | import org.originit.et.executor.AbstractConvertExecutor;
8 | import org.originit.et.util.TemplateUtil;
9 |
10 | import javax.sql.DataSource;
11 | import java.sql.Connection;
12 | import java.sql.SQLException;
13 | import java.util.List;
14 |
15 | /**
16 | * @author xxc
17 | */
18 | @Slf4j
19 | public class SimpleConvertExecutor extends AbstractConvertExecutor {
20 |
21 | public SimpleConvertExecutor(ConvertConfig config) {
22 | super(config);
23 | }
24 |
25 |
26 | private static DataSource ds;
27 | private synchronized static DataSource getDs(ConvertConfig config) {
28 | if (ds != null) {
29 | return ds;
30 | }
31 | //具体的配置参数请参阅Druid官方文档
32 | ds = new SimpleDataSource(config.getUrl(), config.getUsername(), config.getPassword());
33 | return ds;
34 | }
35 |
36 | @Override
37 | public void execute() {
38 | // 1. 获取到要转换的表
39 | List tableList = this.tables;
40 | // 2. 获取jdbc执行
41 | try {
42 | final Connection connection = getDs(this.config).getConnection();
43 | for (Table table : tableList) {
44 | final String template = TemplateUtil.getTemplate("/table/create.ftl", table);
45 | log.debug(template);
46 | connection.createStatement().execute(template);
47 | }
48 | } catch (SQLException e) {
49 | throw new RuntimeException(e);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/common-file/common-disk-file-starter/src/main/java/org/originit/file/disk/uploader/DiskFileManager.java:
--------------------------------------------------------------------------------
1 | package org.originit.file.disk.uploader;
2 |
3 | import com.originit.common.utils.FileUDUtil;
4 | import org.originit.common.file.FileManager;
5 | import org.originit.common.file.entity.FileInfo;
6 | import org.originit.common.file.entity.UploadConfig;
7 | import org.originit.common.file.entity.UploadResult;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.stereotype.Component;
10 |
11 | import java.io.File;
12 |
13 | @Component
14 | public class DiskFileManager implements FileManager {
15 |
16 | @Autowired
17 | org.originit.file.disk.property.UploadConfig fileConfig;
18 |
19 | public static final UploadConfig DEFAULT_CONFIG = UploadConfig.builder().module("default").tag("default").build();
20 |
21 | @Override
22 | public UploadResult upload(FileInfo fileInfo, UploadConfig config) {
23 | if (config == null) {
24 | config = DEFAULT_CONFIG;
25 | }
26 | final String folder = new StringBuilder().append(fileConfig.getRootPath())
27 | .append("/").append(config.getModule()==null?DEFAULT_CONFIG.getModule():config.getModule()).append("/")
28 | .append(config.getTag()==null?DEFAULT_CONFIG.getTag():config.getTag()).append("/").toString() ;
29 | return UploadResult.success(FileUDUtil.saveFile(fileInfo.getInputStream(),
30 | folder, fileInfo.getOriginalFileName()));
31 | }
32 |
33 | @Override
34 | public File getFile(String path) {
35 | return FileUDUtil.getFile(path);
36 | }
37 |
38 | @Override
39 | public void deleteFile(String path) {
40 | final File file = getFile(path);
41 | if (file.exists()) {
42 | file.delete();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/info/ModelTableInfoAcquirer.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.info;
2 |
3 | import cn.hutool.core.util.StrUtil;
4 | import org.originit.et.entity.Column;
5 | import org.originit.et.entity.Id;
6 | import org.originit.et.entity.Table;
7 |
8 | import java.util.List;
9 | import java.util.stream.Collectors;
10 |
11 | /**
12 | * @author xxc
13 | */
14 | public interface ModelTableInfoAcquirer {
15 |
16 | /**
17 | * 是否符合表的注释
18 | * @param c
19 | * @return
20 | */
21 | void isTable(Class> c) throws IllegalStateException;
22 |
23 | /**
24 | * 通过class获取表名
25 | * @param c
26 | * @return
27 | */
28 | String getTableName(Class> c);
29 |
30 | /**
31 | * 获取表的注释
32 | * @param c
33 | * @return
34 | */
35 | String getComment(Class> c);
36 |
37 | /**
38 | * 获取表的列
39 | * @param c
40 | * @return
41 | */
42 | List getColumns(Class> c);
43 |
44 | /**
45 | * 获取表信息
46 | * @param c
47 | * @return
48 | */
49 | default Table getTable(Class> c) {
50 | final List columns = getColumns(c);
51 | columns.forEach(column -> column.setName(StrUtil.toUnderlineCase(column.getName())));
52 | final List idList = columns.stream().filter(column -> column instanceof Id).collect(Collectors.toList());
53 | if (idList.size() > 1) {
54 | throw new IllegalArgumentException("暂不支持多列主键,table:" + getTableName(c) + "idFields:" + idList.stream().map(column -> column.getName()).collect(Collectors.toList()));
55 | }
56 | Id id = idList.size() == 0?null: (Id) idList.get(0);
57 | return Table.builder().columns(columns.stream().filter(column -> !(column instanceof Id)).collect(Collectors.toList())).id(id).comment(getComment(c)).name(getTableName(c)).build();
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/entity2table/mp2table_acquirer/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | web-common
7 | org.originit
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | mp2table_acquirer
13 |
14 | annotation_mp2table
15 |
16 |
17 | UTF-8
18 | 1.8
19 | 1.8
20 |
21 |
22 |
23 |
24 | org.originit
25 | entity2table-core
26 | 1.0-SNAPSHOT
27 |
28 |
29 | com.baomidou
30 | mybatis-plus-annotation
31 | 3.5.2
32 |
33 |
34 | cn.hutool
35 | hutool-all
36 |
37 |
38 | io.swagger
39 | swagger-annotations
40 | 1.5.2
41 |
42 |
43 |
44 |
45 |
46 |
47 | cn.hutool
48 | hutool-all
49 | 5.8.4
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/test/resources/spring-mybatis.xml:
--------------------------------------------------------------------------------
1 |
2 |
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 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/test/resources/MapperConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
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 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/info/ColumnInfoAcquirer.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.info;
2 |
3 | import org.originit.et.entity.Column;
4 | import org.originit.et.entity.Id;
5 | import org.originit.et.jdbc.JDBCType;
6 |
7 | import java.lang.reflect.Field;
8 |
9 | /**
10 | * @author xxc
11 | */
12 | public interface ColumnInfoAcquirer {
13 |
14 | /**
15 | * 是否为表的列
16 | * @param field
17 | * @return
18 | */
19 | boolean isTableField(Field field);
20 |
21 | /**
22 | * 是否为id列
23 | * @param field
24 | * @return
25 | */
26 | boolean isId(Field field);
27 |
28 | /**
29 | * 是否id自增
30 | * @param field
31 | * @return
32 | */
33 | boolean isIdAuto(Field field);
34 |
35 | /**
36 | * 列名
37 | * @param field
38 | * @return
39 | */
40 | String columnName(Field field);
41 |
42 | /**
43 | * 列类型
44 | * @param field
45 | * @return
46 | */
47 | JDBCType jdbcType(Field field);
48 |
49 | /**
50 | * 是否唯一
51 | * @param field
52 | * @return
53 | */
54 | boolean unique(Field field);
55 |
56 | /**
57 | * 是否非空
58 | */
59 | boolean notNull(Field field);
60 |
61 | /**
62 | * 注释信息
63 | * @param declaredField
64 | * @return
65 | */
66 | String comment(Field declaredField);
67 |
68 | /**
69 | * 字段长度
70 | * @param declaredField
71 | * @return
72 | */
73 | Integer length(Field declaredField);
74 |
75 | /**
76 | * 获取列信息
77 | * @param field 属性
78 | * @return
79 | */
80 | default Column getColumn(Field field) {
81 | Column column = null;
82 | if (this.isId(field)) {
83 | Id id = new Id();
84 | id.setAuto(isIdAuto(field));
85 | column = id;
86 | } else {
87 | column = new Column();
88 | }
89 | column.setComment(comment(field));
90 | column.setLength(length(field));
91 | column.setNotNull(notNull(field));
92 | column.setName(columnName(field));
93 | column.setUnique(unique(field));
94 | column.setType(jdbcType(field).name());
95 | return column;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/SecurityUtil.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | import java.util.Random;
4 | import java.util.regex.Matcher;
5 | import java.util.regex.Pattern;
6 |
7 | public class SecurityUtil {
8 |
9 | public static String htmlEncode(String source) {
10 | if (source == null) {
11 | return "";
12 | }
13 | String html = "";
14 | StringBuffer buffer = new StringBuffer();
15 | for (int i = 0; i < source.length(); i++) {
16 | char c = source.charAt(i);
17 | switch (c) {
18 | case '<':
19 | buffer.append("<");
20 | break;
21 | case '>':
22 | buffer.append(">");
23 | break;
24 | case '&':
25 | buffer.append("&");
26 | break;
27 | case '"':
28 | buffer.append(""");
29 | break;
30 | case 10:
31 | case 13:
32 | break;
33 | default:
34 | buffer.append(c);
35 | }
36 | }
37 | html = buffer.toString();
38 | return html;
39 | }
40 |
41 | public static String filterHtml(String source) {
42 | Pattern pattern = Pattern.compile("<([^>]*)>");
43 | Matcher matcher = pattern.matcher(source);
44 | StringBuffer sb = new StringBuffer();
45 | boolean result1 = matcher.find();
46 | while (result1) {
47 | matcher.appendReplacement(sb, "");
48 | result1 = matcher.find();
49 | }
50 | matcher.appendTail(sb);
51 | return sb.toString();
52 | }
53 |
54 | /**
55 | * 获取一定长度的随机字符串
56 | * @param length 指定字符串长度
57 | * @return 一定长度的字符串
58 | */
59 | public static String getRandomString(int length) {
60 | String base = "abcdefghijklmnopqrstuvwxyz0123456789";
61 | Random random = new Random();
62 | StringBuffer sb = new StringBuffer();
63 | for (int i = 0; i < length; i++) {
64 | int number = random.nextInt(base.length());
65 | sb.append(base.charAt(number));
66 | }
67 | return sb.toString();
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/info/impl/JPAColumnInfoAcquirer.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.info.impl;
2 |
3 | import cn.hutool.core.annotation.AnnotationUtil;
4 | import cn.hutool.core.util.ClassUtil;
5 | import org.originit.et.anno.Comment;
6 | import org.originit.et.converter.TypeConverter;
7 | import org.originit.et.info.AbstractColumnInfoAcquirer;
8 | import org.originit.et.info.ColumnInfoAcquirer;
9 | import org.originit.et.jdbc.JDBCType;
10 |
11 | import javax.persistence.*;
12 | import java.lang.reflect.Field;
13 | import java.lang.reflect.Method;
14 | import java.util.Map;
15 |
16 | /**
17 | * @author xxc
18 | */
19 | public class JPAColumnInfoAcquirer extends AbstractColumnInfoAcquirer {
20 |
21 | public JPAColumnInfoAcquirer(Map, TypeConverter> convertRules) {
22 | super(convertRules);
23 | }
24 |
25 |
26 | @Override
27 | public boolean isId(Field field) {
28 | return AnnotationUtil.hasAnnotation(field, Id.class);
29 | }
30 |
31 | @Override
32 | public boolean isIdAuto(Field field) {
33 | final GeneratedValue generatedValue = AnnotationUtil.getAnnotation(field, GeneratedValue.class);
34 | if (generatedValue != null) {
35 | return generatedValue.strategy().equals(GenerationType.AUTO);
36 | }
37 | return false;
38 | }
39 |
40 | @Override
41 | public String columnName(Field field) {
42 | final Column annotation = AnnotationUtil.getAnnotation(field, Column.class);
43 | if (annotation != null) {
44 | return annotation.name();
45 | } else {
46 | return field.getName();
47 | }
48 | }
49 |
50 | @Override
51 | public JDBCType jdbcType(Field field) {
52 | final Class> type = field.getType();
53 | if (!convertRules.containsKey(type)) {
54 | throw new IllegalStateException("请为类型" + type.getName() + "配置TypeConverter");
55 | }
56 | return this.convertRules.get(type).jdbcType();
57 | }
58 |
59 | @Override
60 | public String comment(Field declaredField) {
61 | final Comment annotation = AnnotationUtil.getAnnotation(declaredField,Comment.class);
62 | if (annotation != null) {
63 | return annotation.value();
64 | }
65 | return null;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/test/java/org/originit/crud/pojo/User.java:
--------------------------------------------------------------------------------
1 | package org.originit.crud.pojo;
2 |
3 | import lombok.Data;
4 | import org.originit.crud.anno.Column;
5 | import org.originit.crud.anno.Id;
6 | import org.originit.crud.anno.LogicDelete;
7 | import org.originit.crud.anno.TableName;
8 |
9 | import java.util.Objects;
10 |
11 | @TableName("t_user")
12 | public class User {
13 |
14 | @Id
15 | private Long id;
16 |
17 | private String name;
18 |
19 | private Integer age;
20 |
21 | @LogicDelete
22 | @Column("is_del")
23 | private Boolean isDel;
24 |
25 | public User() {
26 | }
27 |
28 | public User(Long id) {
29 | this.id = id;
30 | }
31 |
32 | public User(Long id, String name) {
33 | this.id = id;
34 | this.name = name;
35 | }
36 |
37 | public User(Long id, String name, Integer age) {
38 | this.id = id;
39 | this.name = name;
40 | this.age = age;
41 | }
42 |
43 | public Long getId() {
44 | return id;
45 | }
46 |
47 | public void setId(Long id) {
48 | this.id = id;
49 | }
50 |
51 | public String getName() {
52 | return name;
53 | }
54 |
55 | public void setName(String name) {
56 | this.name = name;
57 | }
58 |
59 | public Integer getAge() {
60 | return age;
61 | }
62 |
63 | public void setAge(Integer age) {
64 | this.age = age;
65 | }
66 |
67 | public Boolean getIsDel() {
68 | return isDel;
69 | }
70 |
71 | public void setIsDel(Boolean isDel) {
72 | this.isDel = isDel;
73 | }
74 |
75 | @Override
76 | public boolean equals(Object o) {
77 | if (this == o) return true;
78 | if (o == null || getClass() != o.getClass()) return false;
79 | User user = (User) o;
80 | return Objects.equals(id, user.id) && Objects.equals(name, user.name) && Objects.equals(age, user.age) && Objects.equals(isDel, user.isDel);
81 | }
82 |
83 | @Override
84 | public int hashCode() {
85 | return Objects.hash(id, name, age, isDel);
86 | }
87 |
88 | @Override
89 | public String toString() {
90 | return "User{" +
91 | "id=" + id +
92 | ", name='" + name + '\'' +
93 | ", age=" + age +
94 | ", isDel='" + isDel + '\'' +
95 | '}';
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/common-file/common-disk-file-starter/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | common-file
6 | org.originit
7 | 1.0-SNAPSHOT
8 |
9 | 4.0.0
10 | common-disk-file-starter
11 | 1.0-SNAPSHOT
12 | common-disk-file-starter
13 | common-disk-file-starter
14 |
15 |
16 | 1.8
17 | UTF-8
18 | UTF-8
19 |
20 |
21 |
22 |
23 | org.originit
24 | common-file-core
25 | 1.0-SNAPSHOT
26 |
27 |
28 | org.projectlombok
29 | lombok
30 | true
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 | org.junit.vintage
39 | junit-vintage-engine
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | org.apache.maven.plugins
49 | maven-compiler-plugin
50 | 3.8.1
51 |
52 | 1.8
53 | 1.8
54 | UTF-8
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/common-response-starter/src/main/java/com/originit/response/config/ResponseAutoConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.originit.response.config;
2 |
3 |
4 | import com.originit.response.anotation.ResponseResult;
5 | import com.originit.response.property.ResponseProperty;
6 | import com.originit.response.handler.ResponseResultHandler;
7 | import com.originit.response.interceptor.ResponseResultInterceptor;
8 | import com.originit.response.result.PlatformResult;
9 | import com.originit.response.success.DefaultSuccessCodeAcquirer;
10 | import com.originit.response.success.SuccessCodeAcquirer;
11 | import org.springframework.boot.autoconfigure.AutoConfigureAfter;
12 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
13 | import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
14 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
15 | import org.springframework.context.annotation.Bean;
16 | import org.springframework.context.annotation.Configuration;
17 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
18 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
19 |
20 | /**
21 | * 注册拦截器
22 | */
23 | @Configuration
24 | @AutoConfigureAfter(WebMvcAutoConfiguration.class)
25 | @ConditionalOnProperty(prefix = "common.response",name = "enable",havingValue = "true",matchIfMissing = true)
26 | @EnableConfigurationProperties({ResponseProperty.class})
27 | public class ResponseAutoConfiguration implements WebMvcConfigurer {
28 |
29 |
30 | // 添加自定义的MessageConverter
31 | // @Bean
32 | // public HttpMessageConverters customConverts () {
33 | // return new HttpMessageConverters(new FastJsonHttpMessageConverter());
34 | // }
35 | private ResponseProperty responseProperty;
36 |
37 | public ResponseAutoConfiguration(ResponseProperty responseProperty) {
38 | this.responseProperty = responseProperty;
39 | }
40 |
41 | @Override
42 | public void addInterceptors(InterceptorRegistry registry) {
43 | registry.addInterceptor(new ResponseResultInterceptor(responseProperty)).addPathPatterns("/**");
44 | }
45 |
46 | @Bean
47 | public ResponseResultHandler responseResultHandler() {
48 | return new ResponseResultHandler();
49 | }
50 |
51 | @Bean
52 | public SuccessCodeAcquirer successCodeAcquirer() {
53 | return new DefaultSuccessCodeAcquirer();
54 | }
55 | }
--------------------------------------------------------------------------------
/common-file/common-file-core/src/main/java/org/originit/common/file/AbstractFileUploader.java:
--------------------------------------------------------------------------------
1 | package org.originit.common.file;
2 |
3 | import com.originit.common.utils.StringUtil;
4 | import org.originit.common.file.entity.ContextInfo;
5 | import org.originit.common.file.entity.FileInfo;
6 | import org.originit.common.file.entity.UploadConfig;
7 | import org.originit.common.file.entity.UploadResult;
8 |
9 | import java.util.Arrays;
10 | import java.util.HashSet;
11 | import java.util.Set;
12 |
13 | /**
14 | * 抽象
15 | * @author xxc
16 | */
17 | public abstract class AbstractFileUploader implements FileUploaderDeprecated {
18 |
19 | protected FileUploadStrategy strategy;
20 |
21 | protected FileFilter filter;
22 |
23 | public final Set IMAGE_TYPES = new HashSet<>(Arrays.asList("bmp","jpg","jpeg","png","gif"));
24 |
25 | public void setStrategy(FileUploadStrategy strategy) {
26 | this.strategy = strategy;
27 | }
28 |
29 | public void setFilter(FileFilter filter) {
30 | this.filter = filter;
31 | }
32 |
33 | @Override
34 | public UploadResult upload(FileInfo file, UploadConfig config) {
35 | if (file == null || file.getSize() <= 0) {
36 | throw new IllegalArgumentException("文件为空!");
37 | }
38 | // 获取文件的后缀以及判断是否是图片
39 | final String suffix = resolveSuffix(file);
40 | ContextInfo contextInfo = new ContextInfo();
41 | contextInfo.setSuffix(suffix);
42 | contextInfo.setIsImg(IMAGE_TYPES.contains(suffix.toLowerCase()));
43 | // 过滤不合法的文件
44 | filter.doFilter(file,config,contextInfo);
45 | // 选择具体的方法进行上传保存
46 | return onUpload(strategy,file,config,contextInfo);
47 | }
48 |
49 | private String resolveSuffix(FileInfo file) {
50 |
51 | int dotIndex = -1;
52 | if (!StringUtil.isEmpty(file.getOriginalFileName())) {
53 | dotIndex = file.getOriginalFileName().lastIndexOf(".");
54 | }
55 | if (dotIndex != -1) {
56 | return file.getOriginalFileName().substring(dotIndex + 1);
57 | }
58 | return "";
59 | }
60 |
61 | /**
62 | * 过滤完成后进行上传
63 | *
64 | * @param strategy 上传策略
65 | * @param file 文件
66 | * @param config 配置
67 | * @param info
68 | * @return 上传结果
69 | */
70 | protected abstract UploadResult onUpload(FileUploadStrategy strategy, FileInfo file, UploadConfig config, ContextInfo info);
71 | }
72 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | org.originit
6 | entity2table
7 | 1.0-SNAPSHOT
8 |
9 |
10 | entity2table-core
11 | jar
12 |
13 | entity2table-core
14 | http://maven.apache.org
15 |
16 |
17 | UTF-8
18 |
19 |
20 |
21 |
22 | junit
23 | junit
24 | 4.13.2
25 | test
26 |
27 |
28 | org.projectlombok
29 | lombok
30 |
31 |
32 | cn.hutool
33 | hutool-all
34 |
35 |
36 | com.google.guava
37 | guava
38 | 22.0
39 |
40 |
41 | org.reflections
42 | reflections
43 | 0.9.10
44 |
45 |
46 | org.javassist
47 | javassist
48 | 3.15.0-GA
49 |
50 |
51 | javax.persistence
52 | persistence-api
53 | 1.0.2
54 |
55 |
56 | org.springframework.boot
57 | spring-boot-starter-freemarker
58 |
59 |
60 | mysql
61 | mysql-connector-java
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/util/TemplateUtil.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.util;
2 |
3 | import freemarker.template.Configuration;
4 | import freemarker.template.TemplateException;
5 | import freemarker.template.TemplateExceptionHandler;
6 | import lombok.extern.slf4j.Slf4j;
7 |
8 | import java.io.IOException;
9 | import java.io.StringWriter;
10 | import java.util.HashMap;
11 | import java.util.Map;
12 |
13 | @Slf4j
14 | public class TemplateUtil {
15 |
16 | private static Configuration configuration;
17 |
18 | public synchronized static Configuration configuration() {
19 | if (configuration != null) {
20 | return configuration;
21 | }
22 | // Create your Configuration instance, and specify if up to what FreeMarker
23 | // version (here 2.3.22) do you want to apply the fixes that are not 100%
24 | // backward-compatible. See the Configuration JavaDoc for details.
25 | Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
26 |
27 | // Specify the source where the template files come from. Here I set a
28 | // plain directory for it, but non-file-system sources are possible too:
29 | cfg.setClassForTemplateLoading(TemplateUtil.class,"/template");
30 |
31 | // Set the preferred charset template files are stored in. UTF-8 is
32 | // a good choice in most applications:
33 | cfg.setDefaultEncoding("UTF-8");
34 |
35 | // Sets how errors will appear.
36 | // During web page *development* TemplateExceptionHandler.HTML_DEBUG_HANDLER is better.
37 | cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
38 | configuration = cfg;
39 | return configuration;
40 | }
41 |
42 |
43 | public static String getTemplate(String template, Object model) {
44 | final StringWriter stringWriter = new StringWriter();
45 | try {
46 | Map root = new HashMap<>(1);
47 | root.put("model", model);
48 | configuration().getTemplate(template).process(root, stringWriter);
49 | } catch (TemplateException e) {
50 | log.error("模板异常, path: {}, msg: {}", template, e.getMessage());
51 | throw new RuntimeException(e);
52 | } catch (IOException e) {
53 | log.error("模板文件异常, path: {}, msg: {}", template, e.getMessage());
54 | throw new RuntimeException(e);
55 | }
56 | return stringWriter.toString();
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/common-file/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | web-common
7 | org.originit
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | common-file
13 | pom
14 |
15 | common-file
16 |
17 | common-file-core
18 | common-disk-file-starter
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework
30 | spring-context
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 |
36 |
37 | org.projectlombok
38 | lombok
39 | true
40 |
41 |
42 | org.springframework.boot
43 | spring-boot-configuration-processor
44 | true
45 |
46 |
47 | org.originit
48 | common
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.originit
56 | common-file-core
57 | 1.0-SNAPSHOT
58 |
59 |
60 | org.originit
61 | common-dfs-file-starter
62 | 1.0-SNAPSHOT
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/common-response-starter/src/main/java/com/originit/response/handler/ResponseResultHandler.java:
--------------------------------------------------------------------------------
1 | package com.originit.response.handler;
2 |
3 |
4 | import cn.hutool.json.JSONUtil;
5 | import com.originit.common.utils.RequestContextHolderUtil;
6 | import com.originit.response.constant.Const;
7 | import com.originit.response.property.ResponseProperty;
8 | import com.originit.response.result.Result;
9 | import com.originit.response.result.SimpleData;
10 | import org.springframework.beans.BeanUtils;
11 | import org.springframework.beans.factory.annotation.Autowired;
12 | import org.springframework.core.MethodParameter;
13 | import org.springframework.http.MediaType;
14 | import org.springframework.http.server.ServerHttpRequest;
15 | import org.springframework.http.server.ServerHttpResponse;
16 | import org.springframework.web.bind.annotation.ControllerAdvice;
17 | import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
18 |
19 | @ControllerAdvice
20 | public class ResponseResultHandler implements ResponseBodyAdvice {
21 |
22 | @Autowired
23 | ResponseProperty property;
24 |
25 | @Override
26 | public boolean supports(MethodParameter returnType, Class converterType) {
27 | Class type = (Class) RequestContextHolderUtil.getRequest().getAttribute(Const.RESPONSE_RESULT);
28 | return type != null && (returnType.getParameterType() == String.class || !BeanUtils.isSimpleProperty(returnType.getParameterType()));
29 | }
30 |
31 | @Override
32 | public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
33 | Class type = (Class) RequestContextHolderUtil.getRequest().getAttribute(Const.RESPONSE_RESULT);
34 | // 如果是Result类型的就不包装了
35 | if(body instanceof Result) {
36 | return body;
37 | }
38 | //如果是通用响应类则进行创建返回
39 | try {
40 | if (returnType.getParameterType() == SimpleData.class) {
41 | return type.getConstructor(Object.class).newInstance(((SimpleData) body).getData());
42 | }
43 | if (returnType.getParameterType() == String.class) {
44 | return JSONUtil.toJsonStr(type.getConstructor(Object.class).newInstance(body));
45 | }
46 | return type.getConstructor(Object.class).newInstance(body);
47 | } catch (Exception e) {
48 | throw new IllegalStateException("Result的子类必须包含一个只有一个Object类型的构造器用于构造成功请求",e);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/common-exception-starter/src/main/java/org/originit/exception/enums/InnerResultCode.java:
--------------------------------------------------------------------------------
1 | package org.originit.exception.enums;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | /**
7 | * @desc API 内部统一返回状态码
8 | * 为了不与用户的code冲突,以1111为前缀
9 | * @since 9/20/2018
10 | */
11 | public enum InnerResultCode {
12 |
13 | /* 参数错误:10001-19999 */
14 | PARAM_IS_INVALID(111110001, "参数无效"),
15 |
16 | /* 系统错误:40001-49999 */
17 | SYSTEM_INNER_ERROR(111140001, "系统繁忙,请稍后重试"),
18 | REQUEST_ERROR(111140002, "请求错误!"),
19 | REQUEST_METHOD_ERROR(111140003, "请求方法不支持!"),
20 |
21 |
22 | /* 权限错误:70001-79999 */
23 | PERMISSION_INVAILD(111170001,"权限异常"),
24 | TOKEN_NOT_FOUND(111170002,"未找到token信息"),
25 |
26 | INVALID_TOKEN_ERROR(111170003,"token信息异常"),
27 | TOKEN_EXPIRED(111170004,"token已过期"),
28 | /**
29 | * 状态异常
30 | *
31 | */
32 | ILLEGAL_STATE(111180001, "状态异常");
33 |
34 | private Integer code;
35 |
36 | private String message;
37 |
38 | InnerResultCode(Integer code, String message) {
39 | this.code = code;
40 | this.message = message;
41 | }
42 |
43 | public Integer code() {
44 | return this.code;
45 | }
46 |
47 | public String message() {
48 | return this.message;
49 | }
50 |
51 | public static String getMessage(String name) {
52 | for (InnerResultCode item : InnerResultCode.values()) {
53 | if (item.name().equals(name)) {
54 | return item.message;
55 | }
56 | }
57 | return name;
58 | }
59 |
60 | public static Integer getCode(String name) {
61 | for (InnerResultCode item : InnerResultCode.values()) {
62 | if (item.name().equals(name)) {
63 | return item.code;
64 | }
65 | }
66 | return null;
67 | }
68 |
69 | @Override
70 | public String toString() {
71 | return this.name();
72 | }
73 |
74 | /***
75 | * 校验重复的code值
76 | */
77 | static void main(String[] args) {
78 | InnerResultCode[] apiResultCodes = InnerResultCode.values();
79 | List codeList = new ArrayList();
80 | for (InnerResultCode apiResultCode : apiResultCodes) {
81 | if (codeList.contains(apiResultCode.code)) {
82 | System.out.println(apiResultCode.code);
83 | } else {
84 | codeList.add(apiResultCode.code());
85 | }
86 |
87 | System.out.println(apiResultCode.code() + " " + apiResultCode.message());
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/common/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | web-common
6 | org.originit
7 | 1.0-SNAPSHOT
8 |
9 | 4.0.0
10 |
11 | common
12 |
13 | common
14 |
15 |
16 |
17 | com.auth0
18 | java-jwt
19 | 4.0.0
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-web
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-test
28 | test
29 |
30 |
31 | junit
32 | junit
33 | test
34 |
35 |
36 | org.hibernate.validator
37 | hibernate-validator
38 | 6.1.5.Final
39 |
40 |
41 | org.projectlombok
42 | lombok
43 | 1.18.16
44 |
45 |
46 | org.apache.commons
47 | commons-lang3
48 | 3.5
49 |
50 |
51 | cn.hutool
52 | hutool-all
53 | 4.5.7
54 |
55 |
56 | commons-io
57 | commons-io
58 | 2.11.0
59 |
60 |
61 |
62 |
63 | UTF-8
64 | 1.8
65 | 1.8
66 |
67 |
68 |
--------------------------------------------------------------------------------
/entity2table/mp2table_acquirer/src/main/java/org/originit/et/mp/MPColumnInfoAcquirer.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.mp;
2 |
3 | import cn.hutool.core.annotation.AnnotationUtil;
4 | import com.baomidou.mybatisplus.annotation.IdType;
5 | import com.baomidou.mybatisplus.annotation.TableField;
6 | import com.baomidou.mybatisplus.annotation.TableId;
7 | import io.swagger.annotations.ApiModelProperty;
8 | import org.originit.et.converter.TypeConverter;
9 | import org.originit.et.info.AbstractColumnInfoAcquirer;
10 |
11 | import javax.persistence.Column;
12 | import java.lang.reflect.Field;
13 | import java.util.Map;
14 |
15 | /**
16 | * @author xxc
17 | */
18 | public class MPColumnInfoAcquirer extends AbstractColumnInfoAcquirer {
19 |
20 | private Map,TypeConverter> convertRules;
21 |
22 | public MPColumnInfoAcquirer(Map, TypeConverter> convertRules) {
23 | super(convertRules);
24 | }
25 |
26 | @Override
27 | public boolean isId(Field field) {
28 | return AnnotationUtil.hasAnnotation(field, TableId.class);
29 | }
30 |
31 | @Override
32 | public boolean isIdAuto(Field field) {
33 | final TableId generatedValue = AnnotationUtil.getAnnotation(field, TableId.class);
34 | if (generatedValue != null) {
35 | return generatedValue.value().equals(IdType.AUTO);
36 | }
37 | return false;
38 | }
39 | @Override
40 | public String columnName(Field field) {
41 | final TableField annotation = AnnotationUtil.getAnnotation(field, TableField.class);
42 | if (annotation != null) {
43 | return annotation.value();
44 | } else {
45 | return field.getName();
46 | }
47 | }
48 |
49 |
50 | @Override
51 | public boolean unique(Field field) {
52 | final Column annotation = AnnotationUtil.getAnnotation(field, Column.class);
53 | if (annotation == null) {
54 | return false;
55 | }
56 | return annotation.unique();
57 | }
58 |
59 | @Override
60 | public boolean notNull(Field field) {
61 | final Column annotation = AnnotationUtil.getAnnotation(field, Column.class);
62 | if (annotation == null) {
63 | return false;
64 | }
65 | final boolean nullable = annotation.nullable();
66 | return !nullable;
67 | }
68 |
69 | @Override
70 | public String comment(Field declaredField) {
71 | final ApiModelProperty annotation = AnnotationUtil.getAnnotation(declaredField, ApiModelProperty.class);
72 | if (annotation != null) {
73 | return annotation.value();
74 | }
75 | return null;
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### JetBrains template
3 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
4 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
5 |
6 | # User-specific stuff
7 | .idea/**/workspace.xml
8 | .idea/**/tasks.xml
9 | .idea/**/usage.statistics.xml
10 | .idea/**/dictionaries
11 | .idea/**/shelf
12 |
13 | # Generated files
14 | .idea/**/contentModel.xml
15 | .idea
16 | .idea/**
17 | # Sensitive or high-churn files
18 | .idea/**/dataSources/
19 | .idea/**/dataSources.ids
20 | .idea/**/dataSources.local.xml
21 | .idea/**/sqlDataSources.xml
22 | .idea/**/dynamic.xml
23 | .idea/**/uiDesigner.xml
24 | .idea/**/dbnavigator.xml
25 |
26 | # Gradle
27 | .idea/**/gradle.xml
28 | .idea/**/libraries
29 |
30 | # Gradle and Maven with auto-import
31 | # When using Gradle or Maven with auto-import, you should exclude module files,
32 | # since they will be recreated, and may cause churn. Uncomment if using
33 | # auto-import.
34 | # .idea/modules.xml
35 | # .idea/*.iml
36 | # .idea/modules
37 | # *.iml
38 | # *.ipr
39 |
40 | # CMake
41 | cmake-build-*/
42 |
43 | # Mongo Explorer plugin
44 | .idea/**/mongoSettings.xml
45 |
46 | # File-based project format
47 | *.iws
48 |
49 | # IntelliJ
50 | out/
51 |
52 | # mpeltonen/sbt-idea plugin
53 | .idea_modules/
54 |
55 | # JIRA plugin
56 | atlassian-ide-plugin.xml
57 |
58 | # Cursive Clojure plugin
59 | .idea/replstate.xml
60 |
61 | # Crashlytics plugin (for Android Studio and IntelliJ)
62 | com_crashlytics_export_strings.xml
63 | crashlytics.properties
64 | crashlytics-build.properties
65 | fabric.properties
66 |
67 | # Editor-based Rest Client
68 | .idea/httpRequests
69 |
70 | # Android studio 3.1+ serialized cache file
71 | .idea/caches/build_file_checksums.ser
72 |
73 | ### Maven template
74 | target/
75 | pom.xml.tag
76 | pom.xml.releaseBackup
77 | pom.xml.versionsBackup
78 | pom.xml.next
79 | release.properties
80 | dependency-reduced-pom.xml
81 | buildNumber.properties
82 | .mvn/timing.properties
83 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar
84 | .mvn/wrapper/maven-wrapper.jar
85 |
86 | ### Java template
87 | # Compiled class file
88 | *.class
89 |
90 | # Log file
91 | *.log
92 |
93 | # BlueJ files
94 | *.ctxt
95 |
96 | # Mobile Tools for Java (J2ME)
97 | .mtj.tmp/
98 |
99 | # Package Files #
100 | *.jar
101 | *.war
102 | *.nar
103 | *.ear
104 | *.zip
105 | *.tar.gz
106 | *.rar
107 |
108 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
109 | hs_err_pid*
110 |
111 | ibderby
112 | */ibderby
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/PropertiesUtil.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | import java.io.*;
4 | import java.net.URI;
5 | import java.util.HashMap;
6 | import java.util.Map;
7 | import java.util.Properties;
8 |
9 | public class PropertiesUtil {
10 |
11 | private static Map propMap = new HashMap();
12 |
13 | /*设置默认的properties文件,方便操作*/
14 | public static final String DEFAULT_PROPERTIES_FILE="application.properties";
15 |
16 | public static Object getProperty(String file,String key){
17 | Properties prop = getProperties(file);
18 | if(prop != null && prop.get(key) != null){
19 | return prop.get(key);
20 | }
21 | return null;
22 | }
23 |
24 | public static Properties getProperties(String file){
25 | try {
26 | if(propMap.get(file) == null){
27 | Properties prop = new Properties();
28 | prop.load(PropertiesUtil.class.getClassLoader().getResourceAsStream(file));
29 | propMap.put(file,prop);
30 | return prop;
31 | }else{
32 | return propMap.get(file);
33 | }
34 | } catch (IOException e) {
35 | e.printStackTrace();
36 | }
37 | return null;
38 | }
39 |
40 | public static void updateProperties(Properties prop,String filePath){
41 |
42 | FileInputStream fis = null;
43 | BufferedInputStream bis = null;
44 | try {
45 | URI fileUri = PropertiesUtil.class.getClassLoader().getResource(filePath).toURI();
46 | File file = new File(fileUri);
47 |
48 | Properties tmpProp = new Properties();
49 | fis = new FileInputStream(file);
50 | bis = new BufferedInputStream(fis);
51 | tmpProp.load(bis);
52 |
53 | FileOutputStream fos = new FileOutputStream(file);
54 | for(Object key : prop.keySet()){
55 | tmpProp.setProperty(String.valueOf(key),String.valueOf(prop.get(key)));
56 | }
57 | tmpProp.store(fos, null);
58 | fis.close();
59 | fos.close();
60 | } catch (Exception e) {
61 | e.printStackTrace();
62 | }
63 | }
64 |
65 | /**
66 | * 从默认配置文件中获取properties
67 | * @return
68 | */
69 | public static Properties getDefaultProperties(){
70 | return getProperties(DEFAULT_PROPERTIES_FILE);
71 | }
72 |
73 | /**
74 | * 从默认配置文件中获取配置项
75 | * @param key
76 | * @return
77 | */
78 | public static String getProperty(String key){
79 | Properties prop = getDefaultProperties();
80 | if(prop != null && prop.get(key) != null){
81 | return prop.getProperty(key);
82 | }
83 | return null;
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/test/kotlin/org/originit/crud/BaseDataTest.java:
--------------------------------------------------------------------------------
1 | package org.originit.crud;
2 |
3 | import org.apache.ibatis.datasource.pooled.PooledDataSource;
4 | import org.apache.ibatis.datasource.unpooled.UnpooledDataSource;
5 | import org.apache.ibatis.io.Resources;
6 | import org.apache.ibatis.jdbc.ScriptRunner;
7 |
8 | import javax.sql.DataSource;
9 | import java.io.IOException;
10 | import java.io.PrintWriter;
11 | import java.io.Reader;
12 | import java.sql.Connection;
13 | import java.sql.SQLException;
14 | import java.util.Properties;
15 |
16 | public abstract class BaseDataTest {
17 |
18 | public static final String BLOG_PROPERTIES = "sql/blog-derby.properties";
19 | public static final String BLOG_DDL = "sql/test-schema.sql";
20 | public static final String BLOG_DATA = "sql/test-dataload.sql";
21 |
22 |
23 | public static UnpooledDataSource createUnpooledDataSource(String resource) throws IOException {
24 | Properties props = Resources.getResourceAsProperties(resource);
25 | UnpooledDataSource ds = new UnpooledDataSource();
26 | ds.setDriver(props.getProperty("driver"));
27 | ds.setUrl(props.getProperty("url"));
28 | ds.setUsername(props.getProperty("username"));
29 | ds.setPassword(props.getProperty("password"));
30 | return ds;
31 | }
32 |
33 | public static PooledDataSource createPooledDataSource(String resource) throws IOException {
34 | Properties props = Resources.getResourceAsProperties(resource);
35 | PooledDataSource ds = new PooledDataSource();
36 | ds.setDriver(props.getProperty("driver"));
37 | ds.setUrl(props.getProperty("url"));
38 | ds.setUsername(props.getProperty("username"));
39 | ds.setPassword(props.getProperty("password"));
40 | return ds;
41 | }
42 |
43 | public static void runScript(DataSource ds, String resource) throws IOException, SQLException, SQLException {
44 | Connection connection = ds.getConnection();
45 | try {
46 | ScriptRunner runner = new ScriptRunner(connection);
47 | runner.setAutoCommit(true);
48 | runner.setStopOnError(true);
49 | runner.setLogWriter(new PrintWriter(System.out));
50 | runner.setErrorLogWriter(new PrintWriter(System.out));
51 | runScript(runner, resource);
52 | } finally {
53 | connection.close();
54 | }
55 | }
56 |
57 | public static void runScript(ScriptRunner runner, String resource) throws IOException, SQLException, IOException {
58 | Reader reader = Resources.getResourceAsReader(resource);
59 | try {
60 | runner.runScript(reader);
61 | } finally {
62 | reader.close();
63 | }
64 | }
65 |
66 | public static DataSource createBlogDataSource() throws IOException, SQLException {
67 | DataSource ds = createUnpooledDataSource(BLOG_PROPERTIES);
68 | runScript(ds, BLOG_DDL);
69 | runScript(ds, BLOG_DATA);
70 | return ds;
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/common-response-starter/src/main/java/com/originit/response/interceptor/ResponseResultInterceptor.java:
--------------------------------------------------------------------------------
1 | package com.originit.response.interceptor;
2 |
3 |
4 | import com.originit.response.anotation.OriginResponse;
5 | import com.originit.response.anotation.ResponseResult;
6 | import com.originit.response.constant.Const;
7 | import com.originit.response.property.ResponseProperty;
8 | import com.originit.response.result.PlatformResult;
9 | import org.springframework.web.bind.annotation.ResponseBody;
10 | import org.springframework.web.bind.annotation.RestController;
11 | import org.springframework.web.method.HandlerMethod;
12 | import org.springframework.web.servlet.HandlerInterceptor;
13 | import org.springframework.web.servlet.ModelAndView;
14 |
15 | import javax.servlet.http.HttpServletRequest;
16 | import javax.servlet.http.HttpServletResponse;
17 |
18 | public class ResponseResultInterceptor implements HandlerInterceptor {
19 |
20 | private final ResponseProperty responseProperty;
21 |
22 | public ResponseResultInterceptor(ResponseProperty responseProperty) {
23 | this.responseProperty = responseProperty;
24 | }
25 |
26 | @Override
27 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object originHandler) {
28 | if(originHandler instanceof HandlerMethod)
29 | {
30 | HandlerMethod handler = (HandlerMethod) originHandler;
31 | // 如果有@OriginResponse注解将不拦截
32 | if(handler.getMethod().isAnnotationPresent(OriginResponse.class)) {
33 | return true;
34 | }
35 | //如果调用的Controller的方法或Controller类上使用了ResponseResult注解,
36 | // 则将响应类型放入请求
37 | boolean isJson = (handler.getBeanType().isAnnotationPresent(RestController.class) ||
38 | handler.getMethod().isAnnotationPresent(ResponseBody.class) ||
39 | handler.getBeanType().isAnnotationPresent(ResponseBody.class)) && !handler.getMethod().getReturnType().isAssignableFrom(ModelAndView.class);
40 | boolean isResult = handler.getBeanType().isAnnotationPresent(ResponseResult.class)
41 | || handler.getMethod().isAnnotationPresent(ResponseResult.class);
42 | if(isJson && isResult)
43 | {
44 | ResponseResult type = handler.getBeanType().getAnnotation(ResponseResult.class);
45 | if(type == null) {
46 | type = handler.getMethod().getAnnotation(ResponseResult.class);
47 | }
48 | if (type == null) {
49 | // 默认用这个
50 | request.setAttribute(Const.RESPONSE_RESULT, PlatformResult.class);
51 | } else {
52 | request.setAttribute(Const.RESPONSE_RESULT,type.value());
53 | }
54 | }
55 | }
56 | return true;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/common-user-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | web-common
7 | org.originit
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | common-user-service
13 |
14 | common-user-service
15 |
16 | http://www.example.com
17 |
18 |
19 | UTF-8
20 | 1.8
21 | 1.8
22 |
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.originit
31 | common-response-starter
32 |
33 |
34 | org.originit
35 | common-exception-starter
36 |
37 |
38 | org.originit
39 | common-logger-starter
40 |
41 |
42 | org.originit
43 | common
44 |
45 |
46 | org.springframework.boot
47 | spring-boot-starter-test
48 | test
49 |
50 |
51 | org.junit.vintage
52 | junit-vintage-engine
53 |
54 |
55 |
56 |
57 | com.baomidou
58 | mybatis-plus-boot-starter
59 |
60 |
61 | org.mybatis.spring.boot
62 | mybatis-spring-boot-starter
63 |
64 |
65 |
66 | mysql
67 | mysql-connector-java
68 | runtime
69 |
70 |
71 | org.projectlombok
72 | lombok
73 | true
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/HttpUtil.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | import org.apache.commons.lang3.StringUtils;
4 |
5 | import javax.servlet.http.HttpServletRequest;
6 | import javax.servlet.http.HttpServletResponse;
7 | import java.io.IOException;
8 |
9 |
10 | /**
11 | * http工具类
12 | */
13 | public class HttpUtil extends org.springframework.web.util.WebUtils{
14 |
15 | public static String getDomain(HttpServletRequest request){
16 | return request.getServerName();
17 | }
18 |
19 | public static String getHttpDomain(HttpServletRequest request){
20 | return request.getScheme() + "://" + request.getServerName();
21 | }
22 |
23 | public static String getContextHttpUri(HttpServletRequest request){
24 | return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
25 | }
26 |
27 | public static String getRealPath(HttpServletRequest request){
28 | return request.getSession().getServletContext().getRealPath("/");
29 | }
30 |
31 | public static String getRequestFullUri(HttpServletRequest request){
32 | String port = "";
33 | if(request.getServerPort() != 80){
34 | port = ":" + request.getServerPort();
35 | }
36 | return request.getScheme() + "://" + request.getServerName() + port + request.getContextPath() + request.getServletPath();
37 | }
38 |
39 | public static String getRequestFullUriNoContextPath(HttpServletRequest request){
40 | String port = "";
41 | if(request.getServerPort() != 80){
42 | port = ":" + request.getServerPort();
43 | }
44 | return request.getScheme() + "://" + request.getServerName() + port + request.getServletPath();
45 | }
46 |
47 | //获取ip地址;
48 | public static String getIpAddr(HttpServletRequest request) {
49 | String ip = request.getHeader("X-Forwarded-For");
50 | if (StringUtils.isNotEmpty(ip) && !"unKnown".equalsIgnoreCase(ip)) {
51 | if(ip.indexOf("::ffff:")!=-1) ip = ip.replace("::ffff:", "");
52 | int index = ip.indexOf(",");
53 | if (index != -1) {
54 | return ip.substring(0, index);
55 | } else {
56 | return ip;
57 | }
58 | }
59 | ip = request.getHeader("X-Real-IP");
60 | if (StringUtils.isNotEmpty(ip) && !"unKnown".equalsIgnoreCase(ip)) {
61 | return ip;
62 | }
63 | return request.getRemoteAddr();
64 | }
65 |
66 | //判断当前请求是否为Ajax
67 | public static boolean isAjaxRequest(HttpServletRequest request) {
68 | String header = request.getHeader("X-Requested-With");
69 | return !StringUtils.isEmpty(header) && "XMLHttpRequest".equals(header);
70 | }
71 |
72 | /**
73 | * 重定向
74 | * @param httpServletRequest
75 | * @param httpServletResponse
76 | * @param url
77 | */
78 | public static void redirectUrl(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String url){
79 | try {
80 | httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + url);
81 | } catch (IOException e) {
82 | e.printStackTrace();
83 | }
84 | }
85 |
86 | /**
87 | * 重定向到http://的url
88 | * @param httpServletRequest
89 | * @param httpServletResponse
90 | * @param url
91 | */
92 | public static void redirectHttpUrl(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String url){
93 | try {
94 | httpServletResponse.sendRedirect(url);
95 | } catch (IOException e) {
96 | e.printStackTrace();
97 | }
98 | }
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/common-file/common-file-core/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | common-file
7 | org.originit
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | common-file-core
13 |
14 | common-file-core
15 |
16 | http://www.example.com
17 |
18 |
19 | UTF-8
20 | 1.8
21 | 1.8
22 |
23 |
24 |
25 |
26 | junit
27 | junit
28 | 4.11
29 | test
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | maven-clean-plugin
39 | 3.1.0
40 |
41 |
42 |
43 | maven-resources-plugin
44 | 3.0.2
45 |
46 |
47 | maven-compiler-plugin
48 | 3.8.0
49 |
50 |
51 | maven-surefire-plugin
52 | 2.22.1
53 |
54 |
55 | maven-jar-plugin
56 | 3.0.2
57 |
58 |
59 | maven-install-plugin
60 | 2.5.2
61 |
62 |
63 | maven-deploy-plugin
64 | 2.8.2
65 |
66 |
67 |
68 | maven-site-plugin
69 | 3.7.1
70 |
71 |
72 | maven-project-info-reports-plugin
73 | 3.0.0
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/DateUtil.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | import java.text.ParseException;
4 | import java.text.SimpleDateFormat;
5 | import java.time.LocalDateTime;
6 | import java.util.Calendar;
7 | import java.util.Date;
8 |
9 | /**
10 | * 日期工具类
11 | */
12 |
13 | public class DateUtil {
14 |
15 | private final SimpleDateFormat format;
16 |
17 | public DateUtil(SimpleDateFormat format) {
18 | this.format = format;
19 | }
20 |
21 | public SimpleDateFormat getFormat() {
22 | return format;
23 | }
24 |
25 | // 紧凑型日期格式,也就是纯数字类型yyyyMMdd
26 | public static final DateUtil COMPAT = new DateUtil(new SimpleDateFormat("yyyyMMdd"));
27 |
28 | // 紧凑型日期格式,也就是纯数字类型yyyyMMdd
29 | public static final DateUtil COMPAT_FULL = new DateUtil(new SimpleDateFormat("yyyyMMddHHmmss"));
30 |
31 | // 常用日期格式,yyyy-MM-dd
32 | public static final DateUtil COMMON = new DateUtil(new SimpleDateFormat("yyyy-MM-dd"));
33 | public static final DateUtil COMMON_FULL = new DateUtil(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
34 |
35 | // 使用斜线分隔的,西方多采用,yyyy/MM/dd
36 | public static final DateUtil SLASH = new DateUtil(new SimpleDateFormat("yyyy/MM/dd"));
37 |
38 | // 中文日期格式常用,yyyy年MM月dd日
39 | public static final DateUtil CHINESE = new DateUtil(new SimpleDateFormat("yyyy年MM月dd日"));
40 | public static final DateUtil CHINESE_FULL = new DateUtil(new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒"));
41 | /**
42 | * 日期获取字符串
43 | */
44 | public String getDateText(Date date) {
45 | return getFormat().format(date);
46 | }
47 |
48 | /**
49 | * 字符串获取日期
50 | * @throws ParseException
51 | */
52 | public Date getTextDate(String text) throws ParseException {
53 | return getFormat().parse(text);
54 | }
55 |
56 | /**
57 | * 日期获取字符串
58 | */
59 | public static String getDateText(Date date, String format) {
60 | return new SimpleDateFormat(format).format(date);
61 | }
62 |
63 | /**
64 | * 字符串获取日期
65 | * @throws ParseException
66 | */
67 | public static Date getTextDate(String dateText, String format) throws ParseException {
68 | return new SimpleDateFormat(format).parse(dateText);
69 | }
70 |
71 | /**
72 | * 根据日期,返回其星期数,周一为1,周日为7
73 | * @param date
74 | * @return
75 | */
76 | public static int getWeekDay(Date date) {
77 | Calendar calendar = Calendar.getInstance();
78 | calendar.setTime(date);
79 | int w = calendar.get(Calendar.DAY_OF_WEEK);
80 | int ret;
81 | if (w == Calendar.SUNDAY)
82 | ret = 7;
83 | else
84 | ret = w - 1;
85 | return ret;
86 | }
87 |
88 | public static int getAge(Date birthday) {
89 | Calendar calendar = Calendar.getInstance();
90 | if (calendar.before(birthday)) {
91 | throw new IllegalArgumentException("出生时间大于当前时间!");
92 | }
93 | int yearNow = calendar.get(Calendar.YEAR);
94 | int monthNow = calendar.get(Calendar.MONTH) + 1;// 注意此处,如果不加1的话计算结果是错误的
95 | int dayOfMonthNow = calendar.get(Calendar.DAY_OF_MONTH);
96 | calendar.setTime(birthday);
97 | int yearBirth = calendar.get(Calendar.YEAR);
98 | int monthBirth = calendar.get(Calendar.MONTH);
99 | int dayOfMonthBirth = calendar.get(Calendar.DAY_OF_MONTH);
100 | int age = yearNow - yearBirth;
101 | if (monthNow < monthBirth ||(monthNow == monthBirth && dayOfMonthNow < dayOfMonthBirth)) {
102 | age--;
103 | }
104 | return age;
105 | }
106 |
107 |
108 | /**
109 | * 现在是否是月初
110 | * @return
111 | */
112 | public static boolean isMonth_1st() {
113 | return LocalDateTime.now().getDayOfMonth() == 1;
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/demo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | web-common
7 | org.originit
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | demo
13 |
14 | demo
15 |
16 | http://www.example.com
17 |
18 |
19 | UTF-8
20 | 1.8
21 | 1.8
22 |
23 |
24 |
25 |
26 | org.originit
27 | common-web-starter
28 | 1.0-SNAPSHOT
29 |
30 |
31 | org.originit
32 | common-response-starter
33 | 1.0-SNAPSHOT
34 |
35 |
36 | org.springframework.boot
37 | spring-boot-starter-web
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-actuator
42 |
43 |
44 | org.springframework.boot
45 | spring-boot-test
46 | test
47 |
48 |
49 | org.mockito
50 | mockito-core
51 | test
52 |
53 |
54 | org.originit
55 | common
56 |
57 |
58 | junit
59 | junit
60 | test
61 |
62 |
63 | org.springframework
64 | spring-test
65 | test
66 |
67 |
68 | org.originit
69 | common-logger-starter
70 |
71 |
72 | org.springframework.boot
73 | spring-boot-configuration-processor
74 | true
75 |
76 |
77 |
78 |
79 |
80 | org.springframework.boot
81 | spring-boot-maven-plugin
82 |
83 |
84 |
85 | org.springframework.boot
86 | spring-boot-configuration-processor
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/ResourceUtil.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | import cn.hutool.core.io.IoUtil;
4 | import lombok.extern.slf4j.Slf4j;
5 | import org.springframework.core.io.ClassPathResource;
6 | import org.springframework.http.*;
7 | import sun.misc.BASE64Encoder;
8 |
9 | import javax.servlet.http.HttpServletResponse;
10 | import java.io.File;
11 | import java.io.IOException;
12 | import java.io.InputStream;
13 | import java.net.URLEncoder;
14 | import java.nio.charset.Charset;
15 |
16 | @Slf4j
17 | public class ResourceUtil {
18 |
19 | public static void getFile2Response(String path, String filename, String agent, HttpServletResponse response) {
20 | try {
21 | ResponseEntity r = getFile2BytesInternal(path, filename, agent);
22 | response.setStatus(r.getStatusCode().value());
23 | r.getHeaders().forEach((s, strings) -> {
24 | if (strings.size() == 1){
25 | response.setHeader(s,strings.get(0));
26 | } else {
27 | for (String string : strings) {
28 | response.addHeader(s,string);
29 | }
30 | }
31 | });
32 | IoUtil.write(response.getOutputStream(),false,r.getBody());
33 | } catch (Exception e) {
34 | log.error("exception:{}\r\nmsg:{}\r\ntrace:{}",e.getClass(),e.getMessage(), cn.hutool.core.exceptions.ExceptionUtil.stacktraceToString(e));
35 | throw new RuntimeException(e);
36 | }
37 | }
38 |
39 | public static ResponseEntity getFile2Bytes(String path, String filename, String agent, HttpServletResponse request) {
40 | try {
41 | return getFile2BytesInternal(path,filename,agent);
42 | } catch (Exception e) {
43 | log.error("exception:{}\r\nmsg:{}\r\ntrace:{}",e.getClass(),e.getMessage(),cn.hutool.core.exceptions.ExceptionUtil.stacktraceToString(e));
44 | throw new RuntimeException(e);
45 | }
46 | }
47 |
48 | private static ResponseEntity getFile2BytesInternal(String path,String filename,String agent) throws IOException {
49 | // 获取目录下的资源
50 | ClassPathResource cpr = new ClassPathResource(path+ File.separatorChar + filename);
51 | // 获得请求头中的User-Agent
52 | // 根据不同的客户端进行不同的编码
53 | String filenameEncoder;
54 | if (agent != null) {
55 | if (agent.contains("MSIE")){
56 | // IE浏览器
57 | filenameEncoder = URLEncoder.encode(filename, "utf-8");
58 | filenameEncoder = filenameEncoder.replace("+", " ");
59 | }
60 | else if (agent.contains("Firefox"))
61 | {
62 | // 火狐浏览器
63 | BASE64Encoder base64Encoder = new BASE64Encoder();
64 | filenameEncoder = "=?utf-8?B?" + base64Encoder.encode(filename.getBytes(Charset.forName("utf-8"))) + "?=";
65 | }else { // 其它浏览器
66 | filenameEncoder = URLEncoder.encode(filename, "utf-8");
67 | }
68 | }
69 | else { // 其它浏览器
70 | filenameEncoder = URLEncoder.encode(filename, "utf-8");
71 | }
72 | // 模板代码,装配ResponseEntity
73 | InputStream input = cpr.getInputStream();
74 | byte[] bytes = IoUtil.readBytes(input);
75 | HttpHeaders headers = new HttpHeaders();
76 | headers.setContentType(MediaTypeFactory.getMediaType(filename).orElse(MediaType.MULTIPART_FORM_DATA));
77 | // 让浏览器显示下载文件对话框
78 | headers.add("Content-Disposition", "attchement;filename="+filenameEncoder);
79 | HttpStatus statusCode = HttpStatus.OK;
80 | return new ResponseEntity<>(bytes, headers, statusCode);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/StringUtil.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | /**
4 | * @author zhumaer
5 | * @desc 字符串操作工具类
6 | * @since 6/20/2017 16:37 PM
7 | */
8 | public class StringUtil {
9 |
10 | /**
11 | * 判断传入的字符串是否为空串
12 | */
13 | public static boolean isEmpty(String str) {
14 | return str == null || ("".equals(str.trim()));
15 | }
16 |
17 | /**
18 | * 判断传入的字符串是否为空串
19 | */
20 | public static boolean isNotEmpty(String str) {
21 | return !isEmpty(str);
22 | }
23 |
24 | /**
25 | * 判断传入的是否存在空字符串
26 | */
27 | public static boolean isAnyBlank(CharSequence... css) {
28 | if (css == null || css.length == 0) {
29 | return true;
30 | }
31 |
32 | for (CharSequence cs : css) {
33 | if (isBlank(cs)) {
34 | return true;
35 | }
36 | }
37 | return false;
38 | }
39 |
40 | private static boolean isBlank(final CharSequence cs) {
41 | int strLen;
42 | if (cs == null || (strLen = cs.length()) == 0) {
43 | return true;
44 | }
45 | for (int i = 0; i < strLen; i++) {
46 | if (Character.isWhitespace(cs.charAt(i)) == false) {
47 | return false;
48 | }
49 | }
50 | return true;
51 | }
52 |
53 | /**
54 | * 子字符串出现的个数
55 | */
56 | public static int getSubStrCount(String str, String subStr) {
57 | int count = 0;
58 | int index = 0;
59 | while ((index = str.indexOf(subStr, index)) != -1) {
60 | index = index + subStr.length();
61 | count++;
62 | }
63 | return count;
64 | }
65 |
66 |
67 | /**
68 | * 替换字符串
69 | */
70 | public static String replace(String inString, String oldPattern, String newPattern) {
71 | if (isNotEmpty(inString) && isNotEmpty(oldPattern) && newPattern != null) {
72 | int index = inString.indexOf(oldPattern);
73 | if (index == -1) {
74 | return inString;
75 | } else {
76 | int capacity = inString.length();
77 | if (newPattern.length() > oldPattern.length()) {
78 | capacity += 16;
79 | }
80 |
81 | StringBuilder sb = new StringBuilder(capacity);
82 | int pos = 0;
83 |
84 | for (int patLen = oldPattern.length(); index >= 0; index = inString.indexOf(oldPattern, pos)) {
85 | sb.append(inString.substring(pos, index));
86 | sb.append(newPattern);
87 | pos = index + patLen;
88 | }
89 |
90 | sb.append(inString.substring(pos));
91 | return sb.toString();
92 | }
93 | } else {
94 | return inString;
95 | }
96 | }
97 |
98 | /**
99 | * 格式化字符串(替换符为%s)
100 | */
101 | public static String formatIfArgs(String format, Object... args) {
102 | if (isEmpty(format)) {
103 | return format;
104 | }
105 |
106 | return (args == null || args.length == 0) ? String.format(format.replaceAll("%([^n])", "%%$1")) : String.format(format, args);
107 | }
108 |
109 | /**
110 | * 格式化字符串(替换符自己指定)
111 | */
112 | public static String formatIfArgs(String format, String replaceOperator, Object... args) {
113 | if (isEmpty(format) || isEmpty(replaceOperator)) {
114 | return format;
115 | }
116 |
117 | format = replace(format, replaceOperator, "%s");
118 | return formatIfArgs(format, args);
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/param/anno/BodyFieldArgResolver.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.param.anno;
2 |
3 | import cn.hutool.core.convert.Convert;
4 | import cn.hutool.core.io.IoUtil;
5 | import cn.hutool.core.util.ClassUtil;
6 | import cn.hutool.core.util.StrUtil;
7 | import cn.hutool.json.JSON;
8 | import cn.hutool.json.JSONArray;
9 | import cn.hutool.json.JSONObject;
10 | import cn.hutool.json.JSONUtil;
11 | import org.springframework.core.MethodParameter;
12 | import org.springframework.web.bind.support.WebDataBinderFactory;
13 | import org.springframework.web.context.request.NativeWebRequest;
14 | import org.springframework.web.method.support.HandlerMethodArgumentResolver;
15 | import org.springframework.web.method.support.ModelAndViewContainer;
16 |
17 | import javax.servlet.http.HttpServletRequest;
18 | import java.lang.reflect.ParameterizedType;
19 | import java.lang.reflect.Type;
20 | import java.util.Arrays;
21 | import java.util.List;
22 | import java.util.stream.Collectors;
23 |
24 | public class BodyFieldArgResolver implements HandlerMethodArgumentResolver {
25 |
26 |
27 | public static final String APPLICAITON_JSON = "application/json";
28 |
29 | @Override
30 | public boolean supportsParameter(MethodParameter methodParameter) {
31 | return methodParameter.hasParameterAnnotation(BodyField.class);
32 | }
33 |
34 | @Override
35 | public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer, NativeWebRequest nativeWebRequest, WebDataBinderFactory webDataBinderFactory) throws Exception {
36 | final BodyField bodyField = methodParameter.getParameterAnnotation(BodyField.class);
37 | final HttpServletRequest request = nativeWebRequest.getNativeRequest(HttpServletRequest.class);
38 | final String contentType = request.getContentType();
39 | if (!contentType.equals(APPLICAITON_JSON)) {
40 | throw new IllegalArgumentException("not json request");
41 | }
42 | final String body = IoUtil.read(request.getReader());
43 | String path = bodyField.value();
44 | if (StrUtil.isBlank(path)) {
45 | path = methodParameter.getParameterName();
46 | }
47 | final JSON jsonParsed = JSONUtil.parse(body);
48 | final Object obj = jsonParsed.getByPath(path);
49 | if (ClassUtil.isBasicType(methodParameter.getParameterType()) || methodParameter.getParameterType().isAssignableFrom(String.class)){
50 | return Convert.convert(methodParameter.getParameterType(), obj);
51 | } else {
52 | if (obj instanceof JSONArray) {
53 | if (methodParameter.getParameterType().isAssignableFrom(List.class)) {
54 | final ParameterizedType genericParameterType = (ParameterizedType) methodParameter.getGenericParameterType();
55 | final Type actualTypeArgument = genericParameterType.getActualTypeArguments()[0];
56 | final Object[] objects = ((JSONArray) obj).stream().toArray();
57 | return Arrays.stream(objects).map(o -> (JSONObject)o).map(jsonObject -> jsonObject.toBean(actualTypeArgument)).collect(Collectors.toList());
58 | }
59 | throw new IllegalArgumentException("参数类型错误,json数据" + methodParameter.getParameterName() + "是数组,请使用List接收而不是" + methodParameter.getParameterType().getName());
60 | } else if (obj instanceof JSONObject) {
61 | return ((JSONObject) obj).toBean(methodParameter.getParameterType());
62 | }
63 | else {
64 | throw new IllegalArgumentException("参数类型错误,json数据是基本类型,但参数[" + methodParameter.getParameterName() + "]不为基本类型:" + methodParameter.getParameterType());
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/common/src/main/java/com/originit/common/utils/EncryptUtil.java:
--------------------------------------------------------------------------------
1 | package com.originit.common.utils;
2 |
3 | import org.apache.tomcat.util.codec.binary.Base64;
4 |
5 | import javax.crypto.Cipher;
6 | import javax.crypto.spec.IvParameterSpec;
7 | import javax.crypto.spec.SecretKeySpec;
8 | import java.security.MessageDigest;
9 | import java.security.NoSuchAlgorithmException;
10 | import java.util.Arrays;
11 |
12 | /**
13 | * 加解密工具类
14 | */
15 | public class EncryptUtil {
16 | public static String encodedByMD5(String source) {
17 | try {
18 | MessageDigest md = MessageDigest.getInstance("MD5");
19 | byte[] results = md.digest(source.getBytes());
20 | String result = bytesToHex(results);
21 | return result.toUpperCase();
22 | } catch (NoSuchAlgorithmException e) {
23 | throw new IllegalArgumentException(e);
24 | }
25 | }
26 |
27 | public static String bytesToHex(byte[] src) {
28 | StringBuilder stringBuilder = new StringBuilder();
29 | if (src == null || src.length <= 0)
30 | return null;
31 | for (int i = 0; i < src.length; i++) {
32 | int v = src[i] & 0xFF;
33 | String hv = Integer.toHexString(v);
34 | if (hv.length() < 2) {
35 | stringBuilder.append(0);
36 | }
37 | stringBuilder.append(hv);
38 | }
39 | return stringBuilder.toString().toUpperCase();
40 | }
41 |
42 | public static String encryptSHA1(String content){
43 | try {
44 | MessageDigest digest = MessageDigest
45 | .getInstance("SHA-1");
46 | digest.update(content.getBytes());
47 | byte messageDigest[] = digest.digest();
48 | // Create Hex String
49 | StringBuffer hexString = new StringBuffer();
50 | for (int i = 0; i < messageDigest.length; i++) {
51 | String shaHex = Integer.toHexString(messageDigest[i] & 0xFF);
52 | if (shaHex.length() < 2) {
53 | hexString.append(0);
54 | }
55 | hexString.append(shaHex);
56 | }
57 | return hexString.toString();
58 |
59 | } catch (NoSuchAlgorithmException e) {
60 | e.printStackTrace();
61 | }
62 | return null;
63 | }
64 |
65 | /**
66 | * 使用AES的CBC模式加密
67 | * @param key 加密的秘钥
68 | * @param text 待加密的内容
69 | * @return 经过Base64编码的密文
70 | */
71 | public static String encryptByAESWithCBC(byte[] key,byte[] text){
72 | try {
73 | Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
74 | SecretKeySpec keySpec = new SecretKeySpec(key, "AES");
75 | IvParameterSpec iv = new IvParameterSpec(key, 0, 16);
76 | cipher.init(Cipher.ENCRYPT_MODE, keySpec, iv);
77 | byte[] encrypted = cipher.doFinal(text);
78 | String base64Encrypted = new Base64().encodeToString(encrypted);
79 | return base64Encrypted;
80 | } catch (Exception e) {
81 | e.printStackTrace();
82 | }
83 | return null;
84 | }
85 |
86 | /**
87 | *
88 | * @param key 经Base64编码的AES秘钥
89 | * @param text 经Base64编码的加密串
90 | * @return
91 | */
92 | public static byte[] decryptByAESWithCBC(byte[] key,byte[] text){
93 | byte[] original=null;
94 | try {
95 | Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
96 | SecretKeySpec key_spec = new SecretKeySpec(key, "AES");
97 | IvParameterSpec iv = new IvParameterSpec(Arrays.copyOfRange(key, 0, 16));
98 | cipher.init(Cipher.DECRYPT_MODE, key_spec, iv);
99 | original = cipher.doFinal(text);
100 | } catch (Exception e) {
101 | e.printStackTrace();
102 | }
103 | return original;
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/entity2table/entity2table-core/src/main/java/org/originit/et/info/AbstractColumnInfoAcquirer.java:
--------------------------------------------------------------------------------
1 | package org.originit.et.info;
2 |
3 | import cn.hutool.core.annotation.AnnotationUtil;
4 | import cn.hutool.core.util.ClassUtil;
5 | import org.originit.et.anno.Comment;
6 | import org.originit.et.converter.TypeConverter;
7 | import org.originit.et.jdbc.JDBCType;
8 |
9 | import javax.persistence.*;
10 | import java.lang.reflect.Field;
11 | import java.lang.reflect.Method;
12 | import java.util.Map;
13 |
14 | /**
15 | * @author xxc
16 | */
17 | public abstract class AbstractColumnInfoAcquirer implements ColumnInfoAcquirer {
18 |
19 | protected Map,TypeConverter> convertRules;
20 |
21 | public AbstractColumnInfoAcquirer(Map, TypeConverter> convertRules) {
22 | this.convertRules = convertRules;
23 | }
24 |
25 | @Override
26 | public boolean isTableField(Field field) {
27 | return !AnnotationUtil.hasAnnotation(field,Transient.class) && isBeanField(field);
28 | }
29 |
30 |
31 |
32 | protected boolean isBeanField(Field field) {
33 | final String name = field.getName();
34 | final String capitalName = name.substring(0,1).toUpperCase() + name.substring(1);
35 | final Class> type = field.getType();
36 | if (type == boolean.class || type == Boolean.class) {
37 | final Method getMethod = ClassUtil.getPublicMethod(field.getDeclaringClass(), "is" + capitalName);
38 | final Method setMethod = ClassUtil.getPublicMethod(field.getDeclaringClass(), "set" + capitalName);
39 | if (getMethod != null && setMethod != null) {
40 | return true;
41 | }
42 | }
43 | final Method getMethod = ClassUtil.getPublicMethod(field.getDeclaringClass(), "get" + capitalName);
44 | if (getMethod == null) {
45 | return false;
46 | }
47 | final Method setMethod = ClassUtil.getPublicMethod(field.getDeclaringClass(), "set" + capitalName, field.getType());
48 | if (setMethod == null) {
49 | return false;
50 | }
51 | return true;
52 | }
53 |
54 |
55 | @Override
56 | public JDBCType jdbcType(Field field) {
57 | final Class> type = field.getType();
58 | if (!convertRules.containsKey(type)) {
59 | throw new IllegalStateException(field.getDeclaringClass().getName() + "." + field.getName() + "没有合适的类型转换器,请为类型" + type.getName() + "配置TypeConverter");
60 | }
61 | return this.convertRules.get(type).jdbcType();
62 | }
63 |
64 | @Override
65 | public boolean unique(Field field) {
66 | final Column annotation = AnnotationUtil.getAnnotation(field, Column.class);
67 | if (annotation == null) {
68 | return false;
69 | }
70 | return annotation.unique();
71 | }
72 |
73 | @Override
74 | public boolean notNull(Field field) {
75 | final Column annotation = AnnotationUtil.getAnnotation(field, Column.class);
76 | if (annotation == null) {
77 | return false;
78 | }
79 | final boolean nullable = annotation.nullable();
80 | return !nullable;
81 | }
82 |
83 | @Override
84 | public String comment(Field declaredField) {
85 | final Comment annotation = AnnotationUtil.getAnnotation(declaredField,Comment.class);
86 | if (annotation != null) {
87 | return annotation.value();
88 | }
89 | return null;
90 | }
91 |
92 | @Override
93 | public Integer length(Field declaredField) {
94 | final Column annotation = AnnotationUtil.getAnnotation(declaredField, Column.class);
95 | if (annotation != null) {
96 | return annotation.length();
97 | }
98 | final TypeConverter typeConverter = this.convertRules.get(declaredField.getType());
99 | if (typeConverter != null){
100 | return typeConverter.defaultLength();
101 | }
102 | return null;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/common-mybatis-crud/src/main/kotlin/org/originit/crud/factory/MapperProxyFactoryBean.kt:
--------------------------------------------------------------------------------
1 | package org.originit.crud.factory
2 |
3 | import org.mybatis.spring.mapper.MapperFactoryBean
4 | import org.originit.crud.anno.*
5 | import org.originit.crud.mapper.CrudMapper
6 | import org.originit.crud.meta.ClassMetaInfo
7 | import org.originit.crud.meta.FieldMetaInfo
8 | import org.originit.crud.meta.MetaCache
9 | import org.originit.crud.util.camelCaseToUnderscores
10 | import java.lang.IllegalStateException
11 | import java.lang.reflect.Modifier
12 | import java.lang.reflect.ParameterizedType
13 | import java.lang.reflect.Type
14 |
15 |
16 | class MapperProxyFactoryBean : MapperFactoryBean {
17 | constructor()
18 | constructor(mapperInterface: Class?) : super(mapperInterface)
19 |
20 | override fun checkDaoConfig() {
21 | super.checkDaoConfig()
22 | // 此处要编写解析逻辑
23 | MetaCache.putCache(this.mapperInterface,resolveMetaInfo(this.mapperInterface))
24 | }
25 | private fun resolveMetaInfo(mapperType: Class<*>): ClassMetaInfo {
26 | val classMetaInfo = ClassMetaInfo()
27 |
28 | val parameterizedType = mapperType.genericInterfaces.filter {type ->
29 | if (type is ParameterizedType) {
30 | val parameterizedType = type as ParameterizedType
31 | val rawType: Type = parameterizedType.rawType
32 | rawType === CrudMapper::class.java
33 | } else {
34 | false
35 | }
36 | }[0] as ParameterizedType
37 | val (entityClass, idType) = parameterizedType.actualTypeArguments
38 | classMetaInfo.entityClass = entityClass as Class<*>
39 | classMetaInfo.tableName = if (classMetaInfo.entityClass!!.isAnnotationPresent(TableName::class.java)) {
40 | classMetaInfo.entityClass!!.getAnnotation(TableName::class.java).value
41 | } else {
42 | resolveDefaultTableName(classMetaInfo.entityClass!!)
43 | }
44 | for (declaredField in entityClass.declaredFields) {
45 | if (Modifier.isStatic(declaredField.modifiers) || declaredField.isAnnotationPresent(Transient::class.java)) {
46 | continue
47 | }
48 | val field = FieldMetaInfo()
49 | if (declaredField.isAnnotationPresent(Id::class.java)) {
50 | classMetaInfo.idField = declaredField.name
51 | classMetaInfo.idColumn = declaredField.getAnnotation(Id::class.java).value
52 | if (classMetaInfo.idColumn == ""){
53 | classMetaInfo.idColumn = classMetaInfo.idField
54 | }
55 | if (declaredField.isAnnotationPresent(KeyGenerator::class.java)) {
56 | classMetaInfo.idGenerator = declaredField.getAnnotation(KeyGenerator::class.java).value
57 | }
58 | field.primary = true
59 | }
60 |
61 | field.fieldName = declaredField.name
62 | field.updateIfNull = if (declaredField.isAnnotationPresent(Column::class.java)) {
63 | val column = declaredField.getAnnotation(Column::class.java)
64 | field.columnName = column.value
65 | column.updateIfNull
66 | } else {
67 | field.columnName = field.fieldName
68 | false
69 | }
70 | if (declaredField.isAnnotationPresent(LogicDelete::class.java)) {
71 | if (declaredField.type.typeName != "java.lang.Boolean") {
72 | throw IllegalStateException("逻辑删除字段必须是Boolean类型,请检查${entityClass.name}.${declaredField.name}")
73 | }
74 | if (classMetaInfo.logicField != null) {
75 | throw IllegalStateException("存在多个逻辑删除属性:${classMetaInfo.logicField}, ${declaredField.name}")
76 | }
77 | classMetaInfo.logicField = field.fieldName
78 | classMetaInfo.logicColumn = field.columnName
79 | }
80 |
81 | classMetaInfo.fields.add(field)
82 | }
83 | return classMetaInfo
84 | }
85 |
86 | private fun resolveDefaultTableName(mapperType: Class<*>): String {
87 | return mapperType.simpleName.camelCaseToUnderscores()
88 | }
89 |
90 | }
--------------------------------------------------------------------------------