Merge remote-tracking branch 'origin/master'
# Conflicts: # features/register/src/main/ets/view/LoginComp.ets
This commit is contained in:
@@ -7,7 +7,7 @@ export class BasicConstant {
|
||||
|
||||
//测试环境
|
||||
static readonly urlExpertAPI = "https://dev-app.igandan.com/app/expertAPI/";
|
||||
static readonly urlExpertApp = "https://dev-app.igandan.com//app/expertApp/"
|
||||
static readonly urlExpertApp = "https://dev-app.igandan.com/app/expertApp/"
|
||||
static readonly urlHtml = "http://dev-doc.igandan.com/app/"
|
||||
static readonly urlImage = "https://dev-doc.igandan.com/app/"
|
||||
static readonly urlExpert = "https://dev-app.igandan.com/app/expert/"
|
||||
@@ -29,6 +29,9 @@ export class BasicConstant {
|
||||
static readonly zhibourl = BasicConstant.wxUrl+"hcp/setInfo";
|
||||
static readonly videoByTypeNew = BasicConstant.urlExpertApp + 'videoByTypeNew'
|
||||
static readonly videoDetail = BasicConstant.urlExpertAPI + "videoDetail";
|
||||
static readonly videoCommentListV2 = BasicConstant.urlExpertAPI + "videoCommentListV2";//视频详情评价列表
|
||||
static readonly addCommentV2 = BasicConstant.urlExpertAPI+'addCommentV2';//评论回复
|
||||
static readonly deleteComment = BasicConstant.urlExpertApp+'deleteComment';//删除评论
|
||||
static readonly meetingHistoryList = BasicConstant.urlExpertAPI + "meetingHistoryList";
|
||||
static readonly videoRoll = BasicConstant.urlExpertAPI + "videoRoll";
|
||||
static readonly expertVideoTypeList = BasicConstant.urlExpertAPI + "expertVideoTypeList";
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import { Entity, Columns, Id, ColumnType } from '@ohos/dataorm';
|
||||
|
||||
// 表名需与sqlite一致
|
||||
@Entity('t_huanzhelast444')
|
||||
export class Huanzhelast444Model {
|
||||
@Id()
|
||||
@Columns({ columnName: '_id', types: ColumnType.num }) // 主键字段映射
|
||||
_id: number = 0;
|
||||
|
||||
@Columns({ columnName: 'id', types: ColumnType.num })
|
||||
id: number = 0;
|
||||
|
||||
@Columns({ columnName: 'fullname', types: ColumnType.str })
|
||||
fullname: string = '';
|
||||
|
||||
@Columns({ columnName: 'name', types: ColumnType.str })
|
||||
name: string = '';
|
||||
|
||||
@Columns({ columnName: 'parent', types: ColumnType.num })
|
||||
parent: number = 0;
|
||||
|
||||
@Columns({ columnName: 'treePath', types: ColumnType.str })
|
||||
treePath: string = '';
|
||||
|
||||
// 必须包含所有非静态变量的构造函数
|
||||
constructor(
|
||||
_id: number = 0,
|
||||
id: number = 0,
|
||||
fullname: string = '',
|
||||
name: string = '',
|
||||
parent: number = 0,
|
||||
treePath: string = ''
|
||||
) {
|
||||
this._id = _id;
|
||||
this.id = id;
|
||||
this.fullname = fullname;
|
||||
this.name = name;
|
||||
this.parent = parent;
|
||||
this.treePath = treePath;
|
||||
}
|
||||
|
||||
setTreePath(treePath:string) {
|
||||
this.treePath = treePath;
|
||||
}
|
||||
|
||||
getTreePath():string {
|
||||
return this.treePath;
|
||||
}
|
||||
|
||||
setParent(parent:number) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
getParent():number {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
setName(name:string) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
getName():string {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
setFullname(fullname:string) {
|
||||
this.fullname = fullname;
|
||||
}
|
||||
|
||||
getFullname():string {
|
||||
return this.fullname;
|
||||
}
|
||||
|
||||
getId():number {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
setId(id:number) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
import fs from '@ohos.file.fs';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import relationalStore from '@ohos.data.relationalStore';
|
||||
import util from '@ohos.util';
|
||||
import { Huanzhelast444Model } from '../models/Huanzhelast444Model'
|
||||
|
||||
const huanzhelastFile: string = 'huanzhelas.sqlite';
|
||||
|
||||
// 步骤1:将rawfile数据库文件复制到应用沙箱
|
||||
async function copyDatabase(context: common.Context): Promise<void> {
|
||||
try {
|
||||
const resourceMgr = context.resourceManager;
|
||||
const rawFile = await resourceMgr.getRawFileContent(huanzhelastFile);
|
||||
|
||||
// 将Uint8Array转为ArrayBuffer
|
||||
const arrayBuffer = rawFile.buffer;
|
||||
|
||||
// 创建沙箱路径
|
||||
const dbPath = context.filesDir + '/' + huanzhelastFile;
|
||||
console.info(`[DB] context.filesDir: ${context.filesDir}`);
|
||||
console.info(`[DB] dbPath: ${dbPath}`);
|
||||
// 确保目录存在
|
||||
try {
|
||||
fs.accessSync(context.filesDir);
|
||||
} catch (e) {
|
||||
fs.mkdirSync(context.filesDir);
|
||||
}
|
||||
|
||||
// 写入文件
|
||||
const file = fs.openSync(dbPath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
|
||||
fs.writeSync(file.fd, arrayBuffer);
|
||||
fs.closeSync(file);
|
||||
|
||||
// 检查文件是否存在
|
||||
try {
|
||||
fs.accessSync(dbPath);
|
||||
console.info(`[DB] DB file exists after copy: ${dbPath}`);
|
||||
} catch (e) {
|
||||
console.error(`[DB] DB file does not exist after copy: ${dbPath}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Copy database failed: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 步骤2:数据库操作封装类
|
||||
class HuanzhelasDbHelper {
|
||||
private rdbStore: relationalStore.RdbStore | null = null;
|
||||
|
||||
// 初始化数据库连接
|
||||
async initDatabase(context: common.Context): Promise<void> {
|
||||
await copyDatabase(context);
|
||||
const storeConfig: relationalStore.StoreConfig = {
|
||||
name: huanzhelastFile,
|
||||
securityLevel: relationalStore.SecurityLevel.S1
|
||||
};
|
||||
|
||||
try {
|
||||
this.rdbStore = await relationalStore.getRdbStore(context, storeConfig);
|
||||
console.info('Database connection established');
|
||||
} catch (error) {
|
||||
console.error(`Init database failed: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
async queryHuanzhelastData():Promise<Array<HuanzhelastEntity>> {
|
||||
if (!this.rdbStore) {
|
||||
console.error('Database not initialized');
|
||||
throw new Error('Database not initialized');
|
||||
}
|
||||
// const resultSet = await this.rdbStore.querySql('SELECT * FROM t_huanzhelast444', []);
|
||||
// if (resultSet.rowCount > 0) {
|
||||
// resultSet.goToFirstRow();
|
||||
// do {
|
||||
// console.info('[DB] Table:', resultSet.getString(0));
|
||||
// } while (resultSet.goToNextRow());
|
||||
// }
|
||||
// resultSet.close();
|
||||
// try {
|
||||
// const predicates = new relationalStore.RdbPredicates('t_huanzhelast444');
|
||||
// console.info('[DB] Querying table: t_huanzhelast444');
|
||||
// const resultSet = await this.rdbStore.query(predicates);
|
||||
//
|
||||
// if (resultSet.isClosed) {
|
||||
// console.error('[DB] ResultSet is closed immediately after query!');
|
||||
// return;
|
||||
// }
|
||||
// console.info('[DB] ResultSet columnNames:', resultSet.columnNames);
|
||||
// console.info('[DB] Query finished, rowCount:', resultSet.rowCount);
|
||||
//
|
||||
// if (resultSet.rowCount > 0) {
|
||||
// resultSet.goToFirstRow();
|
||||
// do {
|
||||
// // // 打印每一行
|
||||
// // let row: Required = {};
|
||||
// // for (let i = 0; i < resultSet.columnNames.length; i++) {
|
||||
// // row[resultSet.columnNames[i]] = resultSet.getString(i);
|
||||
// // }
|
||||
// // console.info('[DB] Row:', JSON.stringify(row));
|
||||
// console.info('[DB] Row:');
|
||||
// } while (resultSet.goToNextRow());
|
||||
// } else {
|
||||
// console.warn('[DB] No data found, please check table name and data!');
|
||||
// }
|
||||
// resultSet.close();
|
||||
// } catch (e) {
|
||||
// console.error('[DB] Query error:', e);
|
||||
// throw new Error('Database query error');
|
||||
// }
|
||||
try {///data/app/el2/100/base/com.example.expert/haps/default/files/databases/huanzhelas.sqlite
|
||||
const predicates = new relationalStore.RdbPredicates('cn_shangyu_gdxzExpert_bean_City');
|
||||
const resultSet = await this.rdbStore.query(predicates);
|
||||
|
||||
const dataList: Array<HuanzhelastEntity> = [];
|
||||
if (resultSet.rowCount > 0) {
|
||||
resultSet.goToFirstRow();
|
||||
do {
|
||||
dataList.push(this.parseResultSet(resultSet));
|
||||
} while (resultSet.goToNextRow());
|
||||
} else {
|
||||
console.error(`Query failed: ${predicates}`);
|
||||
}
|
||||
resultSet.close();
|
||||
return dataList;
|
||||
} catch (error) {
|
||||
console.error(`Query failed: ${error}`);
|
||||
throw new Error('Database query error');
|
||||
}
|
||||
}
|
||||
|
||||
private parseResultSet(resultSet: relationalStore.ResultSet): HuanzhelastEntity {
|
||||
return {
|
||||
_id: resultSet.getDouble(resultSet.getColumnIndex('_id')),
|
||||
id: resultSet.getDouble(resultSet.getColumnIndex('id')),
|
||||
fullname: resultSet.getString(resultSet.getColumnIndex('fullname')),
|
||||
name: resultSet.getString(resultSet.getColumnIndex('name')),
|
||||
parent: resultSet.getDouble(resultSet.getColumnIndex('parent')),
|
||||
treePath: resultSet.getString(resultSet.getColumnIndex('treePath'))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// 实体类型定义
|
||||
interface HuanzhelastEntity {
|
||||
_id: number;
|
||||
id: number;
|
||||
fullname: string;
|
||||
name: string;
|
||||
parent: number;
|
||||
treePath: string;
|
||||
}
|
||||
|
||||
export const huanzheDb = new HuanzhelasDbHelper()
|
||||
@@ -151,7 +151,7 @@ class HdHttp {
|
||||
logger.info('Response httpReq:' + data.result);
|
||||
let json:TimestampBean = JSON.parse(data.result.toString()) as TimestampBean;
|
||||
let tp = json.timestamp;
|
||||
datas.set("user_uuid", authStore.getUser().uuid?authStore.getUser().uuid:'5kO57cuAL8seXQpxgtc');
|
||||
datas.set("user_uuid", authStore.getUser().uuid?authStore.getUser().uuid:'');
|
||||
datas.set("client_type", 'A');
|
||||
datas.set("version",'4.0.0' );
|
||||
datas.set('timestamp',tp+'');
|
||||
|
||||
Reference in New Issue
Block a user