Merge pull request #433 from getrebuild/fix-2.7.2

Fix 2.7.2
This commit is contained in:
RB 2022-02-13 17:56:05 +08:00 committed by GitHub
commit 056ab46487
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 58 additions and 31 deletions

View file

@ -10,7 +10,7 @@
</parent>
<groupId>com.rebuild</groupId>
<artifactId>rebuild</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
<name>rebuild</name>
<description>RB V2 use SpringBoot</description>
<!-- UNCOMMENT USE TOMCAT -->
@ -254,7 +254,7 @@
<dependency>
<groupId>com.github.devezhao</groupId>
<artifactId>commons</artifactId>
<version>1.3.5</version>
<version>1.3.6</version>
<exclusions>
<exclusion>
<artifactId>httpclient</artifactId>

View file

@ -64,11 +64,11 @@ public class Application implements ApplicationListener<ApplicationStartedEvent>
/**
* Rebuild Version
*/
public static final String VER = "2.7.1";
public static final String VER = "2.7.2";
/**
* Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2}
*/
public static final int BUILD = 2070103;
public static final int BUILD = 2070204;
static {
// Driver for DB

View file

@ -8,6 +8,7 @@ See LICENSE and COMMERCIAL in the project root for license information.
package com.rebuild.core.service.query;
import cn.devezhao.persist4j.Entity;
import cn.devezhao.persist4j.Query;
import cn.devezhao.persist4j.engine.ID;
import com.alibaba.fastjson.JSONObject;
import com.rebuild.core.Application;
@ -42,4 +43,16 @@ public class QueryHelper {
}
return true;
}
/**
* @param sql
* @param useEntity
* @return
*/
public static Query createQuery(String sql, Entity useEntity) {
if (MetadataHelper.hasPrivilegesField(useEntity) || useEntity.getMainEntity() != null) {
return Application.createQuery(sql);
}
return Application.createQueryNoFilter(sql);
}
}

View file

@ -8,6 +8,7 @@ See LICENSE and COMMERCIAL in the project root for license information.
package com.rebuild.core.support;
import cn.devezhao.commons.CodecUtils;
import cn.devezhao.commons.identifier.ComputerIdentifier;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rebuild.core.Application;
@ -27,7 +28,7 @@ import java.util.Locale;
public final class License {
private static final String OSA_KEY = "IjkMHgq94T7s7WkP";
private static final String TEMP_SN = "SN-000000-00000000000000";
private static final String TEMP_SN = "SN000-00000000-000000000";
private static String USE_SN;
private static Boolean USE_RBV;
@ -50,10 +51,11 @@ public final class License {
}
if (SN == null) {
SN = String.format("ZR%d%s-%s",
Application.BUILD,
SN = String.format("RB%s%s-%s-%s",
Application.VER.charAt(0),
Locale.getDefault().getCountry().substring(0, 2),
CodecUtils.randomCode(14).toUpperCase());
ComputerIdentifier.generateIdentifierKey(),
CodecUtils.randomCode(9)).toUpperCase();
RebuildConfiguration.set(ConfigurationItem.SN, SN);
}
@ -102,7 +104,7 @@ public final class License {
}
public static JSONObject siteApi(String api, boolean useCache) {
if (useCache) {
if (useCache && Application.isReady()) {
Object o = Application.getCommonsCache().getx(api);
if (o != null) {
return (JSONObject) o;
@ -120,7 +122,7 @@ public final class License {
String hasError = o.getString("error");
if (hasError != null) {
log.error("Bad result : {}", result);
} else {
} else if (Application.isReady()) {
Application.getCommonsCache().putx(api, o, CommonsCache.TS_HOUR);
}
return o;

View file

@ -7,6 +7,7 @@ See LICENSE and COMMERCIAL in the project root for license information.
package com.rebuild.utils;
import cn.devezhao.commons.identifier.ComputerIdentifier;
import com.alibaba.fastjson.JSON;
import com.rebuild.core.Application;
import com.rebuild.core.support.RebuildConfiguration;
@ -25,7 +26,7 @@ import java.util.concurrent.TimeUnit;
*
* @author devezhao
* @see org.springframework.http.HttpStatus
* @see org.springframework.http.HttpHeaders
* @see HttpHeaders
* @since 2020/7/15
*/
@Slf4j
@ -33,9 +34,13 @@ public class HttpUtils {
private static OkHttpClient okHttpClient = null;
private static final String RB_UA =
String.format("RB/%s (%s/%s)", Application.VER, SystemUtils.OS_NAME, SystemUtils.JAVA_SPECIFICATION_VERSION);
private static final String RB_LANG = Locale.getDefault().toString(); // zh_CN
private static final String RB_UA = String.format("RB/%s (%s/%s)",
Application.VER, SystemUtils.OS_NAME, SystemUtils.JAVA_SPECIFICATION_VERSION);
private static final Locale l = Locale.getDefault();
private static final String RB_LANG = l.getLanguage() + "_" + l.getCountry();
private static String RB_CI;
/**
* 获取客户端如本类提供的 GET/POST 方法无法满足需求可以自己构建然后通过此 Client 调用
@ -51,6 +56,7 @@ public class HttpUtils {
.readTimeout(30, TimeUnit.SECONDS)
.retryOnConnectionFailure(true)
.build();
RB_CI = ComputerIdentifier.generateIdentifierKey();
}
return okHttpClient;
}
@ -75,11 +81,12 @@ public class HttpUtils {
* @throws IOException
*/
public static String get(String url, Map<String, String> headers) throws IOException {
OkHttpClient client = getHttpClient();
Request.Builder builder = new Request.Builder().url(url);
Request request = useHeaders(builder, headers).build();
long ms = System.currentTimeMillis();
try (Response response = getHttpClient().newCall(request).execute()) {
try (Response response = client.newCall(request).execute()) {
return Objects.requireNonNull(response.body()).string();
} finally {
ms = System.currentTimeMillis() - ms;
@ -129,13 +136,14 @@ public class HttpUtils {
requestBody = RequestBody.create(reqData == null ? "" : reqData.toString(), MediaType.parse("text/plain"));
}
OkHttpClient client = getHttpClient();
Request.Builder builder = new Request.Builder().url(url);
Request request = useHeaders(builder, headers)
.post(requestBody)
.build();
long ms = System.currentTimeMillis();
try (Response response = getHttpClient().newCall(request).execute()) {
try (Response response = client.newCall(request).execute()) {
return Objects.requireNonNull(response.body()).string();
} finally {
ms = System.currentTimeMillis() - ms;
@ -166,10 +174,11 @@ public class HttpUtils {
* @throws IOException
*/
public static boolean readBinary(String url, File dest, Map<String, String> headers) throws IOException {
OkHttpClient client = getHttpClient();
Request.Builder builder = new Request.Builder().url(url);
Request request = useHeaders(builder, headers).build();
try (Response response = getHttpClient().newCall(request).execute()) {
try (Response response = client.newCall(request).execute()) {
try (InputStream is = Objects.requireNonNull(response.body()).byteStream()) {
try (BufferedInputStream bis = new BufferedInputStream(is)) {
try (OutputStream os = new FileOutputStream(dest)) {
@ -189,6 +198,7 @@ public class HttpUtils {
private static Request.Builder useHeaders(Request.Builder builder, Map<String, String> headers) {
builder.addHeader(HttpHeaders.USER_AGENT, RB_UA);
builder.addHeader(HttpHeaders.ACCEPT_LANGUAGE, RB_LANG);
if (RB_CI != null) builder.addHeader("X-RB-CI", RB_CI);
if (headers != null && !headers.isEmpty()) {
for (Map.Entry<String, String> e : headers.entrySet()) {

View file

@ -9,7 +9,6 @@ package com.rebuild.web.general;
import cn.devezhao.persist4j.Entity;
import cn.devezhao.persist4j.Field;
import cn.devezhao.persist4j.Query;
import cn.devezhao.persist4j.dialect.FieldType;
import cn.devezhao.persist4j.engine.ID;
import com.alibaba.fastjson.JSON;
@ -26,6 +25,7 @@ import com.rebuild.core.privileges.UserService;
import com.rebuild.core.service.NoRecordFoundException;
import com.rebuild.core.service.general.RecentlyUsedHelper;
import com.rebuild.core.service.query.ParseHelper;
import com.rebuild.core.service.query.QueryHelper;
import com.rebuild.core.support.general.FieldValueHelper;
import com.rebuild.core.support.general.ProtocolFilterParser;
import com.rebuild.core.support.i18n.Language;
@ -132,6 +132,8 @@ public class ReferenceSearchController extends EntityController {
String searchWhere = StringUtils.join(searchFields.iterator(), like + " or ") + like;
if (appendWhere != null) {
searchWhere = String.format("(%s) and (%s)", appendWhere, searchWhere);
} else {
searchWhere = String.format("(%s)", searchWhere);
}
List<Object> result = resultSearch(searchWhere, searchEntity, maxResults);
@ -153,7 +155,7 @@ public class ReferenceSearchController extends EntityController {
String q = getParameter(request, "q");
// 为空则加载最近使用的
if (StringUtils.isBlank(q)) {
String type = "d" + useClassification;
String type = "d" + useClassification + ":" + ClassificationManager.instance.getOpenLevel(fieldMeta);
ID[] recently = RecentlyUsedHelper.gets(user, "ClassificationData", type);
if (recently.length == 0) {
return JSONUtils.EMPTY_ARRAY;
@ -189,9 +191,7 @@ public class ReferenceSearchController extends EntityController {
}
}
Query query = MetadataHelper.hasPrivilegesField(entity)
? Application.createQuery(sql) : Application.createQueryNoFilter(sql);
Object[][] array = query.setLimit(maxResults).array();
Object[][] array = QueryHelper.createQuery(sql, entity).setLimit(maxResults).array();
List<Object> result = new ArrayList<>();
for (Object[] o : array) {
@ -271,7 +271,8 @@ public class ReferenceSearchController extends EntityController {
// 可新建
mv.getModel().put("canCreate",
Application.getPrivilegesManager().allowCreate(user, searchEntity.getEntityCode()));
searchEntity.getMainEntity() == null
&& Application.getPrivilegesManager().allowCreate(user, searchEntity.getEntityCode()));
if (ProtocolFilterParser.getFieldDataFilter(field) != null
|| ProtocolFilterParser.hasFieldCascadingField(field)) {

View file

@ -11,7 +11,6 @@ import cn.devezhao.bizz.security.member.Team;
import cn.devezhao.commons.ObjectUtils;
import cn.devezhao.persist4j.Entity;
import cn.devezhao.persist4j.Field;
import cn.devezhao.persist4j.Query;
import cn.devezhao.persist4j.dialect.FieldType;
import cn.devezhao.persist4j.engine.ID;
import com.alibaba.fastjson.JSON;
@ -20,6 +19,7 @@ import com.rebuild.core.metadata.EntityHelper;
import com.rebuild.core.metadata.MetadataHelper;
import com.rebuild.core.service.feeds.FeedsType;
import com.rebuild.core.service.query.ParseHelper;
import com.rebuild.core.service.query.QueryHelper;
import com.rebuild.core.support.general.FieldValueHelper;
import com.rebuild.core.support.i18n.I18nUtils;
import com.rebuild.utils.JSONUtils;
@ -63,9 +63,7 @@ public class RelatedListController extends BaseController {
Entity relatedEntity = MetadataHelper.getEntity(related.split("\\.")[0]);
Query query = MetadataHelper.hasPrivilegesField(relatedEntity)
? Application.createQuery(sql) : Application.createQueryNoFilter(sql);
Object[][] array = query.setLimit(ps, pn * ps - ps).array();
Object[][] array = QueryHelper.createQuery(sql, relatedEntity).setLimit(ps, pn * ps - ps).array();
for (Object[] o : array) {
Object nameValue = o[1];
nameValue = FieldValueHelper.wrapFieldValue(nameValue, relatedEntity.getNameField(), true);
@ -94,8 +92,7 @@ public class RelatedListController extends BaseController {
// 任务是获取了全部的相关记录因此总数可能与实际显示的条目数量不一致
Entity relatedEntity = MetadataHelper.getEntity(related.split("\\.")[0]);
Object[] count = MetadataHelper.hasPrivilegesField(relatedEntity)
? Application.createQuery(sql).unique() : Application.createQueryNoFilter(sql).unique();
Object[] count = QueryHelper.createQuery(sql, relatedEntity).unique();
countMap.put(related, ObjectUtils.toInt(count[0]));
}
}

View file

@ -3999,6 +3999,10 @@ h3.modal-title > .rbv {
cursor: default;
}
.CodeMirror-wrap pre {
word-break: break-all;
}
.mdedit-content p,
.mdedit-content ul,
.mdedit-content ol,

View file

@ -1497,7 +1497,7 @@ class RbFormClassification extends RbFormElement {
this.__select2.on('change', () => {
const v = this.__select2.val()
if (v) $.post(`/commons/search/recently-add?id=${v}&type=d${this.props.classification}`)
if (v) $.post(`/commons/search/recently-add?id=${v}&type=d${this.props.classification}:${this.props.openLevel}`)
this.handleChange({ target: { value: v } }, true)
})

View file

@ -113,7 +113,7 @@
privileges: [(${entityPrivileges})],
viewTabs: [(${ViewTabs})],
viewTabsAutoExpand: '[[${ViewTabsAutoExpand}]]',
viewTabsAutoHide: '[[${ViewTabsAutoExpand}]]',
viewTabsAutoHide: '[[${ViewTabsAutoHide}]]',
viewAdds: [(${ViewAdds})],
transformTos: [(${TransformTos})],
recordId: '[[${id}]]',