wupengfei 2 years ago
parent
commit
4541530e82

+ 8 - 5
.idea/workspace.xml

@@ -2,7 +2,10 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="1a36929e-c054-4875-a943-593a74e55fa4" name="Default Changelist" comment="">
+      <change afterPath="$PROJECT_DIR$/application/common/model/DemandComment.php" afterDir="false" />
       <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/common/model/PlatformLike.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/common/model/PlatformLike.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/application/operate/controller/Demand.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/operate/controller/Demand.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
@@ -122,7 +125,7 @@
     <property name="WebServerToolWindowPanel.toolwindow.show.date" value="false" />
     <property name="WebServerToolWindowPanel.toolwindow.show.permissions" value="false" />
     <property name="WebServerToolWindowPanel.toolwindow.show.size" value="false" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$/application/operate/view" />
+    <property name="last_opened_file_path" value="$PROJECT_DIR$/application/common/model" />
     <property name="node.js.detected.package.eslint" value="true" />
     <property name="node.js.detected.package.tslint" value="true" />
     <property name="node.js.path.for.package.eslint" value="project" />
@@ -133,9 +136,9 @@
   </component>
   <component name="RecentsManager">
     <key name="CopyFile.RECENT_KEYS">
+      <recent name="D:\zs\gaoyixia\application\common\model" />
       <recent name="D:\zs\gaoyixia\application\operate\view" />
       <recent name="D:\zs\gaoyixia\application\operate\controller" />
-      <recent name="D:\zs\gaoyixia\application\common\model" />
       <recent name="D:\zs\gaoyixia\application\api\controller" />
       <recent name="D:\zs\gaoyixia\application\operate\view\activity" />
     </key>
@@ -208,7 +211,7 @@
       <workItem from="1663216924630" duration="8987000" />
       <workItem from="1663289320226" duration="8186000" />
       <workItem from="1663374115380" duration="19161000" />
-      <workItem from="1663548946176" duration="7836000" />
+      <workItem from="1663548946176" duration="9058000" />
     </task>
     <servers />
   </component>
@@ -234,10 +237,10 @@
       <screen x="0" y="0" width="2560" height="1400" />
     </state>
     <state x="1175" y="519" key="#com.intellij.fileTypes.FileTypeChooser/0.0.2560.1400@0.0.2560.1400" timestamp="1659079177590" />
-    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1663557510639">
+    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1663559178235">
       <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="1663557510639" />
+    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/0.0.2560.1400@0.0.2560.1400" timestamp="1663559178235" />
     <state x="283" y="145" width="1942" height="1088" key="DiffContextDialog" timestamp="1663143508458">
       <screen x="0" y="0" width="2560" height="1400" />
     </state>

+ 81 - 1
application/api/controller/Demand.php

@@ -1,6 +1,9 @@
 <?php
 namespace app\api\controller;
+use app\common\model\ArticleCommentLike;
 use app\common\model\PlatformDemand;
+use app\common\model\DemandComment;
+use app\common\model\PlatformLike;
 use app\common\model\UserDemand;
 use app\common\model\UserSearch;
 use library\tools\Data;
@@ -114,13 +117,90 @@ class Demand extends Base
 
     /**
      * @title 以下接口调用验证登录【需要header传Authorization】
-     * @desc 转发成功后调用
+     * @desc
      * @author qc
      * @method
      * @url /api/Demand/needLogin
      */
     public function needLogin(){}
 
+
+    /**
+     * @title 需求评论
+     * @desc 需求评论
+     * @author qc
+     * @method POST
+     * @url /api/Demand/demandComment
+     * @header name:Authorization require:1 desc:Token
+     * @param name:id type:int default:1 desc:需求id
+     * @param name:content type:string default:-- desc:内容
+     * @return name:name type:string default:-- desc:会员名称
+     * @return name:headimg type:string default:-- desc:会员头像
+     * @return name:content type:string default:-- desc:内容
+     * @return name:create_at type:string default:-- desc:时间
+     */
+    public function demandComment()
+    {
+        $id = input('post.id');
+        $content = input('post.content',0);
+        if(!$content) $this->error('请输入评论内容');
+        $res = DemandComment::create(['user_id'=>$this->user_id,'content'=>$content,'first_id'=>$id,'type'=>1]);
+        $detail  =DemandComment::where('p.id',$res->id)
+            ->alias('p')
+            ->field('p.id,p.content,p.create_at,u.name,u.headimg')
+            ->leftJoin('store_member u','u.id = p.user_id')
+            ->find()->toArray();
+        $this->success('评论成功',['detail'=>$detail]);
+    }
+
+    /**
+     * @title 需求二级评论
+     * @desc 需求二级评论
+     * @author qc
+     * @method POST
+     * @url /api/Demand/demandSecondComment
+     * @header name:Authorization require:1 desc:Token
+     * @param name:id type:int default:1 desc:评论id
+     * @param name:content type:string default:-- desc:内容
+     * @return name:name type:string default:-- desc:会员名称
+     * @return name:headimg type:string default:-- desc:会员头像
+     * @return name:content type:string default:-- desc:内容
+     */
+    public function demandSecondComment()
+    {
+        $comment = DemandComment::where('id',input('post.id'))->find()->toArray();
+        unset($comment['id']);
+        unset($comment['create_at']);
+        $comment['pid'] = input('post.id');
+        $comment['user_id'] = $this->user_id;
+        $comment['content'] = input('post.content');
+        $comment['lev']++;
+        if(!$comment['source_id']) $comment['source_id'] = input('post.id');
+        $res = DemandComment::create($comment);
+        $detail  = DemandComment::where('p.id',$res->id)
+            ->alias('p')
+            ->field('p.id,p.content,p.create_at,u.name,u.headimg')
+            ->leftJoin('store_member u','u.id = p.user_id')
+            ->find()->toArray();
+        $this->success('评论成功',['detail'=>$detail]);
+    }
+
+    /**
+     * @title 评论点赞||取消点赞
+     * @desc 评论
+     * @author qc
+     * @method POST
+     * @url /api/Demand/commentTags
+     * @header name:Authorization require:1 desc:Token
+     * @param name:comment_id type:int default:1 desc:评论记录id
+     * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
+     */
+    public function commentTags()
+    {
+        $ret_val = PlatformLike::userTags($this->user_id,input('post.comment_id'),6);
+        $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
+    }
+    
     /**
      * @title 用户提交||修改需求【用户】
      * @desc 用户提交||修改需求

+ 8 - 0
application/common/model/DemandComment.php

@@ -0,0 +1,8 @@
+<?php
+namespace app\common\model;
+use think\Model;
+// 需求评论
+class DemandComment extends Model
+{
+
+}

+ 1 - 0
application/common/model/PlatformLike.php

@@ -12,6 +12,7 @@ class PlatformLike extends Model
         3=>'论坛回答',
         4=>'活动',
         5=>'招聘',
+        6=>'需求评论',
     ];
     /**
      *  验证是否点赞

+ 5 - 0
application/operate/controller/Demand.php

@@ -74,6 +74,11 @@ class Demand extends Controller
     protected function _form_filter(&$data)
     {
         if($this->request->isGet()) $this->user_info  = Db::name('store_member')->find($data['user_id']);
+        if($this->request->isPost())
+        {
+            $user_demand = Db::name('user_demand')->find($data['id']);
+            if($user_demand['status'] != 0) $this->error('不能重复审核');
+        }
 
     }