123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- /* indent size: 2 */
- // eslint-disable-next-line strict
- module.exports = app => {
- const DataTypes = app.Sequelize;
- const Model = app.model.define('Users', {
- user_id: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- allowNull: false,
- primaryKey: true,
- autoIncrement: true,
- },
- nickname: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- account_name: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- openid: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- /* new_openid: {
- type: DataTypes.STRING(128),
- allowNull: true,
- },
- ori_openid: {
- type: DataTypes.STRING(128),
- allowNull: true,
- },*/
- unionid: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- password: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- money: {
- type: DataTypes.FLOAT,
- allowNull: true,
- },
- commission: {
- type: DataTypes.FLOAT,
- allowNull: true,
- },
- intergral: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- allowNull: true,
- },
- headimgurl: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- login_time: {
- type: DataTypes.DATE,
- allowNull: true,
- },
- city: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- province: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- country: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- sex: {
- type: DataTypes.CHAR(1),
- allowNull: true,
- },
- subscribe: {
- type: DataTypes.INTEGER(1).UNSIGNED,
- allowNull: true,
- },
- update_ttime: {
- type: DataTypes.TIME,
- },
- create_time: {
- type: DataTypes.DATE,
- allowNull: true,
- },
- lucky_time: {
- type: DataTypes.DATE,
- allowNull: true,
- },
- is_proxy: {
- type: DataTypes.INTEGER(1).UNSIGNED,
- allowNull: true,
- },
- is_employee: {
- type: DataTypes.INTEGER(1).UNSIGNED,
- allowNull: true,
- },
- is_office: {
- type: DataTypes.INTEGER(1).UNSIGNED,
- allowNull: true,
- },
- is_family: {
- type: DataTypes.INTEGER(1).UNSIGNED,
- allowNull: true,
- },
- partner_id: {
- type: DataTypes.INTEGER(11),
- allowNull: true,
- },
- }, {
- tableName: 'szj_users',
- });
- Model.associate = function() {
- // 关联地址表
- Model.hasMany(app.model.Address, { foreignKey: 'user_id', targetKey: 'user_id', as: 'address' });
- // 关联购物车表
- Model.hasMany(app.model.Carts, { foreignKey: 'user_id', targetKey: 'user_id', as: 'carts' });
- // 关联收藏表
- Model.hasMany(app.model.Collects, { foreignKey: 'user_id', targetKey: 'user_id', as: 'collects' });
- // 关联代理认证申请
- Model.hasOne(app.model.ProxyApplyLogs, { foreignKey: 'user_id', targetKey: 'user_id', as: 'proxyApplyLogs' });
- // Model.hasOne(app.model.RelUserInviter, { foreignKey: 'user_id', targetKey: 'user_id', as: 'relUser' });
- };
- // 同步:没有就新建,有就不变
- Model.sync();
- return Model;
- };
|