wupengfei 2 лет назад
Родитель
Сommit
049121103a
2 измененных файлов с 64 добавлено и 8 удалено
  1. 6 6
      .idea/workspace.xml
  2. 58 2
      application/api/controller/Forum.php

+ 6 - 6
.idea/workspace.xml

@@ -3,7 +3,7 @@
   <component name="ChangeListManager">
     <list default="true" id="1a36929e-c054-4875-a943-593a74e55fa4" name="Default Changelist" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/application/api/controller/Demand.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/api/controller/Demand.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/api/controller/Forum.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/api/controller/Forum.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -201,7 +201,7 @@
       <workItem from="1670461023846" duration="27678000" />
       <workItem from="1670547445908" duration="12147000" />
       <workItem from="1670633686675" duration="15717000" />
-      <workItem from="1670719843429" duration="5534000" />
+      <workItem from="1670719843429" duration="6432000" />
     </task>
     <servers />
   </component>
@@ -271,10 +271,10 @@
     </option>
   </component>
   <component name="WindowStateProjectService">
-    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1670726404008">
+    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1670726459686">
       <screen x="0" y="0" width="2560" height="1400" />
     </state>
-    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/0.0.2560.1400@0.0.2560.1400" timestamp="1670726404008" />
+    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/0.0.2560.1400@0.0.2560.1400" timestamp="1670726459686" />
     <state x="283" y="145" width="1942" height="1088" key="DiffContextDialog" timestamp="1670291222413">
       <screen x="0" y="0" width="2560" height="1400" />
     </state>
@@ -308,9 +308,9 @@
       <screen x="0" y="0" width="2560" height="1400" />
     </state>
     <state x="1291" y="317" key="run.anything.popup/0.0.2560.1400@0.0.2560.1400" timestamp="1668056889671" />
-    <state x="1237" y="367" width="672" height="678" key="search.everywhere.popup" timestamp="1669438998762">
+    <state x="1237" y="367" width="672" height="678" key="search.everywhere.popup" timestamp="1670727204367">
       <screen x="0" y="0" width="2560" height="1400" />
     </state>
-    <state x="1237" y="367" width="672" height="678" key="search.everywhere.popup/0.0.2560.1400@0.0.2560.1400" timestamp="1669438998762" />
+    <state x="1237" y="367" width="672" height="678" key="search.everywhere.popup/0.0.2560.1400@0.0.2560.1400" timestamp="1670727204367" />
   </component>
 </project>

+ 58 - 2
application/api/controller/Forum.php

@@ -635,6 +635,59 @@ class Forum extends Base
         $this->success('ok',['list'=>$list]);
     }
 
+
+
+    /**
+     * @title 获取角标数量
+     * @desc 获取角标数量
+     * @author qc
+     * @method GET
+     * @url /api/Forum/getMarkNum
+     * @header name:Authorization require:1 desc:Token
+     * @return name:answer_num type:int default:-- desc:未读量--回答我的
+     * @return name:reply_num type:int default:-- desc:未读量--回复我的
+     * @return name:comment_num type:int default:-- desc:未读量--评论我的
+     */
+    public function getMarkNum()
+    {
+        //回答我的
+        $answer_num = ForumReply::where([['r.issue_user','=',$this->user_id],['r.is_deleted','=',0],['r.is_read','=',0]])
+            ->alias('r')->leftJoin('user_forum f','r.forum_id = f.id')->count();
+        // 回复我的
+        $all_comment = ForumReplyComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
+        $reply_num =  ForumReplyComment::where([['t.is_deleted','=',0],['t.lev','>=',2],['t.is_read','=',0],['t.pid','in',implode(',',$all_comment)]])->alias('t')->count();
+        // 评论我的
+        $comment_num = ForumReplyComment::alias('c')
+            ->where(['r.user_id'=>$this->user_id,'r.is_deleted'=>0,'c.is_read'=>0])
+            ->leftJoin('forum_reply r','c.reply_id = r.id')
+            ->count();
+        $this->success('ok',compact(['answer_num','reply_num','comment_num']));
+    }
+
+    /**
+     * @title 消息已读
+     * @desc 消息已读
+     * @author qc
+     * @method POST
+     * @url /api/Forum/unreadChange
+     * @header name:Authorization require:1 desc:Token
+     * @param name:id type:string default:-- desc:记录id【区分类型!!!!】
+     * @param name:type type:int default:-- desc:1回答我的,2回复我的,3评论我的
+     */
+    public function unreadChange()
+    {
+        $type = input('post.type');
+        if($type == 1) {
+            ForumReply::where('id',input('post.id'))->update(['is_read'=>1]);
+        }else{
+            ForumReplyComment::where('id',input('post.id'))->update(['is_read'=>1]);
+        }
+        $this->success('ok');
+    }
+
+
+
+
     /**
      * @title 回答我的
      * @desc 回答我的
@@ -650,6 +703,7 @@ class Forum extends Base
      * @return name:name type:string default:-- desc:用户
      * @return name:headimg type:string default:-- desc:用户头像
      * @return name:create_at type:string default:-- desc:时间
+     * @return name:is_read type:int default:-- desc:是否已读(0未读1已读)
      * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
      */
     public function replyToMyForum()
@@ -660,7 +714,7 @@ class Forum extends Base
         if($title = input('title'))$where[] = ['r.content','like','%'.$title.'%'];
         $list = ForumReply::where($where)
             ->alias('r')
-            ->field('r.id,r.content,r.create_at,f.title,u.name,r.forum_id ,u.headimg')
+            ->field('r.id,r.is_read,r.content,r.create_at,f.title,u.name,r.forum_id ,u.headimg')
             ->leftJoin('user_forum f','r.forum_id = f.id')
             ->leftJoin('store_member u','r.user_id = u.id')
             ->limit($this->off_set,$this->page_num)
@@ -689,6 +743,7 @@ class Forum extends Base
      * @return name:reply_content type:string default:0 desc:回复内容
      * @return name:name type:string default:-- desc:评论用户
      * @return name:headimg type:string default:-- desc:评论用户头像
+     * @return name:is_read type:int default:-- desc:是否已读(0未读1已读)
      * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
      */
     public function commentOnMyReply()
@@ -766,6 +821,7 @@ class Forum extends Base
      * @return name:user_name type:string default:-- desc:用户名【其他会员】
      * @return name:headimg type:string default:-- desc:用户头像【其他会员】
      * @return name:content type:string default:-- desc:回复内容
+     * @return name:is_read type:int default:-- desc:是否已读(0未读1已读)
      * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
      * @return name:parent_comment type:array default:-- desc:你的评论内容
      * @return name:parent_comment.content type:string default:-- desc:内容
@@ -788,7 +844,7 @@ class Forum extends Base
         $sel_where[]  = ['t.pid','in',implode(',',$all_comment)];
         $list = ForumReplyComment::where($sel_where)
             ->alias('t')
-            ->field('t.id,t.create_at,t.content,t.pid,forum_id,u.name user_name,u.headimg,i.title')
+            ->field('t.id,t.create_at,t.is_read,t.content,t.pid,forum_id,u.name user_name,u.headimg,i.title')
             ->leftJoin('store_member u','t.user_id = u.id')
             ->leftJoin('UserForum i','t.forum_id = i.id')
             ->order('t.id desc')