@ -6481,14 +6481,24 @@ app.get('/api/online-stats', async (req, res) => {
} ) ;
}
} ) ;
// REST API接口 - 获取客服列表 - 修改为按照用户需求:工位名为采购员且有电话号码
// REST API接口 - 获取客服列表 - 支持按角色类型查询(销售员/采购员)
app . get ( '/api/managers' , async ( req , res ) => {
try {
// 查询userlogin数据库中的personnel表,获取工位为销售员且有电话号码的用户
// 获取请求参数中的角色类型(seller=销售员,buyer=采购员)
const { type } = req . query ;
console . log ( '获取客服列表请求,类型:' , type ) ;
// 根据角色类型确定查询的projectName值
let projectName = '销售员' ; // 默认查询销售员
if ( type === 'buyer' ) {
projectName = '采购员' ; // 如果类型为buyer,查询采购员
}
// 查询userlogin数据库中的personnel表,获取指定工位且有电话号码的用户
// 根据表结构选择所有需要的字段
const [ personnelData ] = await sequelize . query (
'SELECT id, managerId, managercompany, managerdepartment, organization, projectName, name, alias, phoneNumber, avatarUrl FROM userlogin.personnel WHERE projectName = ? AND phoneNumber IS NOT NULL AND phoneNumber != "" ORDER BY id ASC' ,
{ replacements : [ '销售员' ] }
{ replacements : [ projectName ] }
) ;
// 查询chat_online_status表获取客服在线状态(添加错误处理)