/// modules/hospital/service.js /// 描述:医院资源的业务逻辑层(所有 SQL 集中在这里) const { getPool } = require('../../db'); /** * 列出所有医院 * @returns {Promise>} */ const listAll = async () => { const [rows] = await getPool().query('SELECT * FROM hospitals ORDER BY id'); return rows; }; /** * 按 ID 获取医院 * @param {string} id * @returns {Promise} */ const findById = async (id) => { const [rows] = await getPool().query('SELECT * FROM hospitals WHERE id = ?', [id]); return rows[0] || null; }; module.exports = { listAll, findById };