File tree Expand file tree Collapse file tree 5 files changed +16
-36
lines changed
Handler/Topic/Middleware/Update Expand file tree Collapse file tree 5 files changed +16
-36
lines changed Original file line number Diff line number Diff line change @@ -268,35 +268,6 @@ public function topic_comment_data(): array
268
268
return Json_Api (200 ,true ,$ data );
269
269
}
270
270
271
- #[PostMapping(path:"topic.comment.update " )]
272
- public function topic_comment_update (UpdateComment $ request ){
273
- $ id = $ request ->input ("comment_id " ); // 获取评论id
274
- if (!TopicComment::query ()->where ("id " ,$ id )->exists ()){
275
- return Json_Api (404 ,false ,["id为: " .$ id ."的评论不存在 " ]);
276
- }
277
- $ data = TopicComment::query ()->where ("id " ,$ id )->first ();
278
- $ quanxian = false ;
279
- if (Authority ()->check ("admin_topic_edit " ) && curd ()->GetUserClass (auth ()->data ()->class_id )['permission-value ' ]>curd ()->GetUserClass ($ data ->user ->class_id )['permission-value ' ]){
280
- $ quanxian = true ;
281
- }
282
- if (Authority ()->check ("topic_edit " ) && auth ()->id () === $ data ->user ->id ){
283
- $ quanxian = true ;
284
- }
285
- if ($ quanxian ===false ){
286
- return Json_Api (419 ,false ,["无权修改! " ]);
287
- }
288
- // 过滤xss
289
- $ content = xss ()->clean ($ request ->input ('content ' ));
290
-
291
- // 解析艾特
292
- $ content = $ this ->topic_create_at ($ content );
293
- $ post_id = TopicComment::query ()->find ($ id )->post_id ;
294
- Post::query ()->where ("id " ,$ post_id )->update ([
295
- 'content ' => $ content ,
296
- ]);
297
- return Json_Api (200 ,true ,["更新成功! " ]);
298
- }
299
-
300
271
#[PostMapping("topic.caina.comment " )]
301
272
public function topic_caina_comment (){
302
273
$ comment_id = request ()->input ('comment_id ' );
Original file line number Diff line number Diff line change @@ -27,10 +27,10 @@ public function index($id)
27
27
}
28
28
$ data = TopicComment::query ()->find ($ id );
29
29
$ quanxian = false ;
30
- if (Authority ()->check ('admin_topic_edit ' ) && curd ()->GetUserClass (auth ()->data ()->class_id )['permission-value ' ] > curd ()->GetUserClass ($ data ->user ->class_id )['permission-value ' ]) {
30
+ if (Authority ()->check ('admin_comment_edit ' ) && curd ()->GetUserClass (auth ()->data ()->class_id )['permission-value ' ] > curd ()->GetUserClass ($ data ->user ->class_id )['permission-value ' ]) {
31
31
$ quanxian = true ;
32
32
}
33
- if (Authority ()->check ('topic_edit ' ) && auth ()->id () === $ data ->user ->id ) {
33
+ if (Authority ()->check ('comment_edit ' ) && auth ()->id () === $ data ->user ->id ) {
34
34
$ quanxian = true ;
35
35
}
36
36
if ($ quanxian === false ) {
Original file line number Diff line number Diff line change @@ -239,9 +239,9 @@ public function set_topic_delete(): array
239
239
}
240
240
$ data = Topic::query ()->where ('id ' , $ topic_id )->first ();
241
241
$ quanxian = false ;
242
- if (Authority ()->check ('admin_topic_edit ' ) && curd ()->GetUserClass (auth ()->data ()->class_id )['permission-value ' ] > curd ()->GetUserClass ($ data ->user ->class_id )['permission-value ' ]) {
242
+ if (Authority ()->check ('admin_topic_delete ' ) && curd ()->GetUserClass (auth ()->data ()->class_id )['permission-value ' ] > curd ()->GetUserClass ($ data ->user ->class_id )['permission-value ' ]) {
243
243
$ quanxian = true ;
244
- } elseif (Authority ()->check ('topic_edit ' ) && auth ()->id () === $ data ->user ->id ) {
244
+ } elseif (Authority ()->check ('topic_delete ' ) && auth ()->id () === $ data ->user ->id ) {
245
245
$ quanxian = true ;
246
246
}
247
247
Original file line number Diff line number Diff line change 15
15
use App \Plugins \Topic \src \Handler \Topic \EditTopic ;
16
16
use App \Plugins \Topic \src \Handler \Topic \EditTopicView ;
17
17
use App \Plugins \Topic \src \Models \Topic ;
18
- use App \Plugins \Topic \src \Requests \Topic \CreateTopicRequest ;
19
- use App \Plugins \Topic \src \Requests \Topic \UpdateTopicRequest ;
20
18
use App \Plugins \User \src \Middleware \LoginMiddleware ;
21
19
use Hyperf \HttpServer \Annotation \Controller ;
22
20
use Hyperf \HttpServer \Annotation \GetMapping ;
@@ -87,7 +85,7 @@ public function edit($topic_id)
87
85
}
88
86
89
87
#[PostMapping(path: '/topic/update ' )]
90
- #[RateLimit(create:1 , capacity:1 , consume:1 )]
88
+ #[RateLimit(create: 1 , capacity: 1 , consume: 1 )]
91
89
public function edit_post ()
92
90
{
93
91
$ quanxian = false ;
Original file line number Diff line number Diff line change @@ -51,6 +51,17 @@ public function handler($data, \Closure $next)
51
51
return redirect ()->with ('danger ' , $ validator ->errors ()->first ())->url ('topic/ ' . $ data ['basis ' ]['topic_id ' ] . '/edit ' )->go ();
52
52
}
53
53
$ data ['topic_id ' ] = $ data ['basis ' ]['topic_id ' ];
54
+ $ topic = Topic::query ()->find ($ data ['topic_id ' ]);
55
+ $ quanxian = false ;
56
+ if (Authority ()->check ("admin_topic_edit " ) && auth ()->Class ()['permission-value ' ]>curd ()->GetUserClass ($ topic ->user ->class_id )['permission-value ' ]){
57
+ $ quanxian = true ;
58
+ }
59
+ if (Authority ()->check ("topic_edit " ) && auth ()->id () === $ topic ->user ->id ){
60
+ $ quanxian = true ;
61
+ }
62
+ if ($ quanxian ===false ){
63
+ return redirect ()->back ()->with ('danger ' ,'无权修改! ' )->go ();
64
+ }
54
65
$ data = $ this ->update ($ data );
55
66
return $ next ($ data );
56
67
}
You can’t perform that action at this time.
0 commit comments