校友资料登记平台小程序开发笔记二-云数据库设计

230 阅读4分钟

云开发数据库

云开发提供了一个 JSON 数据库,顾名思义,数据库中的每条记录都是一个 JSON 格式的对象。一个数据库可以有多个集合(相当于关系型数据中的表),集合可看做一个 JSON 数组,数组中的每个对象就是一条记录,记录的格式是 JSON 对象。

关系型数据库和 JSON 数据库的概念对应关系如下表:

主要表ER图

校友信息表

UserModel.DB_STRUCTURE = {
    _pid: 'string|true',
    USER_ID: 'string|true',

    USER_NAME: 'string|true|comment=用户姓名',
    USER_PIC: 'string|true|comment=用户头像',
    USER_PIC_CLOUD_ID: 'string|false|comment=用户头像云存储地址',

    USER_PHONE_CHECKED: 'string|true|comment=已校验的手机号码',
    USER_MINI_QRCODE: 'object|false|comment=小程序码地址{url,cloudId}',

    USER_MINI_OPENID: 'string|true|comment=小程序openid',
    USER_MINI_ORI_OPENID: 'string|true|comment=小程序原始openid',
    USER_UNIONID: 'string|false|comment=微信开放平台unionid',

    USER_WX_OPENID: 'string|false|comment=公众号openid',
    USER_IS_SUBSCRIBE: 'int|true|default=0|comment=公众号是否关注 0/1',
    USER_SUBSCRIBE_TIME: 'int|true|default=0|comment=公众号关注时间',

    USER_IS_MASK: 'int|true|default=0|comment=是否马甲 0/1',
    USER_STATUS: 'int|true|default=1|comment=状态 0=待审核,1=正常,8=VIP(###1-8为正常区间),9=禁用, 10=已删除',
    USER_IS_SUPP: 'int|true|default=1|comment=待补充资料 0/1',
    USER_INVITE_ID: 'string|false|comment=邀请码',

    USER_TYPE: 'int|true|default=0|comment=用户类型 0=求学,1=教职工',

    USER_CHECK_PIC: 'array|false|default=[]|comment=审核图片 对象数组[{cloudId,url}]',


    USER_SEX: 'int|true|default=1|comment=性别 1=男,2=女',
    USER_BIRTH: 'string|true|comment=出生年月',
    USER_NATIVE: 'string|false|comment=籍贯',

    USER_OPEN_SET: 'int|true|default=1|comment=联系资料公开方式 1=所有用户,8=认证用户和交换名片用户, 3=好友, 9=已交换名片的用户',


    USER_WHOLE: 'int|true|default=0|comment=资料完整度',

    USER_IS_CARD: 'int|true|default=1|comment=是否接受名片 0/1',
    USER_IS_CARD_MSG: 'int|true|default=1|comment=是否接受交换名片消息提醒 0/1',

    USER_MOBILE: 'string|false|comment=联系电话',
    USER_WECHAT: 'string|false|comment=微信',
    USER_QQ: 'string|false|comment=QQ',
    USER_EMAIL: 'string|false',

    USER_ITEM: 'string|true|comment=班级',
    USER_ENROLL: 'int|true|default=0|comment=入学年份',
    USER_GRAD: 'string|true|default=0|comment=毕业年份',
    USER_EDU: 'string|true|comment=学历 中学,高职,大专,本科,硕士,博士,博士后,其他',

    USER_ITEM2: 'string|false|comment=班级2',
    USER_ENROLL2: 'int|false|default=0|comment=入学年份2',
    USER_GRAD2: 'string|false|default=0|comment=毕业年份2',
    USER_EDU2: 'string|false|comment=学历2 中学,高职,大专,本科,硕士,博士,博士后,其他',

    USER_ITEM3: 'string|false|comment=班级3',
    USER_ENROLL3: 'int|false|default=0|comment=入学年份3',
    USER_GRAD3: 'string|false|default=0|comment=毕业年份3',
    USER_EDU3: 'string|false|comment=学历3 中学,高职,大专,本科,硕士,博士,博士后,其他',

    USER_COMPANY: 'string|false|comment=当前单位',
    USER_COMPANY_DEF: 'string|false|comment=当前单位性质 保留,机关部门,事业单位,国企,世界500强,外企,上市企业,民营企业,自有企业,个体经营,自由职业,其他',
    USER_COMPANY_DESC: 'string|false|comment=公司/单位介绍',
    USER_COMPANY_DUTY: 'string|false|comment=当前职位',
    USER_TRADE: 'string|false|comment=当前行业',
    USER_TRADE_EX: 'string|false|comment=当前行业补充说明',
    USER_CITY: 'string|false|comment=当前城市',
    USER_WORK_STATUS: 'string|false|comment=工作状态 保留,全职,兼职,学生,待业,退休,老板,自由职业者,家庭主妇,其他',

    USER_DESC: 'string|false|comment=自我介绍',
    USER_RESOURCE: 'string|false|comment=可提供资源',
    USER_NEED: 'string|false|comment=需求',


    USER_SUPP: 'string|false|comment=注册补充说明',

    USER_FAV_CNT: 'int|true|default=0|comment=被收藏人数',
    USER_INVITE_CNT: 'int|true|default=0|comment=邀请人数',
    USER_VIEW_CNT: 'int|true|default=0|comment=被查看次数',
    USER_ALBUM_CNT: 'int|true|default=0|comment=发相册数量',
    USER_INFO_CNT: 'int|true|default=0|comment=发互助数量',
    USER_MEET_CNT: 'int|true|default=0|comment=发起活动次数',
    USER_MEET_JOIN_CNT: 'int|true|default=0|comment=活动报名次数',
    USER_MEET_CHECK_IN_CNT: 'int|true|default=0|comment=活动签到次数',

    USER_WX_GENDER: 'int|true|default=0|comment=微信性别 0=未定义,1=男,2=女',
    USER_WX_AVATAR_URL: 'string|false|comment=微信头像链接',
    USER_WX_NICKNAME: 'string|false|comment=微信昵称',
    USER_WX_LANGUAGE: 'string|false|comment=微信语言',
    USER_WX_CITY: 'string|false|comment=微信城市',
    USER_WX_PROVINCE: 'string|false|comment=微信省份',
    USER_WX_COUNTRY: 'string|false|comment=微信国家',
    USER_WX_UPDATE_TIME: 'int|false|comment=微信信息更新时间',

    USER_ACTIVE: 'array|false|comment=用户动态',

    USER_LOGIN_CNT: 'int|true|default=0|comment=登陆次数',
    USER_LOGIN_TIME: 'int|false|comment=最近登录时间',

    USER_ADD_TIME: 'int|true',
    USER_ADD_IP: 'string|false',

    USER_EDIT_TIME: 'int|true',
    USER_EDIT_IP: 'string|false',
}

后台操作日志表

LogModel.DB_STRUCTURE = {
    _pid: 'string|true',
    LOG_ID: 'string|true',
    LOG_CONTENT: 'string|true',
    LOG_ADMIN_ID: 'string|true|comment=校友资料平台管理员',

    LOG_TYPE: 'int|true|comment=日志类型 ',

    LOG_ADD_TIME: 'int|true',
    LOG_EDIT_TIME: 'int|true',
    LOG_ADD_IP: 'string|false',
    LOG_EDIT_IP: 'string|false',
};

校友名片表

CardModel.DB_STRUCTURE = {
    _pid: 'string|true',
    CARD_ID: 'string|true',
    CARD_MY_ID: 'string|true',
    CARD_YOUR_ID: 'string|true|comment=所有者',

    CARD_MSG: 'string|false|comment=留言',
    CARD_STATUS: 'int|true|default=0|comment=状态 0=等待 1=拒绝 9=通过',

    CARD_ADD_TIME: 'int|true',
    CARD_EDIT_TIME: 'int|true',
    CARD_ADD_IP: 'string|false',
    CARD_EDIT_IP: 'string|false',
};

系统设置表

SetupModel.DB_STRUCTURE = {
    _pid: 'string|true',
    SETUP_ID: 'string|true',

    SETUP_TITLE: 'string|false|comment=网站名称',
    SETUP_ABOUT: 'string|false|comment=关于我们',

    SETUP_SKIN: 'string|true|default=skin1|comment=皮肤',
    SETUP_MARK: 'object|false|default={}|comment=校徽 对象{cloudId,url}',

    SETUP_LOGO: 'object|false|default={}|comment=网站首页底图 对象{cloudId,url}',
    SETUP_LOGO_USER: 'object|false|default={}|comment=网站用户详情底图 对象{cloudId,url}',
    SETUP_LOGO_MY: 'object|false|default={}|comment=网站个人中心底图 对象{cloudId,url}',

    SETUP_MINI_QRCODE: 'object|false|default={}|comment=学校小程序码 对象{cloudId,url}',

    SETUP_AD_PIC: 'array|false|default=[]|comment=海报底图 对象数组[cloud1,cloud2,cloud3]',

    SETUP_REG_CHECK: 'int|true|default=0|comment=注册是否审核 0/1',
    SETUP_REG_CHECK_DESC: 'string|false|comment=注册审核说明',
    SETUP_REG_CHECK_PIC: 'int|true|default=0|comment=注册是否审核 0/1',
    SETUP_REG_CHECK_PIC_DESC: 'string|false|comment=注册审核说明',

    SETUP_ALBUM_CHECK: 'int|true|default=0|comment=相册是否审核 0/1',
    SETUP_MEET_CHECK: 'int|true|default=0|comment=活动是否审核 0/1',
    SETUP_INFO_CHECK: 'int|true|default=0|comment=互助是否审核 0/1',

    SETUP_ALBUM_COMMENT: 'int|true|default=1|comment=相册是否允许评论 0/1',
    SETUP_MEET_COMMENT: 'int|true|default=1|comment=活动是否允许评论 0/1',
    SETUP_INFO_COMMENT: 'int|true|default=1|comment=互助是否允许评论 0/1',
    SETUP_NEWS_COMMENT: 'int|true|default=1|comment=资讯是否允许评论 0/1',

    SETUP_REG_WORK: 'int|true|default=0|comment=注册是否允许教职工 0/1',

    SETUP_ADD_TIME: 'int|true',
    SETUP_EDIT_TIME: 'int|true',
    SETUP_ADD_IP: 'string|false',
    SETUP_EDIT_IP: 'string|false',
};

项目代码GIT: github.com/ccliqi/CC-a…