Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jump_hm_warehouse
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
毛勇泽
jump_hm_warehouse
Commits
3995052f
Commit
3995052f
authored
Jan 18, 2024
by
毛勇泽
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
78aa52b4
c1174f1a
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
29 行增加
和
3 行删除
+29
-3
BaseTable.ets
common/src/main/ets/db/BaseTable.ets
+29
-1
DwInfoDao.ets
common/src/main/ets/db/dao/DwInfoDao.ets
+0
-2
没有找到文件。
common/src/main/ets/db/BaseTable.ets
View file @
3995052f
...
@@ -57,12 +57,19 @@ export default abstract class BaseTable<T> implements ITable {
...
@@ -57,12 +57,19 @@ export default abstract class BaseTable<T> implements ITable {
}
}
bindToValuesBucket(bucket: ValuesBucket, item: T) {
bindToValuesBucket(bucket: ValuesBucket, item: T) {
Logger.info(this, "表结构数据>>" + JSON.stringify(this.getTableColumns()))
this.getTableColumns().forEach((col) => {
this.getTableColumns().forEach((col) => {
bucket[col] = item[col]
bucket[col] = item[col]
})
})
}
}
toBucket(bucket: ValuesBucket, item: T): ValuesBucket {
this.getTableColumns().forEach((col) => {
bucket[col] = item[col]
})
return bucket;
}
/**
/**
* 清空表
* 清空表
*/
*/
...
@@ -92,6 +99,27 @@ export default abstract class BaseTable<T> implements ITable {
...
@@ -92,6 +99,27 @@ export default abstract class BaseTable<T> implements ITable {
}
}
/**
/**
* 插入数据
* @param item 插入对象
*/
async batchInsert(item: T[]): Promise<number> {
Logger.info(this, '批量插入数据>>' + JSON.stringify(item))
let bucket = [];
if (item) {
item.forEach(it => {
let tmp = {};
bucket.push(this.toBucket(tmp, it));
})
Logger.info(this, '绑定到Bucket数据>>' + JSON.stringify(bucket))
let db = await this.futureDb;
return db.batchInsert(this.tableName, bucket);
} else {
throw new Error('插入数据为空');
}
}
/**
* 删除数据
* 删除数据
*/
*/
async delete(item: T): Promise<number> {
async delete(item: T): Promise<number> {
...
...
common/src/main/ets/db/dao/DwInfoDao.ets
View file @
3995052f
import relationalStore from '@ohos.data.relationalStore';
import relationalStore from '@ohos.data.relationalStore';
import { DwInfo } from '../../entity/DwInfo';
import { DwInfo } from '../../entity/DwInfo';
import { Logger } from '../../utils/Logger';
import BaseTable, { ValueType } from '../BaseTable';
import BaseTable, { ValueType } from '../BaseTable';
import { Table } from '../decorator/Decorators';
import { Table } from '../decorator/Decorators';
import { BaseSql } from '../sql/BaseSql';
/**
/**
* 单位的数据层
* 单位的数据层
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论