瀏覽代碼

初始

master
郑根木 2 年之前
父節點
當前提交
28d320da42
共有 3 個文件被更改,包括 10 次插入4 次删除
  1. +4
    -3
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractSaveHandler.java
  2. +5
    -0
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java
  3. +1
    -1
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/util/jackson/LongSerializer.java

+ 4
- 3
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractSaveHandler.java 查看文件

@@ -1,11 +1,8 @@
package cc.smtweb.framework.core.mvc.service;

import cc.smtweb.framework.core.R;
import cc.smtweb.framework.core.SwException;
import cc.smtweb.framework.core.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker;
import cc.smtweb.framework.core.session.UserSession;
import lombok.extern.slf4j.Slf4j;

/**
@@ -29,6 +26,9 @@ public abstract class AbstractSaveHandler<T> extends AbstractHandler {
bean = loadComp(id);
}
readFromPage();
if (isNew) {
setNewId();
}
checkValid();
DbEngine.getInstance().doTrans(new AbsDbWorker() {
@Override
@@ -57,6 +57,7 @@ public abstract class AbstractSaveHandler<T> extends AbstractHandler {
protected long readId() {
return params.readLong("id", 0L);
}
protected abstract void setNewId();

//从页面读取数据
protected abstract void readFromPage();


+ 5
- 0
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java 查看文件

@@ -47,6 +47,11 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan
}

@Override
protected void setNewId() {
bean.setEntityId(DbEngine.getInstance().nextId());
}

@Override
protected T loadComp(long id) {
return new DefaultProvider<T>(tableName).getBean(id);
}


+ 1
- 1
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/util/jackson/LongSerializer.java 查看文件

@@ -13,7 +13,7 @@ public class LongSerializer extends JsonSerializer<Long> {
if (value == null) {
gen.writeNull();
} else {
gen.writeString(value.toString());
gen.writeNumber(value);
}
}
}

Loading…
取消
儲存