27 lines
846 B
JavaScript
27 lines
846 B
JavaScript
const mongoose = require('mongoose');
|
|
|
|
const storeSchema = new mongoose.Schema({
|
|
storeId: { type: String, required: true, unique: true },
|
|
name: { type: String, required: true },
|
|
address: { type: String },
|
|
phone: { type: String },
|
|
manager: { type: String },
|
|
status: { type: String, enum: ['营业中', '已停业', '装修中'], default: '营业中' },
|
|
approvalStatus: { type: String, enum: ['待审批', '已通过', '已拒绝'], default: '待审批' },
|
|
rejectReason: { type: String },
|
|
images: [{
|
|
type: { type: String }, // 门店照片/营业执照/身份证
|
|
url: { type: String }
|
|
}],
|
|
createdAt: { type: Date, default: Date.now }
|
|
});
|
|
|
|
storeSchema.pre('save', function(next) {
|
|
if (!this.storeId) {
|
|
this.storeId = `STORE${Date.now()}`;
|
|
}
|
|
next();
|
|
});
|
|
|
|
module.exports = mongoose.model('Store', storeSchema);
|