hsweb-starter.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2016 http://www.hswebframework.org
  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. //组件信息
  18. var info = {
  19. groupId: "${project.groupId}",
  20. artifactId: "${project.artifactId}",
  21. version: "${project.version}",
  22. website: "https://github.com/hs-web/hsweb-framework/tree/master/hsweb-system/hsweb-system-organizational",
  23. author: "admin@hsweb.me",
  24. comment: "组织架构"
  25. };
  26. //版本更新信息
  27. var versions = [
  28. // {
  29. // version: "3.0.0",
  30. // upgrade: function (context) {
  31. // java.lang.System.out.println("更新到3.0.2了");
  32. // }
  33. // }
  34. ];
  35. var JDBCType = java.sql.JDBCType;
  36. function install(context) {
  37. var database = context.database;
  38. database.createOrAlter("s_organization")
  39. .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit()
  40. .addColumn().name("name_en").alias("nameEn").comment("名称(英文)").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
  41. .addColumn().name("leader").alias("leader").comment("机构负责人").jdbcType(java.sql.JDBCType.VARCHAR).length(256).commit()
  42. .addColumn().name("other_property").alias("otherProperty").comment("其他属性").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
  43. .comment("组织机构表").commit();
  44. database.createOrAlter("s_user")
  45. .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit()
  46. .addColumn().name("nick_name").alias("nickName").comment("昵称").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
  47. .comment("用户表").commit();
  48. }
  49. //设置依赖
  50. dependency.setup(info)
  51. .onInstall(install)
  52. .onUpgrade(function (context) { //更新时执行
  53. var upgrader = context.upgrader;
  54. upgrader.filter(versions)
  55. .upgrade(function (newVer) {
  56. newVer.upgrade(context);
  57. });
  58. })
  59. .onUninstall(function (context) { //卸载时执行
  60. });