|
|
|
@ -2116,6 +2116,31 @@ Cover.init({ |
|
|
|
timestamps: false |
|
|
|
}); |
|
|
|
|
|
|
|
// goods_root模型 - 用于存储小品种和大贸易的创建者
|
|
|
|
class GoodsRoot extends Model { } |
|
|
|
GoodsRoot.init({ |
|
|
|
id: { |
|
|
|
type: DataTypes.INTEGER, |
|
|
|
primaryKey: true, |
|
|
|
autoIncrement: true |
|
|
|
}, |
|
|
|
name: { |
|
|
|
type: DataTypes.STRING(100), |
|
|
|
allowNull: false, |
|
|
|
comment: '创建者姓名' |
|
|
|
}, |
|
|
|
root: { |
|
|
|
type: DataTypes.STRING(50), |
|
|
|
allowNull: false, |
|
|
|
comment: '分类:小品种或大贸易' |
|
|
|
} |
|
|
|
}, { |
|
|
|
sequelize, |
|
|
|
modelName: 'GoodsRoot', |
|
|
|
tableName: 'goods_root', |
|
|
|
timestamps: false |
|
|
|
}); |
|
|
|
|
|
|
|
// 简道云销售订单主表模型(新添加)
|
|
|
|
class JdSalesMain extends Model { } |
|
|
|
JdSalesMain.init({ |
|
|
|
@ -3156,6 +3181,43 @@ app.post('/api/user/get', async (req, res) => { |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 获取goods_root数据
|
|
|
|
app.post('/api/goods/root', async (req, res) => { |
|
|
|
try { |
|
|
|
console.log('===== 获取goods_root数据请求 ====='); |
|
|
|
console.log('1. 收到请求体:', JSON.stringify(req.body, null, 2)); |
|
|
|
|
|
|
|
// 从数据库获取goods_root表中的所有数据
|
|
|
|
const roots = await GoodsRoot.findAll(); |
|
|
|
console.log('2. 数据库查询结果数量:', roots.length); |
|
|
|
console.log('3. 数据库查询结果:', roots); |
|
|
|
|
|
|
|
// 格式化响应数据
|
|
|
|
const formattedRoots = roots.map(root => ({ |
|
|
|
id: root.id, |
|
|
|
name: root.name, |
|
|
|
root: root.root |
|
|
|
})); |
|
|
|
|
|
|
|
console.log('4. 格式化后的结果:', formattedRoots); |
|
|
|
|
|
|
|
res.json({ |
|
|
|
success: true, |
|
|
|
code: 200, |
|
|
|
message: '获取goods_root数据成功', |
|
|
|
roots: formattedRoots |
|
|
|
}); |
|
|
|
} catch (error) { |
|
|
|
console.error('获取goods_root数据失败:', error); |
|
|
|
res.status(500).json({ |
|
|
|
success: false, |
|
|
|
code: 500, |
|
|
|
message: '获取goods_root数据失败', |
|
|
|
error: error.message |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 添加用户踪迹记录
|
|
|
|
app.post('/api/user-trace/add', async (req, res) => { |
|
|
|
try { |
|
|
|
|