Skip to content

Commit

Permalink
feat: followingUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
getrebuild committed Nov 15, 2024
1 parent e291ada commit 110d25e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 98 deletions.
2 changes: 1 addition & 1 deletion @rbv
Submodule @rbv updated from e9b0df to 97e889
1 change: 0 additions & 1 deletion src/main/java/com/rebuild/core/metadata/EntityHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ public static boolean isUnsavedId(Object id) {
public static final int SmsendLog = 35;
public static final int Language = 36;
public static final int TransformConfig = 37;
public static final int TransformTrace = 96;
public static final int FrontjsCode = 38;
public static final int NreferenceItem = 39;
public static final int TagItem = 80;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.rebuild.core.metadata.MetadataHelper;
import com.rebuild.core.service.general.GeneralEntityService;
import com.rebuild.core.service.query.QueryHelper;
import com.rebuild.core.support.CommonsLog;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
Expand Down Expand Up @@ -61,7 +62,7 @@ public ID transform(ID sourceRecordId, ID specMainId, ID targetExistsRecordId) {
if (targetExistsRecordId != null) specMainId = forceGetSpecMainId(targetExistsRecordId);

ID theNewId = super.transform(sourceRecordId, specMainId);
TransfomerTrace.trace(sourceRecordId, theNewId, transid, getUser());
CommonsLog.createTransformLog(getUser(), sourceRecordId, theNewId, transid);
return theNewId;
}

Expand Down

This file was deleted.

34 changes: 26 additions & 8 deletions src/main/java/com/rebuild/core/support/CommonsLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import cn.devezhao.commons.CalendarUtils;
import cn.devezhao.persist4j.Record;
import cn.devezhao.persist4j.engine.ID;
import com.alibaba.fastjson.JSON;
import com.rebuild.core.Application;
import com.rebuild.core.metadata.EntityHelper;
import com.rebuild.core.support.task.TaskExecutors;
import com.rebuild.utils.CommonsUtils;
import com.rebuild.utils.JSONUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;

Expand All @@ -33,6 +35,7 @@ public class CommonsLog {
public static final String TYPE_EXPORT = "EXPORT";
public static final String TYPE_ACCESS = "ACCESS";
public static final String TYPE_EXTFORM = "EXTFORM";
public static final String TYPE_TRANSFORM = "TRANSFORM";

/**
* @param type
Expand Down Expand Up @@ -62,14 +65,29 @@ public static void createLog(String type, ID user, ID source, Throwable error) {
* @param status
*/
public static void createLog(String type, ID user, ID source, String content, int status) {
Record clog = EntityHelper.forNew(EntityHelper.CommonsLog, user);
clog.setString("type", type);
clog.setID("user", user);
clog.setID("source", ObjectUtils.defaultIfNull(source, user));
clog.setInt("status", status);
clog.setDate("logTime", CalendarUtils.now());
if (content != null) clog.setString("logContent", CommonsUtils.maxstr(content, 32767));
Record comLog = EntityHelper.forNew(EntityHelper.CommonsLog, user);
comLog.setString("type", type);
comLog.setID("user", user);
comLog.setID("source", ObjectUtils.defaultIfNull(source, user));
comLog.setInt("status", status);
comLog.setDate("logTime", CalendarUtils.now());
if (content != null) comLog.setString("logContent", CommonsUtils.maxstr(content, 32767));

TaskExecutors.queue(() -> Application.getCommonsService().create(clog, false));
TaskExecutors.queue(() -> Application.getCommonsService().create(comLog, false));
}

/**
* 记录转换日志
*
* @param user
* @param sourceId
* @param targetId
* @param transformId
*/
public static void createTransformLog(ID user, ID sourceId, ID targetId, ID transformId) {
JSON content = JSONUtils.toJSONObject(
new String[]{"transform", "source"},
new Object[]{transformId, sourceId});
createLog(TYPE_TRANSFORM, user, targetId, content.toJSONString(), STATUS_OK);
}
}
10 changes: 0 additions & 10 deletions src/main/resources/metadata-conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -416,16 +416,6 @@
<field name="isDisabled" type="bool" default-value="F" description="是否禁用"/>
</entity>

<entity name="TransformTrace" type-code="096" description="记录转换跟踪" queryable="false" parent="false">
<field name="traceId" type="primary"/>
<field name="transformConfigId" type="reference" ref-entity="TransformConfig" nullable="false" updatable="false" description="记录转换"/>
<field name="sourceRecordId" type="any-reference" nullable="false" updatable="false" description="源记录"/>
<field name="targetRecordId" type="any-reference" nullable="false" updatable="false" description="目标记录"/>
<field name="createdBy" type="reference" ref-entity="User" nullable="false" creatable="false" updatable="false" description="创建人"/>
<field name="createdOn" type="timestamp" nullable="false" creatable="false" updatable="false" description="创建时间"/>
<index field-list="sourceRecordId,targetRecordId,transformConfigId"/>
</entity>

<entity name="FrontjsCode" type-code="038" description="FrontJS 代码" queryable="false">
<field name="codeId" type="primary"/>
<field name="name" type="string" max-length="100" nullable="false" description="名称"/>
Expand Down
12 changes: 0 additions & 12 deletions src/main/resources/scripts/db-upgrade.sql
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
-- Database upgrade scripts for rebuild 1.x and 2.x
-- Each upgraded starts with `-- #VERSION`

-- #61 (v3.9)
-- ************ Entity [TransformTrace] DDL ************
create table if not exists `transform_trace` (
`TRACE_ID` char(20) not null,
`TRANSFORM_CONFIG_ID` char(20) not null comment '记录转换',
`SOURCE_RECORD_ID` char(20) not null comment '源记录',
`TARGET_RECORD_ID` char(20) not null comment '目标记录',
`CREATED_BY` char(20) not null comment '创建人',
`CREATED_ON` timestamp not null default current_timestamp comment '创建时间',
primary key (`TRACE_ID`)
)Engine=InnoDB;

-- #60 (v3.9)
alter table `user`
add column `SEQ` int(11) default '0' comment '排序 (小到大)';
Expand Down

0 comments on commit 110d25e

Please sign in to comment.