From 270dea02e8457f54d52e70f4dc3fa43340c11b25 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Mon, 28 Aug 2017 18:21:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8A=A8=E6=80=81=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=20crud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hsweb-system-script-controller/pom.xml | 32 +++++ .../controller/script/ScriptController.java | 35 ++++++ .../hsweb-system-script-dao-api/pom.xml | 27 ++++ .../web/dao/script/ScriptDao.java | 11 ++ .../hsweb-system-script-dao-mybatis/pom.xml | 26 ++++ .../mybatis/mappers/script/ScriptMapper.xml | 51 ++++++++ .../hsweb-system-script-dao/pom.xml | 18 +++ .../hsweb-system-script-entity/pom.xml | 22 ++++ .../web/entity/script/ScriptEntity.java | 105 ++++++++++++++++ .../web/entity/script/SimpleScriptEntity.java | 115 ++++++++++++++++++ .../hsweb-system-script-service-api/pom.xml | 26 ++++ .../web/service/script/ScriptService.java | 13 ++ .../pom.xml | 26 ++++ .../script/simple/SimpleScriptService.java | 30 +++++ .../hsweb-system-script-service/pom.xml | 18 +++ .../hsweb-system-script-starter/pom.xml | 78 ++++++++++++ .../src/main/resources/hsweb-starter.js | 47 +++++++ hsweb-system/hsweb-system-script/pom.xml | 8 ++ 18 files changed, 688 insertions(+) create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-controller/pom.xml create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-controller/src/main/java/org/hswebframework/web/controller/script/ScriptController.java create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-dao/hsweb-system-script-dao-api/pom.xml create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-dao/hsweb-system-script-dao-api/src/main/java/org/hswebframework/web/dao/script/ScriptDao.java create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-dao/hsweb-system-script-dao-mybatis/pom.xml create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-dao/hsweb-system-script-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/script/ScriptMapper.xml create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-dao/pom.xml create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-entity/pom.xml create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-entity/src/main/java/org/hswebframework/web/entity/script/ScriptEntity.java create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-entity/src/main/java/org/hswebframework/web/entity/script/SimpleScriptEntity.java create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-api/pom.xml create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-api/src/main/java/org/hswebframework/web/service/script/ScriptService.java create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-simple/pom.xml create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-simple/src/main/java/org/hswebframework/web/service/script/simple/SimpleScriptService.java create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-service/pom.xml create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-starter/pom.xml create mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/resources/hsweb-starter.js diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-controller/pom.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-controller/pom.xml new file mode 100644 index 000000000..489eec20c --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-controller/pom.xml @@ -0,0 +1,32 @@ + + + + hsweb-system-script + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-script-controller + + + + javax.servlet + servlet-api + 2.5 + true + + + org.hswebframework.web + hsweb-system-script-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-script/hsweb-system-script-controller/src/main/java/org/hswebframework/web/controller/script/ScriptController.java b/hsweb-system/hsweb-system-script/hsweb-system-script-controller/src/main/java/org/hswebframework/web/controller/script/ScriptController.java new file mode 100644 index 000000000..7d284ce9e --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-controller/src/main/java/org/hswebframework/web/controller/script/ScriptController.java @@ -0,0 +1,35 @@ +package org.hswebframework.web.controller.script; + +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.script.ScriptEntity; +import org.hswebframework.web.logging.AccessLogger; +import org.hswebframework.web.service.script.ScriptService; +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.script:script}") +@Authorize(permission = "script") +@AccessLogger("动态脚本") +public class ScriptController implements SimpleGenericEntityController { + + private ScriptService scriptService; + + @Autowired + public void setScriptService(ScriptService scriptService) { + this.scriptService = scriptService; + } + + @Override + public ScriptService getService() { + return scriptService; + } +} diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-dao/hsweb-system-script-dao-api/pom.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-dao/hsweb-system-script-dao-api/pom.xml new file mode 100644 index 000000000..2a8c51d93 --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-dao/hsweb-system-script-dao-api/pom.xml @@ -0,0 +1,27 @@ + + + + hsweb-system-script-dao + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-script-dao-api + + + + org.hswebframework.web + hsweb-system-script-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-script/hsweb-system-script-dao/hsweb-system-script-dao-api/src/main/java/org/hswebframework/web/dao/script/ScriptDao.java b/hsweb-system/hsweb-system-script/hsweb-system-script-dao/hsweb-system-script-dao-api/src/main/java/org/hswebframework/web/dao/script/ScriptDao.java new file mode 100644 index 000000000..a3084266d --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-dao/hsweb-system-script-dao-api/src/main/java/org/hswebframework/web/dao/script/ScriptDao.java @@ -0,0 +1,11 @@ +package org.hswebframework.web.dao.script; + +import org.hswebframework.web.dao.CrudDao; +import org.hswebframework.web.entity.script.ScriptEntity; + +/** +* 动态脚本 DAO接口 +* @author hsweb-generator-online + */ +public interface ScriptDao extends CrudDao { +} diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-dao/hsweb-system-script-dao-mybatis/pom.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-dao/hsweb-system-script-dao-mybatis/pom.xml new file mode 100644 index 000000000..cbe302aa1 --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-dao/hsweb-system-script-dao-mybatis/pom.xml @@ -0,0 +1,26 @@ + + + + hsweb-system-script-dao + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-script-dao-mybatis + + + + org.hswebframework.web + hsweb-system-script-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-script/hsweb-system-script-dao/hsweb-system-script-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/script/ScriptMapper.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-dao/hsweb-system-script-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/script/ScriptMapper.xml new file mode 100644 index 000000000..2b4ab4d1d --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-dao/hsweb-system-script-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/script/ScriptMapper.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + delete from s_script where u_id =#{id} + + + + + + + + + + + + + + + + diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-dao/pom.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-dao/pom.xml new file mode 100644 index 000000000..307682cd7 --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-dao/pom.xml @@ -0,0 +1,18 @@ + + + + hsweb-system-script + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-script-dao + pom + + hsweb-system-script-dao-api + hsweb-system-script-dao-mybatis + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-entity/pom.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-entity/pom.xml new file mode 100644 index 000000000..8afbd60aa --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-entity/pom.xml @@ -0,0 +1,22 @@ + + + + hsweb-system-script + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-script-entity + + + + org.hswebframework.web + hsweb-commons-entity + ${project.version} + + + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-entity/src/main/java/org/hswebframework/web/entity/script/ScriptEntity.java b/hsweb-system/hsweb-system-script/hsweb-system-script-entity/src/main/java/org/hswebframework/web/entity/script/ScriptEntity.java new file mode 100644 index 000000000..71746b02a --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-entity/src/main/java/org/hswebframework/web/entity/script/ScriptEntity.java @@ -0,0 +1,105 @@ +package org.hswebframework.web.entity.script; +import org.hswebframework.web.commons.entity.GenericEntity; + +/** +* 动态脚本 实体 +* @author hsweb-generator-online +*/ +public interface ScriptEntity extends GenericEntity{ + /*------------------------------------------- + | 属性名常量 | + ===========================================*/ + /** + * 脚本名称 + */ + String name="name"; + /** + * 类型 + */ + String type="type"; + /** + * 脚本内容 + */ + String script="script"; + /** + * 脚本语言 + */ + String language="language"; + /** + * 备注 + */ + String remark="remark"; + /** + * 状态 + */ + String status="status"; + /** + * 脚本标签 + */ + String tag="tag"; + + /** + * @return 脚本名称 + */ + String getName(); + + /** + * @param name 脚本名称 + */ + void setName(String name); + /** + * @return 类型 + */ + String getType(); + + /** + * @param type 类型 + */ + void setType(String type); + /** + * @return 脚本内容 + */ + String getScript(); + + /** + * @param script 脚本内容 + */ + void setScript(String script); + /** + * @return 脚本语言 + */ + String getLanguage(); + + /** + * @param language 脚本语言 + */ + void setLanguage(String language); + /** + * @return 备注 + */ + String getRemark(); + + /** + * @param remark 备注 + */ + void setRemark(String remark); + /** + * @return 状态 + */ + Long getStatus(); + + /** + * @param status 状态 + */ + void setStatus(Long status); + /** + * @return 脚本标签 + */ + String getTag(); + + /** + * @param tag 脚本标签 + */ + void setTag(String tag); + +} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-entity/src/main/java/org/hswebframework/web/entity/script/SimpleScriptEntity.java b/hsweb-system/hsweb-system-script/hsweb-system-script-entity/src/main/java/org/hswebframework/web/entity/script/SimpleScriptEntity.java new file mode 100644 index 000000000..c450ce9cc --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-entity/src/main/java/org/hswebframework/web/entity/script/SimpleScriptEntity.java @@ -0,0 +1,115 @@ +package org.hswebframework.web.entity.script; +import org.hswebframework.web.commons.entity.SimpleGenericEntity; + +/** +* 动态脚本 +* @author hsweb-generator-online +*/ +public class SimpleScriptEntity extends SimpleGenericEntity implements ScriptEntity{ + //脚本名称 + private String name; + //类型 + private String type; + //脚本内容 + private String script; + //脚本语言 + private String language; + //备注 + private String remark; + //状态 + private Long status; + //脚本标签 + private String tag; + + /** + * @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 getScript(){ + return this.script; + } + + /** + * @param script 脚本内容 + */ + public void setScript(String script){ + this.script=script; + } + /** + * @return 脚本语言 + */ + public String getLanguage(){ + return this.language; + } + + /** + * @param language 脚本语言 + */ + public void setLanguage(String language){ + this.language=language; + } + /** + * @return 备注 + */ + public String getRemark(){ + return this.remark; + } + + /** + * @param remark 备注 + */ + public void setRemark(String remark){ + this.remark=remark; + } + /** + * @return 状态 + */ + public Long getStatus(){ + return this.status; + } + + /** + * @param status 状态 + */ + public void setStatus(Long status){ + this.status=status; + } + /** + * @return 脚本标签 + */ + public String getTag(){ + return this.tag; + } + + /** + * @param tag 脚本标签 + */ + public void setTag(String tag){ + this.tag=tag; + } +} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-api/pom.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-api/pom.xml new file mode 100644 index 000000000..a065b791f --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-api/pom.xml @@ -0,0 +1,26 @@ + + + + hsweb-system-script-service + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-script-service-api + + + + org.hswebframework.web + hsweb-commons-service-api + ${project.version} + + + org.hswebframework.web + hsweb-system-script-dao-api + ${project.version} + + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-api/src/main/java/org/hswebframework/web/service/script/ScriptService.java b/hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-api/src/main/java/org/hswebframework/web/service/script/ScriptService.java new file mode 100644 index 000000000..edd6af712 --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-api/src/main/java/org/hswebframework/web/service/script/ScriptService.java @@ -0,0 +1,13 @@ +package org.hswebframework.web.service.script; + +import org.hswebframework.web.entity.script.ScriptEntity; +import org.hswebframework.web.service.CrudService; + +/** + * 动态脚本 服务类 + * + * @author hsweb-generator-online + */ +public interface ScriptService extends CrudService { + +} diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-simple/pom.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-simple/pom.xml new file mode 100644 index 000000000..64c043ce8 --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-simple/pom.xml @@ -0,0 +1,26 @@ + + + + hsweb-system-script-service + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-script-service-simple + + + + org.hswebframework.web + hsweb-commons-service-simple + ${project.version} + + + org.hswebframework.web + hsweb-system-script-service-api + ${project.version} + + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-simple/src/main/java/org/hswebframework/web/service/script/simple/SimpleScriptService.java b/hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-simple/src/main/java/org/hswebframework/web/service/script/simple/SimpleScriptService.java new file mode 100644 index 000000000..ecbf7ba2d --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-service/hsweb-system-script-service-simple/src/main/java/org/hswebframework/web/service/script/simple/SimpleScriptService.java @@ -0,0 +1,30 @@ +package org.hswebframework.web.service.script.simple; + +import org.hswebframework.web.dao.script.ScriptDao; +import org.hswebframework.web.entity.script.ScriptEntity; +import org.hswebframework.web.service.GenericEntityService; +import org.hswebframework.web.id.IDGenerator; +import org.hswebframework.web.service.script.ScriptService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 默认的服务实现 + * + * @author hsweb-generator-online + */ +@Service("scriptService") +public class SimpleScriptService extends GenericEntityService + implements ScriptService { + @Autowired + private ScriptDao scriptDao; + @Override + protected IDGenerator getIDGenerator() { + return IDGenerator.MD5; + } + @Override + public ScriptDao getDao() { + return scriptDao; + } + +} diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-service/pom.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-service/pom.xml new file mode 100644 index 000000000..f2041b9ea --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-service/pom.xml @@ -0,0 +1,18 @@ + + + + hsweb-system-script + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-script-service + pom + + hsweb-system-script-service-api + hsweb-system-script-service-simple + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-starter/pom.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-starter/pom.xml new file mode 100644 index 000000000..246913847 --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-starter/pom.xml @@ -0,0 +1,78 @@ + + + + hsweb-system-script + org.hswebframework.web + 3.0-SNAPSHOT + + 4.0.0 + + hsweb-system-script-starter + + + + + + src/main/resources + true + + + + + + + org.hswebframework.web + hsweb-system-script-service-simple + ${project.version} + + + + org.hswebframework.web + hsweb-system-script-dao-mybatis + ${project.version} + + + + org.hswebframework.web + hsweb-system-script-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-script/hsweb-system-script-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/resources/hsweb-starter.js new file mode 100644 index 000000000..18fdc0705 --- /dev/null +++ b/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/resources/hsweb-starter.js @@ -0,0 +1,47 @@ +//组件信息 +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_script") + .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(256).commit() + .addColumn().name("type").alias("type").comment("类型").jdbcType(java.sql.JDBCType.VARCHAR).length(256).commit() + .addColumn().name("script").alias("script").comment("脚本内容").jdbcType(java.sql.JDBCType.CLOB).commit() + .addColumn().name("language").alias("language").comment("脚本语言").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() + .addColumn().name("remark").alias("remark").comment("备注").jdbcType(java.sql.JDBCType.VARCHAR).length(512).commit() + .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() + .addColumn().name("tag").alias("tag").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-script/pom.xml b/hsweb-system/hsweb-system-script/pom.xml index 50ccdc779..7cf4119ec 100644 --- a/hsweb-system/hsweb-system-script/pom.xml +++ b/hsweb-system/hsweb-system-script/pom.xml @@ -10,6 +10,14 @@ 4.0.0 hsweb-system-script + pom + + hsweb-system-script-dao + hsweb-system-script-service + hsweb-system-script-controller + hsweb-system-script-entity + hsweb-system-script-starter + \ No newline at end of file