Server:优化批量新增、修改后返回的字段,保持和规范统一;删除 APIJSONBoot 和 APIJSONBootTest 中多余的 apijson-orm 依赖

This commit is contained in:
TommyLemon 2020-03-08 18:49:13 +08:00
parent 482d885508
commit 050ee4039a
6 changed files with 14 additions and 14 deletions

View File

@ -65,11 +65,6 @@
</dependency>
<!-- 没找到合适且稳定的 Oracle 的 JDBC Maven 依赖,已在 libs 目录放了对应的 jar 包来替代 -->
<dependency>
<groupId>com.github.APIJSON</groupId>
<artifactId>apijson-orm</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.github.APIJSON</groupId>
<artifactId>apijson-framework</artifactId>

View File

@ -30,6 +30,13 @@ import apijson.orm.AbstractSQLConfig;
*/
public class DemoSQLConfig extends APIJSONSQLConfig {
public DemoSQLConfig() {
super();
}
public DemoSQLConfig(RequestMethod method, String table) {
super(method, table);
}
static {
DEFAULT_DATABASE = DATABASE_MYSQL; //TODO 默认数据库类型改成你自己的
DEFAULT_SCHEMA = "sys"; //TODO 默认模式名改成你自己的默认情况是 MySQL: sys, PostgreSQL: public, SQL Server: dbo, Oracle:
@ -44,7 +51,7 @@ public class DemoSQLConfig extends APIJSONSQLConfig {
@Override
public AbstractSQLConfig getSQLConfig(RequestMethod method, String database, String schema, String table) {
return new APIJSONSQLConfig(method, table);
return new DemoSQLConfig(method, table);
}
//取消注释来实现自定义各个表的主键名
@ -68,6 +75,7 @@ public class DemoSQLConfig extends APIJSONSQLConfig {
};
}
@Override
public String getDBVersion() {
if (isMySQL()) {

View File

@ -55,11 +55,6 @@
</dependency>
<!-- 没找到合适且稳定的 Oracle 的 JDBC Maven 依赖,已在 libs 目录放了对应的 jar 包来替代 -->
<dependency>
<groupId>com.github.APIJSON</groupId>
<artifactId>apijson-orm</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.github.APIJSON</groupId>
<artifactId>apijson-framework</artifactId>

View File

@ -42,6 +42,7 @@ public class DemoApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(DemoApplication.class, args);
System.out.println("\n\n<<<<<<<<<<<<<<<<<<<<<<<<< APIJSON 启动完成,试试调用自动化 API 吧 ^_^ >>>>>>>>>>>>>>>>>>>>>>>>\n");
}
}

View File

@ -573,6 +573,7 @@ public abstract class AbstractObjectParser implements ObjectParser {
int version = parser.getVersion();
int maxUpdateCount = parser.getMaxUpdateCount();
String idKey = parser.createSQLConfig().getIdKey(); //Table[]: [{}] arrayConfig null
for (int i = 0; i < valueArray.size(); i++) { //只要有一条失败则抛出异常全部失败
//TODO 改成一条多 VALUES SQL 性能更高报错也更会更好处理更人性化
JSONObject item;
@ -596,12 +597,12 @@ public abstract class AbstractObjectParser implements ObjectParser {
}
allCount += count;
ids.add(result.get(JSONResponse.KEY_ID));
ids.add(result.get(idKey));
}
JSONObject allResult = AbstractParser.newSuccessResult();
allResult.put(JSONResponse.KEY_ID_IN, ids);
allResult.put(JSONResponse.KEY_COUNT, allCount);
allResult.put(idKey + "[]", ids);
response.put(key, allResult); //不按原样返回避免数据量过大
}

View File

@ -222,12 +222,12 @@ public abstract class AbstractSQLExecutor implements SQLExecutor {
, updateCount > 0 ? JSONResponse.MSG_SUCCEED : "没权限访问或对象不存在!");
//id,id{}至少一个会有一定会返回不用抛异常来阻止关联写操作时前面错误导致后面无条件执行
result.put(JSONResponse.KEY_COUNT, updateCount);//返回修改的记录数
if (config.getId() != null) {
result.put(config.getIdKey(), config.getId());
} else {
result.put(config.getIdKey() + "[]", config.getWhere(config.getIdKey() + "{}", true));
}
result.put(JSONResponse.KEY_COUNT, updateCount);//返回修改的记录数
return result;
case GET: