Browse Source

初始

master
郑根木 2 years ago
parent
commit
28d320da42
3 changed files with 10 additions and 4 deletions
  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 View File

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


import cc.smtweb.framework.core.R; 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.DbEngine;
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; import cc.smtweb.framework.core.db.jdbc.AbsDbWorker;
import cc.smtweb.framework.core.session.UserSession;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;


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


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


+ 5
- 0
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java View File

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


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

@Override
protected T loadComp(long id) { protected T loadComp(long id) {
return new DefaultProvider<T>(tableName).getBean(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 View File

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

Loading…
Cancel
Save