1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
   | var moment = require('moment'); module.exports = function (sequelize, DataTypes) {   var partner = sequelize.define('partner', {     id: {       type: DataTypes.INTEGER,       primaryKey: true,       autoIncrement: true,       comment: '合作伙伴ID',       allowNull: false     },     name: {       type: DataTypes.STRING(32),       allowNull: false,       comment: '合作伙伴名称,可以是个人也可以使组织机构',       description: '合作伙伴名称,可以是个人也可以使组织机构'     },     concat: {       type: DataTypes.STRING(16),       allowNull: false,       comment: '联系人姓名',       description: '联系人姓名'
      },     cellphone: {       type: DataTypes.STRING(11),       allowNull: false,       comment: '联系人手机号码',       description: '联系人手机号码'     },     email: {       type: DataTypes.STRING(64),       allowNull: true,       comment: '联系人电子邮件地址',       description: '联系人电子邮件地址'     },     status: {       type: DataTypes.STRING(16),       allowNull: false,       defaultValue: 'PENDING',        comment: '合作伙伴状态,PENDING:等待审核,APPROVED:已经核准,REJECTED:已拒绝',       description: '合作伙伴状态,PENDING:等待审核,APPROVED:已经核准,REJECTED:已拒绝'     }   }, {     comment: '合作伙伴信息表',     classMethods: {       associate: function (models) {         partner.hasMany(models.map);       }     },     getterMethods: {       created_at: function () {         return moment(this.getDataValue('created_at')).format('YYYY-MM-DD');       },       updated_at: function () {         return moment(this.getDataValue('updated_at')).format('YYYY-MM-DD HH:mm:ss');       },       deleted_at: function () {         return moment(this.getDataValue('deleted_at')).format('YYYY-MM-DD HH:mm:ss');       }     },     indexes: [       {         name: 'partner_unique_index_name',         unique: true,         method: 'BTREE',         fields: ['name']       },       {         name: 'partner_unique_index_cellphone',         unique: true,         method: 'BTREE',         fields: ['cellphone']       }     ]   });   partner._status = {     PENDING: 'PENDING',     APPROVED: 'APPROVED',     REJECTED: 'REJECTED'   };   return partner; };
  |