diff --git a/hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/SimpleAuthorizeMethodInterceptor.java b/hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/SimpleAuthorizeMethodInterceptor.java index 5ecd673e1..9f04a757b 100644 --- a/hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/SimpleAuthorizeMethodInterceptor.java +++ b/hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/SimpleAuthorizeMethodInterceptor.java @@ -100,10 +100,16 @@ public void assertAuthorized(Annotation a) throws AuthorizationException { .stream() .filter(authorizeConfig.action::contains) .collect(Collectors.toList()); + + if (actions.isEmpty()) return false; + //如果 控制逻辑是or,则只要过滤结果数量不为0.否则过滤结果数量必须和配置的数量相同 return logicalIsOr ? actions.size() > 0 : permission.getActions().containsAll(actions); }).collect(Collectors.toList()); - access = logicalIsOr ? permissions.size() > 0 : permissions.size() == authorizeConfig.permission.size(); + access = logicalIsOr ? + permissions.size() > 0 : + //权限数量和配置的数量相同 + permissions.size() == authorizeConfig.permission.size(); } //控制角色 if (!authorizeConfig.role.isEmpty()) { diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericEntityService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericEntityService.java index fb7b49249..f4c9afaa4 100644 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericEntityService.java +++ b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericEntityService.java @@ -22,10 +22,10 @@ import org.hswebframework.web.commons.entity.RecordCreationEntity; import org.hswebframework.web.dao.CrudDao; import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.utils.ClassUtils; import org.hswebframework.web.validator.group.CreateGroup; import org.hswebframework.web.validator.group.UpdateGroup; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.Assert; import java.util.ArrayList; import java.util.List; @@ -58,6 +58,7 @@ public GenericEntityService() { @Override public int deleteByPk(PK pk) { + Assert.notNull(pk, "parameter can not be null"); return createDelete() .where(GenericEntity.id, pk) .exec(); @@ -65,11 +66,13 @@ public int deleteByPk(PK pk) { @Override public int updateByPk(PK pk, E entity) { + Assert.notNull(pk, "primary key can not be null"); + Assert.notNull(entity, "entity can not be null"); entity.setId(pk); tryValidate(entity, UpdateGroup.class); return createUpdate(entity) //如果是RecordCreationEntity则不修改creator_id和creator_time - .when(ClassUtils.instanceOf(getEntityType(), RecordCreationEntity.class), + .when(entity instanceof RecordCreationEntity, update -> update.and().excludes(RecordCreationEntity.creatorId, RecordCreationEntity.createTime)) .where(GenericEntity.id, pk) .exec(); diff --git a/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/DefaultJdbcExecutor.java b/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/DefaultJdbcExecutor.java index 563a4f14d..f64f409e4 100644 --- a/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/DefaultJdbcExecutor.java +++ b/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/DefaultJdbcExecutor.java @@ -16,14 +16,23 @@ */ @Transactional(rollbackFor = Throwable.class) public class DefaultJdbcExecutor extends AbstractJdbcSqlExecutor { - + @Override public Connection getConnection() { - return DataSourceUtils.getConnection(DataSourceHolder.currentDataSource().getNative()); + DataSource dataSource = DataSourceHolder.currentDataSource().getNative(); + Connection connection = DataSourceUtils.getConnection(dataSource); + boolean isConnectionTransactional = DataSourceUtils.isConnectionTransactional(connection, dataSource); + if (logger.isDebugEnabled()) { + logger.debug("DataSource ({}) JDBC Connection [{}] will {}be managed by Spring", DataSourceHolder.switcher().currentDataSourceId(), connection, (isConnectionTransactional ? "" : "not ")); + } + return connection; } @Override public void releaseConnection(Connection connection) throws SQLException { + if (logger.isDebugEnabled()) { + logger.debug("Releasing DataSource ({}) JDBC Connection [{}]", DataSourceHolder.switcher().currentDataSourceId(), connection); + } DataSourceUtils.releaseConnection(connection, DataSourceHolder.currentDataSource().getNative()); } diff --git a/hsweb-datasource/hsweb-datasource-jta/pom.xml b/hsweb-datasource/hsweb-datasource-jta/pom.xml index 681a85462..4873da565 100644 --- a/hsweb-datasource/hsweb-datasource-jta/pom.xml +++ b/hsweb-datasource/hsweb-datasource-jta/pom.xml @@ -25,6 +25,12 @@ test + + net.sourceforge.jtds + jtds + test + + org.springframework spring-jdbc diff --git a/hsweb-datasource/hsweb-datasource-jta/src/main/java/org/hswebframework/web/datasource/jta/JtaJdbcSqlExecutor.java b/hsweb-datasource/hsweb-datasource-jta/src/main/java/org/hswebframework/web/datasource/jta/JtaJdbcSqlExecutor.java index 03030c5b7..23cc268f0 100644 --- a/hsweb-datasource/hsweb-datasource-jta/src/main/java/org/hswebframework/web/datasource/jta/JtaJdbcSqlExecutor.java +++ b/hsweb-datasource/hsweb-datasource-jta/src/main/java/org/hswebframework/web/datasource/jta/JtaJdbcSqlExecutor.java @@ -7,6 +7,7 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import javax.sql.DataSource; import java.sql.Connection; import java.sql.SQLException; @@ -20,11 +21,20 @@ public class JtaJdbcSqlExecutor extends AbstractJdbcSqlExecutor { @Override public Connection getConnection() { - return DataSourceUtils.getConnection(DataSourceHolder.currentDataSource().getNative()); + DataSource dataSource = DataSourceHolder.currentDataSource().getNative(); + Connection connection = DataSourceUtils.getConnection(dataSource); + boolean isConnectionTransactional = DataSourceUtils.isConnectionTransactional(connection, dataSource); + if (logger.isDebugEnabled()) { + logger.debug("DataSource ({}) JDBC Connection [{}] will {}be managed by Spring", DataSourceHolder.switcher().currentDataSourceId(), connection, (isConnectionTransactional ? "" : "not ")); + } + return connection; } @Override public void releaseConnection(Connection connection) throws SQLException { + if (logger.isDebugEnabled()) { + logger.debug("Releasing DataSource ({}) JDBC Connection [{}]", DataSourceHolder.switcher().currentDataSourceId(), connection); + } DataSourceUtils.releaseConnection(connection, DataSourceHolder.currentDataSource().getNative()); } diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-controller/pom.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-controller/pom.xml new file mode 100644 index 000000000..0240903aa --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-controller/pom.xml @@ -0,0 +1,32 @@ + + + + hsweb-system-template + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-template-controller + + + + javax.servlet + servlet-api + 2.5 + true + + + org.hswebframework.web + hsweb-system-template-service-api + ${project.version} + + + org.hswebframework.web + hsweb-commons-controller + ${project.version} + + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-controller/src/main/java/org/hswebframework/web/controller/tempalte/TempalteController.java b/hsweb-system/hsweb-system-template/hsweb-system-template-controller/src/main/java/org/hswebframework/web/controller/tempalte/TempalteController.java new file mode 100644 index 000000000..2229e7911 --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-controller/src/main/java/org/hswebframework/web/controller/tempalte/TempalteController.java @@ -0,0 +1,35 @@ +package org.hswebframework.web.controller.tempalte; + +import org.hswebframework.web.authorization.annotation.Authorize; +import org.hswebframework.web.commons.entity.param.QueryParamEntity; +import org.hswebframework.web.controller.SimpleGenericEntityController; +import org.hswebframework.web.entity.tempalte.TemplateEntity; +import org.hswebframework.web.logging.AccessLogger; +import org.hswebframework.web.service.tempalte.TemplateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 模板 + * + * @author hsweb-generator-online + */ +@RestController +@RequestMapping("${hsweb.web.mappings.template:template}") +@Authorize(permission = "template") +@AccessLogger("模板") +public class TempalteController implements SimpleGenericEntityController { + + private TemplateService templateService; + + @Autowired + public void setTemplateService(TemplateService templateService) { + this.templateService = templateService; + } + + @Override + public TemplateService getService() { + return templateService; + } +} diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-dao/hsweb-system-template-dao-api/pom.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-dao/hsweb-system-template-dao-api/pom.xml new file mode 100644 index 000000000..f370e8c23 --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-dao/hsweb-system-template-dao-api/pom.xml @@ -0,0 +1,27 @@ + + + + hsweb-system-template-dao + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-template-dao-api + + + + org.hswebframework.web + hsweb-system-template-entity + ${project.version} + + + org.hswebframework.web + hsweb-commons-dao-api + ${project.version} + + + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-dao/hsweb-system-template-dao-api/src/main/java/org/hswebframework/web/dao/tempalte/TemplateDao.java b/hsweb-system/hsweb-system-template/hsweb-system-template-dao/hsweb-system-template-dao-api/src/main/java/org/hswebframework/web/dao/tempalte/TemplateDao.java new file mode 100644 index 000000000..ccb0a69ee --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-dao/hsweb-system-template-dao-api/src/main/java/org/hswebframework/web/dao/tempalte/TemplateDao.java @@ -0,0 +1,11 @@ +package org.hswebframework.web.dao.tempalte; + +import org.hswebframework.web.dao.CrudDao; +import org.hswebframework.web.entity.tempalte.TemplateEntity; + +/** +* 模板 DAO接口 +* @author hsweb-generator-online + */ +public interface TemplateDao extends CrudDao { +} diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-dao/hsweb-system-template-dao-mybatis/pom.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-dao/hsweb-system-template-dao-mybatis/pom.xml new file mode 100644 index 000000000..52b4b883e --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-dao/hsweb-system-template-dao-mybatis/pom.xml @@ -0,0 +1,26 @@ + + + + hsweb-system-template-dao + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-template-dao-mybatis + + + + org.hswebframework.web + hsweb-system-template-dao-api + ${project.version} + + + org.hswebframework.web + hsweb-commons-dao-mybatis + ${project.version} + + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-dao/hsweb-system-template-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/tempalte/TempalteMapper.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-dao/hsweb-system-template-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/tempalte/TempalteMapper.xml new file mode 100644 index 000000000..f077f767f --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-dao/hsweb-system-template-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/tempalte/TempalteMapper.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + delete from s_template where u_id =#{id} + + + + + + + + + + + + + + + + diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-dao/pom.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-dao/pom.xml new file mode 100644 index 000000000..88a60c0a9 --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-dao/pom.xml @@ -0,0 +1,18 @@ + + + + hsweb-system-template + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-template-dao + pom + + hsweb-system-template-dao-api + hsweb-system-template-dao-mybatis + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-entity/pom.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-entity/pom.xml new file mode 100644 index 000000000..533c52fbb --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-entity/pom.xml @@ -0,0 +1,22 @@ + + + + hsweb-system-template + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-template-entity + + + + org.hswebframework.web + hsweb-commons-entity + ${project.version} + + + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-entity/src/main/java/org/hswebframework/web/entity/tempalte/SimpleTemplateEntity.java b/hsweb-system/hsweb-system-template/hsweb-system-template-entity/src/main/java/org/hswebframework/web/entity/tempalte/SimpleTemplateEntity.java new file mode 100644 index 000000000..f3ffc3dc0 --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-entity/src/main/java/org/hswebframework/web/entity/tempalte/SimpleTemplateEntity.java @@ -0,0 +1,100 @@ +package org.hswebframework.web.entity.tempalte; +import org.hswebframework.web.commons.entity.SimpleGenericEntity; + +/** +* 模板 +* @author hsweb-generator-online +*/ +public class SimpleTemplateEntity extends SimpleGenericEntity implements TemplateEntity { + //模板名称 + private String name; + //模板类型 + private String type; + //模板内容 + private String template; + //模板配置 + private String config; + //版本号 + private Long version; + //模板分类 + private String classified; + + /** + * @return 模板名称 + */ + public String getName(){ + return this.name; + } + + /** + * @param name 模板名称 + */ + public void setName(String name){ + this.name=name; + } + /** + * @return 模板类型 + */ + public String getType(){ + return this.type; + } + + /** + * @param type 模板类型 + */ + public void setType(String type){ + this.type=type; + } + /** + * @return 模板内容 + */ + public String getTemplate(){ + return this.template; + } + + /** + * @param template 模板内容 + */ + public void setTemplate(String template){ + this.template=template; + } + /** + * @return 模板配置 + */ + public String getConfig(){ + return this.config; + } + + /** + * @param config 模板配置 + */ + public void setConfig(String config){ + this.config=config; + } + /** + * @return 版本号 + */ + public Long getVersion(){ + return this.version; + } + + /** + * @param version 版本号 + */ + public void setVersion(Long version){ + this.version=version; + } + /** + * @return 模板分类 + */ + public String getClassified(){ + return this.classified; + } + + /** + * @param classified 模板分类 + */ + public void setClassified(String classified){ + this.classified=classified; + } +} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-entity/src/main/java/org/hswebframework/web/entity/tempalte/TemplateEntity.java b/hsweb-system/hsweb-system-template/hsweb-system-template-entity/src/main/java/org/hswebframework/web/entity/tempalte/TemplateEntity.java new file mode 100644 index 000000000..6cac126e0 --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-entity/src/main/java/org/hswebframework/web/entity/tempalte/TemplateEntity.java @@ -0,0 +1,107 @@ +package org.hswebframework.web.entity.tempalte; + +import org.hibernate.validator.constraints.NotBlank; +import org.hswebframework.web.commons.entity.GenericEntity; +import org.hswebframework.web.validator.group.CreateGroup; + +import javax.validation.constraints.NotNull; + +/** + * 模板 实体 + * + * @author hsweb-generator-online + */ +public interface TemplateEntity extends GenericEntity { + /*------------------------------------------- + | 属性名常量 | + ===========================================*/ + /** + * 模板名称 + */ + String name = "name"; + /** + * 模板类型 + */ + String type = "type"; + /** + * 模板内容 + */ + String template = "template"; + /** + * 模板配置 + */ + String config = "config"; + /** + * 版本号 + */ + String version = "version"; + /** + * 模板分类 + */ + String classified = "classified"; + + /** + * @return 模板名称 + */ + @NotBlank(groups = CreateGroup.class) + String getName(); + + /** + * @param name 模板名称 + */ + void setName(String name); + + /** + * @return 模板类型 + */ + @NotBlank(groups = CreateGroup.class) + String getType(); + + /** + * @param type 模板类型 + */ + void setType(String type); + + /** + * @return 模板内容 + */ + @NotBlank(groups = CreateGroup.class) + String getTemplate(); + + /** + * @param template 模板内容 + */ + void setTemplate(String template); + + /** + * @return 模板配置 + */ + String getConfig(); + + /** + * @param config 模板配置 + */ + void setConfig(String config); + + /** + * @return 版本号 + */ + @NotNull(groups = CreateGroup.class) + Long getVersion(); + + /** + * @param version 版本号 + */ + void setVersion(Long version); + + /** + * @return 模板分类 + */ + String getClassified(); + + /** + * @param classified 模板分类 + */ + void setClassified(String classified); + +} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-api/pom.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-api/pom.xml new file mode 100644 index 000000000..5c980680c --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-api/pom.xml @@ -0,0 +1,26 @@ + + + + hsweb-system-template-service + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-template-service-api + + + + org.hswebframework.web + hsweb-commons-service-api + ${project.version} + + + org.hswebframework.web + hsweb-system-template-dao-api + ${project.version} + + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-api/src/main/java/org/hswebframework/web/service/tempalte/TemplateRendeFacotry.java b/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-api/src/main/java/org/hswebframework/web/service/tempalte/TemplateRendeFacotry.java new file mode 100644 index 000000000..e926646a3 --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-api/src/main/java/org/hswebframework/web/service/tempalte/TemplateRendeFacotry.java @@ -0,0 +1,15 @@ +package org.hswebframework.web.service.tempalte; + +import org.hswebframework.web.entity.tempalte.TemplateEntity; + +/** + * 模板渲染器工厂 + * + * @author zhouhao + * @since 3.0 + */ +public interface TemplateRendeFacotry { + boolean isSupport(String type); + + TemplateRender create(TemplateEntity templateEntity); +} diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-api/src/main/java/org/hswebframework/web/service/tempalte/TemplateRender.java b/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-api/src/main/java/org/hswebframework/web/service/tempalte/TemplateRender.java new file mode 100644 index 000000000..f28557022 --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-api/src/main/java/org/hswebframework/web/service/tempalte/TemplateRender.java @@ -0,0 +1,11 @@ +package org.hswebframework.web.service.tempalte; + +/** + * 模板渲染器 + * + * @author zhouhao + * @since 3.0 + */ +public interface TemplateRender { + String render(Object context); +} diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-api/src/main/java/org/hswebframework/web/service/tempalte/TemplateService.java b/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-api/src/main/java/org/hswebframework/web/service/tempalte/TemplateService.java new file mode 100644 index 000000000..b03b5bd16 --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-api/src/main/java/org/hswebframework/web/service/tempalte/TemplateService.java @@ -0,0 +1,13 @@ +package org.hswebframework.web.service.tempalte; + +import org.hswebframework.web.entity.tempalte.TemplateEntity; +import org.hswebframework.web.service.CrudService; + +/** + * 模板 服务类 + * + * @author hsweb-generator-online + */ +public interface TemplateService extends CrudService { + +} diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-simple/pom.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-simple/pom.xml new file mode 100644 index 000000000..f0ffe3fe3 --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-simple/pom.xml @@ -0,0 +1,26 @@ + + + + hsweb-system-template-service + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-template-service-simple + + + + org.hswebframework.web + hsweb-commons-service-simple + ${project.version} + + + org.hswebframework.web + hsweb-system-template-service-api + ${project.version} + + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-simple/src/main/java/org/hswebframework/web/service/tempalte/simple/SimpleTemplateService.java b/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-simple/src/main/java/org/hswebframework/web/service/tempalte/simple/SimpleTemplateService.java new file mode 100644 index 000000000..53ecfe3ef --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-service/hsweb-system-template-service-simple/src/main/java/org/hswebframework/web/service/tempalte/simple/SimpleTemplateService.java @@ -0,0 +1,41 @@ +package org.hswebframework.web.service.tempalte.simple; + +import org.hswebframework.web.dao.tempalte.TemplateDao; +import org.hswebframework.web.entity.tempalte.TemplateEntity; +import org.hswebframework.web.service.GenericEntityService; +import org.hswebframework.web.id.IDGenerator; +import org.hswebframework.web.service.tempalte.TemplateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 默认的服务实现 + * + * @author hsweb-generator-online + */ +@Service("templateService") +public class SimpleTemplateService extends GenericEntityService + implements TemplateService { + @Autowired + private TemplateDao templateDao; + + @Override + protected IDGenerator getIDGenerator() { + return IDGenerator.MD5; + } + + @Override + public TemplateDao getDao() { + return templateDao; + } + + @Override + public int updateByPk(String id, TemplateEntity entity) { + TemplateEntity old = selectByPk(id); + assertNotNull(old); + entity.setVersion(old.getVersion() + 1); + return super.updateByPk(id, entity); + } + + +} diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-service/pom.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-service/pom.xml new file mode 100644 index 000000000..6987f60bc --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-service/pom.xml @@ -0,0 +1,18 @@ + + + + hsweb-system-template + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-template-service + pom + + hsweb-system-template-service-api + hsweb-system-template-service-simple + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-starter/pom.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-starter/pom.xml new file mode 100644 index 000000000..5bda0b58f --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-starter/pom.xml @@ -0,0 +1,78 @@ + + + + hsweb-system-template + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-template-starter + + + + + + src/main/resources + true + + + + + + + org.hswebframework.web + hsweb-system-template-service-simple + ${project.version} + + + + org.hswebframework.web + hsweb-system-template-dao-mybatis + ${project.version} + + + + org.hswebframework.web + hsweb-system-template-controller + ${project.version} + + + + com.h2database + h2 + test + + + + com.alibaba + druid + 1.0.26 + test + + + + org.hswebframework.web + hsweb-spring-boot-starter + ${project.version} + test + + + + org.hswebframework.web + hsweb-tests + ${project.version} + test + + + + javax.servlet + servlet-api + 2.5 + test + + + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/resources/hsweb-starter.js new file mode 100644 index 000000000..653fdaa3a --- /dev/null +++ b/hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/resources/hsweb-starter.js @@ -0,0 +1,45 @@ +//组件信息 +var info = { + groupId: "${project.groupId}", + artifactId: "${project.artifactId}", + version: "${project.version}", + website: "https://github.com/hs-web/hsweb-framework", + author: "admin@hsweb.me", + comment: "模板" +}; + +//版本更新信息 +var versions = [ + // { + // version: "3.0.2", + // upgrade: function (context) { + // java.lang.System.out.println("更新到3.0.2了"); + // } + // } +]; +var JDBCType = java.sql.JDBCType; +function install(context) { + var database = context.database; + database.createOrAlter("s_template") + .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() + .addColumn().name("name").alias("name").comment("模板名称").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() + .addColumn().name("type").alias("type").comment("模板类型").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() + .addColumn().name("template").alias("template").comment("模板内容").jdbcType(java.sql.JDBCType.CLOB).commit() + .addColumn().name("config").alias("config").comment("模板配置").jdbcType(java.sql.JDBCType.CLOB).commit() + .addColumn().name("version").alias("version").comment("版本号").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() + .addColumn().name("classified").alias("classified").comment("模板分类").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() + .comment("模板").commit(); +} +//设置依赖 +dependency.setup(info) + .onInstall(install) + .onUpgrade(function (context) { //更新时执行 + var upgrader = context.upgrader; + upgrader.filter(versions) + .upgrade(function (newVer) { + newVer.upgrade(context); + }); + }) + .onUninstall(function (context) { //卸载时执行 + + }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/pom.xml b/hsweb-system/hsweb-system-template/pom.xml index 9a3b95a80..5a8c9c38e 100644 --- a/hsweb-system/hsweb-system-template/pom.xml +++ b/hsweb-system/hsweb-system-template/pom.xml @@ -10,6 +10,13 @@ 4.0.0 hsweb-system-template + pom - + + hsweb-system-template-controller + hsweb-system-template-dao + hsweb-system-template-entity + hsweb-system-template-service + hsweb-system-template-starter + \ No newline at end of file