mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-05-18 22:13:07 +08:00
一大波优化,完善部分注释
This commit is contained in:
@@ -41,13 +41,13 @@
|
||||
|
||||
| 组织&个人 | 方式 |
|
||||
| ------------- |:-------------:|
|
||||
| [jetbrains.com](https://www.jetbrains.com) |正版[IDE](https://www.jetbrains.com/Toolbox/) 授权 |
|
||||
| [jetbrains.com](https://www.jetbrains.com) |正版 [IDE](https://www.jetbrains.com/Toolbox/) 授权 |
|
||||
| [@杭州-smart](https://github.com/JetBrainZP) |赞助: ¥150 (用于服务器升级) |
|
||||
| [@北京-50%](https://github.com/longfeizheng) |赞助: ¥50 (用于服务器升级) |
|
||||
| [@王乐](https://github.com/gmle) |赞助: ¥20 (用于服务器升级) |
|
||||
| 匿名 |赞助: ¥100 (用于服务器升级) |
|
||||
| [@西安-un](https://github.com/lw5826618) |赞助: ¥50 (用于服务器升级) |
|
||||
| [@重庆-下下](#) |赞助: ¥250 (用于服务器升级) |
|
||||
| [@重庆-下下](https://github.com/web-xiaxia) |赞助: ¥250 (用于服务器升级) |
|
||||
| [@天津-Mr.Chang](https://github.com/changdaye) |赞助: ¥100 (用于服务器升级) |
|
||||
|
||||
| [@北京-青春无罪](https://github.com/gxz04220427) |赞助: ¥100 (用于服务器升级) |
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ package org.hsweb.web.bean.po;
|
||||
import org.hsweb.commons.MD5;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -12,7 +13,7 @@ import java.util.UUID;
|
||||
* 通用的PO对象,实现基本的属性和方法。新建的PO都应继承该类
|
||||
* Created by 浩 on 2015-07-20 0020.
|
||||
*/
|
||||
public class GenericPo<PK> implements Serializable {
|
||||
public class GenericPo<PK> implements Serializable, Cloneable {
|
||||
private static final long serialVersionUID = 9197157871004374522L;
|
||||
/**
|
||||
* 主键
|
||||
@@ -72,4 +73,13 @@ public class GenericPo<PK> implements Serializable {
|
||||
public void setProperties(Map<String, Object> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
Field[] fields = this.getClass().getDeclaredFields();
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
|
||||
}
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,132 +1,154 @@
|
||||
/*
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.hsweb.web.bean.po.classified;
|
||||
|
||||
import org.hsweb.web.bean.po.GenericPo;
|
||||
|
||||
/**
|
||||
*
|
||||
* Created by hsweb-generator 2016-5-14 10:18:41
|
||||
*/
|
||||
public class Classified extends GenericPo<String>{
|
||||
//分类名称
|
||||
private String name;
|
||||
//备注
|
||||
private String remark;
|
||||
//分类类型
|
||||
private String type;
|
||||
//父级分类
|
||||
private String parentId;
|
||||
//显示图标
|
||||
private String icon;
|
||||
//其他配置
|
||||
private String config;
|
||||
//排序
|
||||
private int sortIndex;
|
||||
* 资源分类实体,用于对系统中各种类型的资源进行分类
|
||||
*
|
||||
* @author zhouhao admin@hsweb.me
|
||||
* @since 1.0
|
||||
*/
|
||||
public class Classified extends GenericPo<String> {
|
||||
//分类名称
|
||||
private String name;
|
||||
//备注
|
||||
private String remark;
|
||||
//分类类型
|
||||
private String type;
|
||||
//父级分类
|
||||
private String parentId;
|
||||
//显示图标
|
||||
private String icon;
|
||||
//其他配置
|
||||
private String config;
|
||||
//排序
|
||||
private int sortIndex;
|
||||
|
||||
/**
|
||||
* 获取 分类名称
|
||||
* @return java.lang.String 分类名称
|
||||
*/
|
||||
public String getName(){
|
||||
if(this.name==null)
|
||||
return "";
|
||||
/**
|
||||
* 获取 分类名称
|
||||
*
|
||||
* @return java.lang.String 分类名称
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 分类名称
|
||||
*/
|
||||
public void setName(String name){
|
||||
this.name=name;
|
||||
}
|
||||
/**
|
||||
* 获取 备注
|
||||
* @return java.lang.String 备注
|
||||
*/
|
||||
public String getRemark(){
|
||||
if(this.remark==null)
|
||||
return "";
|
||||
/**
|
||||
* 设置 分类名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 备注
|
||||
*
|
||||
* @return java.lang.String 备注
|
||||
*/
|
||||
public String getRemark() {
|
||||
return this.remark;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 备注
|
||||
*/
|
||||
public void setRemark(String remark){
|
||||
this.remark=remark;
|
||||
}
|
||||
/**
|
||||
* 获取 分类类型
|
||||
* @return java.lang.String 分类类型
|
||||
*/
|
||||
public String getType(){
|
||||
if(this.type==null)
|
||||
return "";
|
||||
/**
|
||||
* 设置 备注
|
||||
*/
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 分类类型
|
||||
*
|
||||
* @return java.lang.String 分类类型
|
||||
*/
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 分类类型
|
||||
*/
|
||||
public void setType(String type){
|
||||
this.type=type;
|
||||
}
|
||||
/**
|
||||
* 获取 父级分类
|
||||
* @return java.lang.String 父级分类
|
||||
*/
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
/**
|
||||
* 设置 分类类型
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 父级分类
|
||||
*/
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
/**
|
||||
* 获取 父级分类
|
||||
*
|
||||
* @return java.lang.String 父级分类
|
||||
*/
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 显示图标
|
||||
* @return java.lang.String 显示图标
|
||||
*/
|
||||
public String getIcon(){
|
||||
if(this.icon==null)
|
||||
return "";
|
||||
/**
|
||||
* 设置 父级分类
|
||||
*/
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 显示图标
|
||||
*
|
||||
* @return java.lang.String 显示图标
|
||||
*/
|
||||
public String getIcon() {
|
||||
return this.icon;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 显示图标
|
||||
*/
|
||||
public void setIcon(String icon){
|
||||
this.icon=icon;
|
||||
}
|
||||
/**
|
||||
* 获取 其他配置
|
||||
* @return java.lang.String 其他配置
|
||||
*/
|
||||
public String getConfig(){
|
||||
if(this.config==null)
|
||||
return "";
|
||||
/**
|
||||
* 设置 显示图标
|
||||
*/
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 其他配置
|
||||
*
|
||||
* @return java.lang.String 其他配置
|
||||
*/
|
||||
public String getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 其他配置
|
||||
*/
|
||||
public void setConfig(String config){
|
||||
this.config=config;
|
||||
}
|
||||
/**
|
||||
* 获取 排序
|
||||
* @return int 排序
|
||||
*/
|
||||
public int getSortIndex() {
|
||||
return sortIndex;
|
||||
}
|
||||
/**
|
||||
* 设置 其他配置
|
||||
*/
|
||||
public void setConfig(String config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 排序
|
||||
*/
|
||||
public void setSortIndex(int sortIndex) {
|
||||
this.sortIndex = sortIndex;
|
||||
}
|
||||
/**
|
||||
* 获取 排序
|
||||
*
|
||||
* @return int 排序
|
||||
*/
|
||||
public int getSortIndex() {
|
||||
return sortIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 排序
|
||||
*/
|
||||
public void setSortIndex(int sortIndex) {
|
||||
this.sortIndex = sortIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,32 @@
|
||||
/*
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.hsweb.web.bean.po.config;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.hsweb.web.bean.po.GenericPo;
|
||||
import org.hsweb.web.bean.po.classified.Classified;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统配置
|
||||
* Created by generator
|
||||
* 系统配置实体
|
||||
*/
|
||||
public class Config extends GenericPo<String> {
|
||||
|
||||
@@ -36,13 +53,13 @@ public class Config extends GenericPo<String> {
|
||||
* @return String 备注
|
||||
*/
|
||||
public String getRemark() {
|
||||
if (this.remark == null)
|
||||
return "";
|
||||
return this.remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 备注
|
||||
*
|
||||
* @param remark 备注
|
||||
*/
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
@@ -54,13 +71,13 @@ public class Config extends GenericPo<String> {
|
||||
* @return String 配置内容
|
||||
*/
|
||||
public String getContent() {
|
||||
if (this.content == null)
|
||||
return "";
|
||||
return this.content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 配置内容
|
||||
*
|
||||
* @param content 配置内容
|
||||
*/
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
@@ -69,16 +86,18 @@ public class Config extends GenericPo<String> {
|
||||
/**
|
||||
* 获取 创建日期
|
||||
*
|
||||
* @return java.util.Date 创建日期
|
||||
* @return {@link Date} 创建日期
|
||||
*/
|
||||
public java.util.Date getCreateDate() {
|
||||
public Date getCreateDate() {
|
||||
return this.createDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 创建日期
|
||||
*
|
||||
* @param createDate 创建日期
|
||||
*/
|
||||
public void setCreateDate(java.util.Date createDate) {
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
@@ -87,26 +106,46 @@ public class Config extends GenericPo<String> {
|
||||
*
|
||||
* @return java.util.Date 最后一次修改日期
|
||||
*/
|
||||
public java.util.Date getUpdateDate() {
|
||||
public Date getUpdateDate() {
|
||||
return this.updateDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 最后一次修改日期
|
||||
*
|
||||
* @param updateDate 最后一次修改日期
|
||||
*/
|
||||
public void setUpdateDate(java.util.Date updateDate) {
|
||||
public void setUpdateDate(Date updateDate) {
|
||||
this.updateDate = updateDate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取分类ID {@link Classified#getId()}
|
||||
*
|
||||
* @return 分类ID
|
||||
*/
|
||||
public String getClassifiedId() {
|
||||
return classifiedId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置分类ID
|
||||
*
|
||||
* @param classifiedId 分类ID
|
||||
*/
|
||||
public void setClassifiedId(String classifiedId) {
|
||||
this.classifiedId = classifiedId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将配置(json)转为map,如果配置内容不为map结构({"key":"value"})
|
||||
* 则使用array[map]方式转换,将array里的map的key的值作为key。value的值作为value。
|
||||
* 比如: 配置内容为[{"key":"1","value":"男"},{"key":"0","value":"女"}].转为map后,则为{"1":"男","2":"女"}
|
||||
*
|
||||
* @return 转换的结果
|
||||
* @since 1.0
|
||||
*/
|
||||
public Map<Object, Object> toMap() {
|
||||
if (getContent().trim().startsWith("{")) {
|
||||
return JSON.parseObject(getContent(), Map.class);
|
||||
@@ -116,6 +155,12 @@ public class Config extends GenericPo<String> {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转为list结构,(如果配置内容结构不为json。将可能抛出异常{@link com.alibaba.fastjson.JSONException})
|
||||
*
|
||||
* @return list结构
|
||||
* @throws com.alibaba.fastjson.JSONException 解析配置内容错误
|
||||
*/
|
||||
public List<Map<Object, Object>> toList() {
|
||||
List<Map<Object, Object>> array = (List) JSON.parseArray(getContent(), Map.class);
|
||||
return array;
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
package org.hsweb.web.bean.po.quartz;
|
||||
|
||||
import org.hsweb.web.bean.po.GenericPo;
|
||||
|
||||
/**
|
||||
* Created by zhouhao on 16-5-20.
|
||||
*/
|
||||
public class QuartzJob extends GenericPo<String> {
|
||||
private String name;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String cron;
|
||||
|
||||
private String script;
|
||||
|
||||
private String language = "groovy";
|
||||
|
||||
private boolean running;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private boolean ready;
|
||||
|
||||
private long lastRunningStartTime;
|
||||
|
||||
private long lastRunningEndTime;
|
||||
|
||||
private String lastResult;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getCron() {
|
||||
return cron;
|
||||
}
|
||||
|
||||
public void setCron(String cron) {
|
||||
this.cron = cron;
|
||||
}
|
||||
|
||||
public String getScript() {
|
||||
return script;
|
||||
}
|
||||
|
||||
public void setScript(String script) {
|
||||
this.script = script;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return running;
|
||||
}
|
||||
|
||||
public void setRunning(boolean running) {
|
||||
this.running = running;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public long getLastRunningStartTime() {
|
||||
return lastRunningStartTime;
|
||||
}
|
||||
|
||||
public void setLastRunningStartTime(long lastRunningStartTime) {
|
||||
this.lastRunningStartTime = lastRunningStartTime;
|
||||
}
|
||||
|
||||
public long getLastRunningEndTime() {
|
||||
return lastRunningEndTime;
|
||||
}
|
||||
|
||||
public void setLastRunningEndTime(long lastRunningEndTime) {
|
||||
this.lastRunningEndTime = lastRunningEndTime;
|
||||
}
|
||||
|
||||
public String getLastResult() {
|
||||
return lastResult;
|
||||
}
|
||||
|
||||
public void setLastResult(String lastResult) {
|
||||
this.lastResult = lastResult;
|
||||
}
|
||||
}
|
||||
@@ -243,14 +243,46 @@ CREATE TABLE "S_HISTORY"
|
||||
"CREATE_DATE" DATETIME NOT NULL,
|
||||
"CREATOR_ID" VARCHAR2(32)
|
||||
);
|
||||
ALTER TABLE "S_USER_PROFILE" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_CLASSIFIED" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_CONFIG" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_MODULES" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_MODULE_META" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_RESOURCES" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_ROLE" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_ROLE_MODULES" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_SCRIPT" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_USER" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_USER_ROLE" ADD PRIMARY KEY ("U_ID");
|
||||
|
||||
CREATE TABLE "S_QUERY_PLAN" (
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"TYPE" VARCHAR2(256) NOT NULL,
|
||||
"CONFIG" CLOB,
|
||||
"SHARING" NUMBER(4),
|
||||
"CREATOR_ID" VARCHAR2(32) NOT NULL,
|
||||
"CREATE_DATE" DATE NOT NULL
|
||||
);
|
||||
COMMENT ON TABLE "S_QUERY_PLAN" IS '查询方案表';
|
||||
COMMENT ON COLUMN "S_QUERY_PLAN"."U_ID" IS '主键';
|
||||
COMMENT ON COLUMN "S_QUERY_PLAN"."NAME" IS '方案名称';
|
||||
COMMENT ON COLUMN "S_QUERY_PLAN"."TYPE" IS '方案分类';
|
||||
COMMENT ON COLUMN "S_QUERY_PLAN"."CONFIG" IS '方案配置';
|
||||
COMMENT ON COLUMN "S_QUERY_PLAN"."SHARING" IS '是否共享方案';
|
||||
COMMENT ON COLUMN "S_QUERY_PLAN"."CREATOR_ID" IS '创建人ID';
|
||||
COMMENT ON COLUMN "S_QUERY_PLAN"."CREATE_DATE" IS '创建日期';
|
||||
|
||||
ALTER TABLE "S_QUERY_PLAN"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_USER_PROFILE"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_CLASSIFIED"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_CONFIG"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_MODULES"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_MODULE_META"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_RESOURCES"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_ROLE"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_ROLE_MODULES"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_SCRIPT"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_USER"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE "S_USER_ROLE"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
@@ -23,7 +23,8 @@ CREATE TABLE `s_config` (
|
||||
`update_date` DATETIME
|
||||
COMMENT '修改日期'
|
||||
);
|
||||
ALTER TABLE `s_config` COMMENT '系统配置文件表';
|
||||
ALTER TABLE `s_config`
|
||||
COMMENT '系统配置文件表';
|
||||
CREATE TABLE `s_form` (
|
||||
`u_id` VARCHAR(32) NOT NULL PRIMARY KEY
|
||||
COMMENT 'uid',
|
||||
@@ -42,7 +43,8 @@ CREATE TABLE `s_form` (
|
||||
`update_date` DATETIME COMMENT '修改日期',
|
||||
`remark` VARCHAR(200)
|
||||
);
|
||||
ALTER TABLE `s_form` COMMENT '动态表单';
|
||||
ALTER TABLE `s_form`
|
||||
COMMENT '动态表单';
|
||||
CREATE TABLE `s_template` (
|
||||
`u_id` VARCHAR(32) NOT NULL PRIMARY KEY
|
||||
COMMENT 'uid',
|
||||
@@ -61,7 +63,8 @@ CREATE TABLE `s_template` (
|
||||
`using` TINYINT COMMENT '是否使用中',
|
||||
`remark` VARCHAR(200)
|
||||
);
|
||||
ALTER TABLE `s_template` COMMENT '模板';
|
||||
ALTER TABLE `s_template`
|
||||
COMMENT '模板';
|
||||
CREATE TABLE `s_modules` (
|
||||
`u_id` VARCHAR(32) NOT NULL PRIMARY KEY
|
||||
COMMENT 'uid',
|
||||
@@ -82,7 +85,8 @@ CREATE TABLE `s_modules` (
|
||||
`sort_index` INT(32) NOT NULL
|
||||
COMMENT '排序'
|
||||
);
|
||||
ALTER TABLE `s_modules` COMMENT '系统模块';
|
||||
ALTER TABLE `s_modules`
|
||||
COMMENT '系统模块';
|
||||
CREATE TABLE `s_module_meta` (
|
||||
`u_id` VARCHAR(32) NOT NULL PRIMARY KEY
|
||||
COMMENT 'uid',
|
||||
@@ -99,7 +103,8 @@ CREATE TABLE `s_module_meta` (
|
||||
`meta` TEXT NULL
|
||||
COMMENT '定义内容'
|
||||
);
|
||||
ALTER TABLE `s_modules` COMMENT '系统模块配置';
|
||||
ALTER TABLE `s_modules`
|
||||
COMMENT '系统模块配置';
|
||||
CREATE TABLE `s_resources` (
|
||||
`u_id` VARCHAR(32) NOT NULL PRIMARY KEY
|
||||
COMMENT 'uid',
|
||||
@@ -120,7 +125,8 @@ CREATE TABLE `s_resources` (
|
||||
`creator_id` VARCHAR(256) NOT NULL
|
||||
COMMENT '创建人'
|
||||
);
|
||||
ALTER TABLE `s_resources` COMMENT '资源表';
|
||||
ALTER TABLE `s_resources`
|
||||
COMMENT '资源表';
|
||||
CREATE TABLE `s_classified` (
|
||||
`u_id` VARCHAR(32) NOT NULL PRIMARY KEY
|
||||
COMMENT 'uid',
|
||||
@@ -137,7 +143,8 @@ CREATE TABLE `s_classified` (
|
||||
`sort_index` INT NOT NULL
|
||||
COMMENT '排序'
|
||||
);
|
||||
ALTER TABLE `s_resources` COMMENT '资源表';
|
||||
ALTER TABLE `s_resources`
|
||||
COMMENT '资源表';
|
||||
CREATE TABLE `s_role` (
|
||||
`u_id` VARCHAR(32) NOT NULL PRIMARY KEY
|
||||
COMMENT 'uid',
|
||||
@@ -148,7 +155,8 @@ CREATE TABLE `s_role` (
|
||||
`remark` VARCHAR(512) NULL
|
||||
COMMENT '备注'
|
||||
);
|
||||
ALTER TABLE `s_role` COMMENT '角色表';
|
||||
ALTER TABLE `s_role`
|
||||
COMMENT '角色表';
|
||||
CREATE TABLE `s_role_modules` (
|
||||
`u_id` VARCHAR(32) NOT NULL PRIMARY KEY
|
||||
COMMENT 'uid',
|
||||
@@ -159,7 +167,8 @@ CREATE TABLE `s_role_modules` (
|
||||
`actions` TEXT NULL
|
||||
COMMENT '可操作权限'
|
||||
);
|
||||
ALTER TABLE `s_role_modules` COMMENT '角色模块绑定表';
|
||||
ALTER TABLE `s_role_modules`
|
||||
COMMENT '角色模块绑定表';
|
||||
CREATE TABLE `s_script` (
|
||||
`u_id` VARCHAR(32) NOT NULL PRIMARY KEY
|
||||
COMMENT 'uid',
|
||||
@@ -176,7 +185,8 @@ CREATE TABLE `s_script` (
|
||||
`status` INT(4) NULL
|
||||
COMMENT '状态'
|
||||
);
|
||||
ALTER TABLE `s_script` COMMENT '脚本';
|
||||
ALTER TABLE `s_script`
|
||||
COMMENT '脚本';
|
||||
CREATE TABLE `s_user` (
|
||||
`u_id` VARCHAR(32) NOT NULL PRIMARY KEY
|
||||
COMMENT 'ID',
|
||||
@@ -197,7 +207,8 @@ CREATE TABLE `s_user` (
|
||||
`update_date` DATETIME NULL
|
||||
COMMENT '修改日期'
|
||||
);
|
||||
ALTER TABLE `s_user` COMMENT '用户表';
|
||||
ALTER TABLE `s_user`
|
||||
COMMENT '用户表';
|
||||
CREATE TABLE `s_user_role` (
|
||||
`u_id` VARCHAR(32) NOT NULL PRIMARY KEY
|
||||
COMMENT 'UID',
|
||||
@@ -206,10 +217,11 @@ CREATE TABLE `s_user_role` (
|
||||
`role_id` VARCHAR(256) NOT NULL
|
||||
COMMENT '角色ID'
|
||||
);
|
||||
ALTER TABLE `s_user_role` COMMENT '用户角色关联表';
|
||||
ALTER TABLE `s_user_role`
|
||||
COMMENT '用户角色关联表';
|
||||
CREATE TABLE s_history
|
||||
(
|
||||
`u_id` VARCHAR(32) NOT NULL
|
||||
`u_id` VARCHAR(32) NOT NULL PRIMARY KEY
|
||||
COMMENT 'UID',
|
||||
`type` VARCHAR(64) NOT NULL
|
||||
COMMENT '类型',
|
||||
@@ -222,4 +234,23 @@ CREATE TABLE s_history
|
||||
COMMENT '创建日期',
|
||||
`creator_id` VARCHAR(32) COMMENT '创建人'
|
||||
);
|
||||
ALTER TABLE `s_history` COMMENT '操作记录表';
|
||||
ALTER TABLE `s_history`
|
||||
COMMENT '操作记录表';
|
||||
|
||||
CREATE TABLE s_query_plan
|
||||
(
|
||||
`u_id` VARCHAR(32) NOT NULL PRIMARY KEY
|
||||
COMMENT 'UID',
|
||||
`name` VARCHAR(256) NOT NULL
|
||||
COMMENT '名称',
|
||||
`type` VARCHAR(256) NOT NULL
|
||||
COMMENT '类型',
|
||||
`CONFIG` TEXT COMMENT '方案配置内容',
|
||||
`SHARING` TINYINT COMMENT '是否共享',
|
||||
`CREATOR_ID` VARCHAR(32) NOT NULL
|
||||
COMMENT '创建人ID',
|
||||
`CREATE_DATE` DATE NOT NULL
|
||||
COMMENT '创建日期'
|
||||
);
|
||||
ALTER TABLE `s_query_plan`
|
||||
COMMENT '查询方案';
|
||||
@@ -1,8 +1,8 @@
|
||||
CREATE TABLE ${jdbc.username}."S_USER_PROFILE" (
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"CONTENT" CLOB NOT NULL,
|
||||
"TYPE" VARCHAR2(512) NULL,
|
||||
"USER_ID" VARCHAR2(32) NULL
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"CONTENT" CLOB NOT NULL,
|
||||
"TYPE" VARCHAR2(512) NULL,
|
||||
"USER_ID" VARCHAR2(32) NULL
|
||||
);
|
||||
COMMENT ON TABLE ${jdbc.username}."S_USER_PROFILE" IS '用户配置表';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_USER_PROFILE"."U_ID" IS 'UID';
|
||||
@@ -10,14 +10,13 @@ COMMENT ON COLUMN ${jdbc.username}."S_USER_PROFILE"."CONTENT" IS '配置内容';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_USER_PROFILE"."TYPE" IS '类型';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_USER_PROFILE"."USER_ID" IS '用户ID';
|
||||
|
||||
|
||||
CREATE TABLE ${jdbc.username}."S_CONFIG" (
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"CONTENT" CLOB NOT NULL,
|
||||
"REMARK" VARCHAR2(512) NULL,
|
||||
"CLASSIFIED_ID" VARCHAR2(32) NULL,
|
||||
"CREATE_DATE" DATE NOT NULL,
|
||||
"UPDATE_DATE" DATE NULL
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"CONTENT" CLOB NOT NULL,
|
||||
"REMARK" VARCHAR2(512) NULL,
|
||||
"CLASSIFIED_ID" VARCHAR2(32) NULL,
|
||||
"CREATE_DATE" DATE NOT NULL,
|
||||
"UPDATE_DATE" DATE NULL
|
||||
);
|
||||
COMMENT ON TABLE ${jdbc.username}."S_CONFIG" IS '系统配置文件表';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_CONFIG"."U_ID" IS 'UID';
|
||||
@@ -27,20 +26,21 @@ COMMENT ON COLUMN ${jdbc.username}."S_CONFIG"."CLASSIFIED_ID" IS '分类ID';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_CONFIG"."CREATE_DATE" IS '创建日期';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_CONFIG"."UPDATE_DATE" IS '修改日期';
|
||||
CREATE TABLE ${jdbc.username}."S_FORM" (
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"CLASSIFIED_ID" VARCHAR2(32),
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"HTML" CLOB NULL,
|
||||
"META" CLOB NULL,
|
||||
"CONFIG" CLOB NULL,
|
||||
"VERSION" NUMBER(32) NULL,
|
||||
"REVISION" NUMBER(32) NULL,
|
||||
"RELEASE" NUMBER(32) NULL,
|
||||
"USING" NUMBER(4) NULL,
|
||||
"CREATE_DATE" DATE NOT NULL,
|
||||
"UPDATE_DATE" DATE NULL,
|
||||
"REMARK" VARCHAR2(200) NULL
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"CLASSIFIED_ID" VARCHAR2(32),
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"HTML" CLOB NULL,
|
||||
"META" CLOB NULL,
|
||||
"CONFIG" CLOB NULL,
|
||||
"VERSION" NUMBER(32) NULL,
|
||||
"REVISION" NUMBER(32) NULL,
|
||||
"RELEASE" NUMBER(32) NULL,
|
||||
"USING" NUMBER(4) NULL,
|
||||
"CREATE_DATE" DATE NOT NULL,
|
||||
"UPDATE_DATE" DATE NULL,
|
||||
"REMARK" VARCHAR2(200) NULL
|
||||
);
|
||||
COMMENT ON TABLE ${jdbc.username}."S_FORM" IS '动态表单';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_FORM"."U_ID" IS 'UID';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_FORM"."CLASSIFIED_ID" IS '分类ID';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_FORM"."NAME" IS '名称';
|
||||
@@ -54,21 +54,22 @@ COMMENT ON COLUMN ${jdbc.username}."S_FORM"."USING" IS '是否使用中';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_FORM"."CREATE_DATE" IS '创建日期';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_FORM"."UPDATE_DATE" IS '修改日期';
|
||||
CREATE TABLE ${jdbc.username}."S_TEMPLATE" (
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"TEMPLATE" CLOB NULL,
|
||||
"CLASSIFIED_ID" VARCHAR2(32) NULL,
|
||||
"TYPE" VARCHAR2(64) NULL,
|
||||
"SCRIPT" CLOB NULL,
|
||||
"CSS" CLOB NULL,
|
||||
"CSS_LINKS" CLOB NULL,
|
||||
"SCRIPT_LINKS" CLOB NULL,
|
||||
"VERSION" NUMBER(32) NULL,
|
||||
"REVISION" NUMBER(32) NULL,
|
||||
"RELEASE" NUMBER(32) NULL,
|
||||
"USING" NUMBER(4) NULL,
|
||||
"REMARK" VARCHAR2(200) NULL
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"TEMPLATE" CLOB NULL,
|
||||
"CLASSIFIED_ID" VARCHAR2(32) NULL,
|
||||
"TYPE" VARCHAR2(64) NULL,
|
||||
"SCRIPT" CLOB NULL,
|
||||
"CSS" CLOB NULL,
|
||||
"CSS_LINKS" CLOB NULL,
|
||||
"SCRIPT_LINKS" CLOB NULL,
|
||||
"VERSION" NUMBER(32) NULL,
|
||||
"REVISION" NUMBER(32) NULL,
|
||||
"RELEASE" NUMBER(32) NULL,
|
||||
"USING" NUMBER(4) NULL,
|
||||
"REMARK" VARCHAR2(200) NULL
|
||||
);
|
||||
COMMENT ON TABLE ${jdbc.username}."S_TEMPLATE" IS '模板';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_TEMPLATE"."U_ID" IS 'UID';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_TEMPLATE"."NAME" IS '名称';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_TEMPLATE"."TEMPLATE" IS '模板';
|
||||
@@ -83,15 +84,15 @@ COMMENT ON COLUMN ${jdbc.username}."S_TEMPLATE"."REVISION" IS '修订版';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_TEMPLATE"."RELEASE" IS '当前发布版本';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_TEMPLATE"."USING" IS '是否使用中';
|
||||
CREATE TABLE ${jdbc.username}."S_MODULES" (
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"URI" VARCHAR2(1024) NULL,
|
||||
"ICON" VARCHAR2(256) NULL,
|
||||
"PARENT_ID" VARCHAR2(256) NOT NULL,
|
||||
"REMARK" VARCHAR2(512) NULL,
|
||||
"STATUS" NUMBER(4) NULL,
|
||||
"OPTIONAL" CLOB NOT NULL,
|
||||
"SORT_INDEX" NUMBER(32) NOT NULL
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"URI" VARCHAR2(1024) NULL,
|
||||
"ICON" VARCHAR2(256) NULL,
|
||||
"PARENT_ID" VARCHAR2(256) NOT NULL,
|
||||
"REMARK" VARCHAR2(512) NULL,
|
||||
"STATUS" NUMBER(4) NULL,
|
||||
"OPTIONAL" CLOB NOT NULL,
|
||||
"SORT_INDEX" NUMBER(32) NOT NULL
|
||||
);
|
||||
COMMENT ON TABLE ${jdbc.username}."S_MODULES" IS '系统模块';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_MODULES"."U_ID" IS 'UID';
|
||||
@@ -104,14 +105,14 @@ COMMENT ON COLUMN ${jdbc.username}."S_MODULES"."STATUS" IS '状态';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_MODULES"."OPTIONAL" IS '可选权限';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_MODULES"."SORT_INDEX" IS '排序';
|
||||
CREATE TABLE ${jdbc.username}."S_CLASSIFIED" (
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"REMARK" VARCHAR2(1024) NULL,
|
||||
"TYPE" VARCHAR2(256) NULL,
|
||||
"PARENT_ID" VARCHAR2(32) NOT NULL,
|
||||
"ICON" VARCHAR2(256) NULL,
|
||||
"CONFIG" CLOB NULL,
|
||||
"SORT_INDEX" NUMBER(32) NULL
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"REMARK" VARCHAR2(1024) NULL,
|
||||
"TYPE" VARCHAR2(256) NULL,
|
||||
"PARENT_ID" VARCHAR2(32) NOT NULL,
|
||||
"ICON" VARCHAR2(256) NULL,
|
||||
"CONFIG" CLOB NULL,
|
||||
"SORT_INDEX" NUMBER(32) NULL
|
||||
);
|
||||
COMMENT ON TABLE ${jdbc.username}."S_CLASSIFIED" IS '数据分类表';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_CLASSIFIED"."U_ID" IS 'UID';
|
||||
@@ -123,13 +124,13 @@ COMMENT ON COLUMN ${jdbc.username}."S_CLASSIFIED"."ICON" IS '图标';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_CLASSIFIED"."CONFIG" IS '分类配置';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_CLASSIFIED"."SORT_INDEX" IS '排序';
|
||||
CREATE TABLE ${jdbc.username}."S_MODULE_META" (
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"KEY" VARCHAR2(256) NOT NULL,
|
||||
"MODULE_ID" VARCHAR2(32) NOT NULL,
|
||||
"ROLE_ID" VARCHAR2(32) NULL,
|
||||
"REMARK" VARCHAR2(1024) NULL,
|
||||
"META" CLOB NULL,
|
||||
"STATUS" NUMBER(4) NULL
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"KEY" VARCHAR2(256) NOT NULL,
|
||||
"MODULE_ID" VARCHAR2(32) NOT NULL,
|
||||
"ROLE_ID" VARCHAR2(32) NULL,
|
||||
"REMARK" VARCHAR2(1024) NULL,
|
||||
"META" CLOB NULL,
|
||||
"STATUS" NUMBER(4) NULL
|
||||
);
|
||||
COMMENT ON TABLE ${jdbc.username}."S_MODULE_META" IS '系统模块配置';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_MODULE_META"."U_ID" IS 'UID';
|
||||
@@ -140,16 +141,16 @@ COMMENT ON COLUMN ${jdbc.username}."S_MODULE_META"."META" IS '定义内容';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_MODULE_META"."REMARK" IS '备注';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_MODULE_META"."STATUS" IS '状态';
|
||||
CREATE TABLE ${jdbc.username}."S_RESOURCES" (
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"PATH" VARCHAR2(1024) NOT NULL,
|
||||
"TYPE" VARCHAR2(256) NOT NULL,
|
||||
"CLASSIFIED" VARCHAR2(32) NULL,
|
||||
"MD5" VARCHAR2(256) NOT NULL,
|
||||
"SIZE" NUMBER(32) NULL,
|
||||
"STATUS" NUMBER(4) NULL,
|
||||
"CREATE_DATE" DATE NOT NULL,
|
||||
"CREATOR_ID" VARCHAR2(256) NOT NULL
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"PATH" VARCHAR2(1024) NOT NULL,
|
||||
"TYPE" VARCHAR2(256) NOT NULL,
|
||||
"CLASSIFIED" VARCHAR2(32) NULL,
|
||||
"MD5" VARCHAR2(256) NOT NULL,
|
||||
"SIZE" NUMBER(32) NULL,
|
||||
"STATUS" NUMBER(4) NULL,
|
||||
"CREATE_DATE" DATE NOT NULL,
|
||||
"CREATOR_ID" VARCHAR2(256) NOT NULL
|
||||
);
|
||||
COMMENT ON TABLE ${jdbc.username}."S_RESOURCES" IS '资源表';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_RESOURCES"."U_ID" IS 'UID';
|
||||
@@ -163,10 +164,10 @@ COMMENT ON COLUMN ${jdbc.username}."S_RESOURCES"."STATUS" IS '状态';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_RESOURCES"."CREATE_DATE" IS '创建时间';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_RESOURCES"."CREATOR_ID" IS '创建人';
|
||||
CREATE TABLE ${jdbc.username}."S_ROLE" (
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"TYPE" VARCHAR2(50) NULL,
|
||||
"REMARK" VARCHAR2(512) NULL
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"TYPE" VARCHAR2(50) NULL,
|
||||
"REMARK" VARCHAR2(512) NULL
|
||||
);
|
||||
COMMENT ON TABLE ${jdbc.username}."S_ROLE" IS '角色表';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_ROLE"."U_ID" IS 'UID';
|
||||
@@ -174,10 +175,10 @@ COMMENT ON COLUMN ${jdbc.username}."S_ROLE"."NAME" IS '角色名称';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_ROLE"."TYPE" IS '类型';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_ROLE"."REMARK" IS '备注';
|
||||
CREATE TABLE ${jdbc.username}."S_ROLE_MODULES" (
|
||||
"U_ID" VARCHAR2(23) NOT NULL,
|
||||
"MODULE_ID" VARCHAR2(256) NOT NULL,
|
||||
"ROLE_ID" VARCHAR2(256) NOT NULL,
|
||||
"ACTIONS" CLOB NULL
|
||||
"U_ID" VARCHAR2(23) NOT NULL,
|
||||
"MODULE_ID" VARCHAR2(256) NOT NULL,
|
||||
"ROLE_ID" VARCHAR2(256) NOT NULL,
|
||||
"ACTIONS" CLOB NULL
|
||||
);
|
||||
COMMENT ON TABLE ${jdbc.username}."S_ROLE_MODULES" IS '角色模块绑定表';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_ROLE_MODULES"."U_ID" IS 'UID';
|
||||
@@ -185,13 +186,13 @@ COMMENT ON COLUMN ${jdbc.username}."S_ROLE_MODULES"."MODULE_ID" IS '模块ID';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_ROLE_MODULES"."ROLE_ID" IS '角色ID';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_ROLE_MODULES"."ACTIONS" IS '可操作权限';
|
||||
CREATE TABLE ${jdbc.username}."S_SCRIPT" (
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"CLASSIFIED_ID" VARCHAR2(1024) NOT NULL,
|
||||
"TYPE" VARCHAR2(256) NOT NULL,
|
||||
"CONTENT" CLOB NOT NULL,
|
||||
"REMARK" VARCHAR2(512) NULL,
|
||||
"STATUS" NUMBER(4) NULL
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"CLASSIFIED_ID" VARCHAR2(1024) NOT NULL,
|
||||
"TYPE" VARCHAR2(256) NOT NULL,
|
||||
"CONTENT" CLOB NOT NULL,
|
||||
"REMARK" VARCHAR2(512) NULL,
|
||||
"STATUS" NUMBER(4) NULL
|
||||
);
|
||||
COMMENT ON TABLE ${jdbc.username}."S_SCRIPT" IS '脚本';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_SCRIPT"."U_ID" IS 'UID';
|
||||
@@ -202,15 +203,15 @@ COMMENT ON COLUMN ${jdbc.username}."S_SCRIPT"."CONTENT" IS '内容';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_SCRIPT"."REMARK" IS '备注';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_SCRIPT"."STATUS" IS '状态';
|
||||
CREATE TABLE ${jdbc.username}."S_USER" (
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"USERNAME" VARCHAR2(64) NOT NULL,
|
||||
"PASSWORD" VARCHAR2(64) NOT NULL,
|
||||
"NAME" VARCHAR2(64) NULL,
|
||||
"EMAIL" VARCHAR2(512) NULL,
|
||||
"PHONE" VARCHAR2(64) NULL,
|
||||
"STATUS" NUMBER(4) NULL,
|
||||
"CREATE_DATE" DATE NOT NULL,
|
||||
"UPDATE_DATE" DATE NULL
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"USERNAME" VARCHAR2(64) NOT NULL,
|
||||
"PASSWORD" VARCHAR2(64) NOT NULL,
|
||||
"NAME" VARCHAR2(64) NULL,
|
||||
"EMAIL" VARCHAR2(512) NULL,
|
||||
"PHONE" VARCHAR2(64) NULL,
|
||||
"STATUS" NUMBER(4) NULL,
|
||||
"CREATE_DATE" DATE NOT NULL,
|
||||
"UPDATE_DATE" DATE NULL
|
||||
);
|
||||
COMMENT ON TABLE ${jdbc.username}."S_USER" IS '用户表';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_USER"."U_ID" IS 'ID';
|
||||
@@ -223,33 +224,66 @@ COMMENT ON COLUMN ${jdbc.username}."S_USER"."STATUS" IS '状态';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_USER"."CREATE_DATE" IS '创建日期';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_USER"."UPDATE_DATE" IS '修改日期';
|
||||
CREATE TABLE ${jdbc.username}."S_USER_ROLE" (
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"USER_ID" VARCHAR2(256) NOT NULL,
|
||||
"ROLE_ID" VARCHAR2(256) NOT NULL
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"USER_ID" VARCHAR2(256) NOT NULL,
|
||||
"ROLE_ID" VARCHAR2(256) NOT NULL
|
||||
);
|
||||
CREATE TABLE ${jdbc.username}."S_HISTORY"
|
||||
(
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"TYPE" VARCHAR2(64) NOT NULL,
|
||||
"DESCRIBE" VARCHAR2(512),
|
||||
"PRIMARY_KEY_NAME" VARCHAR2(32),
|
||||
"PRIMARY_KEY_VALUE" VARCHAR2(64),
|
||||
"CHANGE_BEFORE" CLOB,
|
||||
"CHANGE_AFTER" CLOB,
|
||||
"CREATE_DATE" DATE NOT NULL,
|
||||
"CREATOR_ID" VARCHAR2(32)
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"TYPE" VARCHAR2(64) NOT NULL,
|
||||
"DESCRIBE" VARCHAR2(512),
|
||||
"PRIMARY_KEY_NAME" VARCHAR2(32),
|
||||
"PRIMARY_KEY_VALUE" VARCHAR2(64),
|
||||
"CHANGE_BEFORE" CLOB,
|
||||
"CHANGE_AFTER" CLOB,
|
||||
"CREATE_DATE" DATE NOT NULL,
|
||||
"CREATOR_ID" VARCHAR2(32)
|
||||
);
|
||||
COMMENT ON TABLE ${jdbc.username}."S_HISTORY" IS '历史记录';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_USER_ROLE"."U_ID" IS 'UID';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_USER_ROLE"."USER_ID" IS '用户ID';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_USER_ROLE"."ROLE_ID" IS '角色ID';
|
||||
ALTER TABLE ${jdbc.username}."S_USER_PROFILE" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_CLASSIFIED" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_CONFIG" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_MODULES" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_MODULE_META" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_RESOURCES" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_ROLE" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_ROLE_MODULES" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_SCRIPT" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_USER" ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_USER_ROLE" ADD PRIMARY KEY ("U_ID");
|
||||
|
||||
CREATE TABLE ${jdbc.username}."S_QUERY_PLAN" (
|
||||
"U_ID" VARCHAR2(32) NOT NULL,
|
||||
"NAME" VARCHAR2(256) NOT NULL,
|
||||
"TYPE" VARCHAR2(256) NOT NULL,
|
||||
"CONFIG" CLOB,
|
||||
"SHARING" NUMBER(4),
|
||||
"CREATOR_ID" VARCHAR2(32) NOT NULL,
|
||||
"CREATE_DATE" DATE NOT NULL
|
||||
);
|
||||
COMMENT ON TABLE ${jdbc.username}."S_QUERY_PLAN" IS '查询方案表';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_QUERY_PLAN"."U_ID" IS '主键';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_QUERY_PLAN"."NAME" IS '方案名称';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_QUERY_PLAN"."TYPE" IS '方案分类';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_QUERY_PLAN"."CONFIG" IS '方案配置';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_QUERY_PLAN"."SHARING" IS '是否共享方案';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_QUERY_PLAN"."CREATOR_ID" IS '创建人ID';
|
||||
COMMENT ON COLUMN ${jdbc.username}."S_QUERY_PLAN"."CREATE_DATE" IS '创建日期';
|
||||
|
||||
ALTER TABLE ${jdbc.username}."S_QUERY_PLAN"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_USER_PROFILE"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_CLASSIFIED"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_CONFIG"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_MODULES"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_MODULE_META"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_RESOURCES"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_ROLE"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_ROLE_MODULES"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_SCRIPT"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_USER"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
ALTER TABLE ${jdbc.username}."S_USER_ROLE"
|
||||
ADD PRIMARY KEY ("U_ID");
|
||||
@@ -1,4 +1,4 @@
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.hsweb.concureent.cache.RedisCacheManagerAutoConfig,\
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.hsweb.concureent.cache.RedisCacheManagerAutoConfig,\
|
||||
org.hsweb.concureent.cache.ConcurrentMapCacheManagerAutoConfig
|
||||
@@ -33,6 +33,10 @@ public class RedisLock implements Lock {
|
||||
lockValue = new byte[0];
|
||||
}
|
||||
|
||||
public void setWaitTime(long waitTime) {
|
||||
this.waitTime = waitTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lock() {
|
||||
redisTemplate.execute((RedisCallback<Boolean>) connection -> {
|
||||
|
||||
@@ -18,7 +18,6 @@ public class RedisReadWriteLock implements ReadWriteLock {
|
||||
static final long DEFAULT_EXPIRE = 60;
|
||||
private ReadLock readLock;
|
||||
private WriteLock writeLock;
|
||||
private String key;
|
||||
private long lockKeyExpireTime = DEFAULT_EXPIRE;
|
||||
private long waitTime = 30;
|
||||
protected byte[] lockValue;
|
||||
@@ -29,7 +28,6 @@ public class RedisReadWriteLock implements ReadWriteLock {
|
||||
public RedisReadWriteLock(String key, RedisTemplate redisTemplate) {
|
||||
Assert.notNull(key);
|
||||
Assert.notNull(redisTemplate);
|
||||
this.key = key;
|
||||
this.redisTemplate = redisTemplate;
|
||||
readLock = new ReadLock();
|
||||
writeLock = new WriteLock();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.hsweb.concurrent.lock.LockFactoryAutoConfig,\
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.hsweb.concurrent.lock.LockFactoryAutoConfig,\
|
||||
org.hsweb.concurrent.lock.support.redis.RedisLockFactoryAutoConfig
|
||||
@@ -2,6 +2,7 @@ package org.hsweb.web.controller;
|
||||
|
||||
import org.hsweb.web.core.exception.BusinessException;
|
||||
import org.hsweb.web.core.message.ResponseMessage;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
|
||||
@@ -9,5 +9,4 @@ import java.util.Map;
|
||||
*/
|
||||
public interface DynamicFormAuthorizeValidator {
|
||||
boolean validate(String formName, User user,Map<String,Object> params, String... actions);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 https://github.com/hs-web
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,9 +17,10 @@
|
||||
package org.hsweb.web.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.hsweb.web.core.authorize.annotation.Authorize;
|
||||
import org.hsweb.commons.ClassUtils;
|
||||
import org.hsweb.web.bean.common.QueryParam;
|
||||
import org.hsweb.web.bean.po.GenericPo;
|
||||
import org.hsweb.web.core.authorize.annotation.Authorize;
|
||||
import org.hsweb.web.core.exception.BusinessException;
|
||||
import org.hsweb.web.core.exception.NotFoundException;
|
||||
import org.hsweb.web.core.logger.annotation.AccessLogger;
|
||||
@@ -29,11 +30,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.hsweb.commons.ClassUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通用控制器,此控制器实现了通用的增删改查功能
|
||||
@@ -134,7 +132,7 @@ public abstract class GenericController<PO, PK> {
|
||||
@AccessLogger("新增")
|
||||
@Authorize(action = "C")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ResponseMessage add(@RequestBody(required = true) PO object) {
|
||||
public ResponseMessage add(@RequestBody PO object) {
|
||||
PK pk = getService().insert(object);
|
||||
return ResponseMessage.created(pk);
|
||||
}
|
||||
@@ -167,7 +165,7 @@ public abstract class GenericController<PO, PK> {
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
|
||||
@AccessLogger("修改")
|
||||
@Authorize(action = "U")
|
||||
public ResponseMessage update(@PathVariable("id") PK id, @RequestBody(required = true) PO object) {
|
||||
public ResponseMessage update(@PathVariable("id") PK id, @RequestBody PO object) {
|
||||
PO old = getService().selectByPk(id);
|
||||
assertFound(old, "data is not found!");
|
||||
if (object instanceof GenericPo) {
|
||||
@@ -187,7 +185,7 @@ public abstract class GenericController<PO, PK> {
|
||||
@RequestMapping(method = RequestMethod.PUT)
|
||||
@AccessLogger("批量修改")
|
||||
@Authorize(action = "U")
|
||||
public ResponseMessage update(@RequestBody(required = true) String json) {
|
||||
public ResponseMessage update(@RequestBody String json) {
|
||||
int number;
|
||||
if (json.startsWith("[")) {
|
||||
number = getService().update(JSON.parseArray(json, getPOType()));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 https://github.com/hs-web
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 https://github.com/hs-web
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 https://github.com/hs-web/
|
||||
* Copyright 2015-2016 http://hsweb.me/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 https://github.com/hs-web
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 https://github.com/hs-web
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package org.hsweb.web.controller.form;
|
||||
|
||||
import org.hsweb.ezorm.meta.FieldMetaData;
|
||||
import org.hsweb.ezorm.meta.TableMetaData;
|
||||
import org.hsweb.ezorm.meta.expand.OptionConverter;
|
||||
import org.hsweb.web.bean.common.QueryParam;
|
||||
import org.hsweb.web.bean.common.UpdateMapParam;
|
||||
import org.hsweb.web.bean.po.form.Form;
|
||||
@@ -28,6 +31,7 @@ import org.hsweb.web.core.message.ResponseMessage;
|
||||
import org.hsweb.web.service.form.DynamicFormService;
|
||||
import org.hsweb.web.service.form.FormService;
|
||||
import org.hsweb.web.service.resource.FileService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -125,6 +129,24 @@ public class DynamicFormController {
|
||||
.onlyData();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据表单名称和查询参数,查询表单的数据数量
|
||||
*
|
||||
* @param name 表单名称
|
||||
* @param param 查询参数{@link QueryParam}
|
||||
* @return 查询结果
|
||||
* @throws SQLException 执行查询sql错误
|
||||
* @throws NotFoundException 表单不存在或在未发布
|
||||
*/
|
||||
@RequestMapping(value = "/{name}/total", method = RequestMethod.GET)
|
||||
@AccessLogger("查看数据数量")
|
||||
@Authorize(expression = "#dynamicFormAuthorizeValidator.validate(#name,#user,#paramsMap,'R')")
|
||||
public ResponseMessage total(@PathVariable("name") String name,
|
||||
QueryParam param) throws SQLException {
|
||||
return ResponseMessage.ok(dynamicFormService.total(name, param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据表单名和主键值查询数据
|
||||
*
|
||||
@@ -251,4 +273,40 @@ public class DynamicFormController {
|
||||
return ResponseMessage.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据字典映射:将指定的数据映射为数据字典对应的数据。<br>
|
||||
* 如: 表单{name}的字段{field}的字典配置为 [{"男":"1"},{"女":"0"}];<br>
|
||||
* 传入参数type=1,data=男,得到结果 {data:"1"}。传入参数 type!=1,data=1.得到结果{data:"男"}
|
||||
*
|
||||
* @param name 表单名称
|
||||
* @param field 字段
|
||||
* @param data 要映射的数据
|
||||
* @param type 映射的类型 ,1或其他值,当为1时,将key映射为value,其他则将value映射为key。
|
||||
* @return 映射结果
|
||||
* @throws NotFoundException 表单或字段不存在
|
||||
*/
|
||||
@RequestMapping(value = "/{name}/{field}/{type}/{data:.+}")
|
||||
@AccessLogger("数据字典映射")
|
||||
@Authorize
|
||||
public ResponseMessage mapperOption(@PathVariable("name") String name,
|
||||
@PathVariable("field") String field,
|
||||
@PathVariable("data") String data,
|
||||
@PathVariable("type") String type) {
|
||||
try {
|
||||
TableMetaData metaData = dynamicFormService.getDefaultDatabase().getTable(name).getMeta();
|
||||
FieldMetaData fieldMetaData = metaData.findFieldByName(field);
|
||||
if (fieldMetaData == null) throw new NullPointerException();
|
||||
OptionConverter converter = fieldMetaData.getOptionConverter();
|
||||
if (converter == null) return ResponseMessage.ok(data);
|
||||
switch (type) {
|
||||
case "1":
|
||||
return ResponseMessage.ok(converter.converterData(data));
|
||||
default:
|
||||
return ResponseMessage.ok(converter.converterValue(data));
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
throw new NotFoundException("字段不存在");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 https://github.com/hs-web
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 https://github.com/hs-web
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -110,8 +110,7 @@ public class AuthorizeController {
|
||||
@Authorize
|
||||
public ResponseMessage onlineInfo() {
|
||||
return ResponseMessage.ok(httpSessionManager.tryGetAllUser())
|
||||
.include(User.class, "id", "username", "name", "phone", "email")
|
||||
.exclude(User.class, "password");
|
||||
.include(User.class, "id", "username", "name", "phone", "email");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 https://github.com/hs-web
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 https://github.com/hs-web
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 https://github.com/hs-web
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -34,7 +34,6 @@ public class UserController extends GenericController<User, String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
@AccessLogger("获取列表")
|
||||
public ResponseMessage list(QueryParam param) {
|
||||
param.excludes("password");
|
||||
return super.list(param)
|
||||
@@ -43,7 +42,6 @@ public class UserController extends GenericController<User, String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
@AccessLogger("获取用户详情")
|
||||
public ResponseMessage info(@PathVariable("id") String id) {
|
||||
return super.info(id).exclude(User.class, "password", "modules");
|
||||
}
|
||||
@@ -57,8 +55,8 @@ public class UserController extends GenericController<User, String> {
|
||||
}
|
||||
|
||||
@AccessLogger("启用")
|
||||
@Authorize(action = "enable")
|
||||
@RequestMapping(value = "/{id}/enable", method = RequestMethod.PUT)
|
||||
@Authorize(action = "enable")
|
||||
public ResponseMessage enable(@PathVariable("id") String id) {
|
||||
getService().enableUser(id);
|
||||
return ResponseMessage.ok();
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.hsweb.web.controller.ControllerAutoConfiguration
|
||||
@@ -7,6 +7,7 @@ import org.hsweb.web.core.authorize.validator.SimpleAuthorizeValidator;
|
||||
import org.hsweb.web.bean.po.user.User;
|
||||
import org.hsweb.web.core.exception.AuthorizeException;
|
||||
import org.hsweb.web.core.session.HttpSessionManager;
|
||||
import org.hsweb.web.core.utils.AopUtils;
|
||||
import org.hsweb.web.core.utils.WebUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.hsweb.commons.ClassUtils;
|
||||
@@ -27,7 +28,7 @@ public class AopAuthorizeValidator extends SimpleAuthorizeValidator {
|
||||
protected ConcurrentMap<String, AuthorizeValidatorConfig> configCache = new ConcurrentHashMap<>();
|
||||
|
||||
protected AuthorizeValidatorConfig getConfig(ProceedingJoinPoint pjp) {
|
||||
String cacheKey = StringUtils.concat(pjp.getTarget().getClass().getName(), ".", getMethodName(pjp));
|
||||
String cacheKey = StringUtils.concat(pjp.getTarget().getClass().getName(), ".", AopUtils.getMethodName(pjp));
|
||||
AuthorizeValidatorConfig config = configCache.get(cacheKey);
|
||||
if (config == null) {
|
||||
config = this.createConfig();
|
||||
@@ -76,15 +77,4 @@ public class AopAuthorizeValidator extends SimpleAuthorizeValidator {
|
||||
return validate(user, param, config);
|
||||
}
|
||||
|
||||
protected String getMethodName(ProceedingJoinPoint pjp) {
|
||||
StringBuilder methodName = new StringBuilder(pjp.getSignature().getName()).append("(");
|
||||
MethodSignature signature = (MethodSignature) pjp.getSignature();
|
||||
String[] names = signature.getParameterNames();
|
||||
Class[] args = signature.getParameterTypes();
|
||||
for (int i = 0, len = args.length; i < len; i++) {
|
||||
if (i != 0) methodName.append(",");
|
||||
methodName.append(args[i].getSimpleName()).append(" ").append(names[i]);
|
||||
}
|
||||
return methodName.append(")").toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.hsweb.commons.DateTimeUtils;
|
||||
import org.hsweb.web.bean.po.logger.LoggerInfo;
|
||||
import org.hsweb.web.core.logger.annotation.AccessLogger;
|
||||
import org.hsweb.web.core.utils.AopUtils;
|
||||
import org.hsweb.web.core.utils.WebUtil;
|
||||
import org.hsweb.commons.ClassUtils;
|
||||
import org.hsweb.commons.MD5;
|
||||
@@ -31,8 +32,7 @@ public class AopAccessLoggerResolver {
|
||||
StringBuilder describe = new StringBuilder();
|
||||
MethodSignature methodSignature = ((MethodSignature) pjp.getSignature());
|
||||
Method method = methodSignature.getMethod();
|
||||
String methodName = getMethodName(pjp);
|
||||
|
||||
String methodName = AopUtils.getMethodName(pjp);
|
||||
AccessLogger classAnnotation = ClassUtils.getAnnotation(target, AccessLogger.class);
|
||||
AccessLogger methodAnnotation = ClassUtils.getAnnotation(method, AccessLogger.class);
|
||||
if (classAnnotation != null) {
|
||||
@@ -81,16 +81,6 @@ public class AopAccessLoggerResolver {
|
||||
return logInfo;
|
||||
}
|
||||
|
||||
protected String getMethodName(ProceedingJoinPoint pjp) {
|
||||
StringBuilder methodName = new StringBuilder(pjp.getSignature().getName()).append("(");
|
||||
MethodSignature signature = (MethodSignature) pjp.getSignature();
|
||||
String[] names = signature.getParameterNames();
|
||||
Class[] args = signature.getParameterTypes();
|
||||
for (int i = 0, len = args.length; i < len; i++) {
|
||||
if (i != 0) methodName.append(",");
|
||||
methodName.append(args[i].getSimpleName()).append(" ").append(names[i]);
|
||||
}
|
||||
return methodName.append(")").toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@ package org.hsweb.web.core.logger.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Created by 浩 on 2016-01-16 0016.
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface AccessLogger {
|
||||
String value();
|
||||
|
||||
String[] describe() default "";
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@ import javax.servlet.http.HttpSession;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by zhouhao on 16-6-2.
|
||||
*/
|
||||
public abstract class AbstractHttpSessionManager implements HttpSessionManager {
|
||||
|
||||
private List<HttpSessionManagerListener> listeners = new ArrayList<>();
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
package org.hsweb.web.core.session.siample;
|
||||
|
||||
import org.hsweb.web.bean.po.user.User;
|
||||
import org.hsweb.web.core.session.HttpSessionManager;
|
||||
import org.hsweb.web.core.utils.WebUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpSessionEvent;
|
||||
import javax.servlet.http.HttpSessionListener;
|
||||
|
||||
public class UserLoginOutListener implements HttpSessionListener {
|
||||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private HttpSessionManager httpSessionManager;
|
||||
|
||||
/* Session创建事件 */
|
||||
public void sessionCreated(HttpSessionEvent se) {
|
||||
logger.info("session created:" + se.getSession().getId());
|
||||
}
|
||||
|
||||
/* Session失效事件 */
|
||||
public void sessionDestroyed(HttpSessionEvent se) {
|
||||
HttpSession session = se.getSession();
|
||||
try {
|
||||
User user = WebUtil.getLoginUser(session);
|
||||
if (user != null) {
|
||||
httpSessionManager.removeUser(user.getId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("remove session or user error!", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setHttpSessionManager(HttpSessionManager httpSessionManager) {
|
||||
this.httpSessionManager = httpSessionManager;
|
||||
}
|
||||
package org.hsweb.web.core.session.siample;
|
||||
|
||||
import org.hsweb.web.bean.po.user.User;
|
||||
import org.hsweb.web.core.session.HttpSessionManager;
|
||||
import org.hsweb.web.core.utils.WebUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpSessionEvent;
|
||||
import javax.servlet.http.HttpSessionListener;
|
||||
|
||||
public class UserLoginOutListener implements HttpSessionListener {
|
||||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private HttpSessionManager httpSessionManager;
|
||||
|
||||
/* Session创建事件 */
|
||||
public void sessionCreated(HttpSessionEvent se) {
|
||||
logger.info("session created:" + se.getSession().getId());
|
||||
}
|
||||
|
||||
/* Session失效事件 */
|
||||
public void sessionDestroyed(HttpSessionEvent se) {
|
||||
HttpSession session = se.getSession();
|
||||
try {
|
||||
User user = WebUtil.getLoginUser(session);
|
||||
if (user != null) {
|
||||
httpSessionManager.removeUser(user.getId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("remove session or user error!", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setHttpSessionManager(HttpSessionManager httpSessionManager) {
|
||||
this.httpSessionManager = httpSessionManager;
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
package org.hsweb.web.core.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by 浩 on 2016-01-27 0027.
|
||||
*/
|
||||
public class AccessUtils {
|
||||
private static String[] modules;
|
||||
private static Map<String, Integer> moduleAccessInfo = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 给角色注册模块权限
|
||||
*
|
||||
* @param role 角色标识
|
||||
* @param module 权限标识
|
||||
* @param modules 同时注册多个模块权限
|
||||
*/
|
||||
public static final void registerAccessRole(String role, String module, String... modules) {
|
||||
Integer accessInfo = moduleAccessInfo.get(role);
|
||||
if (accessInfo == null) accessInfo = 0;
|
||||
int moduleIndex = indexOf(AccessUtils.modules, module);
|
||||
if (moduleIndex == -1) return;
|
||||
int access = (moduleIndex + 1) << 1;
|
||||
accessInfo = accessInfo | access;
|
||||
if (modules.length > 0) {
|
||||
for (int i = 0; i < modules.length; i++) {
|
||||
moduleIndex = indexOf(AccessUtils.modules, modules[i]);
|
||||
if (moduleIndex == -1) continue;
|
||||
access = (moduleIndex + 1) << 1;
|
||||
accessInfo = accessInfo | access;
|
||||
}
|
||||
}
|
||||
moduleAccessInfo.put(role, accessInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消某个角色的权限信息
|
||||
*
|
||||
* @param role 角色标识
|
||||
* @param module 权限标识
|
||||
* @param modules 同时取消多个模块权限
|
||||
*/
|
||||
public static final void cancelAccessRole(String role, String module, String... modules) {
|
||||
Integer accessInfo = moduleAccessInfo.get(role);
|
||||
if (accessInfo == null) accessInfo = 0;
|
||||
int moduleIndex = indexOf(AccessUtils.modules, module);
|
||||
if (moduleIndex == -1) return;
|
||||
int access = (moduleIndex + 1) << 1;
|
||||
accessInfo = accessInfo & (~access);
|
||||
if (modules.length > 0) {
|
||||
for (int i = 0; i < modules.length; i++) {
|
||||
moduleIndex = indexOf(AccessUtils.modules, modules[i]);
|
||||
if (moduleIndex == -1) continue;
|
||||
access = (moduleIndex + 1) << 1;
|
||||
accessInfo = accessInfo & (~access);
|
||||
}
|
||||
}
|
||||
moduleAccessInfo.put(role, accessInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断某个角色是否持有某个模块的权限
|
||||
*
|
||||
* @param role 角色
|
||||
* @param module
|
||||
* @return
|
||||
*/
|
||||
public static final boolean roleAccessModule(String role, String module) {
|
||||
Integer accessInfo = moduleAccessInfo.get(role);
|
||||
if (accessInfo == null) return false;
|
||||
int moduleIndex = indexOf(AccessUtils.modules, module);
|
||||
if (moduleIndex == -1) return false;
|
||||
int access = (moduleIndex + 1) << 1;
|
||||
return (accessInfo & access) == access;
|
||||
}
|
||||
|
||||
public static final void initModules(String... modules) {
|
||||
AccessUtils.modules = modules;
|
||||
}
|
||||
|
||||
private static final int indexOf(String[] arr, String str) {
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
if (arr[i].equals(str)) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
initModules("admin", "test", "test1", "test2", "test3");
|
||||
|
||||
//给角色注册2个权限
|
||||
registerAccessRole("hehe", "admin", "test");
|
||||
|
||||
System.out.println(roleAccessModule("hehe", "admin"));
|
||||
System.out.println(roleAccessModule("hehe", "test"));
|
||||
//注册test3权限
|
||||
registerAccessRole("hehe", "test3");
|
||||
System.out.println(roleAccessModule("hehe", "test3"));
|
||||
//取消test3权限
|
||||
cancelAccessRole("hehe", "test3");
|
||||
System.out.println(roleAccessModule("hehe", "test3"));
|
||||
//
|
||||
System.out.println(roleAccessModule("hehe", "test2"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.hsweb.web.core.utils;
|
||||
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
|
||||
/**
|
||||
* AOP 工具类,用于进行常用的aop操作
|
||||
*/
|
||||
public class AopUtils {
|
||||
|
||||
public static final String getMethodName(ProceedingJoinPoint pjp) {
|
||||
StringBuilder methodName = new StringBuilder(pjp.getSignature().getName()).append("(");
|
||||
MethodSignature signature = (MethodSignature) pjp.getSignature();
|
||||
String[] names = signature.getParameterNames();
|
||||
Class[] args = signature.getParameterTypes();
|
||||
for (int i = 0, len = args.length; i < len; i++) {
|
||||
if (i != 0) methodName.append(",");
|
||||
methodName.append(args[i].getSimpleName()).append(" ").append(names[i]);
|
||||
}
|
||||
return methodName.append(")").toString();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.hsweb.web.core.CoreAutoConfiguration
|
||||
@@ -1,74 +1,74 @@
|
||||
package org.hsweb.web.crawler.extracter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class DefaultHtmlContentExtractor implements HtmlContentExtractor {
|
||||
private static String clearLabel(String html) {
|
||||
html = html.replaceAll("(?is)<!DOCTYPE.*?>", "");
|
||||
html = html.replaceAll("(?is)<!--.*?-->", ""); // remove html comment
|
||||
html = html.replaceAll("(?is)<script.*?>.*?</script>", ""); // remove javascript
|
||||
html = html.replaceAll("(?is)<style.*?>.*?</style>", ""); // remove css
|
||||
html = html.replaceAll("&.{2,5};|&#.{2,5};", " "); // remove special char
|
||||
html = html.replaceAll("(?is)<.*?>", "");
|
||||
return html;
|
||||
}
|
||||
private int defaultThreshold=35;
|
||||
public DefaultHtmlContentExtractor(){}
|
||||
public DefaultHtmlContentExtractor(int threshold){
|
||||
this.defaultThreshold=threshold;
|
||||
}
|
||||
@Override
|
||||
public String parse(String html) {
|
||||
html = clearLabel(html);
|
||||
final int blocksWidth = 3;
|
||||
int start, end, threshold = defaultThreshold;
|
||||
StringBuilder text = new StringBuilder();
|
||||
List<Integer> indexDistribution = new ArrayList<>();
|
||||
List<String> lines = Arrays.asList(html.split("\n"));
|
||||
indexDistribution.clear();
|
||||
for (int i = 0; i < lines.size() - blocksWidth; i++) {
|
||||
int wordsNum = 0;
|
||||
for (int j = i; j < i + blocksWidth; j++) {
|
||||
lines.set(j, lines.get(j).replaceAll("\\s+", ""));
|
||||
wordsNum += lines.get(j).length();
|
||||
}
|
||||
indexDistribution.add(wordsNum);
|
||||
}
|
||||
start = -1;
|
||||
end = -1;
|
||||
boolean boolStart = false, boolEnd = false;
|
||||
text.setLength(0);
|
||||
for (int i = 0, len = indexDistribution.size(); i < len - 1; i++) {
|
||||
if (indexDistribution.get(i) > threshold && !boolStart) {
|
||||
if (indexDistribution.get(i + 1).intValue() != 0
|
||||
|| indexDistribution.get(i + 2).intValue() != 0
|
||||
|| indexDistribution.get(i + 3).intValue() != 0) {
|
||||
boolStart = true;
|
||||
start = i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (boolStart) {
|
||||
if (indexDistribution.get(i).intValue() == 0
|
||||
|| indexDistribution.get(i + 1).intValue() == 0) {
|
||||
end = i;
|
||||
boolEnd = true;
|
||||
}
|
||||
}
|
||||
if (boolEnd) {
|
||||
StringBuilder tmp = new StringBuilder();
|
||||
for (int ii = start; ii <= end; ii++) {
|
||||
if (lines.get(ii).length() < 5) continue;
|
||||
tmp.append(lines.get(ii) + "\n");
|
||||
}
|
||||
String str = tmp.toString();
|
||||
if (str.toLowerCase().contains("copyright") || str.contains("版权所有")) continue;
|
||||
text.append(str);
|
||||
boolStart = boolEnd = false;
|
||||
}
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
}
|
||||
package org.hsweb.web.crawler.extracter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class DefaultHtmlContentExtractor implements HtmlContentExtractor {
|
||||
private static String clearLabel(String html) {
|
||||
html = html.replaceAll("(?is)<!DOCTYPE.*?>", "");
|
||||
html = html.replaceAll("(?is)<!--.*?-->", ""); // remove html comment
|
||||
html = html.replaceAll("(?is)<script.*?>.*?</script>", ""); // remove javascript
|
||||
html = html.replaceAll("(?is)<style.*?>.*?</style>", ""); // remove css
|
||||
html = html.replaceAll("&.{2,5};|&#.{2,5};", " "); // remove special char
|
||||
html = html.replaceAll("(?is)<.*?>", "");
|
||||
return html;
|
||||
}
|
||||
private int defaultThreshold=35;
|
||||
public DefaultHtmlContentExtractor(){}
|
||||
public DefaultHtmlContentExtractor(int threshold){
|
||||
this.defaultThreshold=threshold;
|
||||
}
|
||||
@Override
|
||||
public String parse(String html) {
|
||||
html = clearLabel(html);
|
||||
final int blocksWidth = 3;
|
||||
int start, end, threshold = defaultThreshold;
|
||||
StringBuilder text = new StringBuilder();
|
||||
List<Integer> indexDistribution = new ArrayList<>();
|
||||
List<String> lines = Arrays.asList(html.split("\n"));
|
||||
indexDistribution.clear();
|
||||
for (int i = 0; i < lines.size() - blocksWidth; i++) {
|
||||
int wordsNum = 0;
|
||||
for (int j = i; j < i + blocksWidth; j++) {
|
||||
lines.set(j, lines.get(j).replaceAll("\\s+", ""));
|
||||
wordsNum += lines.get(j).length();
|
||||
}
|
||||
indexDistribution.add(wordsNum);
|
||||
}
|
||||
start = -1;
|
||||
end = -1;
|
||||
boolean boolStart = false, boolEnd = false;
|
||||
text.setLength(0);
|
||||
for (int i = 0, len = indexDistribution.size(); i < len - 1; i++) {
|
||||
if (indexDistribution.get(i) > threshold && !boolStart) {
|
||||
if (indexDistribution.get(i + 1).intValue() != 0
|
||||
|| indexDistribution.get(i + 2).intValue() != 0
|
||||
|| indexDistribution.get(i + 3).intValue() != 0) {
|
||||
boolStart = true;
|
||||
start = i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (boolStart) {
|
||||
if (indexDistribution.get(i).intValue() == 0
|
||||
|| indexDistribution.get(i + 1).intValue() == 0) {
|
||||
end = i;
|
||||
boolEnd = true;
|
||||
}
|
||||
}
|
||||
if (boolEnd) {
|
||||
StringBuilder tmp = new StringBuilder();
|
||||
for (int ii = start; ii <= end; ii++) {
|
||||
if (lines.get(ii).length() < 5) continue;
|
||||
tmp.append(lines.get(ii) + "\n");
|
||||
}
|
||||
String str = tmp.toString();
|
||||
if (str.toLowerCase().contains("copyright") || str.contains("版权所有")) continue;
|
||||
text.append(str);
|
||||
boolStart = boolEnd = false;
|
||||
}
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.hsweb.web.crawler.extracter;
|
||||
|
||||
/**
|
||||
* html正文提取器
|
||||
* Created by 浩 on 2015-09-07 0007.
|
||||
*/
|
||||
public interface HtmlContentExtractor {
|
||||
String parse(String html);
|
||||
}
|
||||
package org.hsweb.web.crawler.extracter;
|
||||
|
||||
/**
|
||||
* html正文提取器
|
||||
* Created by 浩 on 2015-09-07 0007.
|
||||
*/
|
||||
public interface HtmlContentExtractor {
|
||||
String parse(String html);
|
||||
}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
package org.hsweb.web.crawler.extracter;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
/**
|
||||
* Created by 浩 on 2015-09-07 0007.
|
||||
*/
|
||||
public class JsoupHtmlContentExtractor implements HtmlContentExtractor {
|
||||
|
||||
public JsoupHtmlContentExtractor(String select) {
|
||||
this.select = select;
|
||||
}
|
||||
|
||||
private String select;
|
||||
|
||||
@Override
|
||||
public String parse(String html) {
|
||||
Document document = Jsoup.parse(html);
|
||||
if (select == null)
|
||||
return document.text();
|
||||
return document.select(select).text();
|
||||
}
|
||||
|
||||
public String getSelect() {
|
||||
return select;
|
||||
}
|
||||
|
||||
public void setSelect(String select) {
|
||||
this.select = select;
|
||||
}
|
||||
}
|
||||
package org.hsweb.web.crawler.extracter;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
/**
|
||||
* Created by 浩 on 2015-09-07 0007.
|
||||
*/
|
||||
public class JsoupHtmlContentExtractor implements HtmlContentExtractor {
|
||||
|
||||
public JsoupHtmlContentExtractor(String select) {
|
||||
this.select = select;
|
||||
}
|
||||
|
||||
private String select;
|
||||
|
||||
@Override
|
||||
public String parse(String html) {
|
||||
Document document = Jsoup.parse(html);
|
||||
if (select == null)
|
||||
return document.text();
|
||||
return document.select(select).text();
|
||||
}
|
||||
|
||||
public String getSelect() {
|
||||
return select;
|
||||
}
|
||||
|
||||
public void setSelect(String select) {
|
||||
this.select = select;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.hsweb.web.mybatis.MybatisDaoAutoConfiguration
|
||||
@@ -51,9 +51,8 @@
|
||||
|
||||
<select id="selectLatestList" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="FormResultMap">
|
||||
<include refid="config"/>
|
||||
<!--定义字段配置-->
|
||||
<bind name="tableName" value="'t2'"/>
|
||||
<!--定义表名-->
|
||||
<bind name="tableName" value="'t2'"/>
|
||||
select
|
||||
<!--动态生成要查询的字段-->
|
||||
<include refid="BasicMapper.buildSelectField"/>
|
||||
|
||||
@@ -39,7 +39,7 @@ public class CacheDraftService implements DraftService {
|
||||
if (wrapper == null) {
|
||||
drafts = new LinkedHashMap<>();
|
||||
} else {
|
||||
drafts = ((Map) wrapper.get());
|
||||
drafts = ((Map<String, Draft>) wrapper.get());
|
||||
}
|
||||
drafts.put(draft.getId(), draft);
|
||||
cache.put(key, drafts);
|
||||
@@ -51,7 +51,7 @@ public class CacheDraftService implements DraftService {
|
||||
Cache cache = cacheManager.getCache(cacheKey + userId);
|
||||
Cache.ValueWrapper wrapper = cache.get(key);
|
||||
if (wrapper != null) {
|
||||
return new ArrayList<>(((Map) wrapper.get()).values());
|
||||
return new ArrayList<>(((Map<String, Draft>) wrapper.get()).values());
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class CacheDraftService implements DraftService {
|
||||
Cache cache = cacheManager.getCache(cacheKey + userId);
|
||||
Cache.ValueWrapper wrapper = cache.get(key);
|
||||
if (wrapper != null) {
|
||||
Map<String, Draft> drafts = ((Map) wrapper.get());
|
||||
Map<String, Draft> drafts = ((Map<String, Draft>) wrapper.get());
|
||||
drafts.remove(id);
|
||||
cache.put(key, drafts);
|
||||
return true;
|
||||
|
||||
@@ -109,6 +109,7 @@ public class DefaultFormParser implements FormParser {
|
||||
DynamicScriptEngine scriptEngine = DynamicScriptEngineFactory.getEngine("groovy");
|
||||
String meta = form.getMeta();
|
||||
TableMetaData metaData = new TableMetaData();
|
||||
metaData.setProperty("version",form.getRelease());
|
||||
metaData.setName(form.getName());
|
||||
metaData.setComment(form.getRemark());
|
||||
JSONObject object = JSON.parseObject(meta);
|
||||
@@ -180,8 +181,9 @@ public class DefaultFormParser implements FormParser {
|
||||
fieldMeta.setProperty(key, value);
|
||||
}
|
||||
});
|
||||
//name为空的时候 不保持此字段
|
||||
if (!"main".equals(id) && !StringUtils.isNullOrEmpty(fieldMeta.getName())) {
|
||||
//name为空的时候 不保存此字段
|
||||
if (!"main".equals(id)
|
||||
&& !StringUtils.isNullOrEmpty(fieldMeta.getName())) {
|
||||
initField(fieldMeta);
|
||||
if (StringUtils.isNullOrEmpty(fieldMeta.getAlias()))
|
||||
fieldMeta.setAlias(fieldMeta.getName());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.hsweb.web.service.impl.form;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.hsweb.commons.StringUtils;
|
||||
import org.hsweb.concurrent.lock.annotation.LockName;
|
||||
import org.hsweb.concurrent.lock.annotation.ReadLock;
|
||||
import org.hsweb.concurrent.lock.annotation.WriteLock;
|
||||
@@ -33,7 +34,6 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.hsweb.commons.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.InputStream;
|
||||
@@ -84,7 +84,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
FieldMetaData id = new FieldMetaData("u_id", String.class, dataType, JDBCType.VARCHAR);
|
||||
id.setComment("主键");
|
||||
id.setProperty("read-only", true);
|
||||
|
||||
id.setProperty("not-null", true);
|
||||
metaData.setPrimaryKeys(new HashSet<>(Arrays.asList("u_id")));
|
||||
metaData.setProperty("primaryKey", "u_id");
|
||||
metaData.addField(id);
|
||||
@@ -97,7 +97,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableMetaData parseMeta(Form form){
|
||||
public TableMetaData parseMeta(Form form) {
|
||||
return formParser.parse(form);
|
||||
}
|
||||
|
||||
@@ -136,11 +136,11 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
@Override
|
||||
@WriteLock
|
||||
@LockName(value = "'form.lock.'+#form.name", isExpression = true)
|
||||
public void unDeploy(Form form){
|
||||
public void unDeploy(Form form) {
|
||||
database.removeTable(form.getName());
|
||||
}
|
||||
|
||||
public Table getTableByName(String name){
|
||||
public Table getTableByName(String name) {
|
||||
try {
|
||||
Table table = database.getTable(name);
|
||||
if (table == null) {
|
||||
@@ -214,6 +214,16 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveOrUpdate(String name, List<Map<String, Object>> map) throws SQLException {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (Map<String, Object> objectMap : map) {
|
||||
String id = saveOrUpdate(name, objectMap);
|
||||
builder.append(id).append(",");
|
||||
}
|
||||
return builder.substring(0, builder.length());
|
||||
}
|
||||
|
||||
protected String getRepeatDataId(String name, Map<String, Object> data) {
|
||||
if (dynamicFormDataValidator != null) {
|
||||
for (DynamicFormDataValidator validator : dynamicFormDataValidator) {
|
||||
@@ -251,8 +261,10 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
@LockName(value = "'form.lock.'+#name", isExpression = true)
|
||||
public int updateByPk(String name, String pk, UpdateParam<Map<String, Object>> param) throws SQLException {
|
||||
Table table = getTableByName(name);
|
||||
String pkName = getPrimaryKeyName(name);
|
||||
Update update = table.createUpdate().setParam(param);
|
||||
update.where(getPrimaryKeyName(name), pk);
|
||||
param.getData().put(pkName, pk);
|
||||
update.where(pkName, pk);
|
||||
return update.exec();
|
||||
}
|
||||
|
||||
@@ -267,7 +279,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
|
||||
@ReadLock
|
||||
@LockName(value = "'form.lock.'+#tableName", isExpression = true)
|
||||
public String getPrimaryKeyName(String tableName){
|
||||
public String getPrimaryKeyName(String tableName) {
|
||||
Table table = getTableByName(tableName);
|
||||
return table.getMeta().getProperty("primaryKey", "u_id").toString();
|
||||
}
|
||||
@@ -340,7 +352,8 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
@Override
|
||||
@ReadLock
|
||||
@LockName(value = "'form.lock.'+#name", isExpression = true)
|
||||
public Map<String, Object> importExcel(String name, InputStream inputStream){
|
||||
public Map<String, Object> importExcel(String name, InputStream inputStream) {
|
||||
Table table = getTableByName(name);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
long startTime = System.currentTimeMillis();
|
||||
List<Map<String, Object>> excelData;
|
||||
@@ -351,7 +364,6 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
}
|
||||
List<Map<String, Object>> dataList = new LinkedList<>();
|
||||
Map<String, String> headerMapper = new HashMap<>();
|
||||
Table table = getTableByName(name);
|
||||
TableMetaData metaData = table.getMeta();
|
||||
metaData.getFields().forEach(fieldMetaData -> {
|
||||
PropertyWrapper valueWrapper = fieldMetaData.getProperty("importExcel", true);
|
||||
|
||||
@@ -54,13 +54,13 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
protected DynamicFormService dynamicFormService;
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "#id")
|
||||
public Form selectByPk(String id) {
|
||||
// @Cacheable(value = CACHE_KEY, key = "#id")
|
||||
public Form selectByPk(String id) {
|
||||
return super.selectByPk(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createNewVersion(String oldVersionId) {
|
||||
public String createNewVersion(String oldVersionId) {
|
||||
Form old = this.selectByPk(oldVersionId);
|
||||
assertNotNull(old, "表单不存在!");
|
||||
old.setId(RandomUtil.randomChar());
|
||||
@@ -75,7 +75,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public String insert(Form data) {
|
||||
public String insert(Form data) {
|
||||
List<Form> old = this.select(QueryParam.build().where("name", data.getName()));
|
||||
Assert.isTrue(old.isEmpty(), "表单 [" + data.getName() + "] 已存在!");
|
||||
data.setCreateDate(new Date());
|
||||
@@ -93,7 +93,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
@CacheEvict(value = {CACHE_KEY}, key = "#data.name+':'+#data.version")
|
||||
}
|
||||
)
|
||||
public int update(Form data) {
|
||||
public int update(Form data) {
|
||||
Form old = this.selectByPk(data.getId());
|
||||
assertNotNull(old, "表单不存在!");
|
||||
data.setUpdateDate(new Date());
|
||||
@@ -105,7 +105,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = CACHE_KEY, key = "#id")
|
||||
public int delete(String id) {
|
||||
public int delete(String id) {
|
||||
Form old = this.selectByPk(id);
|
||||
assertNotNull(old, "表单不存在!");
|
||||
Assert.isTrue(!old.isUsing(), "表单正在使用,无法删除!");
|
||||
@@ -114,19 +114,19 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<Form> selectLatestList(QueryParam param) {
|
||||
public List<Form> selectLatestList(QueryParam param) {
|
||||
return formMapper.selectLatestList(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public int countLatestList(QueryParam param) {
|
||||
public int countLatestList(QueryParam param) {
|
||||
return formMapper.countLatestList(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "#name+':'+#version")
|
||||
public Form selectByVersion(String name, int version) {
|
||||
public Form selectByVersion(String name, int version) {
|
||||
QueryParam param = QueryParam.build()
|
||||
.where("name", name).where("version", version);
|
||||
List<Form> formList = formMapper.selectLatestList(param);
|
||||
@@ -134,7 +134,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public Form selectLatest(String name) {
|
||||
public Form selectLatest(String name) {
|
||||
QueryParam param = QueryParam.build()
|
||||
.where("name", name).orderBy("version").asc();
|
||||
List<Form> formList = formMapper.selectLatestList(param);
|
||||
@@ -148,7 +148,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
@CacheEvict(value = {CACHE_KEY + ".deploy"}, key = "'deploy.'+target.selectByPk(#formId).getName()"),
|
||||
@CacheEvict(value = {CACHE_KEY}, key = "'using.'+target.selectByPk(#formId).getName()")
|
||||
})
|
||||
public void deploy(String formId) throws Exception {
|
||||
public void deploy(String formId) throws SQLException {
|
||||
Form old = this.selectByPk(formId);
|
||||
assertNotNull(old, "表单不存在");
|
||||
//先卸载正在使用的表单
|
||||
@@ -177,7 +177,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
@CacheEvict(value = {CACHE_KEY + ".deploy"}, key = "'deploy.'+target.selectByPk(#formId).getName()"),
|
||||
@CacheEvict(value = {CACHE_KEY}, key = "'using.'+target.selectByPk(#formId).getName()")
|
||||
})
|
||||
public void unDeploy(String formId) {
|
||||
public void unDeploy(String formId) {
|
||||
Form old = this.selectByPk(formId);
|
||||
assertNotNull(old, "表单不存在");
|
||||
dynamicFormService.unDeploy(old);
|
||||
@@ -189,7 +189,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY + ".deploy", key = "'deploy.'+#name+'.html'")
|
||||
public String createDeployHtml(String name) {
|
||||
public String createDeployHtml(String name) {
|
||||
History history = historyService.selectLastHistoryByType("form.deploy." + name);
|
||||
assertNotNull(history, "表单不存在");
|
||||
return formParser.parseHtml(JSON.parseObject(history.getChangeAfter(), Form.class));
|
||||
@@ -197,7 +197,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY + ".deploy", key = "'deploy.'+#name")
|
||||
public Form selectDeployed(String name) {
|
||||
public Form selectDeployed(String name) {
|
||||
Form using = selectUsing(name);
|
||||
assertNotNull(using, "表单不存在或未部署");
|
||||
History history = historyService.selectLastHistoryByType("form.deploy." + name);
|
||||
@@ -206,7 +206,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createViewHtml(String formId) {
|
||||
public String createViewHtml(String formId) {
|
||||
Form form = this.selectByPk(formId);
|
||||
assertNotNull(form, "表单不存在");
|
||||
return formParser.parseHtml(form);
|
||||
@@ -214,7 +214,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "'using.'+#name")
|
||||
public Form selectUsing(String name) {
|
||||
public Form selectUsing(String name) {
|
||||
return formMapper.selectUsing(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.hsweb.web.service.impl.form.validator.java;
|
||||
|
||||
import org.apache.commons.beanutils.BeanMap;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.hsweb.expands.script.engine.DynamicScriptEngine;
|
||||
import org.hsweb.expands.script.engine.DynamicScriptEngineFactory;
|
||||
import org.hsweb.ezorm.exception.ValidationException;
|
||||
import org.hsweb.ezorm.meta.expand.Validator;
|
||||
import org.hsweb.web.bean.valid.ValidResults;
|
||||
import org.hsweb.web.core.exception.BusinessException;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
public class JavaDycBeanValidator implements Validator {
|
||||
|
||||
private Class clazz;
|
||||
private javax.validation.Validator hibernateValidator;
|
||||
|
||||
|
||||
public JavaDycBeanValidator(Class clazz, javax.validation.Validator hibernateValidator) {
|
||||
this.clazz = clazz;
|
||||
this.hibernateValidator = hibernateValidator;
|
||||
}
|
||||
|
||||
public boolean validateMap(Map<Object, Object> data, Operation operation) {
|
||||
ValidResults results = new ValidResults();
|
||||
try {
|
||||
Object validatorTarget = clazz.newInstance();
|
||||
Set<ConstraintViolation<Object>> result = new LinkedHashSet<>();
|
||||
if (operation == Operation.INSERT) {
|
||||
data.forEach((key, value) -> {
|
||||
try {
|
||||
BeanUtils.setProperty(validatorTarget, (String) key, value);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
});
|
||||
result.addAll(hibernateValidator.validate(validatorTarget));
|
||||
} else
|
||||
data.forEach((key, value) -> {
|
||||
Field field = ReflectionUtils.findField(clazz, (String) key);
|
||||
if (field != null)
|
||||
result.addAll(hibernateValidator.validateValue(clazz, (String) key, value));
|
||||
});
|
||||
if (result.size() > 0) {
|
||||
for (ConstraintViolation<Object> violation : result) {
|
||||
String property = violation.getPropertyPath().toString();
|
||||
results.addResult(property, violation.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("验证器异常!", e, 500);
|
||||
}
|
||||
if (results.size() > 0) throw new ValidationException(results.get(0).getMessage(), results);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate(Object data, Operation operation) throws ValidationException {
|
||||
if (data instanceof Map)
|
||||
return validateMap(((Map) data), operation);
|
||||
if (data instanceof Collection) {
|
||||
for (Object o : ((Collection) data)) {
|
||||
validate(o, operation);
|
||||
}
|
||||
} else {
|
||||
BeanMap beanMap = new BeanMap();
|
||||
beanMap.setBean(data);
|
||||
validateMap(beanMap, operation);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright 2015-2016 http://hsweb.me
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.hsweb.web.service.impl.form.validator.java;
|
||||
|
||||
import org.hsweb.commons.StringUtils;
|
||||
import org.hsweb.expands.script.engine.DynamicScriptEngine;
|
||||
import org.hsweb.expands.script.engine.DynamicScriptEngineFactory;
|
||||
import org.hsweb.ezorm.meta.FieldMetaData;
|
||||
import org.hsweb.ezorm.meta.TableMetaData;
|
||||
import org.hsweb.ezorm.meta.expand.Validator;
|
||||
import org.hsweb.ezorm.meta.expand.ValidatorFactory;
|
||||
import org.hsweb.web.core.exception.BusinessException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 基于groovy动态bean的校验器
|
||||
*/
|
||||
//@Component
|
||||
public class JavaDycBeanValidatorFactory implements ValidatorFactory {
|
||||
|
||||
@Autowired
|
||||
private javax.validation.Validator hibernateValidator;
|
||||
|
||||
private Map<String, Validator> base = new HashMap<>();
|
||||
|
||||
private static final Map<Class, String> simpleType = new HashMap<>();
|
||||
|
||||
protected static DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine("java");
|
||||
|
||||
public static final String basePackage = "org.hsweb.web.bean.dyn_form";
|
||||
|
||||
private static final String[] imports = {
|
||||
"import org.hibernate.validator.constraints.*;",
|
||||
"import javax.validation.constraints.*;"
|
||||
};
|
||||
|
||||
static {
|
||||
simpleType.put(Integer.class, "int");
|
||||
simpleType.put(Long.class, "long");
|
||||
simpleType.put(String.class, "String");
|
||||
simpleType.put(Double.class, "double");
|
||||
simpleType.put(Float.class, "float");
|
||||
simpleType.put(Boolean.class, "boolean");
|
||||
simpleType.put(Short.class, "short");
|
||||
simpleType.put(Byte.class, "byte");
|
||||
simpleType.put(Character.class, "char");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Validator createValidator(TableMetaData metaData) {
|
||||
return initValidator(metaData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据表结构动态生成一个基于hibernate-validator的bean
|
||||
*
|
||||
* @param metaData 表结构
|
||||
* @return 验证器对象
|
||||
*/
|
||||
public Validator initValidator(TableMetaData metaData) {
|
||||
StringBuilder script = new StringBuilder();
|
||||
String className = StringUtils.concat(basePackage, ".", metaData.getName());
|
||||
script.append("package ").append(basePackage).append(";\n");
|
||||
for (String anImport : imports) {
|
||||
script.append(anImport).append("\n");
|
||||
}
|
||||
script.append("public class ").append(metaData.getName()).append("{\n");
|
||||
boolean hasValidator = false;
|
||||
for (FieldMetaData fieldMetaData : metaData.getFields()) {
|
||||
String typeName = simpleType.get(fieldMetaData.getJavaType());
|
||||
if (typeName == null) typeName = fieldMetaData.getJavaType().getName();
|
||||
if (fieldMetaData.getValidator() == null || fieldMetaData.getValidator().isEmpty()) continue;
|
||||
for (String ann : fieldMetaData.getValidator()) {
|
||||
hasValidator = true;
|
||||
script.append("\t@").append(ann).append("\n");
|
||||
}
|
||||
script.append("\tprivate ")
|
||||
.append(typeName).append(" ")
|
||||
.append(fieldMetaData.getName()).append(";\n\n");
|
||||
}
|
||||
//没有配置验证器
|
||||
if (!hasValidator) return null;
|
||||
for (FieldMetaData fieldMetaData : metaData.getFields()) {
|
||||
String typeName = simpleType.get(fieldMetaData.getJavaType());
|
||||
if (typeName == null) typeName = fieldMetaData.getJavaType().getName();
|
||||
if (fieldMetaData.getValidator() == null || fieldMetaData.getValidator().isEmpty()) continue;
|
||||
script.append("public ")
|
||||
.append(typeName).append("boolean".equals(typeName) ? "is" : " get")
|
||||
.append(StringUtils.toUpperCaseFirstOne(fieldMetaData.getName()))
|
||||
.append("(){\n")
|
||||
.append("\treturn this.").append(fieldMetaData.getName()).append(";")
|
||||
.append("\n}\n");
|
||||
script.append("public void set").append(StringUtils.toUpperCaseFirstOne(fieldMetaData.getName()))
|
||||
.append("(")
|
||||
.append(typeName).append(" ").append(fieldMetaData.getName())
|
||||
.append(")")
|
||||
.append("{\n")
|
||||
.append("\tthis.").append(fieldMetaData.getName()).append("=").append(fieldMetaData.getName()).append(";")
|
||||
.append("\n}\n\n");
|
||||
}
|
||||
script.append("}");
|
||||
try {
|
||||
engine.compile(className, script.toString());
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("创建动态表单验证器失败!", e, 500);
|
||||
}
|
||||
JavaDycBeanValidator validator = new JavaDycBeanValidator(((Class) engine.execute(className).getResult()), hibernateValidator);
|
||||
base.put(metaData.getName(), validator);
|
||||
return validator;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.hsweb.web.service.impl.ServiceAutoConfiguration
|
||||
@@ -1,15 +1,14 @@
|
||||
package org.hsweb.web.service.impl.form;
|
||||
|
||||
import org.hsweb.commons.file.FileUtils;
|
||||
import org.hsweb.ezorm.executor.SqlExecutor;
|
||||
import org.hsweb.ezorm.run.Database;
|
||||
import org.hsweb.ezorm.run.Table;
|
||||
import org.hsweb.web.core.authorize.ExpressionScopeBean;
|
||||
import org.hsweb.web.bean.po.form.Form;
|
||||
import org.hsweb.web.core.authorize.ExpressionScopeBean;
|
||||
import org.hsweb.web.core.utils.RandomUtil;
|
||||
import org.hsweb.web.service.form.DynamicFormService;
|
||||
import org.hsweb.web.service.form.FormService;
|
||||
import org.hsweb.web.service.impl.AbstractTestCase;
|
||||
import org.hsweb.web.core.utils.RandomUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -103,6 +102,7 @@ public class FormServiceImplTest extends AbstractTestCase {
|
||||
|
||||
Table<Map<String, Object>> table = dataBase.getTable("test_form");
|
||||
table.createUpdate().set("name", "张三").where("u_id", "test").exec();
|
||||
|
||||
Map<String, Object> data = table.createQuery().where("name$LIKE", "张三").single();
|
||||
Assert.assertEquals("张三", data.get("name"));
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.util.List;
|
||||
/**
|
||||
* 通用Service。继承了通用mapper的常用增删改查方法
|
||||
* <p>
|
||||
* Created by zh.sqy@qq.com on 2015-07-20 0020.
|
||||
*/
|
||||
public interface GenericService<Po, Pk> {
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ public interface DynamicFormService {
|
||||
|
||||
String saveOrUpdate(String name, Map<String, Object> map) throws SQLException;
|
||||
|
||||
String saveOrUpdate(String name, List<Map<String, Object>> map) throws SQLException;
|
||||
|
||||
int delete(String name, DeleteParam param) throws SQLException;
|
||||
|
||||
boolean deleteByPk(String name, String pk) throws SQLException;
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.hsweb.web.bean.common.QueryParam;
|
||||
import org.hsweb.web.bean.po.form.Form;
|
||||
import org.hsweb.web.service.GenericService;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -16,7 +17,7 @@ public interface FormService extends GenericService<Form, String> {
|
||||
* 修改表单,不修改原始数据,而是新加入一条数据,版本号自动+1.
|
||||
*/
|
||||
@Override
|
||||
int update(Form data) ;
|
||||
int update(Form data);
|
||||
|
||||
/**
|
||||
* 创建一个新版本的表单
|
||||
@@ -24,7 +25,7 @@ public interface FormService extends GenericService<Form, String> {
|
||||
* @param oldVersionId 旧版本表单ID
|
||||
* @return 新版本表单ID
|
||||
*/
|
||||
String createNewVersion(String oldVersionId) ;
|
||||
String createNewVersion(String oldVersionId);
|
||||
|
||||
/**
|
||||
* 查询最新版本的表单列表
|
||||
@@ -32,7 +33,7 @@ public interface FormService extends GenericService<Form, String> {
|
||||
* @param param 查询参数
|
||||
* @return 表单列表
|
||||
*/
|
||||
List<Form> selectLatestList(QueryParam param) ;
|
||||
List<Form> selectLatestList(QueryParam param);
|
||||
|
||||
/**
|
||||
* 查询最新版本的表单数量
|
||||
@@ -40,24 +41,22 @@ public interface FormService extends GenericService<Form, String> {
|
||||
* @param param 查询参数
|
||||
* @return 表单数量
|
||||
*/
|
||||
int countLatestList(QueryParam param) ;
|
||||
int countLatestList(QueryParam param);
|
||||
|
||||
/**
|
||||
* 发布表单,发布表单后,可通过{@link DynamicFormService}进行调用.
|
||||
* 表单发布后,using属性自动改为true,其他已发布的版本将自动取消发布.
|
||||
*
|
||||
* @param formId 要发布的表单ID
|
||||
* @ 发布失败异常
|
||||
*/
|
||||
void deploy(String formId) throws Exception;
|
||||
void deploy(String formId) throws SQLException;
|
||||
|
||||
/**
|
||||
* 取消发布,取消发布后。表单失效。使用{@link DynamicFormService}后无法再进行调用
|
||||
*
|
||||
* @param formId 要取消发布的表单ID
|
||||
* @ 取消失败异常
|
||||
*/
|
||||
void unDeploy(String formId) ;
|
||||
void unDeploy(String formId);
|
||||
|
||||
/**
|
||||
* 创建当前已部署表单对应的html,用于前端渲染.
|
||||
@@ -65,11 +64,16 @@ public interface FormService extends GenericService<Form, String> {
|
||||
*
|
||||
* @param name 要创建html的表单名称
|
||||
* @return html字符串
|
||||
* @
|
||||
*/
|
||||
String createDeployHtml(String name) ;
|
||||
String createDeployHtml(String name);
|
||||
|
||||
Form selectDeployed(String name) ;
|
||||
/**
|
||||
* 根据名称查询已部署的表单
|
||||
*
|
||||
* @param name 表单名称
|
||||
* @return 已部署的表单
|
||||
*/
|
||||
Form selectDeployed(String name);
|
||||
|
||||
/**
|
||||
* 根据表单名称,获取最新版本的表单
|
||||
@@ -78,7 +82,7 @@ public interface FormService extends GenericService<Form, String> {
|
||||
* @return 表单对象,表单不存在将返回null
|
||||
* @
|
||||
*/
|
||||
Form selectLatest(String name) ;
|
||||
Form selectLatest(String name);
|
||||
|
||||
/**
|
||||
* 根据表单名称和版本,获取表单
|
||||
@@ -88,7 +92,7 @@ public interface FormService extends GenericService<Form, String> {
|
||||
* @return 表单对象,表单不存在将返回null
|
||||
* @
|
||||
*/
|
||||
Form selectByVersion(String name, int version) ;
|
||||
Form selectByVersion(String name, int version);
|
||||
|
||||
/**
|
||||
* 创建表单的html预览。
|
||||
@@ -97,7 +101,7 @@ public interface FormService extends GenericService<Form, String> {
|
||||
* @return html 字符串
|
||||
* @
|
||||
*/
|
||||
String createViewHtml(String id) ;
|
||||
String createViewHtml(String id);
|
||||
|
||||
/**
|
||||
* 查询当前正在使用的表单
|
||||
@@ -106,7 +110,7 @@ public interface FormService extends GenericService<Form, String> {
|
||||
* @return 表单对象。没有则返回null
|
||||
* @
|
||||
*/
|
||||
Form selectUsing(String name) ;
|
||||
Form selectUsing(String name);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ import java.util.List;
|
||||
*/
|
||||
public interface ModuleMetaService extends GenericService<ModuleMeta, String> {
|
||||
|
||||
default List<ModuleMeta> selectByKeyAndRoleId(String key, String... roleId) throws Exception {
|
||||
default List<ModuleMeta> selectByKeyAndRoleId(String key, String... roleId) {
|
||||
QueryParam queryParam = new QueryParam();
|
||||
queryParam.where("key", key).and("role_id$IN", roleId);
|
||||
return this.select(queryParam);
|
||||
}
|
||||
|
||||
default List<ModuleMeta> selectByKey(String key) throws Exception {
|
||||
default List<ModuleMeta> selectByKey(String key) {
|
||||
QueryParam queryParam = new QueryParam();
|
||||
queryParam.where("key", key);
|
||||
return this.select(queryParam);
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.hsweb.web.service.resource;
|
||||
|
||||
import org.hsweb.web.bean.po.resource.Resources;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
@@ -18,13 +19,13 @@ public interface FileService {
|
||||
* @return 生成的资源对象
|
||||
* @throws Exception 保存失败的异常信息
|
||||
*/
|
||||
Resources saveFile(InputStream is, String fileName) throws Exception;
|
||||
Resources saveFile(InputStream is, String fileName) throws IOException;
|
||||
|
||||
InputStream readResources(Resources resources) throws Exception;
|
||||
InputStream readResources(Resources resources) throws IOException;
|
||||
|
||||
InputStream readResources(String resourceId) throws Exception;
|
||||
InputStream readResources(String resourceId) throws IOException;
|
||||
|
||||
void writeResources(Resources resources, OutputStream outputStream) throws Exception;
|
||||
void writeResources(Resources resources, OutputStream outputStream) throws IOException;
|
||||
|
||||
String getFileBasePath();
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hsweb-web-websocket</artifactId>
|
||||
<version>${parent.version}</version>
|
||||
|
||||
<version>${project.parent.version}</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.hsweb.web.socket.CMDWebSocketAutoConfiguration
|
||||
Reference in New Issue
Block a user