1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* @Description 多媒体影像存储
* @Author ZPFly
* @Date 2021/10/12
*/
import dbService from "@/services/db.service";
import { MediaFile } from "@/model/entity/MediaFile";
class MediaService {
static MEDIA_TYPE = { IMAGE: 1, AUDIO: 2, VIDEO: 3 };
table = dbService.store.multiMedia.name;
/**
* @Description 添加影像记录
* @Author ZPFly
* @Date 2021/10/13
*/
add(data: MediaFile) {
return dbService.insert(this.table, data).then((res) => {
console.log("新增影像记录--" + res);
});
}
/**
* @Description 批量添加影像记录
* @Author ZPFly
* @Date 2021/10/13
*/
batAdd(data: MediaFile) {
return dbService.insert(this.table, data).then((res) => {
// alert("新增影像记录--" + res);
});
}
/**
* @Description 批量更新记录
* @Author ZPFly
* @Date 2021/10/13
*/
update(data: any) {
let values: any = [];
if (data instanceof Array) {
values = data;
} else {
values.push(data);
}
dbService.update(this.table, values).then((res) => {
console.log("新增影像记录--" + res);
});
}
/**
* @Description 根据主键更新记录
* @Author ZPFly
* @Date 2021/10/12
*/
updateById(data: MediaFile) {
dbService.update(this.table, [data]).then((res) => {
console.log("更新字典--" + res);
});
}
/**
* @Description 根据objId获取文件记录
* @Author ZPFly
* @Date 2021/10/12
*/
selectByObjId(objId: string) {
return dbService.get(this.table, objId, "objId").then((res) => {
return res;
});
}
}
const mediaService = new MediaService();
export default mediaService;