2026-07-25 01:24:08 +08:00

26 lines
878 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const BaseService = require('./base');
class TestService extends BaseService {
async index(data) {
return this.successResponse('test.index', data, 'Test service index 方法调用成功');
}
async logToRedis(data) {
const {key, message} = data;
const { app } = this;
console.log(`准备写入 Redis,键: ${key}, 消息: ${message},redis对象:`, app.redis);
try {
await app.redis.set(key, message);
console.log(`日志已写入 Redis,键: ${key}, 消息: ${message}`);
return this.successResponse('logToRedis', { key, message }, '日志写入成功');
} catch (error) {
console.error('写入 Redis 时发生错误:', error);
return this.errorResponse('logToRedis', '日志写入失败');
}
}
async ping(){
return this.successResponse('test.ping', 'pong', 'pong');
}
}
module.exports = TestService;