Преглед изворни кода

增加简单的jpa支持。可以使用jpa注解来拓展字段

zhouhao пре 7 година
родитељ
комит
fff48eee71
26 измењених фајлова са 300 додато и 47 уклоњено
  1. 6 0
      hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/pom.xml
  2. 19 10
      hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/MyBatisAutoConfiguration.java
  3. 0 6
      hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/MybatisDaoAutoConfiguration.java
  4. 14 0
      hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/MybatisProperties.java
  5. 24 5
      hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/builder/EasyOrmSqlBuilder.java
  6. 118 0
      hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/builder/jpa/JpaAnnotationParser.java
  7. 3 2
      hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/utils/ResultMapsUtils.java
  8. 24 0
      hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/test/java/org/hswebframework/web/dao/mybatis/builder/jpa/JpaAnnotationParserTest.java
  9. 27 0
      hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/test/java/org/hswebframework/web/dao/mybatis/builder/jpa/TestEntity.java
  10. 6 0
      hsweb-examples/hsweb-examples-custom-entity/pom.xml
  11. 2 4
      hsweb-examples/hsweb-examples-custom-entity/src/main/java/org/hswebframework/web/example/custom/config/CustomMybatisMapperCustomer.java
  12. 7 1
      hsweb-examples/hsweb-examples-custom-entity/src/main/java/org/hswebframework/web/example/custom/entity/CustomUserEntity.java
  13. 8 1
      hsweb-examples/hsweb-examples-custom-entity/src/main/resources/application.yml
  14. 26 0
      hsweb-system/hsweb-system-all/pom.xml
  15. 2 2
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMapper.xml
  16. 2 2
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMenuMapper.xml
  17. 2 2
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuGroupBindMapper.xml
  18. 2 2
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuGroupMapper.xml
  19. 1 1
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuMapper.xml
  20. 1 1
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/PermissionMapper.xml
  21. 1 1
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/RoleMapper.xml
  22. 1 1
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserMapper.xml
  23. 2 2
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserRoleMapper.xml
  24. 0 2
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/UserRoleEntity.java
  25. 2 1
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/UserService.java
  26. 0 1
      hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-entity/src/main/java/org/hswebframework/web/authorization/oauth2/server/entity/SimpleOAuth2AccessEntity.java

+ 6 - 0
hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/pom.xml

@@ -50,6 +50,12 @@
             <artifactId>hsweb-datasource-api</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.hibernate.javax.persistence</groupId>
+            <artifactId>hibernate-jpa-2.0-api</artifactId>
+            <version>1.0.1.Final</version>
+            <optional>true</optional>
+        </dependency>
     </dependencies>
 
 </project>

+ 19 - 10
hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/MyBatisAutoConfiguration.java

@@ -24,8 +24,10 @@ import org.apache.ibatis.session.SqlSessionFactory;
 import org.apache.ibatis.session.TransactionIsolationLevel;
 import org.apache.ibatis.transaction.Transaction;
 import org.hswebframework.web.commons.entity.factory.EntityFactory;
+import org.hswebframework.web.dao.mybatis.builder.EasyOrmSqlBuilder;
 import org.hswebframework.web.dao.mybatis.dynamic.DynamicDataSourceSqlSessionFactoryBuilder;
 import org.hswebframework.web.dao.mybatis.dynamic.DynamicSpringManagedTransaction;
+import org.hswebframework.web.dao.mybatis.utils.ResultMapsUtils;
 import org.mybatis.spring.SqlSessionFactoryBean;
 import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
 import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
@@ -49,8 +51,6 @@ import javax.sql.DataSource;
 @ConditionalOnClass({SqlSessionFactory.class, SqlSessionFactoryBean.class})
 public class MyBatisAutoConfiguration {
 
-    @Resource
-    private MybatisProperties mybatisProperties;
 
     @Autowired(required = false)
     private Interceptor[] interceptors;
@@ -74,11 +74,13 @@ public class MyBatisAutoConfiguration {
     @Bean(name = "sqlSessionFactory")
     public SqlSessionFactory sqlSessionFactory(@Qualifier("dataSource") DataSource dataSource) throws Exception {
         SqlSessionFactoryBean factory = new SqlSessionFactoryBean();
+        MybatisProperties mybatisProperties = this.mybatisProperties();
+
         if (null != entityFactory) {
             factory.setObjectFactory(new MybatisEntityFactory(entityFactory));
         }
         factory.setVfs(SpringBootVFS.class);
-        if (mybatisProperties.isDynamicDatasource()) {
+        if (mybatisProperties().isDynamicDatasource()) {
             factory.setSqlSessionFactoryBuilder(new DynamicDataSourceSqlSessionFactoryBuilder());
             factory.setTransactionFactory(new SpringManagedTransactionFactory() {
                 @Override
@@ -88,24 +90,31 @@ public class MyBatisAutoConfiguration {
             });
         }
         factory.setDataSource(dataSource);
-        if (StringUtils.hasText(this.mybatisProperties.getConfigLocation())) {
-            factory.setConfigLocation(this.resourceLoader.getResource(this.mybatisProperties
+        if (StringUtils.hasText(mybatisProperties.getConfigLocation())) {
+            factory.setConfigLocation(this.resourceLoader.getResource(mybatisProperties
                     .getConfigLocation()));
         }
+        if (mybatisProperties.getConfiguration() != null) {
+            factory.setConfiguration(mybatisProperties.getConfiguration());
+        }
         if (this.interceptors != null && this.interceptors.length > 0) {
             factory.setPlugins(this.interceptors);
         }
         if (this.databaseIdProvider != null) {
             factory.setDatabaseIdProvider(this.databaseIdProvider);
         }
-        factory.setTypeAliasesPackage(this.mybatisProperties.getTypeAliasesPackage());
+        factory.setTypeAliasesPackage(mybatisProperties.getTypeAliasesPackage());
         String typeHandlers = "org.hswebframework.web.dao.mybatis.handler";
-        if (this.mybatisProperties.getTypeHandlersPackage() != null) {
-            typeHandlers = typeHandlers + ";" + this.mybatisProperties.getTypeHandlersPackage();
+        if (mybatisProperties.getTypeHandlersPackage() != null) {
+            typeHandlers = typeHandlers + ";" + mybatisProperties.getTypeHandlersPackage();
         }
         factory.setTypeHandlersPackage(typeHandlers);
-        factory.setMapperLocations(this.mybatisProperties.resolveMapperLocations());
-        return factory.getObject();
+        factory.setMapperLocations(mybatisProperties.resolveMapperLocations());
+        SqlSessionFactory sqlSessionFactory = factory.getObject();
+        ResultMapsUtils.setSqlSession(sqlSessionFactory);
+        EasyOrmSqlBuilder.getInstance().useJpa = mybatisProperties.isUseJpa();
+        EasyOrmSqlBuilder.getInstance().entityFactory = entityFactory;
+        return sqlSessionFactory;
     }
 
 

+ 0 - 6
hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/MybatisDaoAutoConfiguration.java

@@ -37,11 +37,5 @@ import javax.annotation.PostConstruct;
 @EnableConfigurationProperties(MybatisProperties.class)
 public class MybatisDaoAutoConfiguration {
 
-    @Autowired
-    private SqlSessionTemplate sqlSessionTemplate;
 
-    @PostConstruct
-    public void init() {
-        ResultMapsUtils.setSqlSession(sqlSessionTemplate);
-    }
 }

+ 14 - 0
hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/MybatisProperties.java

@@ -56,6 +56,12 @@ public class MybatisProperties extends org.mybatis.spring.boot.autoconfigure.Myb
      * 排除使用{@link Resource#getURL()#toString()}进行对比
      */
     private              String[] mapperLocationExcludes = null;
+    /**
+     * 使用jpa注解来解析表结构,动态生成查询条件
+     */
+    private              boolean  useJpa                 = false;
+
+    private Properties                  mybatisProperties;
 
     private List<MybatisMapperCustomer> mybatisMappers;
 
@@ -80,6 +86,14 @@ public class MybatisProperties extends org.mybatis.spring.boot.autoconfigure.Myb
         this.dynamicDatasource = dynamicDatasource;
     }
 
+    public void setUseJpa(boolean useJpa) {
+        this.useJpa = useJpa;
+    }
+
+    public boolean isUseJpa() {
+        return useJpa;
+    }
+
     @Override
     public Resource[] resolveMapperLocations() {
         Map<String, Resource> resources = new HashMap<>();

+ 24 - 5
hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/builder/EasyOrmSqlBuilder.java

@@ -41,6 +41,8 @@ import org.hswebframework.ezorm.rdb.render.dialect.OracleRDBDatabaseMetaData;
 import org.hswebframework.ezorm.rdb.render.support.simple.CommonSqlRender;
 import org.hswebframework.ezorm.rdb.render.support.simple.SimpleWhereSqlBuilder;
 import org.hswebframework.web.BusinessException;
+import org.hswebframework.web.commons.entity.factory.EntityFactory;
+import org.hswebframework.web.dao.mybatis.builder.jpa.JpaAnnotationParser;
 import org.hswebframework.web.dao.mybatis.plgins.pager.Pager;
 import org.hswebframework.web.dao.mybatis.utils.ResultMapsUtils;
 import org.hswebframework.utils.StringUtils;
@@ -60,6 +62,10 @@ import java.util.concurrent.ConcurrentMap;
  */
 public class EasyOrmSqlBuilder {
 
+    public volatile boolean useJpa = false;
+
+    public EntityFactory entityFactory;
+
     private static final   EasyOrmSqlBuilder  instance   = new EasyOrmSqlBuilder();
     protected static final Map<Class, String> simpleName = new HashMap<>();
 
@@ -109,7 +115,7 @@ public class EasyOrmSqlBuilder {
         public Map<String, RDBTableMetaData> get(Object key) {
             Map<String, RDBTableMetaData> map = super.get(key);
             if (map == null) {
-                map = new HashMap<>();
+                map = new ConcurrentHashMap<>();
                 put((RDBDatabaseMetaData) key, map);
             }
             return map;
@@ -139,14 +145,15 @@ public class EasyOrmSqlBuilder {
             return cached;
         }
         RDBTableMetaData rdbTableMetaData = new RDBTableMetaData();
+        ResultMap resultMaps = ResultMapsUtils.getResultMap(resultMapId);
         rdbTableMetaData.setName(tableName);
         rdbTableMetaData.setDatabaseMetaData(active);
-        ResultMap resultMaps = ResultMapsUtils.getResultMap(resultMapId);
+
         List<ResultMapping> resultMappings = new ArrayList<>(resultMaps.getResultMappings());
         resultMappings.addAll(resultMaps.getIdResultMappings());
         resultMappings.forEach(resultMapping -> {
             if (resultMapping.getNestedQueryId() == null) {
-                RDBColumnMetaData column = new RDBColumnMetaData(){
+                RDBColumnMetaData column = new RDBColumnMetaData() {
                     @Override
                     public RDBColumnMetaData clone() {
                         RDBColumnMetaData target = super.clone();
@@ -161,10 +168,10 @@ public class EasyOrmSqlBuilder {
                 }
                 column.setJavaType(resultMapping.getJavaType());
                 column.setProperty("resultMapping", resultMapping);
-                ValueConverter dateConvert=new DateTimeConverter("yyyy-MM-dd HH:mm:ss", column.getJavaType()){
+                ValueConverter dateConvert = new DateTimeConverter("yyyy-MM-dd HH:mm:ss", column.getJavaType()) {
                     @Override
                     public Object getData(Object value) {
-                        if(value instanceof Number){
+                        if (value instanceof Number) {
                             return new Date(((Number) value).longValue());
                         }
                         return super.getData(value);
@@ -181,6 +188,18 @@ public class EasyOrmSqlBuilder {
             }
         });
         cache.put(cacheKey, rdbTableMetaData);
+        if (useJpa) {
+            Class type = entityFactory.getInstanceType(resultMaps.getType());
+            RDBTableMetaData parseResult = JpaAnnotationParser.parseMetaDataFromEntity(type);
+            if (parseResult != null) {
+                for (RDBColumnMetaData columnMetaData : parseResult.getColumns()) {
+                    if (rdbTableMetaData.findColumn(columnMetaData.getName()) == null) {
+                        columnMetaData=columnMetaData.clone();
+                        rdbTableMetaData.addColumn(columnMetaData);
+                    }
+                }
+            }
+        }
         return rdbTableMetaData;
     }
 

+ 118 - 0
hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/builder/jpa/JpaAnnotationParser.java

@@ -0,0 +1,118 @@
+package org.hswebframework.web.dao.mybatis.builder.jpa;
+
+
+import org.apache.commons.beanutils.BeanUtilsBean;
+import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData;
+import org.hswebframework.ezorm.rdb.meta.RDBTableMetaData;
+import org.springframework.core.annotation.AnnotationUtils;
+
+import javax.persistence.Column;
+import javax.persistence.Enumerated;
+import javax.persistence.Lob;
+import javax.persistence.Table;
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.JDBCType;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.BiFunction;
+
+/**
+ * jpa 注解解析器
+ *
+ * @author zhouhao
+ * @since 3.0
+ */
+public class JpaAnnotationParser {
+
+    private static final Map<Class, RDBTableMetaData> metaDataCache = new ConcurrentHashMap<>(256);
+
+    private static final Map<Class, JDBCType> jdbcTypeMapping = new HashMap<>();
+
+    private static final List<BiFunction<Class, PropertyDescriptor, JDBCType>> jdbcTypeConvert = new ArrayList<>();
+
+    static {
+        jdbcTypeMapping.put(String.class, JDBCType.VARCHAR);
+
+        jdbcTypeMapping.put(Integer.class, JDBCType.INTEGER);
+        jdbcTypeMapping.put(int.class, JDBCType.INTEGER);
+        jdbcTypeMapping.put(Double.class, JDBCType.DECIMAL);
+        jdbcTypeMapping.put(double.class, JDBCType.DECIMAL);
+        jdbcTypeMapping.put(Float.class, JDBCType.DECIMAL);
+        jdbcTypeMapping.put(float.class, JDBCType.DECIMAL);
+        jdbcTypeMapping.put(Boolean.class, JDBCType.BIT);
+        jdbcTypeMapping.put(boolean.class, JDBCType.BIT);
+
+        jdbcTypeMapping.put(byte[].class, JDBCType.BLOB);
+
+        jdbcTypeMapping.put(BigDecimal.class, JDBCType.DECIMAL);
+        jdbcTypeMapping.put(BigInteger.class, JDBCType.INTEGER);
+
+        jdbcTypeConvert.add((type, property) -> {
+            Enumerated enumerated = getAnnotation(type, property, Enumerated.class);
+            return enumerated != null ? JDBCType.VARCHAR : null;
+        });
+        jdbcTypeConvert.add((type, property) -> {
+            Lob enumerated = getAnnotation(type, property, Lob.class);
+            return enumerated != null ? JDBCType.CLOB : null;
+        });
+    }
+
+    public static RDBTableMetaData parseMetaDataFromEntity(Class entityClass) {
+        Table table = AnnotationUtils.findAnnotation(entityClass, Table.class);
+        if (table == null) {
+            return null;
+        }
+        RDBTableMetaData tableMetaData = new RDBTableMetaData();
+        tableMetaData.setName(table.name());
+
+        PropertyDescriptor[] descriptors = BeanUtilsBean.getInstance()
+                .getPropertyUtils()
+                .getPropertyDescriptors(entityClass);
+        for (PropertyDescriptor descriptor : descriptors) {
+            Column column = getAnnotation(entityClass, descriptor, Column.class);
+            if (column == null) {
+                continue;
+            }
+            RDBColumnMetaData columnMetaData = new RDBColumnMetaData();
+            columnMetaData.setName(column.name());
+            columnMetaData.setAlias(descriptor.getName());
+            columnMetaData.setLength(column.length());
+            columnMetaData.setPrecision(column.precision());
+            columnMetaData.setJavaType(descriptor.getPropertyType());
+            JDBCType type = jdbcTypeMapping.get(descriptor.getPropertyType());
+            if (type == null) {
+                type = jdbcTypeConvert.stream()
+                        .map(func -> func.apply(entityClass, descriptor))
+                        .filter(Objects::nonNull)
+                        .findFirst()
+                        .orElse(JDBCType.OTHER);
+            }
+            columnMetaData.setJdbcType(type);
+            tableMetaData.addColumn(columnMetaData);
+        }
+        return tableMetaData;
+    }
+
+    private static <T extends Annotation> T getAnnotation(Class entityClass, PropertyDescriptor descriptor, Class<T> type) {
+        T ann = null;
+        try {
+            Field field = entityClass.getDeclaredField(descriptor.getName());
+            ann = AnnotationUtils.findAnnotation(field, type);
+        } catch (@SuppressWarnings("all") NoSuchFieldException ignore) {
+        }
+        Method read = descriptor.getReadMethod(),
+                write = descriptor.getWriteMethod();
+        if (null == ann && read != null) {
+            ann = AnnotationUtils.findAnnotation(read, type);
+        }
+        if (null == ann && write != null) {
+            ann = AnnotationUtils.findAnnotation(write, type);
+        }
+        return ann;
+    }
+}

+ 3 - 2
hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/utils/ResultMapsUtils.java

@@ -20,6 +20,7 @@ package org.hswebframework.web.dao.mybatis.utils;
 
 import org.apache.ibatis.mapping.ResultMap;
 import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
 import org.mybatis.spring.SqlSessionTemplate;
 
 import java.util.concurrent.CountDownLatch;
@@ -28,7 +29,7 @@ import java.util.concurrent.CountDownLatch;
  * @since 2.0
  */
 public class ResultMapsUtils {
-    private volatile static SqlSession sqlSession;
+    private volatile static SqlSessionFactory sqlSession;
 
     private static CountDownLatch countDownLatch = new CountDownLatch(1);
 
@@ -48,7 +49,7 @@ public class ResultMapsUtils {
         return sqlSession.getConfiguration().getResultMap(id);
     }
 
-    public static void setSqlSession(SqlSessionTemplate sqlSession) {
+    public static void setSqlSession(SqlSessionFactory sqlSession) {
         ResultMapsUtils.sqlSession = sqlSession;
         if (countDownLatch.getCount() != 0) {
             countDownLatch.countDown();

+ 24 - 0
hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/test/java/org/hswebframework/web/dao/mybatis/builder/jpa/JpaAnnotationParserTest.java

@@ -0,0 +1,24 @@
+package org.hswebframework.web.dao.mybatis.builder.jpa;
+
+import org.hswebframework.ezorm.rdb.meta.RDBTableMetaData;
+import org.junit.Test;
+import org.springframework.util.Assert;
+
+import static org.junit.Assert.*;
+
+/**
+ * TODO 完成注释
+ *
+ * @author zhouhao
+ * @since
+ */
+public class JpaAnnotationParserTest {
+
+
+    @Test
+    public void testParse() {
+        RDBTableMetaData metaData = JpaAnnotationParser.parseMetaDataFromEntity(TestEntity.class);
+
+        Assert.notNull(metaData, "metadata parse error");
+    }
+}

+ 27 - 0
hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/test/java/org/hswebframework/web/dao/mybatis/builder/jpa/TestEntity.java

@@ -0,0 +1,27 @@
+package org.hswebframework.web.dao.mybatis.builder.jpa;
+
+import lombok.Data;
+
+import javax.persistence.Column;
+import javax.persistence.Table;
+
+/**
+ * @author zhouhao
+ * @since 3.0
+ */
+@Table(name = "s_test")
+@Data
+public class TestEntity {
+    @Column(name = "id")
+    private String id;
+
+    @Column(name = "name")
+    private String name;
+
+    @Column(name = "age")
+    private Integer age;
+
+    @Column(name = "role_id")
+    private String roleId;
+
+}

+ 6 - 0
hsweb-examples/hsweb-examples-custom-entity/pom.xml

@@ -70,5 +70,11 @@
             <version>${project.version}</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.hibernate.javax.persistence</groupId>
+            <artifactId>hibernate-jpa-2.0-api</artifactId>
+            <version>1.0.1.Final</version>
+            <optional>true</optional>
+        </dependency>
     </dependencies>
 </project>

+ 2 - 4
hsweb-examples/hsweb-examples-custom-entity/src/main/java/org/hswebframework/web/example/custom/config/CustomMybatisMapperCustomer.java

@@ -14,16 +14,14 @@ public class CustomMybatisMapperCustomer implements MybatisMapperCustomer {
     @Override
     public String[] getExcludes() {
         return new String[]{
-                "classpath*:org/hswebframework/**/OrganizationalMapper.xml",
-                "classpath*:org/hswebframework/**/UserMapper.xml"
+                "classpath*:org/hswebframework/**/OrganizationalMapper.xml"
         };
     }
 
     @Override
     public String[] getIncludes() {
         return new String[]{
-                "classpath*:custom/mappers/OrganizationalMapper.xml",
-                "classpath*:custom/mappers/UserMapper.xml"
+                "classpath*:custom/mappers/OrganizationalMapper.xml"
         };
     }
 }

+ 7 - 1
hsweb-examples/hsweb-examples-custom-entity/src/main/java/org/hswebframework/web/example/custom/entity/CustomUserEntity.java

@@ -4,13 +4,19 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import org.hswebframework.web.entity.authorization.bind.SimpleBindRoleUserEntity;
 
+import javax.persistence.Column;
+import javax.persistence.Table;
+
 /**
+ * 使用jpa注解的方式来拓展字段信息
+ *
  * @author zhouhao
  * @since 3.0
  */
 @EqualsAndHashCode(callSuper = true)
 @Data
+@Table
 public class CustomUserEntity extends SimpleBindRoleUserEntity {
-
+    @Column(name = "nick_name")
     private String nickName;
 }

+ 8 - 1
hsweb-examples/hsweb-examples-custom-entity/src/main/resources/application.yml

@@ -1,3 +1,6 @@
+logging:
+    level:
+      org.hswebframework.web: debug
 spring:
     aop:
         auto: true
@@ -21,4 +24,8 @@ hsweb:
 #            mapping:
 #                OrganizationalEntity: CustomOrganizationalEntity
 server:
-  port: 8081
+  port: 8081
+mybatis:
+  use-jpa: true
+  configuration:
+    mapUnderscoreToCamelCase: true

+ 26 - 0
hsweb-system/hsweb-system-all/pom.xml

@@ -11,5 +11,31 @@
     <packaging>pom</packaging>
     <artifactId>hsweb-system-all</artifactId>
 
+    <dependencies>
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-system-authorization-starter</artifactId>
+            <version>${project.version}</version>
+        </dependency>
 
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-system-database-manager-starter</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-system-dictionary-starter</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-system-organizational-starter</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+
+    </dependencies>
 </project>

+ 2 - 2
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMapper.xml

@@ -19,7 +19,7 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.hswebframework.web.dao.authorization.AuthorizationSettingDao">
-    <resultMap id="AuthorizationSettingResultMap" type="org.hswebframework.web.entity.authorization.SimpleAuthorizationSettingEntity">
+    <resultMap id="AuthorizationSettingResultMap" type="org.hswebframework.web.entity.authorization.AuthorizationSettingEntity">
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
         <result property="settingFor" column="setting_for" javaType="String" jdbcType="VARCHAR"/>
@@ -35,7 +35,7 @@
         <bind name="tableName" value="'s_autz_setting'"/>
     </sql>
 
-    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.SimpleAuthorizationSettingEntity">
+    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.AuthorizationSettingEntity">
         <include refid="config"/>
         <include refid="BasicMapper.buildInsertSql"/>
     </insert>

+ 2 - 2
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMenuMapper.xml

@@ -19,7 +19,7 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.hswebframework.web.dao.authorization.AuthorizationSettingMenuDao">
-    <resultMap id="AuthorizationSettingMenuResultMap" type="org.hswebframework.web.entity.authorization.SimpleAuthorizationSettingMenuEntity">
+    <resultMap id="AuthorizationSettingMenuResultMap" type="org.hswebframework.web.entity.authorization.AuthorizationSettingMenuEntity">
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <result property="menuId" column="menu_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="settingId" column="setting_id" javaType="String" jdbcType="VARCHAR"/>
@@ -37,7 +37,7 @@
         <bind name="tableName" value="'s_autz_menu'"/>
     </sql>
 
-    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.SimpleAuthorizationSettingMenuEntity">
+    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.AuthorizationSettingMenuEntity">
         <include refid="config"/>
         <include refid="BasicMapper.buildInsertSql"/>
     </insert>

+ 2 - 2
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuGroupBindMapper.xml

@@ -19,7 +19,7 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.hswebframework.web.dao.authorization.MenuGroupBindDao">
-    <resultMap id="MenuGroupBindResultMap" type="org.hswebframework.web.entity.authorization.SimpleMenuGroupBindEntity">
+    <resultMap id="MenuGroupBindResultMap" type="org.hswebframework.web.entity.authorization.MenuGroupBindEntity">
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <result property="path" column="path" javaType="String" jdbcType="VARCHAR"/>
         <result property="parentId" column="parent_id" javaType="String" jdbcType="VARCHAR"/>
@@ -36,7 +36,7 @@
         <bind name="tableName" value="'s_menu_group_bind'"/>
     </sql>
 
-    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.SimpleMenuGroupBindEntity">
+    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.MenuGroupBindEntity">
         <include refid="config"/>
         <include refid="BasicMapper.buildInsertSql"/>
     </insert>

+ 2 - 2
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuGroupMapper.xml

@@ -19,7 +19,7 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.hswebframework.web.dao.authorization.MenuGroupDao">
-    <resultMap id="MenuGroupResultMap" type="org.hswebframework.web.entity.authorization.SimpleMenuGroupEntity">
+    <resultMap id="MenuGroupResultMap" type="org.hswebframework.web.entity.authorization.MenuGroupEntity">
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
         <result property="describe" column="describe" javaType="String" jdbcType="VARCHAR"/>
@@ -38,7 +38,7 @@
         <bind name="tableName" value="'s_menu_group'"/>
     </sql>
 
-    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.SimpleMenuGroupEntity">
+    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.MenuGroupEntity">
         <include refid="config"/>
         <include refid="BasicMapper.buildInsertSql"/>
     </insert>

+ 1 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuMapper.xml

@@ -21,7 +21,7 @@
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 <mapper namespace="org.hswebframework.web.dao.authorization.MenuDao">
-    <resultMap id="MenuResultMap" type="org.hswebframework.web.entity.authorization.SimpleMenuEntity">
+    <resultMap id="MenuResultMap" type="org.hswebframework.web.entity.authorization.MenuEntity">
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <result property="describe" column="describe" javaType="String" jdbcType="VARCHAR"/>
         <result property="parentId" column="parent_id" javaType="String" jdbcType="VARCHAR"/>

+ 1 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/PermissionMapper.xml

@@ -21,7 +21,7 @@
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 <mapper namespace="org.hswebframework.web.dao.authorization.PermissionDao">
-    <resultMap id="PermissionResultMap" type="org.hswebframework.web.entity.authorization.SimplePermissionEntity">
+    <resultMap id="PermissionResultMap" type="org.hswebframework.web.entity.authorization.PermissionEntity">
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <result property="name" column="name" javaType="string" jdbcType="VARCHAR"/>
         <result property="describe" column="describe" javaType="string" jdbcType="VARCHAR"/>

+ 1 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/RoleMapper.xml

@@ -21,7 +21,7 @@
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 <mapper namespace="org.hswebframework.web.dao.authorization.RoleDao">
-    <resultMap id="RoleResultMap" type="org.hswebframework.web.entity.authorization.SimpleRoleEntity">
+    <resultMap id="RoleResultMap" type="org.hswebframework.web.entity.authorization.RoleEntity">
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <result property="name" column="name" javaType="string" jdbcType="VARCHAR"/>
         <result property="describe" column="describe" javaType="string" jdbcType="VARCHAR"/>

+ 1 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserMapper.xml

@@ -21,7 +21,7 @@
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 <mapper namespace="org.hswebframework.web.dao.authorization.UserDao">
-    <resultMap id="UserResultMap" type="org.hswebframework.web.entity.authorization.SimpleUserEntity">
+    <resultMap id="UserResultMap" type="org.hswebframework.web.entity.authorization.UserEntity">
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <result property="name" column="name" javaType="string" jdbcType="VARCHAR"/>
         <result property="username" column="username" javaType="string" jdbcType="VARCHAR"/>

+ 2 - 2
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserRoleMapper.xml

@@ -21,7 +21,7 @@
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 <mapper namespace="org.hswebframework.web.dao.authorization.UserRoleDao">
-    <resultMap id="UserRoleResultMap" type="org.hswebframework.web.entity.authorization.SimpleUserRoleEntity">
+    <resultMap id="UserRoleResultMap" type="org.hswebframework.web.entity.authorization.UserRoleEntity">
         <result property="roleId" column="role_id" javaType="string" jdbcType="VARCHAR"/>
         <result property="userId" column="user_id" javaType="string" jdbcType="VARCHAR"/>
     </resultMap>
@@ -32,7 +32,7 @@
         <bind name="tableName" value="'s_user_role'"/>
     </sql>
 
-    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.SimpleUserRoleEntity">
+    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.UserRoleEntity">
         <include refid="config"/>
         <include refid="BasicMapper.buildInsertSql"/>
     </insert>

+ 0 - 2
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/UserRoleEntity.java

@@ -3,8 +3,6 @@ package org.hswebframework.web.entity.authorization;
 import org.hswebframework.web.commons.entity.CloneableEntity;
 
 /**
- * TODO 完成注释
- *
  * @author zhouhao
  */
 public interface UserRoleEntity extends CloneableEntity {

+ 2 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/UserService.java

@@ -10,9 +10,10 @@ import org.hswebframework.web.service.QueryService;
 import java.util.List;
 
 /**
- * TODO 完成注释
+ * 用户服务
  *
  * @author zhouhao
+ * @since 3.0
  */
 public interface UserService extends
         CreateEntityService<UserEntity>,

+ 0 - 1
hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-entity/src/main/java/org/hswebframework/web/authorization/oauth2/server/entity/SimpleOAuth2AccessEntity.java

@@ -18,7 +18,6 @@
 
 package org.hswebframework.web.authorization.oauth2.server.entity;
 
-import lombok.Builder;
 import lombok.Getter;
 import lombok.Setter;