Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dingo/api component and jwt-auth component #23

Open
wants to merge 20 commits into
base: dev-website
Choose a base branch
from
Open

Add dingo/api component and jwt-auth component #23

wants to merge 20 commits into from

Conversation

ety001
Copy link

@ety001 ety001 commented May 27, 2017

Need to do:

  1. composer update
  2. php artisan jwt:generate

.gitignore Outdated
/public/bower-assets
.DS_Store
composer.lock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为了保持 vendor 的一致,不应该忽略 composer.lock 文件


$user = $this->auth->user();

$timelines = $query->get()->each(function($item, $key)use($user){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码风格问题

if (!$user) {
$item->is_like = false;
} else {
$item->is_like = TimelineLike::where(['timeline_id' => $item->id, 'user_id' => $user->id])->count() ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

count() 或以替换成 exists()

@ety001
Copy link
Author

ety001 commented Jun 1, 2017

Test URI:

  1. [get] /api/timelines
  2. [get] /api/timelines/{id}
  3. [post] /api/auth/login post_body: {"phone": "foo","password": "bar" }
  4. [get] /api/auth/user

@ety001
Copy link
Author

ety001 commented Jun 1, 2017

Response Data Structure:

Success

http status code : 200
body :

{
    "data": {}
}

Failed

http status code : 4xx or 5xx
body :

{
  "message": "xxxxxxxx",
  "status_code": 4xx or 5xx
}

@ety001
Copy link
Author

ety001 commented Jun 1, 2017

找到一个方法,需要传入一个自定义的函数来实现返回数据的自定义格式。
https://www.laravist.com/discuss/laravel/dingoapi-custom-to-return-to-the-interface-format-586

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants