@@ -18,13 +18,11 @@ class Blog
18
18
*/
19
19
public function update (Request $ request ): Response
20
20
{
21
- $ role = $ request ->role ;
22
- $ user_id = $ request ->userid ;
23
- Redis::expire ($ request ->redisKey , 3600 * 2 );
24
- return api (data: [
25
- 'role ' => 111111 ,
26
- 'user_id ' => $ user_id ,
27
- ]);
21
+ $ blog_idx = $ request ->input ('blog_idx ' );
22
+ // check blog exists
23
+ if (!BlogHelper::checkBlogExistsByBlogIdx ($ blog_idx )) {
24
+ return api (false , '博客不存在 ' );
25
+ }
28
26
}
29
27
30
28
/**
@@ -35,24 +33,24 @@ public function update(Request $request): Response
35
33
*/
36
34
public function del (Request $ request ): Response
37
35
{
38
- $ blog_id = $ request ->input ('blog_id ' );
39
- if ($ blog_id === null ) {
36
+ $ blog_idx = $ request ->input ('blog_idx ' );
37
+ if ($ blog_idx === null ) {
40
38
return api (false , 'blog_id不能为空 ' );
41
39
}
42
- if (!is_numeric ($ blog_id )) {
40
+ if (!is_numeric ($ blog_idx )) {
43
41
return api (false , '非法的blog_id ' );
44
42
}
45
43
46
44
// check blog_id exists
47
- if (!BlogHelper::checkBlogExistsByBlogId ( $ blog_id )) {
45
+ if (!BlogHelper::checkBlogExistsByBlogIdx ( $ blog_idx )) {
48
46
return api (false , '博客不存在 ' );
49
47
}
50
48
51
49
// 删除博客
52
50
try {
53
51
Db::beginTransaction ();
54
- Db::table ('blog ' )->where ('idx ' , $ blog_id )->delete ();
55
- Db::table ('tag ' )->where ('blog_id ' , $ blog_id )->delete ();
52
+ Db::table ('blog ' )->where ('idx ' , $ blog_idx )->delete ();
53
+ Db::table ('tag ' )->where ('blog_id ' , $ blog_idx )->delete ();
56
54
Db::commit ();
57
55
} catch (\Throwable $ e ) {
58
56
Db::rollBack ();
0 commit comments