Compare commits

...

5 Commits

Author SHA1 Message Date
peterlu14 451d246952 [update] init_setting 2022-04-15 17:47:39 +08:00
peterlu14 15d6c2cda6 [update] add meta getattrbyparent 2022-04-15 17:47:21 +08:00
peterlu14 5ad6683b81 [update] remove sd_card column 2021-10-19 10:45:30 +08:00
Jordan Hsu a646844b9a Merge branch 'master' into release/for_elite 2021-10-18 17:48:53 +08:00
Jordan Hsu 97993827b2 [update] api for checking if mini have data 2021-09-10 20:10:08 +08:00
9 changed files with 65 additions and 16 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ export const DB = {
export const pgDB = {
host: '127.0.0.1', // 服务器地址
port: 54321, // 数据库端口号
port: 5432, // 数据库端口号
username: 'biopro', // 数据库用户名
password: 'BioProControlBox', // 数据库密码
database: 'postgres' // 数据库名称
@@ -48,6 +48,16 @@ export const getByParent = async (ctx, next) => {
next()
}
export const getAttrByParent = async (ctx, next) => {
const type = ctx.params.type
const parent = ctx.params.parent
const attr = ctx.params.attr
const result = await recordingDataMeta.getByAttrParent(type, parent, attr)
ctx.body = result
next()
}
export const getCountByParent = async (ctx, next) => {
const type = ctx.params.type
const parent = ctx.params.parent
@@ -61,6 +61,15 @@ export const getByID = async (ctx, next) => {
next()
}
export const getExistOrNotByID = async (ctx, next) => {
const index = ctx.params.channel
const id = ctx.params.id
const result = await recordingDataMini.getExistOrNotByID(id, index)
ctx.body = result
next()
}
export const getByIDs = async (ctx, next) => {
const index = ctx.params.channel
const id = ctx.params.id
+6 -6
View File
@@ -34,12 +34,12 @@ for (let i = 0; i < 32; i++) {
for (let i = 0; i < 32; i++) {
db[i + '_recording_data_minis'] = require('./schema/recording_data_mini.model')(sequelize, Sequelize, i)
}
for (let i = 256; i < 288; i++) {
db[i + '_recording_data_raws'] = require('./schema/recording_data_raw.model')(sequelize, Sequelize, i)
}
for (let i = 256; i < 288; i++) {
db[i + '_recording_data_minis'] = require('./schema/recording_data_mini.model')(sequelize, Sequelize, i)
}
// for (let i = 256; i < 288; i++) {
// db[i + '_recording_data_raws'] = require('./schema/recording_data_raw.model')(sequelize, Sequelize, i)
// }
// for (let i = 256; i < 288; i++) {
// db[i + '_recording_data_minis'] = require('./schema/recording_data_mini.model')(sequelize, Sequelize, i)
// }
db.sequelize.sync()
@@ -43,10 +43,6 @@ module.exports = (sequelize, Sequelize, i) => {
type: Sequelize.TEXT,
defaultValue: ''
},
sd_data: {
type: Sequelize.TEXT,
defaultValue: ''
},
compressed: {
type: Sequelize.BOOLEAN,
defaultValue: false
+22 -1
View File
@@ -98,7 +98,28 @@ class RecordingDataMeta {
return ret
}
async getCountByParent (type, parent) {
async getByAttrParent(type, parent, attr) {
const attrList = attr.split('-')
const collectionType = type + '::jsonb'
const parentOp = {}
parentOp[collectionType] = {
[Op.contains]: '[' + parent + ']'
}
const ret = await db.recording_data_metas.findAll(
{
where: {
parent: parentOp
},
attributes: attrList,
order: [
['id', 'DESC']
],
}
)
return ret
}
async getCountByParent(type, parent) {
const collectionType = type + '::jsonb'
const parentOp = {}
parentOp[collectionType] = {
+13 -2
View File
@@ -31,11 +31,11 @@ class RecordingDataMini {
return ret
}
async clearDeleted (index) {
async clearDeleted (index, where = { deleted: true }) {
const ret = await db[index + '_recording_data_minis'].destroy(
{
where: {
deleted: true
...where
}
}
)
@@ -69,6 +69,17 @@ class RecordingDataMini {
return ret
}
async getExistOrNotByID (id, index) {
const ret = await db[index + '_recording_data_minis'].findOne(
{
where: {
id: id
}
}
).then(token => !(token.data_mean === ''))
return ret
}
async getByIDs (id, index) {
const _id = JSON.parse('[' + id + ']')
const ret = await db[index + '_recording_data_minis'].findAllWithStream(
+2 -2
View File
@@ -37,11 +37,11 @@ class RecordingDataRaw {
return ret
}
async clearDeleted (index) {
async clearDeleted (index, where = { deleted: true }) {
const ret = await db[index + '_recording_data_raws'].destroy(
{
where: {
deleted: true
...where
}
}
)
+2
View File
@@ -39,6 +39,7 @@ export default router
.get('/api/file/meta/get_by_id/:id', controllers.recordingDataMeta.getByID)
.get('/api/file/meta/get_by_path/:path', controllers.recordingDataMeta.getByPath)
.get('/api/file/meta/get_by_parent/:type/:parent', controllers.recordingDataMeta.getByParent)
.get('/api/file/meta/get_attr_by_parent/:type/:parent/:attr', controllers.recordingDataMeta.getAttrByParent)
.get('/api/file/meta/get_count_by_parent/:type/:parent', controllers.recordingDataMeta.getCountByParent)
.get('/api/file/meta/get_by_parent_with_limit/:type/:parent/:limit/:offset/:order', controllers.recordingDataMeta.getByParentWithLimit)
.get('/api/file/meta/get_by_attr_parent_with_limit/:type/:parent/:limit/:offset/:order/:attr', controllers.recordingDataMeta.getByAttrsParentWithLimit)
@@ -64,6 +65,7 @@ export default router
.post('/api/file/mini/update/:channel/:id', controllers.recordingDataMini.update)
.get('/api/file/mini/clear_deleted/:channel/:id', controllers.recordingDataMini.clearDeleted)
.get('/api/file/mini/get_by_id/:channel/:id', controllers.recordingDataMini.getByID)
.get('/api/file/mini/get_exist_or_not_by_id/:channel/:id', controllers.recordingDataMini.getExistOrNotByID)
.get('/api/file/mini/get_by_parent/:channel/:parent', controllers.recordingDataMini.getByParent)
.get('/api/file/mini/get_attr_by_id/:channel/:id/:attr', controllers.recordingDataMini.getAttrByID)
.get('/api/file/mini/get_attr_by_parent/:channel/:parent/:attr', controllers.recordingDataMini.getAttrByParent)