|
|
@@ -187,37 +187,44 @@ class SentenceController extends Controller
|
|
|
|
|
|
//鉴权
|
|
|
$user = AuthApi::current($request);
|
|
|
- if($user ){
|
|
|
- $channel = Channel::where('uid',$param[4])->first();
|
|
|
- if($channel && $channel->owner_uid === $user["user_uid"]){
|
|
|
- $sent = Sentence::firstOrNew([
|
|
|
- "book_id"=>$param[0],
|
|
|
- "paragraph"=>$param[1],
|
|
|
- "word_start"=>$param[2],
|
|
|
- "word_end"=>$param[3],
|
|
|
- "channel_uid"=>$param[4],
|
|
|
- ],[
|
|
|
- "id"=>app('snowflake')->id(),
|
|
|
- "uid"=>Str::orderedUuid(),
|
|
|
- "create_time"=>time()*1000,
|
|
|
- ]);
|
|
|
- $sent->content = $request->get('content');
|
|
|
- $sent->language = $channel->lang;
|
|
|
- $sent->status = $channel->status;
|
|
|
- $sent->editor_uid = $user["user_uid"];
|
|
|
- $sent->strlen = mb_strlen($request->get('content'),"UTF-8");
|
|
|
- $sent->modify_time = time()*1000;
|
|
|
- $sent->save();
|
|
|
- return $this->ok(new SentResource($sent));
|
|
|
- }else{
|
|
|
- //TODO 判断是否为协作
|
|
|
- return $this->error(__('auth.failed'));
|
|
|
- }
|
|
|
- }else{
|
|
|
- //非所有者鉴权失败
|
|
|
-
|
|
|
+ if(!$user){
|
|
|
+ //未登录鉴权失败
|
|
|
return $this->error(__('auth.failed'));
|
|
|
}
|
|
|
+ $channel = Channel::where('uid',$param[4])->first();
|
|
|
+ if(!$channel){
|
|
|
+ return $this->error("not found channel");
|
|
|
+ }
|
|
|
+ if($channel->owner_uid !== $user["user_uid"]){
|
|
|
+ //TODO 判断是否为协作
|
|
|
+ return $this->error(__('auth.failed'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $sent = Sentence::firstOrNew([
|
|
|
+ "book_id"=>$param[0],
|
|
|
+ "paragraph"=>$param[1],
|
|
|
+ "word_start"=>$param[2],
|
|
|
+ "word_end"=>$param[3],
|
|
|
+ "channel_uid"=>$param[4],
|
|
|
+ ],[
|
|
|
+ "id"=>app('snowflake')->id(),
|
|
|
+ "uid"=>Str::orderedUuid(),
|
|
|
+ "create_time"=>time()*1000,
|
|
|
+ ]);
|
|
|
+ $sent->content = $request->get('content');
|
|
|
+ $sent->language = $channel->lang;
|
|
|
+ $sent->status = $channel->status;
|
|
|
+ $sent->editor_uid = $user["user_uid"];
|
|
|
+ $sent->strlen = mb_strlen($request->get('content'),"UTF-8");
|
|
|
+ $sent->modify_time = time()*1000;
|
|
|
+ if($request->has('prEditor')){
|
|
|
+ $sent->acceptor_uid = $user["user_uid"];
|
|
|
+ $sent->pr_edit_at = $request->get('prEditAt');
|
|
|
+ $sent->editor_uid = $request->get('prEditor');
|
|
|
+ $sent->pr_id = $request->get('prId');
|
|
|
+ }
|
|
|
+ $sent->save();
|
|
|
+ return $this->ok(new SentResource($sent));
|
|
|
}
|
|
|
|
|
|
/**
|