Skip to content

Commit

Permalink
Merge pull request #135 from getrebuild/develop
Browse files Browse the repository at this point in the history
Merge v1.8.0
  • Loading branch information
getrebuild authored Feb 18, 2020
2 parents 85c5bfd + 4dd8e08 commit 08e0a4e
Show file tree
Hide file tree
Showing 285 changed files with 5,847 additions and 2,204 deletions.
2 changes: 0 additions & 2 deletions .codebeatignore

This file was deleted.

1 change: 1 addition & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ ignore:
- "src/test/.*"
- "src/main/webapp/.*"
- "src/main/java/com/rebuild/web/.*"
- ".*/.*Exception.java"
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Use ESLint in locally : `npm install eslint babel-eslint eslint-plugin-react --save-dev`
{
"env": {
"browser": true,
Expand All @@ -21,6 +22,7 @@
},
"settings": {
"react": {
"pragma": "React",
"version": "16.10.2"
}
},
Expand Down Expand Up @@ -93,6 +95,7 @@
},
"rules": {
"strict": 0,
"no-redeclare": 0,
"indent": [2, 2],
"linebreak-style": [0, "unix"],
"quotes": [2, "single"],
Expand Down
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @getrebuild @devezhao
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ rebuild.iml

.DS_Store

node_modules
package-lock.json
1 change: 0 additions & 1 deletion .setup/db-init.sql

This file was deleted.

8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"editor.fontSize": 12,
"editor.tabSize": 2,
"editor.formatOnSave": true,
"eslint.autoFixOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.options": {
"configFile": "./.eslintrc.json"
},
Expand All @@ -26,6 +28,4 @@
"prettier.eslintIntegration": true,
"workbench.editor.enablePreview": false,
"java.configuration.updateBuildConfiguration": "disabled"
}
// node and eslint(-g)
// Plugins: Beautify and ESLint
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
[![codecov](https://codecov.io/gh/getrebuild/rebuild/branch/master/graph/badge.svg)](https://codecov.io/gh/getrebuild/rebuild)
[![Build Status](https://travis-ci.org/getrebuild/rebuild.svg?branch=master)](https://travis-ci.org/getrebuild/rebuild)
[![Crowdin](https://badges.crowdin.net/rebuild/localized.svg)](https://crowdin.com/project/rebuild)
[![License GPLv3](https://img.shields.io/github/license/getrebuild/rebuild.svg)](https://raw.githubusercontent.com/getrebuild/rebuild/master/LICENSE)
[![License COMMERCIAL](https://img.shields.io/badge/license-COMMERCIAL-orange.svg)](https://raw.githubusercontent.com/getrebuild/rebuild/master/COMMERCIAL)
[![License GPLv3](https://img.shields.io/github/license/getrebuild/rebuild.svg)](https://getrebuild.com/license/LICENSE.txt)
[![License COMMERCIAL](https://img.shields.io/badge/license-COMMERCIAL-orange.svg)](https://getrebuild.com/license/COMMERCIAL.txt)


## 快速开始
Expand All @@ -29,6 +29,6 @@ REBUILD is a true production-grade project that fully considers security, robust

## 注意 NOTICE

REBUILD 使用 [开源 GPL-3.0](https://raw.githubusercontent.com/getrebuild/rebuild/master/LICENSE)[商用](https://raw.githubusercontent.com/getrebuild/rebuild/master/COMMERCIAL) 双重授权许可,您应当认真阅读许可内容。使用 REBUILD 即表示您完全同意许可内容/条款。感谢支持!
REBUILD 使用 [开源 GPL-3.0](https://getrebuild.com/license/LICENSE.txt)[商用](https://getrebuild.com/license/COMMERCIAL.txt) 双重授权许可,您应当认真阅读许可内容。使用 REBUILD 即表示您完全同意许可内容/条款。感谢支持!

REBUILD uses the [open source GPL-3.0](https://raw.githubusercontent.com/getrebuild/rebuild/master/LICENSE) and [commercial](https://raw.githubusercontent.com/getrebuild/rebuild/master/COMMERCIAL) dual license agreements, and you should read the contents of the agreement carefully. By using REBUILD, you fully agree to the Licensed Content/Terms. Thanks for the support!
REBUILD uses the [open source GPL-3.0](https://getrebuild.com/license/LICENSE.txt) and [commercial](https://getrebuild.com/license/COMMERCIAL.txt) dual license agreements, and you should read the contents of the agreement carefully. By using REBUILD, you fully agree to the Licensed Content/Terms. Thanks for the support!
15 changes: 13 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.rebuild</groupId>
<artifactId>rebuild</artifactId>
<packaging>war</packaging>
<version>1.7.2</version>
<version>1.8.0</version>
<name>rebuild</name>
<description>Building your business-systems free!</description>
<url>https://getrebuild.com/</url>
Expand Down Expand Up @@ -127,7 +127,7 @@
<dependency>
<groupId>com.github.devezhao</groupId>
<artifactId>persist4j</artifactId>
<version>1.3.4</version>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -290,6 +290,12 @@
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.1.3</version>
<exclusions>
<exclusion>
<artifactId>ehcache</artifactId>
<groupId>org.ehcache</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jxls</groupId>
Expand All @@ -316,5 +322,10 @@
<artifactId>h2</artifactId>
<version>1.4.200</version>
</dependency>
<dependency>
<groupId>com.googlecode.aviator</groupId>
<artifactId>aviator</artifactId>
<version>4.2.9</version>
</dependency>
</dependencies>
</project>
27 changes: 16 additions & 11 deletions src/main/java/com/rebuild/api/ApiGateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import cn.devezhao.commons.CalendarUtils;
import cn.devezhao.commons.EncryptUtils;
import cn.devezhao.commons.ObjectUtils;
import cn.devezhao.commons.ThreadPool;
import cn.devezhao.commons.web.ServletUtils;
import cn.devezhao.persist4j.Record;
import cn.devezhao.persist4j.engine.ID;
Expand All @@ -32,6 +33,7 @@
import com.rebuild.server.service.DataSpecificationException;
import com.rebuild.server.service.bizz.UserService;
import com.rebuild.utils.AppUtils;
import com.rebuild.utils.CommonsUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -81,6 +83,7 @@ public void api(@PathVariable String apiName,
JSON ok = formatSuccess(data);
ServletUtils.writeJson(response, ok.toJSONString());
logRequestAsync(reuqestTime, remoteIp, apiName, context, ok);

return;

} catch (ApiInvokeException ex) {
Expand Down Expand Up @@ -201,17 +204,19 @@ protected void logRequestAsync(Date requestTime, String remoteIp, String apiName
return;
}

Record record = EntityHelper.forNew(EntityHelper.RebuildApiRequest, UserService.SYSTEM_USER);
record.setString("appId", context.getAppId());
record.setString("remoteIp", remoteIp);
record.setString("requestUrl", apiName + " " + context.getParameterMap());
if (context.getPostData() != null) {
record.setString("requestBody", context.getPostData().toJSONString());
}
record.setString("responseBody", result.toJSONString());
record.setDate("requestTime", requestTime);
record.setDate("responseTime", CalendarUtils.now());
Application.getCommonService().create(record);
ThreadPool.exec(() -> {
Record record = EntityHelper.forNew(EntityHelper.RebuildApiRequest, UserService.SYSTEM_USER);
record.setString("appId", context.getAppId());
record.setString("remoteIp", remoteIp);
record.setString("requestUrl", CommonsUtils.maxstr(apiName + "?" + context.getParameterMap(),300));
if (context.getPostData() != null) {
record.setString("requestBody", CommonsUtils.maxstr(context.getPostData().toJSONString(), 10000));
}
record.setString("responseBody", CommonsUtils.maxstr(result.toJSONString(), 10000));
record.setDate("requestTime", requestTime);
record.setDate("responseTime", CalendarUtils.now());
Application.getCommonService().create(record, false);
});
}

// -- 注册 API
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rebuild/api/LoginToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static ID verifyToken(String loginToken) {
* @return
*/
public static String checkUser(String user, String password) {
if (!Application.getUserStore().exists(user)) {
if (!Application.getUserStore().existsUser(user)) {
return Languages.lang("InputWrong", "UsernameOrPassword");
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rebuild/server/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public final class Application {

/** Rebuild Version
*/
public static final String VER = "1.7.2";
public static final String VER = "1.8.0";

/** Logging for Global
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/rebuild/server/ServerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import cn.devezhao.commons.CalendarUtils;
import com.rebuild.server.helper.ConfigurableItem;
import com.rebuild.server.helper.SysConfiguration;
import com.rebuild.server.helper.setup.InstallAfter;
import com.rebuild.server.helper.setup.InstallState;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand All @@ -38,7 +38,7 @@
* @author devezhao
* @since 10/13/2018
*/
public class ServerListener extends ContextCleanupListener implements InstallAfter {
public class ServerListener extends ContextCleanupListener implements InstallState {

private static final Log LOG = LogFactory.getLog(ServerListener.class);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rebuild/server/ServerStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected static Status checkCreateFile() {
if (!test.exists()) {
return Status.error(name, "Couldn't create file in temp Directory");
} else {
test.delete();
FileUtils.deleteQuietly(test);
}

} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,25 @@ public boolean submit(JSONObject selectNextUsers) throws ApprovalException {
* @throws ApprovalException
*/
public void approve(ID approver, ApprovalState state, String remark, JSONObject selectNextUsers) throws ApprovalException {
Integer currentState = (Integer) Application.getQueryFactory().unique(this.record, EntityHelper.ApprovalState)[0];
approve(approver, state, remark, selectNextUsers, null);
}

/**
* 审批
*
* @param approver
* @param state
* @param remark
* @param selectNextUsers
* @param addedData
* @throws ApprovalException
*/
public void approve(ID approver, ApprovalState state, String remark, JSONObject selectNextUsers, Record addedData) throws ApprovalException {
Object[] o = Application.getQueryFactory().unique(this.record, EntityHelper.ApprovalState);
if (o == null) {
throw new NoRecordFoundException("审批记录不存在或你无权查看");
}
Integer currentState = (Integer) o[0];
if (currentState != ApprovalState.PROCESSING.getState()) {
throw new ApprovalException("当前记录已经" + (currentState == ApprovalState.APPROVED.getState() ? "审批完成" : "驳回审批"));
}
Expand Down Expand Up @@ -152,28 +170,28 @@ public void approve(ID approver, ApprovalState state, String remark, JSONObject
Set<ID> ccs = nextNodes.getCcUsers(this.getUser(), this.record, selectNextUsers);
Set<ID> nextApprovers = null;
String nextNode = null;
if (!nextNodes.isLastStep()) {

if (state == ApprovalState.APPROVED && !nextNodes.isLastStep()) {
nextApprovers = nextNodes.getApproveUsers(this.getUser(), this.record, selectNextUsers);
if (nextApprovers.isEmpty()) {
throw new ApprovalException("无下一步审批人可用,请联系管理员配置");
}

FlowNode nextApprovalNode = nextNodes.getApprovalNode();
nextNode = nextApprovalNode != null ? nextApprovalNode.getNodeId() : null;
}

FlowNode currentNode = getFlowParser().getNode((String) stepApprover[2]);
Application.getBean(ApprovalStepService.class)
.txApprove(approvedStep, currentNode.getSignMode(), ccs, nextApprovers, nextNode);
.txApprove(approvedStep, currentNode.getSignMode(), ccs, nextApprovers, nextNode, addedData);
}

/**
* 撤销
*
* @param remark
* @throws ApprovalException
*/
public void cancel(String remark) throws ApprovalException {
public void cancel() throws ApprovalException {
Object[] state = Application.getQueryFactory().unique(this.record, EntityHelper.ApprovalState, EntityHelper.ApprovalId);
Integer currentState = (Integer) state[0];
if ((Integer) state[0] != ApprovalState.PROCESSING.getState()) {
Expand All @@ -183,6 +201,13 @@ public void cancel(String remark) throws ApprovalException {
Application.getBean(ApprovalStepService.class).txCancel(this.record, (ID) state[1], getCurrentNodeId());
}

/**
* @return
*/
public FlowNode getCurrentNode() {
return getFlowParser().getNode(getCurrentNodeId());
}

/**
* @return
* @see #getNextNode(String)
Expand Down
24 changes: 22 additions & 2 deletions src/main/java/com/rebuild/server/business/approval/FlowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public Set<ID> getSpecUsers(ID operator, ID record) {
if (userDefs == null || userDefs.isEmpty()) {
return Collections.emptySet();
}

String userType = userDefs.getString(0);
if (USER_SELF.equalsIgnoreCase(userType)) {
Set<ID> users = new HashSet<>();
Expand Down Expand Up @@ -171,7 +171,27 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj.hashCode() == this.hashCode();
if (obj == null) return false;
return obj instanceof FlowNode && obj.hashCode() == this.hashCode();
}

/**
* 节点可编辑字段
*
* @return
*/
public JSONArray getEditableFields() {
JSONArray editableFields = dataMap == null ? null : dataMap.getJSONArray("editableFields");
if (editableFields == null) {
return null;
}

editableFields = (JSONArray) JSONUtils.clone(editableFields);
for (Object o : editableFields) {
JSONObject field = (JSONObject) o;
field.put("nullable", !((Boolean) field.remove("notNull")));
}
return editableFields;
}

// --
Expand Down
Loading

0 comments on commit 08e0a4e

Please sign in to comment.