Commit 1abacafd by wkliang

fix

parent 2aa7e3a4
const ServiceBase = require("../../sve.base");
const system = require('../../../system')
const system = require('../../../system');
const { where } = require("sequelize/lib/sequelize");
class ProductService extends ServiceBase {
constructor() {
super("product", ServiceBase.getDaoName(ProductService));
......@@ -30,6 +31,13 @@ class ProductService extends ServiceBase {
})
result[i].setDataValue("ids", res)
delete result[i].dataValues.productitems
let resItem = await this.dao.model.findAll({
where: {
id: { [this.db.Op.in]: res }
},
attributes: ['id', 'product_name', 'price']
})
result[i].setDataValue('items', resItem)
}
return result
}
......@@ -50,7 +58,15 @@ class ProductService extends ServiceBase {
arr.push(i.product_id)
}
let result = await this.dao.getByIds(arr)
return result
let res = result.map((data) => {
return data.id
})
let ans = {}
ans.items = result
ans.ids = res
let pro = await this.dao.model.findOne({ where: { id: id } })
ans.pro = pro
return ans
}
async checkSitem (ids) {
......
......@@ -51,6 +51,35 @@ module.exports = function (app) {
params.push(req.body);
params.push(req.query);
params.push(req);
let keys = Object.keys(params[2].action_body)
for (let i of keys) {
// 小数处理分转元
let regdig = /^(-?\\d+)(\\.\\d+)?$/
// 整数处理
let regint = /^-?\\d+$/
// 空key处理
if (params[2].action_body[i] == null || params[2].action_body[i] == "" || params[2].action_body[i] == []) {
delete params[2].action_body[i]
} else if (Array.isArray(params[2].action_body[i])) {
// list
for (let j = 0; j < params[2].action_body[i]; ++j) {
if (regdig.test(params[2].action_body[i][j])) {
params[2].action_body[i][j] = Number(params[2].action_body[i][j])
params[2].action_body[i][j] = system.y2f(params[2].action_body[i][j])
} else if (regint.test(params[2].action_body[i][j])) {
params[2].action_body[i][j] = Number(params[2].action_body[i][j])
}
}
} else if (regdig.test(params[2].action_body[i])) {
// 小数
params[2].action_body[i] = Number(params[2].action_body[i])
params[2].action_body[i] = system.y2f(params[2].action_body[i])
} else if (regint.test(params[2].action_body[i])) {
// 整数
params[2].action_body[i] = Number(params[2].action_body[i])
}
}
var p = null;
var invokeObj = system.getObject("api." + classPath);
if (invokeObj["doexec"]) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment