DoraCMS/app/model/adminUser.js
2021-09-25 22:06:30 +08:00

67 lines
1.3 KiB
JavaScript
Executable File
Raw Permalink 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.

/**
* Created by Administrator on 2015/4/15.
* 管理员对象
*/
'use strict';
module.exports = (app) => {
const mongoose = app.mongoose;
const shortid = require('shortid');
const Schema = mongoose.Schema;
const CryptoJS = require('crypto-js');
require('./adminGroup');
const AdminUserSchema = new Schema({
id: String,
_id: {
type: String,
default: shortid.generate,
},
name: String,
userName: String,
password: {
type: String,
set(val) {
return CryptoJS.AES.encrypt(val, app.config.encrypt_key).toString();
},
},
email: String,
phoneNum: String,
countryCode: {
type: String,
}, // 手机号前国家代码
comments: String,
date: {
type: Date,
default: Date.now,
},
logo: {
type: String,
default: '/static/upload/images/defaultlogo.png',
},
enable: {
type: Boolean,
default: false,
},
state: {
type: String,
default: '1', // 1正常0删除
},
auth: {
type: Boolean,
default: false,
},
group: {
type: String,
ref: 'AdminGroup',
},
targetEditor: {
type: String,
ref: 'User',
},
});
return mongoose.model('AdminUser', AdminUserSchema, 'adminusers');
};