feat(admin): enrich admin panel fields; add user index constraint and customer service

- admin controller: add updatedAt to interview/resume selects; add orderCount,
  todayOrders, totalRevenue to overview
- admin.vue: enrich all tabs with more fields
  - overview: order cards (count, revenue)
  - users: wxOpenid, email, createdAt, interviewCount, vipExpireAt, role badge
  - interviews: user email, updatedAt, summary preview
  - orders: title, type, channel, paidAt, wxTransactionId, refund info
  - resumes: user email, updatedAt
  - share: sharer phone, shareCode, isActive, visitorId(IP), creditedAt
  - admins: email, createdAt
- user.schema: add unique indexes on phone/wxOpenid/email; pre-save hook
  requiring at least one contact method
- user/about: add WeChat contact button (open-type=contact) for customer service
This commit is contained in:
yuzhiran
2026-06-20 22:38:33 +08:00
parent 8ee27fdd32
commit ef4d22a633
5 changed files with 165 additions and 38 deletions
+11 -4
View File
@@ -5,10 +5,10 @@ export type UserDocument = User & Document
@Schema({ timestamps: true })
export class User {
@Prop({ sparse: true })
@Prop({ unique: true, sparse: true })
phone?: string
@Prop({ sparse: true })
@Prop({ unique: true, sparse: true })
wxOpenid?: string
@Prop({ default: '' })
@@ -60,11 +60,18 @@ export class User {
@Prop({ default: false })
isSystemAdmin: boolean
@Prop({ sparse: true })
@Prop({ unique: true, sparse: true })
email?: string
@Prop({ default: '', select: false })
password?: string
}
export const UserSchema = SchemaFactory.createForClass(User)
export const UserSchema = SchemaFactory.createForClass(User)
UserSchema.pre('save', function (next) {
if (!this.phone && !this.wxOpenid && !this.email) {
return next(new Error('用户必须至少有一个联系方式(手机号/微信/邮箱)'))
}
next()
})