Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-Server
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
李帅
2023-03-03 00:12:16 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fedc856321dd2705902e8b30109a0a4b9e3723d7
fedc8563
1 parent
0865259b
1.修改用户信息优化
2.新增用户反馈相关接口。 3.新增点赞列表接口。
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
225 additions
and
4 deletions
app/Http/Controllers/V1/ImmerseController.php
app/Http/Controllers/V1/MessageController.php
app/Http/Middleware/Authenticate.php
app/Models/Feedback.php
database/migrations/2023_03_02_213237_alter_user_profiles.php
database/migrations/2023_03_02_214554_create_feedback_table.php
routes/api.php
app/Http/Controllers/V1/ImmerseController.php
View file @
fedc856
...
...
@@ -144,6 +144,44 @@ class ImmerseController extends Controller
else
return
Response
::
success
();
}
public
function
praiseList
(
Request
$request
)
{
$page
=
$request
->
get
(
'page'
,
1
);
$page_size
=
$request
->
get
(
'page_size'
,
20
);
$user
=
$request
->
user
();
$collects
=
Praise
::
query
()
->
where
([
'user_id'
=>
$user
->
id
,
'state'
=>
1
])
->
orderByDesc
(
'created_at'
)
->
skip
((
$page
-
1
)
*
$page_size
)
->
take
(
$page_size
+
1
)
->
get
();
$lists
=
[];
if
(
$collects
->
count
()){
foreach
(
$collects
as
$collect
){
if
(
$collect
->
immerse
){
// 避免删除过临境的还存在收藏列表里
$data
[
'user_id'
]
=
$collect
->
user_id
;
$data
[
'immerse_id'
]
=
$collect
->
immerse_id
;
$data
[
'content'
]
=
$collect
->
immerse
->
content
;
$data
[
'thumbnail'
]
=
$collect
->
immerse
->
thumbnail
;
$data
[
'url'
]
=
$collect
->
immerse
->
url
;
$data
[
'type'
]
=
$collect
->
immerse
->
type
;
$data
[
'is_praise'
]
=
$collect
->
immerse
->
isPraise
(
$collect
->
immerse_id
,
$user
->
id
);
$data
[
'is_collect'
]
=
$collect
->
immerse
->
isCollect
(
$collect
->
immerse_id
,
$user
->
id
);
$lists
[]
=
$data
;
}
}
}
return
\response
([
'status'
=>
'success'
,
'code'
=>
200
,
'message'
=>
'Http ok'
,
'data'
=>
$lists
,
],
200
);
}
public
function
collect
(
$id
,
Request
$request
)
{
$user
=
$request
->
user
();
...
...
app/Http/Controllers/V1/MessageController.php
0 → 100644
View file @
fedc856
<?php
namespace
App\Http\Controllers\V1
;
use
App\Http\Controllers\Controller
;
use
App\Models\Feedback
;
use
Carbon\Carbon
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Auth
;
use
Jiannei\Response\Laravel\Support\Facades\Response
;
class
MessageController
extends
Controller
{
//
public
function
insertFeedback
(
Request
$request
)
{
$user_id
=
Auth
::
user
()
->
getAuthIdentifier
();
$type
=
$request
->
post
(
"type"
,
1
);
$content
=
$request
->
post
(
"content"
);
if
(
!
$content
)
return
Response
::
fail
(
'内容不可为空'
);
$insert
=
[
[
'from_user_id'
=>
$user_id
,
'to_user_id'
=>
1
,
'type'
=>
$type
,
'content'
=>
$content
,
'is_from_user'
=>
1
,
'state'
=>
1
,
'send_time'
=>
Carbon
::
now
()
],
[
'from_user_id'
=>
1
,
'to_user_id'
=>
$user_id
,
'type'
=>
$type
,
'content'
=>
$content
,
'is_from_user'
=>
0
,
'state'
=>
0
,
'send_time'
=>
Carbon
::
now
()
]
];
Feedback
::
query
()
->
insert
(
$insert
);
return
Response
::
success
();
}
public
function
feedbackList
()
{
$user_id
=
Auth
::
user
()
->
getAuthIdentifier
();
$data
=
Feedback
::
query
()
->
where
(
'from_user_id'
,
$user_id
)
->
where
(
'to_user_id'
,
1
)
->
orderBy
(
'send_time'
)
->
limit
(
10
)
->
get
();
return
Response
::
success
(
$data
);
}
public
function
unreadFeedbackCount
()
{
$user_id
=
Auth
::
user
()
->
getAuthIdentifier
();
$count
=
Feedback
::
query
()
->
where
(
'from_user_id'
,
$user_id
)
->
where
(
'is_from_user'
,
0
)
->
count
();
return
Response
::
success
([
'count'
=>
$count
]);
}
public
function
readFeedback
()
{
$user_id
=
Auth
::
user
()
->
getAuthIdentifier
();
$count
=
Feedback
::
query
()
->
where
(
'from_user_id'
,
$user_id
)
->
where
(
'is_from_user'
,
0
)
->
update
([
'state'
=>
1
]);
return
Response
::
success
([
'count'
=>
$count
]);
}
}
app/Http/Middleware/Authenticate.php
View file @
fedc856
...
...
@@ -15,10 +15,10 @@ class Authenticate extends Middleware
*/
protected
function
redirectTo
(
$request
)
{
if
(
!
$request
->
expectsJson
())
{
return
route
(
'login'
);
}
// if ($request->isJson()) {
Response
::
errorUnauthorized
();
// 授权失败 401
// }
// return route('app');
}
}
...
...
app/Models/Feedback.php
0 → 100644
View file @
fedc856
<?php
namespace
App\Models
;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Illuminate\Database\Eloquent\Model
;
class
Feedback
extends
Model
{
use
HasFactory
;
public
$timestamps
=
false
;
}
database/migrations/2023_03_02_213237_alter_user_profiles.php
0 → 100644
View file @
fedc856
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
AlterUserProfiles
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
//
Schema
::
table
(
'user_profiles'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'intro'
)
->
after
(
'user_id'
)
->
default
(
""
)
->
comment
(
'简介'
);
$table
->
date
(
'birthday'
)
->
after
(
'intro'
)
->
default
(
"2023-01-01"
)
->
comment
(
'生日'
);
$table
->
unsignedInteger
(
'follow_count'
)
->
after
(
'video_count'
)
->
default
(
0
)
->
comment
(
'关注数量'
);
$table
->
unsignedInteger
(
'fans_count'
)
->
after
(
'follow_count'
)
->
default
(
0
)
->
comment
(
'粉丝数量'
);
$table
->
unsignedInteger
(
'popular_count'
)
->
after
(
'fans_count'
)
->
default
(
0
)
->
comment
(
'人气数量'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
//
Schema
::
dropColumns
(
'user_profiles'
,
[
'intro'
,
'birthday'
,
'follow_count'
,
'fans_count'
,
'popular_count'
]);
}
}
database/migrations/2023_03_02_214554_create_feedback_table.php
0 → 100644
View file @
fedc856
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateFeedbackTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'feedback'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
unsignedInteger
(
"from_user_id"
)
->
comment
(
"发起用户"
);
$table
->
unsignedInteger
(
"to_user_id"
)
->
default
(
1
)
->
comment
(
"接收用户"
);
$table
->
unsignedTinyInteger
(
"type"
)
->
comment
(
"消息类型"
);
$table
->
text
(
"content"
)
->
comment
(
"内容"
);
$table
->
unsignedTinyInteger
(
"is_from_user"
)
->
comment
(
"发起者"
);
$table
->
unsignedTinyInteger
(
"state"
)
->
comment
(
"0=未读1=已读"
);
$table
->
timestamp
(
'send_time'
,
0
)
->
nullable
()
->
comment
(
"发送时间"
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'feedback'
);
}
}
routes/api.php
View file @
fedc856
...
...
@@ -97,6 +97,9 @@ Route::prefix('v1')->namespace('App\Http\Controllers\V1')->middleware('auth:sanc
/** 点赞 */
$api
->
post
(
'/praise/{id}'
,
'ImmerseController@praise'
);
/** 点赞列表 */
$api
->
get
(
'/praise'
,
'ImmerseController@praiseList'
);
/** 收藏 */
$api
->
post
(
'/collect/{id}'
,
'ImmerseController@collect'
);
...
...
@@ -117,4 +120,16 @@ Route::prefix('v1')->namespace('App\Http\Controllers\V1')->middleware('auth:sanc
/** 调起支付 */
$api
->
apiResource
(
'/pay'
,
'PayController'
);
/** 用户反馈 */
$api
->
post
(
'/feedback'
,
'MessageController@insertFeedback'
);
/** 反馈消息记录 */
$api
->
get
(
'/feedback'
,
'MessageController@feedbackList'
);
/** 未读反馈消息数量 */
$api
->
get
(
'/unreadfc'
,
'MessageController@unreadFeedbackCount'
);
/** 更新读取反馈状态 */
$api
->
put
(
'/feedback'
,
'MessageController@readFeedback'
);
});
\ No newline at end of file
...
...
Please
register
or
login
to post a comment