Skip to content

Commit

Permalink
Fix 3.9 beta3 (#849)
Browse files Browse the repository at this point in the history
* fix

* feat: 记录历史快速查看

* backup

* func HTML

* CLEAR
  • Loading branch information
getrebuild authored Dec 23, 2024
1 parent 54695b7 commit ae25387
Show file tree
Hide file tree
Showing 18 changed files with 181 additions and 42 deletions.
2 changes: 1 addition & 1 deletion @rbv
Submodule @rbv updated from 0695a8 to 3d440c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ protected Map<String, Object> buildData(Record record, Map<String, String> varsM
data.put(varName, buildBarcodeData(easyField.getRawMeta(), record.getPrimary()));
} else if (fieldValue == null) {
// v3.8
Object funcValue = ValueConvertFunc.convert(easyField, null, varName);
Object funcValue = ValueConvertFunc.convert(easyField, null, varName, this.getClass());
data.put(varName, funcValue == null ? StringUtils.EMPTY : funcValue);
} else {

Expand Down Expand Up @@ -418,7 +418,7 @@ else if (dt == DisplayType.REFERENCE || dt == DisplayType.N2NREFERENCE) {
}

// v3.7.0
fieldValue = ValueConvertFunc.convert(easyField, fieldValue, varName);
fieldValue = ValueConvertFunc.convert(easyField, fieldValue, varName, this.getClass());
}

data.put(varName, fieldValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import com.rebuild.core.metadata.easymeta.DisplayType;
import com.rebuild.core.metadata.easymeta.EasyDecimal;
import com.rebuild.core.metadata.easymeta.EasyField;
import com.rebuild.rbv.data.Html5ReportGenerator;
import com.rebuild.utils.CommonsUtils;
import com.rebuild.utils.MarkdownUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -53,14 +55,16 @@ public class ValueConvertFunc {
private static final String PICKAT_4CLASS_DATE = "PICKAT"; // eg. PICKAT:2
private static final String SIZE_4IMG = "SIZE"; // eg. SIZE:100*200, SIZE:100
private static final String EMPTY = "EMPTY"; // eg. EMPTY:无
public static final String CLEAR_4NTEXT = "CLEAR";

/**
* @param field
* @param value
* @param varName
* @param fromClazz
* @return
*/
public static Object convert(EasyField field, Object value, String varName) {
public static Object convert(EasyField field, Object value, String varName, Class<?> fromClazz) {
String thatFunc = splitFunc(varName);
if (thatFunc == null) return value;

Expand Down Expand Up @@ -153,6 +157,15 @@ public static Object convert(EasyField field, Object value, String varName) {
return m[m.length - 1]; // last
}

} else if (type == DisplayType.NTEXT) {
if (thatFunc.equals(CLEAR_4NTEXT)) {
if (fromClazz == Html5ReportGenerator.class) {
String md2html = MarkdownUtils.render((String) value);
return "<div class='mdedit-content md2html'>" + md2html + "</div>";
} else {
return MarkdownUtils.cleanMarks((String) value);
}
}
}

return value;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/rebuild/core/support/KVStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ record = EntityHelper.forUpdate((ID) exists[0], UserService.SYSTEM_USER, false);
*/
protected static String getValue(final String key, boolean noCache, Object defaultValue) {
String value = null;
// be:v3.8
// be:3.8
if (ConfigurationItem.SN.name().equals(key)) {
value = BootEnvironmentPostProcessor.getProperty(key);
} else if (ConfigurationItem.inJvmArgs(key)) {
Expand Down Expand Up @@ -174,7 +174,7 @@ protected static String getValue(final String key, boolean noCache, Object defau

private static final Object THROTTLED_QUEUE_LOCK = new Object();
private static final Map<String, Object> THROTTLED_QUEUE = new ConcurrentHashMap<>();
private static final Timer THROTTLED_TIMER = new Timer("KVStorage-Timer");
private static final Timer THROTTLED_TIMER = new Timer("KVStorage-Syncer");

static {
final TimerTask localTimerTask = new TimerTask() {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/rebuild/utils/MarkdownUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public static String render(String md, boolean targetBlank, boolean keepHtml) {
* @return
*/
public static String cleanMarks(String md) {
md = md.replaceAll("!\\[.*?]\\((.*?)\\)", "[$1]"); // 替换图片
String html = render(md);
return Jsoup.parse(html).body().text();
}
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/rebuild/web/admin/AdminCli3.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.rebuild.core.rbstore.RbSystemImporter;
import com.rebuild.core.service.approval.ApprovalFields2Schema;
import com.rebuild.core.support.ConfigurationItem;
import com.rebuild.core.support.License;
import com.rebuild.core.support.RebuildConfiguration;
import com.rebuild.core.support.setup.DatabaseBackup;
import com.rebuild.core.support.setup.DatafileBackup;
Expand Down Expand Up @@ -186,7 +187,15 @@ protected String execSyscfg() {
// Setter
else {
String value = commands[2];
RebuildConfiguration.set(item, value);
if (item == ConfigurationItem.SN) {
String usql = String.format("update system_config set `VALUE` = '%s' where `ITEM` = 'SN'", value);
Application.getSqlExecutor().execute(usql);
// reset: RB NEED RESTART
Application.getCommonsCache().evict(ConfigurationItem.SN.name());
License.siteApiNoCache("api/authority/query");
} else {
RebuildConfiguration.set(item, value);
}
return "OK";
}

Expand Down
31 changes: 31 additions & 0 deletions src/main/java/com/rebuild/web/admin/ConfigurationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import com.rebuild.core.support.i18n.Language;
import com.rebuild.core.support.integration.QiniuCloud;
import com.rebuild.core.support.integration.SMSender;
import com.rebuild.core.support.setup.DatabaseBackup;
import com.rebuild.core.support.setup.DatafileBackup;
import com.rebuild.utils.CommonsUtils;
import com.rebuild.utils.JSONUtils;
import com.rebuild.utils.RbAssert;
Expand All @@ -46,6 +48,7 @@
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
Expand Down Expand Up @@ -132,6 +135,34 @@ public RespBody postSystems(@RequestBody JSONObject data) {
return RespBody.ok();
}

@PostMapping("systems/backup")
public RespBody postSystemsBackup(HttpServletRequest request) {
RbAssert.isSuperAdmin(getRequestUser(request));
final int type = getIntParameter(request, "type", 3);
final File backups = RebuildConfiguration.getFileOfData("_backups");

String dbFile = null, fileFile = null;
if (type == 1 || type == 3) {
try {
dbFile = "_backups/" + new DatabaseBackup().backup(backups).getName();
} catch (Exception e) {
dbFile = "ERR:" + e.getMessage();
log.error("Executing [DatabaseBackup] fails", e);
}
}
if (type == 2 || type == 3) {
try {
fileFile = "_backups/" + new DatafileBackup().backup(backups).getName();
} catch (Exception e) {
fileFile = "ERR:" + e.getMessage();
log.error("Executing [DataFileBackup] fails", e);
}
}

JSON res = JSONUtils.toJSONObject(new String[]{"db","file"}, new Object[]{dbFile, fileFile});
return RespBody.ok(res);
}

@GetMapping("integration/storage")
public ModelAndView pageIntegrationStorage() {
ModelAndView mv = createModelAndView("/admin/integration/storage-qiniu");
Expand Down
10 changes: 9 additions & 1 deletion src/main/resources/i18n/lang.zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -3335,5 +3335,13 @@
"飞书侧配置":"飞书侧配置",
"已有记录":"已有记录",
"存在同名字段,是否继续添加?":"存在同名字段,是否继续添加?",
"安装系统模版将清空您现有系统的所有数据,包括系统配置、业务实体、数据等。安装前强烈建议您做好系统备份。":"安装系统模版将清空您现有系统的所有数据,包括系统配置、业务实体、数据等。安装前强烈建议您做好系统备份。"
"安装系统模版将清空您现有系统的所有数据,包括系统配置、业务实体、数据等。安装前强烈建议您做好系统备份。":"安装系统模版将清空您现有系统的所有数据,包括系统配置、业务实体、数据等。安装前强烈建议您做好系统备份。",
"请勿在业务高峰时段执行备份":"请勿在业务高峰时段执行备份",
"无需提交":"无需提交",
"数据目录文件":"数据目录文件",
"开始备份":"开始备份",
"立即备份":"立即备份",
"数据库":"数据库",
"未备份":"未备份",
"选择要备份哪些数据":"选择要备份哪些数据"
}
2 changes: 1 addition & 1 deletion src/main/resources/metadata-conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
<index field-list="recordId,channelWith"/>
</entity>

<entity name="RevisionHistory" type-code="034" name-field="recordName" description="变更历史" queryable="false" parent="false">
<entity name="RevisionHistory" type-code="034" name-field="recordId" description="变更历史" queryable="false" parent="false">
<field name="revisionId" type="primary"/>
<field name="belongEntity" type="string" max-length="100" nullable="false" updatable="false" description="所属实体"/>
<field name="recordId" type="any-reference" nullable="false" updatable="false" cascade="ignore" description="记录 ID"/>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/web/admin/audit/revision-history.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
</div>
</div>
<div class="input-group input-search">
<input class="form-control" type="text" th:placeholder="${bundle.L('查询')}" />
<input class="form-control" type="text" th:placeholder="${bundle.L('快速查询')}" />
<span class="input-group-btn">
<button class="btn btn-secondary" type="button"><i class="icon zmdi zmdi-search"></i></button>
</span>
Expand Down
11 changes: 9 additions & 2 deletions src/main/resources/web/admin/integration/dingtalk.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
<th:block th:replace="~{/_include/header}" />
<meta name="page-help" content="https://getrebuild.com/docs/admin/integration-dingtalk" />
<title>[[${bundle.L('钉钉')}]]</title>
<style>
.J_syncUsers {
position: absolute;
margin-top: -6px;
margin-left: 6px;
}
</style>
</head>
<body>
<div class="rb-wrapper rb-fixed-sidebar rb-collapsible-sidebar rb-collapsible-sidebar-hide-logo rb-color-header" th:classappend="${sideCollapsedClazz}">
Expand Down Expand Up @@ -70,8 +77,8 @@ <h5>[[${bundle.L('数据同步')}]]</h5>
<tr>
<td width="40%">[[${bundle.L('自动同步部门用户')}]]</td>
<td data-id="DingtalkSyncUsers" th:data-value="${DingtalkSyncUsers}">
<span class="mr-1">[[${DingtalkSyncUsers ? bundle.L('是') : bundle.L('否')}]]</span>
<button class="btn btn-light btn-sm J_syncUsers up-1" type="button"><i class="icon zmdi zmdi-refresh up-1"></i> [[${bundle.L('立即同步')}]]</button>
<span>[[${DingtalkSyncUsers ? bundle.L('是') : bundle.L('否')}]]</span>
<button class="btn btn-light btn-sm J_syncUsers" type="button"><i class="icon zmdi zmdi-refresh up-1"></i> [[${bundle.L('立即同步')}]]</button>
</td>
</tr>
<tr>
Expand Down
11 changes: 9 additions & 2 deletions src/main/resources/web/admin/integration/feishu.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
<th:block th:replace="~{/_include/header}" />
<meta name="page-help" content="https://getrebuild.com/docs/admin/integration-dingtalk" />
<title>[[${bundle.L('飞书')}]]</title>
<style>
.J_syncUsers {
position: absolute;
margin-top: -6px;
margin-left: 6px;
}
</style>
</head>
<body>
<div class="rb-wrapper rb-fixed-sidebar rb-collapsible-sidebar rb-collapsible-sidebar-hide-logo rb-color-header" th:classappend="${sideCollapsedClazz}">
Expand Down Expand Up @@ -65,8 +72,8 @@ <h5>[[${bundle.L('数据同步')}]]</h5>
<tr>
<td width="40%">[[${bundle.L('自动同步部门用户')}]]</td>
<td data-id="FeishuSyncUsers" th:data-value="${FeishuSyncUsers}">
<span class="mr-1">[[${FeishuSyncUsers ? bundle.L('是') : bundle.L('否')}]]</span>
<button class="btn btn-light btn-sm J_syncUsers up-1" type="button"><i class="icon zmdi zmdi-refresh up-1"></i> [[${bundle.L('立即同步')}]]</button>
<span>[[${FeishuSyncUsers ? bundle.L('是') : bundle.L('否')}]]</span>
<button class="btn btn-light btn-sm J_syncUsers" type="button"><i class="icon zmdi zmdi-refresh up-1"></i> [[${bundle.L('立即同步')}]]</button>
</td>
</tr>
<tr>
Expand Down
11 changes: 9 additions & 2 deletions src/main/resources/web/admin/integration/wxwork.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
<th:block th:replace="~{/_include/header}" />
<meta name="page-help" content="https://getrebuild.com/docs/admin/integration-wxwork" />
<title>[[${bundle.L('企业微信')}]]</title>
<style>
.J_syncUsers {
position: absolute;
margin-top: -6px;
margin-left: 6px;
}
</style>
</head>
<body>
<div class="rb-wrapper rb-fixed-sidebar rb-collapsible-sidebar rb-collapsible-sidebar-hide-logo rb-color-header" th:classappend="${sideCollapsedClazz}">
Expand Down Expand Up @@ -70,8 +77,8 @@ <h5>[[${bundle.L('数据同步')}]]</h5>
<tr>
<td width="40%">[[${bundle.L('自动同步部门用户')}]]</td>
<td data-id="WxworkSyncUsers" th:data-value="${WxworkSyncUsers}">
<span class="mr-1">[[${WxworkSyncUsers ? bundle.L('是') : bundle.L('否')}]]</span>
<button class="btn btn-light btn-sm J_syncUsers up-1" type="button"><i class="icon zmdi zmdi-refresh up-1"></i> [[${bundle.L('立即同步')}]]</button>
<span>[[${WxworkSyncUsers ? bundle.L('是') : bundle.L('否')}]]</span>
<button class="btn btn-light btn-sm J_syncUsers" type="button"><i class="icon zmdi zmdi-refresh up-1"></i> [[${bundle.L('立即同步')}]]</button>
</td>
</tr>
<tr>
Expand Down
25 changes: 16 additions & 9 deletions src/main/resources/web/admin/system-cfg.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,15 @@
padding: 10px 15px;
display: none;
}
td.td-MobileAppPath .J_MobileAppPath-del {
display: none;
.J_backDb,
button.J_MobileAppPath,
button.J_MobileAppPath-del {
position: absolute;
margin-top: -6px;
margin-left: 6px;
}
td.td-MobileAppPath:hover .J_MobileAppPath-del {
display: inline-block;
button.J_MobileAppPath + button.J_MobileAppPath-del {
margin-left: 70px;
}
</style>
</head>
Expand Down Expand Up @@ -242,7 +246,8 @@ <h5>[[${bundle.L('数据安全')}]]</h5>
<tr>
<td width="40%">[[${bundle.L('数据自动备份')}]]</td>
<td data-id="DBBackupsEnable" th:data-value="${DBBackupsEnable}" th:data-form-text="${bundle.L('每日 0 点备份到数据目录,请预留足够磁盘空间')}">
[[${DBBackupsEnable ? bundle.L('是') : bundle.L('否')}]]
<span>[[${DBBackupsEnable ? bundle.L('是') : bundle.L('否')}]]</span>
<button class="btn btn-light btn-sm J_backDb" type="button"><i class="icon mdi mdi-database-export-outline"></i> [[${bundle.L('立即备份')}]]</button>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -291,10 +296,12 @@ <h5>[[${bundle.L('其他')}]]</h5>
<tr>
<td>[[${bundle.L('APP 安装包')}]] <sup class="rbv"></sup></td>
<td class="td-MobileAppPath">
<a class="J_MobileAppPath hide-empty mr-1 link" target="_blank" href="../h5app-download">[[${MobileAppPath}]]</a>
<input type="file" class="hide J_MobileAppPath" accept=".apk" />
<button class="btn btn-light btn-sm J_MobileAppPath" type="button"><i class="icon zmdi zmdi-upload"></i> [[${bundle.L('上传')}]]<span></span></button>
<button class="btn btn-light w-auto btn-sm J_MobileAppPath-del hide" type="button" th:title="${bundle.L('删除')}"><i class="icon zmdi zmdi-delete"></i></button>
<a>[[${MobileAppPath ?:bundle.L('无')}]]</a>
<button class="btn btn-light btn-sm J_MobileAppPath" type="button"><i class="icon mdi mdi-upload"></i> [[${bundle.L('上传')}]]<span></span></button>
<button class="btn btn-light btn-sm J_MobileAppPath-del w-auto hide" type="button" th:title="${bundle.L('删除')}"><i class="icon mdi mdi-delete"></i></button>
<div class="hide">
<input type="file" class="hide J_MobileAppPath" accept=".apk" />
</div>
</td>
</tr>
</tbody>
Expand Down
Loading

0 comments on commit ae25387

Please sign in to comment.