Coder Social home page Coder Social logo

bawangcan's Introduction

饿了么霸王餐模拟

这道题是 v2ex 上看到的一个饿了么的面试题。我试了试

目前将其抽象为这样几个端口

第一 user_login 用户登录

第二 join_activity 用户参与霸王餐活动

第三 heart_beat 定时更新key

第四 activity_record 获取当前活动状态

第五 activity_award 获取用户中奖状态

缺陷

第一,数据库设计直接暴力出奇迹=。=没有考虑更多因素

第二,暂时没有考虑分布式数据库中的事务处理

第三,没有良好的缓存层设计,频繁对数据库操作

第四,没有设计日志系统

第五,join_activity 没有编写单元测试(实际上是我不知道在带事务的情况下,单元测试怎样去构造 Test Case)

说明

/api/user_login/

{
  "user_email":"[email protected]",//用户邮箱
  "password":"f8d6934a93cb488588067fe165203d32",//用户密码 md5 值
  "user_name":"lizheao",// 用户名
  "time_map":123456789 //unix时间戳
}

返回

{
  "user_id":用户编号
  "key":"f8d6934a93cb488588067fe165203d32",
  "code":"lizheao",// 状态码
  "msg":123456789 // 额外消息
}

/api/join_activity/

{
	"key": "47563fdd1a50db6af6004dc2d28116eb",//之前下发的key
	"user_id": "abcsafdsasdfas",//下发的用户id
	"activity_type": 0, //参与的活动类型
	"time_map": 12345, //时间戳
	"email": "[email protected]"//邮箱
	
}

返回

{
  "code":,// 状态码
  "msg" // 额外消息
}

bawangcan's People

Contributors

zheaoli avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.