|
@@ -2,7 +2,6 @@
|
|
|
import relationalStore from '@ohos.data.relationalStore';
|
|
import relationalStore from '@ohos.data.relationalStore';
|
|
|
import { StrUtil } from '@pura/harmony-utils';
|
|
import { StrUtil } from '@pura/harmony-utils';
|
|
|
import Logger from './Logger';
|
|
import Logger from './Logger';
|
|
|
-import MediaTable from './MediaTable';
|
|
|
|
|
import NetAxiosUtil from './NetAxiosUtil';
|
|
import NetAxiosUtil from './NetAxiosUtil';
|
|
|
|
|
|
|
|
//
|
|
//
|
|
@@ -93,7 +92,7 @@ export default class RdbUtils {
|
|
|
|
|
|
|
|
|
|
|
|
|
//检查是否存在相同id的记录,存在则不插入,进一步判断pixelMapPath字段,如果旧值为空而新值不为空,则更新该字段。
|
|
//检查是否存在相同id的记录,存在则不插入,进一步判断pixelMapPath字段,如果旧值为空而新值不为空,则更新该字段。
|
|
|
- async insertData(data: relationalStore.ValuesBucket, callback: Function = () => {}) {
|
|
|
|
|
|
|
+ async insertData(data: relationalStore.ValuesBucket, callback: Function = () => {},cover_api?:string) {
|
|
|
if (!callback || typeof callback !== 'function') {
|
|
if (!callback || typeof callback !== 'function') {
|
|
|
Logger.info(RdbUtils.RDB_TAG, 'insertData() has no valid callback!');
|
|
Logger.info(RdbUtils.RDB_TAG, 'insertData() has no valid callback!');
|
|
|
return;
|
|
return;
|
|
@@ -103,7 +102,7 @@ export default class RdbUtils {
|
|
|
const valueBucket: relationalStore.ValuesBucket = data;
|
|
const valueBucket: relationalStore.ValuesBucket = data;
|
|
|
const id = valueBucket.id;
|
|
const id = valueBucket.id;
|
|
|
let titleNameV = valueBucket.name;
|
|
let titleNameV = valueBucket.name;
|
|
|
- let artistV = valueBucket.artist;
|
|
|
|
|
|
|
+ let artistV = valueBucket.artist ;
|
|
|
let pixelMapPathV = valueBucket.pixelMapPath
|
|
let pixelMapPathV = valueBucket.pixelMapPath
|
|
|
|
|
|
|
|
if (this.rdbStore) {
|
|
if (this.rdbStore) {
|
|
@@ -126,8 +125,8 @@ export default class RdbUtils {
|
|
|
const existingPixelMapPath = resultSet.getString(resultSet.getColumnIndex('pixelMapPath'));
|
|
const existingPixelMapPath = resultSet.getString(resultSet.getColumnIndex('pixelMapPath'));
|
|
|
const name = resultSet.getString(resultSet.getColumnIndex('name'));
|
|
const name = resultSet.getString(resultSet.getColumnIndex('name'));
|
|
|
const artist = resultSet.getString(resultSet.getColumnIndex('artist'));
|
|
const artist = resultSet.getString(resultSet.getColumnIndex('artist'));
|
|
|
- if ((!existingPixelMapPath || existingPixelMapPath.trim() === '') ) {
|
|
|
|
|
- let newPixelMapPath = await NetAxiosUtil.getLyricCover(name,artist)
|
|
|
|
|
|
|
+ if ((!existingPixelMapPath || existingPixelMapPath.trim() === '')&& cover_api!==undefined) {
|
|
|
|
|
+ let newPixelMapPath = await NetAxiosUtil.getLyricCover(name,artist,cover_api)
|
|
|
console.info('onecold getLyricCover success. name= '+name);
|
|
console.info('onecold getLyricCover success. name= '+name);
|
|
|
console.info('onecold getLyricCover success. newPixelMapPath= '+newPixelMapPath);
|
|
console.info('onecold getLyricCover success. newPixelMapPath= '+newPixelMapPath);
|
|
|
if(StrUtil.isNotEmpty(newPixelMapPath)){
|
|
if(StrUtil.isNotEmpty(newPixelMapPath)){
|
|
@@ -158,12 +157,11 @@ export default class RdbUtils {
|
|
|
callback(false);
|
|
callback(false);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
//不存在相同记录 ,判断要不要去请求getLyricCover
|
|
//不存在相同记录 ,判断要不要去请求getLyricCover
|
|
|
- if(pixelMapPathV ===undefined){
|
|
|
|
|
- // if(titleNameV){
|
|
|
|
|
- valueBucket.pixelMapPath = await NetAxiosUtil.getLyricCover(titleNameV+'',artistV+'')
|
|
|
|
|
- console.info('onecold getLyricCover success. valueBucket.pixelMapPath= '+valueBucket.pixelMapPath);
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ if(pixelMapPathV==undefined||pixelMapPathV.toString()==='' ){
|
|
|
|
|
+ valueBucket.pixelMapPath = await NetAxiosUtil.getLyricCover(titleNameV+'',artistV+'',cover_api)
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
console.info('onecold getLyricCover pixelMapPathV1= '+pixelMapPathV);
|
|
console.info('onecold getLyricCover pixelMapPathV1= '+pixelMapPathV);
|
|
|
// Proceed with insert if record does not exist
|
|
// Proceed with insert if record does not exist
|