feat(M08-D): 补门店与房间管理

This commit is contained in:
Codex
2026-08-10 11:40:09 +08:00
parent 04afce4417
commit 1ca783e91b
9 changed files with 1017 additions and 14 deletions
+22 -2
View File
@@ -18,11 +18,18 @@ const storeActor = {
};
const repository = new StoreRoomRepository({
async execute(sql) {
if (sql.includes('FROM qipai_stores')) return [[{ id: 11, name: 'A', longitude: null, latitude: null }], []];
if (sql.includes('FROM qipai_stores')) return [[{
id: 11, name: 'A', longitude: null, latitude: null, wifiConfigured: 1
}], []];
if (sql.includes('FROM qipai_store_business_hours')) return [[{
storeId: 11, weekday: 1, openMinute: 540, closeMinute: 1320, isClosed: 0
}], []];
return [[], []];
}
});
assert.equal((await repository.listStores(storeActor))[0].id, '11');
assert.equal((await repository.listStores(storeActor))[0].wifiConfigured, true);
assert.equal((await repository.listStores(storeActor))[0].businessHours[0].openMinute, 540);
assert.deepEqual(await repository.listRooms({
...storeActor,
access: { roles: ['STAFF'], capabilities: ['store.operation.read'], storeIds: ['11'] }
@@ -39,6 +46,7 @@ const token = signAccessToken({
}, secret, 900);
let roomInput;
let roomStatusInput;
let storeInput;
let currentAccess = tenantActor.access;
const app = await buildApp({
storeRoom: {
@@ -59,7 +67,7 @@ const app = await buildApp({
repository: {
async listStores() { return []; },
async createStore() { return { storeId: '11' }; },
async updateStore() { return { storeId: '11' }; },
async updateStore(_actor, _storeId, input) { storeInput = input; return { storeId: '11' }; },
async archiveStore() { return { storeId: '11', archived: true }; },
async listRooms() { return []; },
async createRoom(_actor, input) { roomInput = input; return { roomId: '31' }; },
@@ -97,6 +105,18 @@ const managementStores = await app.inject({
headers: { authorization: `Bearer ${token}` }
});
assert.equal(managementStores.statusCode, 200);
const updatedStore = await app.inject({
method: 'PUT', url: '/admin-api/stores/11',
headers: { authorization: `Bearer ${token}` },
payload: {
name: 'A 店', address: '测试路 1 号', city: '上海', district: '浦东新区',
contactPhone: '13800000000', timezone: 'Asia/Shanghai', businessStatus: 'OPEN',
wifiSsid: 'qipai-guest', notificationUrl: '', sortOrder: 1,
businessHours: [{ weekday: 1, openMinute: 540, closeMinute: 1320, isClosed: false }]
}
});
assert.equal(updatedStore.statusCode, 200);
assert.equal(storeInput.wifiPassword, undefined);
const statusUpdated = await app.inject({
method: 'PATCH', url: '/app-api/management/rooms/31/status',
headers: { authorization: `Bearer ${token}` },