feat 添加mock数据
This commit is contained in:
@@ -1,16 +1,7 @@
|
||||
/**
|
||||
* RTK 轨迹数据表: 作业记录ID, 时间戳, , 压实度, 纬度, 经度, 高度, 速度, 方向, 创建时间, 外键约束
|
||||
* 字段说明:
|
||||
* - id:轨迹唯一标识符
|
||||
* - work_record_id:作业记录 ID
|
||||
* - timestamp:时间戳
|
||||
* - latitude:纬度
|
||||
* - longitude:经度
|
||||
* - altitude:高度
|
||||
* - speed:速度
|
||||
* - heading:方向
|
||||
* - created_at:记录创建时间(默认值为当前时间)
|
||||
*/
|
||||
import DB from '@/utils/sqlite'
|
||||
|
||||
const TABLE = 'rtk_track'
|
||||
|
||||
export const rtkTrackTableSql = `CREATE TABLE IF NOT EXISTS rtk_track (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
work_record_id INTEGER,
|
||||
@@ -23,3 +14,45 @@ export const rtkTrackTableSql = `CREATE TABLE IF NOT EXISTS rtk_track (
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (work_record_id) REFERENCES work_record(id)
|
||||
)`
|
||||
|
||||
export interface RtkTrack {
|
||||
id?: number
|
||||
work_record_id: number
|
||||
timestamp?: string
|
||||
latitude?: number
|
||||
longitude?: number
|
||||
altitude?: number
|
||||
speed?: number
|
||||
heading?: number
|
||||
created_at?: string
|
||||
}
|
||||
|
||||
/** 查询全部 */
|
||||
export async function selectAll(): Promise<RtkTrack[]> {
|
||||
return DB.select(TABLE)
|
||||
}
|
||||
|
||||
/** 按 ID 查询 */
|
||||
export async function selectById(id: number): Promise<RtkTrack | null> {
|
||||
return DB.selectById(TABLE, id)
|
||||
}
|
||||
|
||||
/** 按作业记录 ID 查询 */
|
||||
export async function selectByWorkRecordId(workRecordId: number): Promise<RtkTrack[]> {
|
||||
return DB.selectByField(TABLE, 'work_record_id', workRecordId)
|
||||
}
|
||||
|
||||
/** 新增 */
|
||||
export async function insert(data: RtkTrack): Promise<any> {
|
||||
return DB.insert(TABLE, data)
|
||||
}
|
||||
|
||||
/** 更新 */
|
||||
export async function update(id: number, data: Partial<RtkTrack>): Promise<any> {
|
||||
return DB.update(TABLE, data, `id = ${id}`)
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
export async function remove(id: number): Promise<any> {
|
||||
return DB.delete(TABLE, `id = ${id}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user