Skip to content

Commit 02f9220

Browse files
authored
Merge pull request hs-web#8 from hs-web/2.2-SNAPSHOT
2.2 snapshot
2 parents 2da4b3b + a957d4d commit 02f9220

File tree

159 files changed

+4648
-1500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+4648
-1500
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 后台管理基础框架
1+
## hsweb后台管理基础框架
22

33
[![Build Status](https://travis-ci.org/hs-web/hsweb-framework.svg?branch=master)](https://travis-ci.org/hs-web/hsweb-framework)
44
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square)](https://www.apache.org/licenses/LICENSE-2.0.html)
@@ -37,6 +37,7 @@
3737
7. 数据库支持 mysql,oracle,h2.
3838
8. websocket支持.
3939
9. 定时调度支持,可在页面配置定时任务,编写任务脚本执行。
40+
10. **强大的dsl查询方式,复杂条件一句生成**
4041

4142
### 演示
4243
1. 示例:[demo.hsweb.me](http://demo.hsweb.me)

doc/2.API.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# hsweb 常用api
2+
3+
## CRUD
4+
[如何创建通用crud](./create-crud.md)
5+
6+
查询:
7+
```java
8+
9+
import static MyBean.Property.*; //属性名
10+
myService.createQuery()
11+
.where(name,"admin")
12+
.or(name,"root")
13+
.list(); //list(), list(0,10), single(),total();
14+
//or
15+
myService.createQuery().fromBean(myBean)
16+
.where(name)
17+
.or(name)
18+
.list();
19+
20+
// 复杂查询条件
21+
// 等同sql where name is not null and (name like '李%' or name like '周%') and age >0
22+
// 参数全部预编译,不用担心注入
23+
myService.createQuery()
24+
.where().notNull(name)
25+
.nest().or().like$(name,"").or().like$(name,"").end()
26+
.and().gt(age,10).list();
27+
28+
//自定义sql条件
29+
30+
myService.createQuery()
31+
.where()
32+
.and().sql("name !=''")
33+
.or().sql("age < #{age}",{age:10})// 使用预编译方式
34+
.or().sql("age = #{[0]}",Arrays.asList(20))//获取集合参数
35+
.or().sql("age > ? and (age <?)",60,100)//使用参数列表方式
36+
.list();
37+
```
38+
39+
修改,支持和query一致的条件
40+
```java
41+
import static MyBean.Property.*;
42+
myService.createUpdate()
43+
.set(status,1)
44+
.where(id,"data-id").exec();
45+
// or
46+
myService.createUpdate(myBean).fromBean().where(id).exec();
47+
```
48+
49+
删除,支持和query一致的条件
50+
```java
51+
import static MyBean.Property.*;
52+
myService.createDelete().where(id,"data-id").exec();
53+
```

hsweb-web-bean/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>hsweb-framework</artifactId>
77
<groupId>org.hsweb</groupId>
8-
<version>2.1-SNAPSHOT</version>
8+
<version>2.2-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111
<artifactId>hsweb-web-bean</artifactId>
@@ -18,7 +18,7 @@
1818
</dependency>
1919
<dependency>
2020
<groupId>org.hsweb</groupId>
21-
<artifactId>hsweb-easy-orm</artifactId>
21+
<artifactId>hsweb-easy-orm-rdb</artifactId>
2222
</dependency>
2323
<dependency>
2424
<groupId>org.hsweb</groupId>

hsweb-web-bean/src/main/java/org/hsweb/web/bean/common/DeleteParam.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Created by zhouhao on 16-4-19.
55
*/
6-
public class DeleteParam extends SqlParam<DeleteParam> {
6+
public class DeleteParam extends SqlParam {
77
public static DeleteParam build() {
88
return new DeleteParam();
99
}

hsweb-web-bean/src/main/java/org/hsweb/web/bean/common/InsertParam.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Created by zhouhao on 16-4-19.
55
*/
6-
public class InsertParam<T> extends org.hsweb.ezorm.param.InsertParam<T> {
6+
public class InsertParam<T> extends org.hsweb.ezorm.core.param.InsertParam<T> {
77

88
public InsertParam() {
99
}

hsweb-web-bean/src/main/java/org/hsweb/web/bean/common/QueryParam.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
package org.hsweb.web.bean.common;
22

33

4-
import org.hsweb.ezorm.param.Term;
5-
import org.hsweb.ezorm.param.TermType;
4+
import org.hsweb.ezorm.core.param.Term;
5+
import org.hsweb.ezorm.core.param.TermType;
66

77
import java.io.Serializable;
88
import java.util.HashMap;
99
import java.util.List;
1010
import java.util.Map;
1111

12-
/**
13-
* Created by 浩 on 2016-01-16 0016.
14-
*/
15-
public class QueryParam extends org.hsweb.ezorm.param.QueryParam<QueryParam> implements Serializable {
16-
private static final long serialVersionUID = 7941767360194797891L;
17-
private Map<String, Object> param = new HashMap<>();
12+
public class QueryParam extends org.hsweb.ezorm.core.param.QueryParam implements Serializable {
13+
private static final long serialVersionUID = 7941767360194797891L;
14+
private Map<String, Object> param = new HashMap<>();
1815

1916
public QueryParam noPaging() {
2017
setPaging(false);

hsweb-web-bean/src/main/java/org/hsweb/web/bean/common/Sort.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

hsweb-web-bean/src/main/java/org/hsweb/web/bean/common/SqlParam.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Created by zhouhao on 16-4-19.
1010
*/
11-
public class SqlParam<R extends SqlParam> extends org.hsweb.ezorm.param.SqlParam<R> {
11+
public class SqlParam extends org.hsweb.ezorm.core.param.Param {
1212

1313
protected Map<String, Object> params = new HashMap<>();
1414

@@ -26,6 +26,6 @@ public String toString() {
2626
}
2727

2828
public static SqlParam build() {
29-
return new SqlParam<>();
29+
return new SqlParam();
3030
}
3131
}

hsweb-web-bean/src/main/java/org/hsweb/web/bean/common/UpdateMapParam.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public UpdateMapParam(Map<String, Object> data) {
1616
}
1717

1818
public UpdateMapParam set(String key, Object value) {
19-
this.getData().put(key, value);
19+
((Map<String, Object>) this.getData()).put(key, value);
2020
return this;
2121
}
2222

hsweb-web-bean/src/main/java/org/hsweb/web/bean/common/UpdateParam.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Created by zhouhao on 16-4-19.
55
*/
6-
public class UpdateParam<T> extends org.hsweb.ezorm.param.UpdateParam<T,UpdateParam<T>> {
6+
public class UpdateParam<T> extends org.hsweb.ezorm.core.param.UpdateParam<T> {
77

88
public UpdateParam() {
99
}

hsweb-web-bean/src/main/java/org/hsweb/web/bean/po/GenericPo.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
import org.hsweb.commons.MD5;
5+
import org.hsweb.web.bean.po.module.Module;
56

67
import java.io.Serializable;
78
import java.lang.reflect.Field;
@@ -60,7 +61,6 @@ public boolean equals(Object obj) {
6061
/**
6162
* 创建一个主键
6263
*
63-
* @return
6464
*/
6565
public static String createUID() {
6666
return MD5.encode(UUID.randomUUID().toString());
@@ -74,12 +74,19 @@ public void setProperties(Map<String, Object> properties) {
7474
this.properties = properties;
7575
}
7676

77-
@Override
78-
public Object clone() throws CloneNotSupportedException {
79-
Field[] fields = this.getClass().getDeclaredFields();
80-
for (int i = 0; i < fields.length; i++) {
81-
82-
}
83-
return super.clone();
77+
public interface Property {
78+
/**
79+
* 主键
80+
*
81+
* @see GenericPo#id
82+
*/
83+
String id = "id";
84+
85+
/**
86+
* 其他属性
87+
*
88+
* @see GenericPo#properties
89+
*/
90+
String properties = "properties";
8491
}
8592
}

hsweb-web-bean/src/main/java/org/hsweb/web/bean/po/classified/Classified.java

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,44 @@ public int getSortIndex() {
151151
public void setSortIndex(int sortIndex) {
152152
this.sortIndex = sortIndex;
153153
}
154-
}
154+
155+
156+
157+
public interface Property extends GenericPo.Property{
158+
/**
159+
*
160+
* @see Classified#name
161+
*/
162+
String name="name";
163+
/**
164+
*
165+
* @see Classified#remark
166+
*/
167+
String remark="remark";
168+
/**
169+
*
170+
* @see Classified#type
171+
*/
172+
String type="type";
173+
/**
174+
*
175+
* @see Classified#parentId
176+
*/
177+
String parentId="parentId";
178+
/**
179+
*
180+
* @see Classified#icon
181+
*/
182+
String icon="icon";
183+
/**
184+
*
185+
* @see Classified#config
186+
*/
187+
String config="config";
188+
/**
189+
*
190+
* @see Classified#sortIndex
191+
*/
192+
String sortIndex="sortIndex";
193+
}
194+
}

hsweb-web-bean/src/main/java/org/hsweb/web/bean/po/config/Config.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,27 @@ public List<Map<Object, Object>> toList() {
165165
List<Map<Object, Object>> array = (List) JSON.parseArray(getContent(), Map.class);
166166
return array;
167167
}
168-
}
168+
169+
public interface Property extends GenericPo.Property {
170+
/**
171+
* @see Config#remark
172+
*/
173+
String remark = "remark";
174+
/**
175+
* @see Config#content
176+
*/
177+
String content = "content";
178+
/**
179+
* @see Config#createDate
180+
*/
181+
String createDate = "createDate";
182+
/**
183+
* @see Config#updateDate
184+
*/
185+
String updateDate = "updateDate";
186+
/**
187+
* @see Config#classifiedId
188+
*/
189+
String classifiedId = "classifiedId";
190+
}
191+
}

hsweb-web-bean/src/main/java/org/hsweb/web/bean/po/datasource/DataSource.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,49 @@ public int getHash() {
154154
builder.append(driver).append(url).append(username).append(password).append(enabled);
155155
return builder.toString().hashCode();
156156
}
157+
158+
159+
160+
public interface Property extends GenericPo.Property{
161+
/**
162+
*
163+
* @see DataSource#name
164+
*/
165+
String name="name";
166+
/**
167+
*
168+
* @see DataSource#driver
169+
*/
170+
String driver="driver";
171+
/**
172+
*
173+
* @see DataSource#url
174+
*/
175+
String url="url";
176+
/**
177+
*
178+
* @see DataSource#username
179+
*/
180+
String username="username";
181+
/**
182+
*
183+
* @see DataSource#testSql
184+
*/
185+
String testSql="testSql";
186+
/**
187+
*
188+
* @see DataSource#password
189+
*/
190+
String password="password";
191+
/**
192+
*
193+
* @see DataSource#enabled
194+
*/
195+
String enabled="enabled";
196+
/**
197+
*
198+
* @see DataSource#createDate
199+
*/
200+
String createDate="createDate";
201+
}
157202
}

hsweb-web-bean/src/main/java/org/hsweb/web/bean/po/draft/Draft.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,34 @@ public String getKey() {
5454
public void setKey(String key) {
5555
this.key = key;
5656
}
57-
}
57+
58+
59+
60+
public interface Property extends GenericPo.Property{
61+
/**
62+
*
63+
* @see Draft#name
64+
*/
65+
String name="name";
66+
/**
67+
*
68+
* @see Draft#value
69+
*/
70+
String value="value";
71+
/**
72+
*
73+
* @see Draft#key
74+
*/
75+
String key="key";
76+
/**
77+
*
78+
* @see Draft#createDate
79+
*/
80+
String createDate="createDate";
81+
/**
82+
*
83+
* @see Draft#creatorId
84+
*/
85+
String creatorId="creatorId";
86+
}
87+
}

0 commit comments

Comments
 (0)