|
@@ -11,7 +11,7 @@ const ParamsDictService = {
|
|
if (isValue(paramsId)) {
|
|
if (isValue(paramsId)) {
|
|
where.push(`params_id = "${paramsId}"`)
|
|
where.push(`params_id = "${paramsId}"`)
|
|
} else {
|
|
} else {
|
|
- reject('参数ID不可为空')
|
|
|
|
|
|
+ return reject('参数ID不可为空')
|
|
}
|
|
}
|
|
if (isValue(name)) {
|
|
if (isValue(name)) {
|
|
where.push(`name LIKE "%${name}%"`)
|
|
where.push(`name LIKE "%${name}%"`)
|
|
@@ -25,10 +25,9 @@ const ParamsDictService = {
|
|
sql += ' ' + `ORDER BY sort DESC`
|
|
sql += ' ' + `ORDER BY sort DESC`
|
|
}
|
|
}
|
|
const result = await sqlHandle(sql)
|
|
const result = await sqlHandle(sql)
|
|
- resolve(result.map(v => new ParamsDictEntity(v)))
|
|
|
|
|
|
+ return resolve(result.map(v => new ParamsDictEntity(v)))
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- console.log(e)
|
|
|
|
- reject(e.sqlMessage)
|
|
|
|
|
|
+ return reject(e.sqlMessage)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -40,7 +39,7 @@ const ParamsDictService = {
|
|
if (isValue(paramsId)) {
|
|
if (isValue(paramsId)) {
|
|
where.push(`params_id = "${paramsId}"`)
|
|
where.push(`params_id = "${paramsId}"`)
|
|
} else {
|
|
} else {
|
|
- reject('参数ID不可为空')
|
|
|
|
|
|
+ return reject('参数ID不可为空')
|
|
}
|
|
}
|
|
if (isValue(name)) {
|
|
if (isValue(name)) {
|
|
where.push(`name LIKE "%${name}%"`)
|
|
where.push(`name LIKE "%${name}%"`)
|
|
@@ -54,9 +53,9 @@ const ParamsDictService = {
|
|
sql += ' ' + `ORDER BY sort DESC`
|
|
sql += ' ' + `ORDER BY sort DESC`
|
|
}
|
|
}
|
|
const result = await PageResult(sql, pageNum, pageSize, ParamsDictEntity)
|
|
const result = await PageResult(sql, pageNum, pageSize, ParamsDictEntity)
|
|
- resolve(result)
|
|
|
|
|
|
+ return resolve(result)
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- reject(e.sqlMessage)
|
|
|
|
|
|
+ return reject(e.sqlMessage)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -66,8 +65,7 @@ const ParamsDictService = {
|
|
let sql = 'SELECT * FROM ship_test_params_dict'
|
|
let sql = 'SELECT * FROM ship_test_params_dict'
|
|
let where = ['del_flag = 0']
|
|
let where = ['del_flag = 0']
|
|
if (!isValue(id)) {
|
|
if (!isValue(id)) {
|
|
- reject('id不可为空')
|
|
|
|
- return
|
|
|
|
|
|
+ return reject('id不可为空')
|
|
} else {
|
|
} else {
|
|
where.push(`id = ${id}`)
|
|
where.push(`id = ${id}`)
|
|
}
|
|
}
|
|
@@ -75,9 +73,9 @@ const ParamsDictService = {
|
|
sql += ' ' + `WHERE ${where.join(' AND ')}`
|
|
sql += ' ' + `WHERE ${where.join(' AND ')}`
|
|
}
|
|
}
|
|
const result = await sqlHandle(sql)
|
|
const result = await sqlHandle(sql)
|
|
- resolve(result.map(v => new ParamsDictEntity(v))?.[0])
|
|
|
|
|
|
+ return resolve(result.map(v => new ParamsDictEntity(v))?.[0])
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- reject(e.sqlMessage)
|
|
|
|
|
|
+ return reject(e.sqlMessage)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -93,9 +91,9 @@ const ParamsDictService = {
|
|
sql += ' ' + `WHERE ${where.join(' AND ')}`
|
|
sql += ' ' + `WHERE ${where.join(' AND ')}`
|
|
}
|
|
}
|
|
const result = await sqlHandle(sql)
|
|
const result = await sqlHandle(sql)
|
|
- resolve(result.map(v => new ParamsDictEntity(v)))
|
|
|
|
|
|
+ return resolve(result.map(v => new ParamsDictEntity(v)))
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- reject(e.sqlMessage)
|
|
|
|
|
|
+ return reject(e.sqlMessage)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -109,23 +107,23 @@ const ParamsDictService = {
|
|
['remark', paramsDictEntity.remark],
|
|
['remark', paramsDictEntity.remark],
|
|
['sort', paramsDictEntity.sort],
|
|
['sort', paramsDictEntity.sort],
|
|
['cql', paramsDictEntity.cql],
|
|
['cql', paramsDictEntity.cql],
|
|
|
|
+ ['active', paramsDictEntity.active],
|
|
]
|
|
]
|
|
const sql = `INSERT INTO ship_test_params_dict (${values.map(v => v[0]).join(',')}) VALUES (${values.map(v => '?').join(',')})`
|
|
const sql = `INSERT INTO ship_test_params_dict (${values.map(v => v[0]).join(',')}) VALUES (${values.map(v => '?').join(',')})`
|
|
if (!isValue(paramsDictEntity.paramsId)) {
|
|
if (!isValue(paramsDictEntity.paramsId)) {
|
|
- reject('参数ID不可为空')
|
|
|
|
|
|
+ return reject('参数ID不可为空')
|
|
}
|
|
}
|
|
if (!isValue(paramsDictEntity.cql)) {
|
|
if (!isValue(paramsDictEntity.cql)) {
|
|
- reject('cql不可为空')
|
|
|
|
|
|
+ return reject('cql不可为空')
|
|
}
|
|
}
|
|
const sameValid = await ParamsDictService.queryBy({name: paramsDictEntity.name})
|
|
const sameValid = await ParamsDictService.queryBy({name: paramsDictEntity.name})
|
|
if (sameValid.length > 0) {
|
|
if (sameValid.length > 0) {
|
|
- reject('已存在相同名称!')
|
|
|
|
- return
|
|
|
|
|
|
+ return reject('已存在相同名称!')
|
|
}
|
|
}
|
|
const result = await sqlHandle(sql, values.map(v => v[1]))
|
|
const result = await sqlHandle(sql, values.map(v => v[1]))
|
|
- resolve(result.insertId)
|
|
|
|
|
|
+ return resolve(result.insertId)
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- reject(e.sqlMessage)
|
|
|
|
|
|
+ return reject(e.sqlMessage)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -141,23 +139,21 @@ const ParamsDictService = {
|
|
]
|
|
]
|
|
let sql = `UPDATE ship_test_params_dict SET ${values.map(v => `${v[0]} = ?`).join(',')}`
|
|
let sql = `UPDATE ship_test_params_dict SET ${values.map(v => `${v[0]} = ?`).join(',')}`
|
|
if (!isValue(paramsDictEntity.id)) {
|
|
if (!isValue(paramsDictEntity.id)) {
|
|
- reject('id不可为空!')
|
|
|
|
- return
|
|
|
|
|
|
+ return reject('id不可为空!')
|
|
} else {
|
|
} else {
|
|
sql += ' ' + `WHERE id = "${paramsDictEntity.id}"`
|
|
sql += ' ' + `WHERE id = "${paramsDictEntity.id}"`
|
|
}
|
|
}
|
|
if (!isValue(paramsDictEntity.cql)) {
|
|
if (!isValue(paramsDictEntity.cql)) {
|
|
- reject('cql不可为空')
|
|
|
|
|
|
+ return reject('cql不可为空')
|
|
}
|
|
}
|
|
const sameValid = await ParamsDictService.queryBy({name: paramsDictEntity.name})
|
|
const sameValid = await ParamsDictService.queryBy({name: paramsDictEntity.name})
|
|
if (sameValid.filter(v => v.id !== paramsDictEntity.id).length > 0) {
|
|
if (sameValid.filter(v => v.id !== paramsDictEntity.id).length > 0) {
|
|
- reject('已存在相同名称!')
|
|
|
|
- return
|
|
|
|
|
|
+ return reject('已存在相同名称!')
|
|
}
|
|
}
|
|
const result = await sqlHandle(sql, values.map(v => v[1]))
|
|
const result = await sqlHandle(sql, values.map(v => v[1]))
|
|
- resolve(paramsDictEntity.id)
|
|
|
|
|
|
+ return resolve(paramsDictEntity.id)
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- reject(e.sqlMessage)
|
|
|
|
|
|
+ return reject(e.sqlMessage)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -166,15 +162,14 @@ const ParamsDictService = {
|
|
try {
|
|
try {
|
|
let sql = 'UPDATE ship_test_params_dict SET del_flag = "1"'
|
|
let sql = 'UPDATE ship_test_params_dict SET del_flag = "1"'
|
|
if (ids?.length === 0) {
|
|
if (ids?.length === 0) {
|
|
- reject('ids不可为空!')
|
|
|
|
- return
|
|
|
|
|
|
+ return reject('ids不可为空!')
|
|
} else {
|
|
} else {
|
|
sql += ' ' + 'WHERE id IN (?)'
|
|
sql += ' ' + 'WHERE id IN (?)'
|
|
}
|
|
}
|
|
const result = await sqlHandle(sql, [ids])
|
|
const result = await sqlHandle(sql, [ids])
|
|
- resolve('删除成功!')
|
|
|
|
|
|
+ return resolve('删除成功!')
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- reject(e.sqlMessage)
|
|
|
|
|
|
+ return reject(e.sqlMessage)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -183,15 +178,14 @@ const ParamsDictService = {
|
|
try {
|
|
try {
|
|
let sql = 'UPDATE ship_test_params_dict SET active = 0'
|
|
let sql = 'UPDATE ship_test_params_dict SET active = 0'
|
|
if (ids?.length === 0) {
|
|
if (ids?.length === 0) {
|
|
- reject('ids不可为空!')
|
|
|
|
- return
|
|
|
|
|
|
+ return reject('ids不可为空!')
|
|
} else {
|
|
} else {
|
|
sql += ' ' + 'WHERE id IN (?)'
|
|
sql += ' ' + 'WHERE id IN (?)'
|
|
}
|
|
}
|
|
const result = await sqlHandle(sql, [ids])
|
|
const result = await sqlHandle(sql, [ids])
|
|
- resolve('启用成功!')
|
|
|
|
|
|
+ return resolve('启用成功!')
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- reject(e.sqlMessage)
|
|
|
|
|
|
+ return reject(e.sqlMessage)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -200,15 +194,14 @@ const ParamsDictService = {
|
|
try {
|
|
try {
|
|
let sql = 'UPDATE ship_test_params_dict SET active = 1'
|
|
let sql = 'UPDATE ship_test_params_dict SET active = 1'
|
|
if (ids?.length === 0) {
|
|
if (ids?.length === 0) {
|
|
- reject('ids不可为空!')
|
|
|
|
- return
|
|
|
|
|
|
+ return reject('ids不可为空!')
|
|
} else {
|
|
} else {
|
|
sql += ' ' + 'WHERE id IN (?)'
|
|
sql += ' ' + 'WHERE id IN (?)'
|
|
}
|
|
}
|
|
const result = await sqlHandle(sql, [ids])
|
|
const result = await sqlHandle(sql, [ids])
|
|
- resolve('禁用成功!')
|
|
|
|
|
|
+ return resolve('禁用成功!')
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- reject(e.sqlMessage)
|
|
|
|
|
|
+ return reject(e.sqlMessage)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|