xielin преди 5 години
родител
ревизия
0a92a4f4bc

+ 35 - 199
app/Http/Controllers/Circle/CircleController.php

@@ -15,9 +15,11 @@ use App\Repositories\Circle\CircleMessageRepository;
 use App\Repositories\Circle\CircleRepository;
 use App\Transformers\Circle\ArticleListTransformer;
 use App\Transformers\Circle\CircleMemberTransformer;
+use App\Transformers\Circle\CommentTransformer;
 use App\Transformers\Circle\DetailTransformer;
 use App\Transformers\Circle\InterestCirclePictureTransformer;
 use App\Transformers\Circle\InterestCircleTransformer;
+use App\Transformers\Circle\MessageDetailTransformer;
 use App\Transformers\Circle\MessageListTransformer;
 use App\Transformers\Circle\PostListTransformer;
 use Carbon\Carbon;
@@ -366,6 +368,12 @@ class CircleController extends Controller
      */
     public function messageList(Request $request)
     {
+        $validator = Validator::make($request->all(), [
+            'circle_id' => 'required|integer'
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
         $commentList = $this->circleMessageRepository->lists($request->all());
         $fractal = new Manager();
         $resource = new Collection($commentList, new MessageListTransformer());
@@ -396,269 +404,97 @@ class CircleController extends Controller
         return $data;
     }
 
-
-    /**
-     * 评论&回复
-     */
-    public function comment(Request $request)
-    {
-        $validator = Validator::make($request->all(), [
-            'post_id' => 'required|integer',
-            'uid' => 'required|integer',
-            'content' => 'required|string|max:150',
-        ]);
-        if ($validator->fails()) {
-            return $this->response->error($validator->errors()->first(), 500);
-        }
-        return $this->postRepository->comment($request->all());
-    }
-
     /**
-     * 增加数据
+     * 圈子留言详情
      */
-    public function addData(Request $request)
+    public function messageDetail(Request $request)
     {
         $validator = Validator::make($request->all(), [
-            'post_id' => 'required|exists:post,id',
-            'add_pv' => 'required|integer|min:0',
-            'add_praise_count' => 'required|integer|min:0',
-            'add_collect_count' => 'required|integer|min:0',
-            'add_share_count' => 'required|integer|min:0',
+            'id' => 'required|exists:interest_circle_messages'
         ]);
         if ($validator->fails()) {
             return $this->response->error($validator->errors()->first(), 500);
         }
-        return $this->postRepository->addData($request->all());
-    }
 
-    /**
-     * 推荐内容
-     */
-    public function suggest(Request $request)
-    {
-        $validator = Validator::make($request->all(), [
-            'id' => 'required|integer',
-        ]);
-        if ($validator->fails()) {
-            return $this->response->error($validator->errors()->first(), 500);
-        }
-        return $this->postRepository->suggest($request->all());
+        $message = $this->circleMessageRepository->detail($request->all());
+        return $this->response->item($message, new MessageDetailTransformer());
     }
 
     /**
-     * 删除内容
+     * 留言 推荐
      */
-    public function delete(Request $request)
-    {
-        $validator = Validator::make($request->all(), [
-            'id' => 'required|integer',
-        ]);
-        if ($validator->fails()) {
-            return $this->response->error($validator->errors()->first(), 500);
-        }
-        return $this->postRepository->delete($request->all());
-    }
-
-    /**
-     * 复原内容
-     */
-    public function restore(Request $request)
+    public function messageRecommend(Request $request)
     {
         $validator = Validator::make($request->all(), [
             'id' => 'required|integer',
+            'circle_id' => 'required|integer'
         ]);
         if ($validator->fails()) {
             return $this->response->error($validator->errors()->first(), 500);
         }
-        return $this->postRepository->restore($request->all());
+        return $this->circleMessageRepository->messageRecommend($request->all());
     }
 
     /**
-     * 删除评论
+     * 删除圈子留言
      */
-    public function commentDelete(Request $request)
+    public function deleteMessage(Request $request)
     {
         $validator = Validator::make($request->all(), [
-            'id' => 'required|integer',
+            'id' => 'required|exists:interest_circle_messages',
+            'circle_id' => 'required|integer'
         ]);
         if ($validator->fails()) {
             return $this->response->error($validator->errors()->first(), 500);
         }
-        return $this->postRepository->commentDelete($request->all());
+        return $this->circleMessageRepository->delete($request->all());
     }
-
     /**
-     * 隐藏内容
+     * 圈子留言评论列表
      */
-    public function hide(Request $request)
+    public function commentList(Request $request)
     {
         $validator = Validator::make($request->all(), [
-            'id' => 'required|integer',
+            'msg_id' => 'required|integer'
         ]);
         if ($validator->fails()) {
             return $this->response->error($validator->errors()->first(), 500);
         }
-        return $this->postRepository->hide($request->all());
-    }
-
-    /**
-     * 日志列表
-     */
-    public function log(Request $request)
-    {
-        $commentList = $this->postRepository->log($request->all());
+        $commentList = $this->circleMessageRepository->commentList($request->all());
         $fractal = new Manager();
-        $resource = new Collection($commentList, new LogTransformer());
+        $resource = new Collection($commentList, new CommentTransformer());
         $resource->setPaginator(new IlluminatePaginatorAdapter($commentList));
         $data = $fractal->createData($resource)->toArray();
 
         $data['extra'] = [
             'filters' => [
-                'log_type',
-                'created_at',
-            ],
-            'columns' => [
-                'id',
-                'username',
-                'log_type',
-                'created_at',
-                'content',
-            ]
-        ];
-        return $data;
-    }
-
-    public function statistics(Request $request)
-    {
-        $request = $request->all();
-        $start = Carbon::parse(!empty($request['start']) ? Carbon::parse($request['start'])->startOfDay()->toDateTimeString() : Carbon::yesterday())->startOfDay()->toDateTimeString();
-        $end = Carbon::parse(!empty($request['end']) ? Carbon::parse($request['end'])->endOfDay()->toDateTimeString() : Carbon::yesterday())->endOfDay()->toDateTimeString();
-        return $this->postRepository->statistics($start, $end);
-    }
-
-    /**
-     * 编辑内容话题
-     */
-    public function updateTopic(Request $request)
-    {
-        $validator = Validator::make($request->all(), [
-            'id' => 'required|integer',
-            'topic_ids' => 'required|string|max:64',
-        ]);
-        if ($validator->fails()) {
-            return $this->response->error($validator->errors()->first(), 500);
-        }
-        return $this->postRepository->updateTopic($request->all());
-    }
-
-    /**
-     * 获取网站内容
-     */
-    public function createStore(Request $request)
-    {
-        $validator = Validator::make($request->all(), [
-            'start_page' => 'required|integer',
-            'end_page' => 'required|integer',
-            'size' => 'required|integer',
-            'category_id' => 'required|integer',
-        ]);
-        if ($validator->fails()) {
-            return $this->response->error($validator->errors()->first(), 500);
-        }
 
-        return $this->postRepository->createStore($request['start_page'], $request['end_page'], $request['size'], $request['category_id']);
-    }
-
-    /**
-     * 获取网站内容
-     */
-    public function getStore(Request $request)
-    {
-        $productList = $this->postRepository->getStore($request->all());
-        $fractal = new Manager();
-        $resource = new Collection($productList, new PostStoreTransformer());
-        $resource->setPaginator(new IlluminatePaginatorAdapter($productList));
-        $data = $fractal->createData($resource)->toArray();
-        $data['extra'] = [
-            'filters' => [
-                'type',
-                'category_id',
-                'title',
-                'content',
-                'source',
-                'is_used',
             ],
             'columns' => [
                 'id',
-                'source',
-                'type',
-                'category_id',
-                'title',
+                'parent_id',
+                'uid',
                 'content',
-                'img',
-                'is_used',
                 'created_at',
+                'is_delete',
             ]
         ];
         return $data;
     }
 
-    /**
-     * 网站内容详情
-     */
-    public function getStoreDetail(Request $request)
-    {
-        $validator = Validator::make($request->all(), [
-            'id' => 'required|exists:post_store'
-        ]);
-        if ($validator->fails()) {
-            return $this->response->error($validator->errors()->first(), 500);
-        }
-
-        $post = $this->postRepository->getStoreDetail($request->all());
-        return $this->response->item($post, new StoreDetailTransformer());
-    }
 
     /**
-     * 内容列表(批量替换话题)
-     */
-    public function topicList(Request $request)
-    {
-        $productList = $this->postRepository->topicList($request->all());
-        $fractal = new Manager();
-        $resource = new Collection($productList, new PostTopicTransformer());
-        $resource->setPaginator(new IlluminatePaginatorAdapter($productList));
-        $data = $fractal->createData($resource)->toArray();
-        $data['extra'] = [
-            'filters' => [
-                'topic_id'
-            ],
-            'columns' => [
-                'id',
-                'created_at',
-                'uid',
-                'topic',
-                'img',
-                'content',
-            ]
-        ];
-        return $data;
-    }
-
-    /**
-     * 批量替换话题
+     * 删除评论
      */
-    public function TopicUpdate(Request $request)
+    public function commentDelete(Request $request)
     {
         $validator = Validator::make($request->all(), [
-            'topic_id' => 'required|integer',
-            'to_topic_id' => 'required|integer',
-            'ids' => 'required|array',
-            'ids.*' => 'required|integer',
+            'id' => 'required|integer',
         ]);
         if ($validator->fails()) {
             return $this->response->error($validator->errors()->first(), 500);
         }
-        return $this->postRepository->TopicUpdate($request->all());
+        return $this->circleMessageRepository->commentDelete($request->all());
     }
+
 }

+ 1 - 1
app/Models/InterestCircleMessage.php

@@ -19,7 +19,7 @@ class InterestCircleMessage extends Model
 
     public function imgs()
     {
-        return $this->hasMany('App\Models\InterestCircleMessageImg', 'circle_id', 'id');
+        return $this->hasMany('App\Models\InterestCircleMessageImg', 'msg_id', 'id');
     }
 
 }

+ 79 - 4
app/Repositories/Circle/CircleMessageRepository.php

@@ -11,6 +11,7 @@ namespace App\Repositories\Circle;
 
 use App\Models\InterestCircle;
 use App\Models\InterestCircleMessage;
+use App\Models\InterestCircleMessageComment;
 use Illuminate\Database\QueryException;
 use Dingo\Api\Http\Response;
 use Illuminate\Support\Carbon;
@@ -21,10 +22,13 @@ use Illuminate\Support\Facades\Redis;
 class CircleMessageRepository
 {
 
-    public function __construct(InterestCircle $interestCircle, InterestCircleMessage $interestCircleMessage)
+    public function __construct(InterestCircle $interestCircle,
+                                InterestCircleMessage $interestCircleMessage,
+                                InterestCircleMessageComment $interestCircleMessageComment)
     {
         $this->interestCircle = $interestCircle;
         $this->interestCircleMessage = $interestCircleMessage;
+        $this->interestCircleMessageComment = $interestCircleMessageComment;
     }
 
     /**
@@ -76,7 +80,9 @@ class CircleMessageRepository
      */
     public function messageRecommend($request)
     {
-        $circle = $this->interestCircleMessage->where('id', $request['id'])->first();
+        $circle = $this->interestCircleMessage
+            ->where('id', $request['id'])
+            ->where('circle_id', $request['circle_id'])->first();
         if (!$circle) {
             return Response::create([
                 'message' => '获取留言信息失败',
@@ -99,7 +105,7 @@ class CircleMessageRepository
 
         } catch (QueryException $exception) {
             DB::rollBack();
-            Log::debug('推荐留言:' . $request['id'] . $exception->getMessage());
+            Log::debug('推荐留言:' . $request['id'] . '-' . $request['circle_id'] . $exception->getMessage());
             return Response::create([
                 'message' => '操作失败,请重试',
                 'error' => $exception->getMessage(),
@@ -113,7 +119,10 @@ class CircleMessageRepository
      */
     public function delete($request)
     {
-        $circle = $this->interestCircleMessage->where('id', $request['id'])->first();
+        $circle = $this->interestCircleMessage
+            ->where('id', $request['id'])
+            ->where('circle_id', $request['circle_id'])
+            ->first();
         if (!$circle) {
             return Response::create([
                 'message' => '获取留言信息失败',
@@ -136,4 +145,70 @@ class CircleMessageRepository
             ]);
         }
     }
+
+    /**
+     * 圈子留言评论列表
+     */
+    public function commentList($request)
+    {
+        $perPage = isset($request['per_page']) ? $request['per_page'] : 20;
+        $where = [];
+        if (isset($request['circle_id'])) {
+            $where[] = ['circle_id', $request['circle_id']];
+        }
+        if (isset($request['msg_id'])) {
+            $where[] = ['msg_id', $request['msg_id']];
+        }
+
+        return $this->interestCircleMessageComment
+            ->where($where)
+            ->orderBy('created_at', 'desc')
+            ->paginate($perPage);
+    }
+
+    /**
+     * 删除评论
+     */
+    public function commentDelete($request)
+    {
+        $comment = $this->interestCircleMessageComment->find($request['id']);
+        if (!$comment) {
+            return Response::create([
+                'message' => '获取评论信息失败',
+                'status_code' => 500
+            ]);
+        }
+
+        if ($comment->is_delete == 1) {
+            return Response::create([
+                'message' => '该评论已经删除',
+                'status_code' => 500
+            ]);
+        }
+
+        DB::beginTransaction();
+        try {
+            $comment->is_delete = 1;
+            $comment->save();
+
+            DB::commit();
+//            Redis::SADD('delete_post_comment_ids', $comment->id);
+//
+//            if (!$comment->parent_id) {
+//                Redis::DEL('post_new_comment_' . $comment->post_id);
+//            } else {
+//                Redis::DEL('post_new_reply_' . $comment->id);
+//            }
+            return Response::create();
+
+        } catch (QueryException $exception) {
+            DB::rollBack();
+            Log::debug('删除评论:' . $request['id'] . $exception->getMessage());
+            return Response::create([
+                'message' => '操作失败,请重试',
+                'error' => $exception->getMessage(),
+                'status_code' => 500
+            ]);
+        }
+    }
 }

+ 93 - 75
app/Repositories/TopicRepository.php

@@ -18,49 +18,55 @@ use Illuminate\Database\QueryException;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Redis;
 
-class TopicRepository {
-    public function __construct(Topic $topic,CategoryTopic $categoryTopic,MemberFollowTopic $memberFollowTopic){
+class TopicRepository
+{
+    public function __construct(Topic $topic, CategoryTopic $categoryTopic, MemberFollowTopic $memberFollowTopic)
+    {
         $this->topic = $topic;
         $this->categoryTopic = $categoryTopic;
         $this->memberFollowTopic = $memberFollowTopic;
     }
+
     //列表
-    public function index($request){
+    public function index($request)
+    {
         $perPage = isset($request['per_page']) ? $request['per_page'] : 20;
         $where = [];
-        if(isset($request['name'])){
+        if (isset($request['name'])) {
             $where[] = ['name', 'like', "%{$request['name']}%"];
         }
-        if(isset($request['topic_status'])){
-            if($request['topic_status'] == 'is_suggest'){
+        if (isset($request['topic_status'])) {
+            if ($request['topic_status'] == 'is_suggest') {
                 $where[] = ['is_suggest', 1];
             }
-            if( $request['topic_status'] == 'is_hot'){
+            if ($request['topic_status'] == 'is_hot') {
                 $where[] = ['is_hot', 1];
             }
-            if($request['topic_status'] == 'is_open'){
+            if ($request['topic_status'] == 'is_open') {
                 $where[] = ['is_open', 1];
             }
-            if($request['topic_status'] == 'is_close'){
+            if ($request['topic_status'] == 'is_close') {
                 $where[] = ['is_open', 0];
             }
         }
 
         return $this->topic
             ->where($where)
-            ->orderBy('is_hot','desc')
-            ->orderBy('is_suggest','desc')
-            ->orderBy('is_open','desc')
-            ->orderBy('id','desc')
+            ->orderBy('is_hot', 'desc')
+            ->orderBy('is_suggest', 'desc')
+            ->orderBy('is_open', 'desc')
+            ->orderBy('id', 'desc')
             ->paginate($perPage);
     }
+
     //新增
-    public function create($request){
-        $topic = $this->topic->where(['name'=>$request['name']])->first();
-        if($topic){
+    public function create($request)
+    {
+        $topic = $this->topic->where(['name' => $request['name']])->first();
+        if ($topic) {
             return Response::create([
-                'message'  => '该话题已存在',
-                'status_code'   => 500
+                'message' => '该话题已存在',
+                'status_code' => 500
             ]);
         }
 
@@ -68,20 +74,21 @@ class TopicRepository {
             'name' => $request['name'],
             'img' => $request['img'],
             'desc' => $request['desc'],
+            'circle_id' => $request['desc'] ?? 0,
         ];
-        if(!empty($request['base_count'])){
+        if (!empty($request['base_count'])) {
             $data['base_count'] = $request['base_count'];
         }
-        if(isset($request['category_ids'])){
+        if (isset($request['category_ids'])) {
             $category_ids = explode(',', $request['category_ids']);
         }
         DB::beginTransaction();
-        try{
+        try {
             $topicInfo = $this->topic->create($data);
-            if($topicInfo){
-                if($category_ids){
+            if ($topicInfo) {
+                if ($category_ids) {
                     $category_topic_data = [];
-                    foreach($category_ids as $value){
+                    foreach ($category_ids as $value) {
                         $category_topic_data[] = [
                             'category_id' => $value,
                             'topic_id' => $topicInfo->id,
@@ -93,54 +100,56 @@ class TopicRepository {
             DB::commit();
             Redis::zadd('topic.name', $topicInfo->id, $topicInfo->name);
             return Response::create();
-        }catch (QueryException $exception){
+        } catch (QueryException $exception) {
             DB::rollBack();
-            Log::debug('新增话题:'.$exception->getMessage());
+            Log::debug('新增话题:' . $exception->getMessage());
             return Response::create([
-                'message'  => '新增话题,请重试',
+                'message' => '新增话题,请重试',
                 'error' => $exception->getMessage(),
-                'status_code'   => 500
+                'status_code' => 500
             ]);
         }
     }
 
-    public function edit($request){
-        $topic = $this->topic->where(['id'=>$request['id']])->first();
-        if(!$topic){
+    public function edit($request)
+    {
+        $topic = $this->topic->where(['id' => $request['id']])->first();
+        if (!$topic) {
             return Response::create([
-                'message'  => '该话题不存在',
-                'status_code'   => 500
+                'message' => '该话题不存在',
+                'status_code' => 500
             ]);
         }
         $oldName = $topic->name;
-        $_topic = $this->topic->where(['name'=>$request['name']])->where('id','<>',$topic->id)->first();
-        if($_topic){
+        $_topic = $this->topic->where(['name' => $request['name']])->where('id', '<>', $topic->id)->first();
+        if ($_topic) {
             return Response::create([
-                'message'  => '该话题已存在',
-                'status_code'   => 500
+                'message' => '该话题已存在',
+                'status_code' => 500
             ]);
         }
 
         $topic->name = $request['name'];
         $topic->img = $request['img'];
         $topic->desc = $request['desc'];
-        if(!empty($request['base_count'])){
+        $topic->circle_id = $request['circle_id'] ?? 0;
+        if (!empty($request['base_count'])) {
             $topic->base_count = $request['base_count'];
         }
         $category_ids = [];
-        if(!empty($request['category_ids'])){
+        if (!empty($request['category_ids'])) {
             $category_ids = explode(',', $request['category_ids']);
         }
         DB::beginTransaction();
-        try{
+        try {
             //保存
             $topicInfo = $topic->save();
             //删除原来关联关系
-            $this->categoryTopic->where(['topic_id'=>$topic->id])->delete();
-            if($topicInfo){
-                if($category_ids){
+            $this->categoryTopic->where(['topic_id' => $topic->id])->delete();
+            if ($topicInfo) {
+                if ($category_ids) {
                     $category_topic_data = [];
-                    foreach($category_ids as $value){
+                    foreach ($category_ids as $value) {
                         $category_topic_data[] = [
                             'category_id' => $value,
                             'topic_id' => $topic->id,
@@ -150,68 +159,77 @@ class TopicRepository {
                 }
             }
             DB::commit();
-            if($oldName != $topic->name){
+            if ($oldName != $topic->name) {
                 Redis::zrem('topic.name', $oldName);
                 Redis::zadd('topic.name', $topic->id, $topic->name);
             }
             return Response::create();
-        }catch (QueryException $exception){
+        } catch (QueryException $exception) {
             DB::rollBack();
-            Log::debug('编辑话题:'.$exception->getMessage());
+            Log::debug('编辑话题:' . $exception->getMessage());
             return Response::create([
-                'message'  => '编辑话题,请重试',
+                'message' => '编辑话题,请重试',
                 'error' => $exception->getMessage(),
-                'status_code'   => 500
+                'status_code' => 500
             ]);
         }
     }
+
     //修改
-    public function update($request){
+    public function update($request)
+    {
         $topic = $this->topic->where('id', $request['id'])->first();
-        if(!$topic){
+        if (!$topic) {
             return Response::create([
-                'message'  => '该话题不存在',
-                'status_code'   => 500
+                'message' => '该话题不存在',
+                'status_code' => 500
             ]);
         }
-        if(isset($request['is_open']) && $request['is_open'] !== null){
+        if (isset($request['is_open']) && $request['is_open'] !== null) {
             $topic->is_open = $request['is_open'];
         }
-        if(!empty($request['type'])){
-            if($topic->is_open == 0){
+        if (!empty($request['type'])) {
+            if ($topic->is_open == 0) {
                 return Response::create([
-                    'message'  => '该话题未开启',
-                    'status_code'   => 500
+                    'message' => '该话题未开启',
+                    'status_code' => 500
                 ]);
             }
-            if(isset($request['type']) && $request['type'] == 1){
+            if (isset($request['type']) && $request['type'] == 1) {
                 $topic->is_suggest = $request['status'];
             }
-            if(isset($request['type']) && $request['type'] == 2){
+            if (isset($request['type']) && $request['type'] == 2) {
                 $topic->is_hot = $request['status'];
             }
         }
 
         $res = $topic->save();
-        if($res){
+        if ($res) {
             return Response::create();
         }
     }
+
     //详情
-    public function view($request){
+    public function view($request)
+    {
         return $this->topic->where('id', $request['id'])->first();
     }
+
     //获取多个话题
-    public function getTopics($ids = []){
-        return $this->topic->whereIn('id', $ids)->select('id','name')->get();
+    public function getTopics($ids = [])
+    {
+        return $this->topic->whereIn('id', $ids)->select('id', 'name')->get();
     }
-    public function getMemberTopics($uid){
-       return $this->memberFollowTopic
-            ->leftJoin('topic','topic.id','=','member_follow_topic.topic_id')
-            ->where('member_follow_topic.uid',$uid)
-            ->select('topic.id','topic.name')
+
+    public function getMemberTopics($uid)
+    {
+        return $this->memberFollowTopic
+            ->leftJoin('topic', 'topic.id', '=', 'member_follow_topic.topic_id')
+            ->where('member_follow_topic.uid', $uid)
+            ->select('topic.id', 'topic.name')
             ->get();
     }
+
     /**
      * 重置话题redis
      */
@@ -220,15 +238,15 @@ class TopicRepository {
         $TopicName = $this->topic->pluck('id', 'name')->toArray();
 
         $res = Redis::zadd('topic.name', $TopicName);
-        if($res){
+        if ($res) {
             return Response::create([
-                'message'  => '重置话题成功',
-                'status_code'   => 500
+                'message' => '重置话题成功',
+                'status_code' => 500
             ]);
-        }else{
+        } else {
             return Response::create([
-                'message'  => '重置话题失败',
-                'status_code'   => 500
+                'message' => '重置话题失败',
+                'status_code' => 500
             ]);
         }
     }

+ 37 - 0
app/Transformers/Circle/CommentTransformer.php

@@ -0,0 +1,37 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/6/10
+ * Time: 10:56
+ */
+
+namespace App\Transformers\Circle;
+use App\Models\InterestCircleMessageComment;
+use Illuminate\Support\Carbon;
+use League\Fractal\TransformerAbstract;
+
+class CommentTransformer extends TransformerAbstract
+{
+    public function transform(InterestCircleMessageComment $interestCircleMessageComment)
+    {
+        if($interestCircleMessageComment['is_delete']){
+            $content = '该评论已被删除';
+        }elseif($interestCircleMessageComment['reply_username']){
+            $content = '回复 @'.subtext($interestCircleMessageComment['reply_username'], 6).': '.$interestCircleMessageComment['content'];
+        }else{
+            $content = $interestCircleMessageComment['content'];
+        }
+        return [
+            'id' => $interestCircleMessageComment['id'],
+            'msg_id' => $interestCircleMessageComment['msg_id'],
+            'parent_id' => $interestCircleMessageComment['parent_id'],
+            'uid' => $interestCircleMessageComment['uid'],
+            'username' => $interestCircleMessageComment['username'],
+            'avatar' => $interestCircleMessageComment['avatar'],
+            'content' => $content,
+            'created_at' => Carbon::parse($interestCircleMessageComment['created_at'])->toDateTimeString(),
+            'is_delete' => $interestCircleMessageComment['is_delete'],
+        ];
+    }
+}

+ 44 - 0
app/Transformers/Circle/MessageDetailTransformer.php

@@ -0,0 +1,44 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/6/6
+ * Time: 14:08
+ */
+
+namespace App\Transformers\Circle;
+
+use App\Models\InterestCircle;
+use App\Models\InterestCircleMessage;
+use App\Models\Post;
+use App\Traits\PostTrait;
+use App\Traits\UserTrait;
+use Illuminate\Support\Carbon;
+use League\Fractal\TransformerAbstract;
+
+class MessageDetailTransformer extends TransformerAbstract
+{
+    use UserTrait;
+
+    public function transform(InterestCircleMessage $interestCircleMessage)
+    {
+        $user = $this->getShortUserInfo($interestCircleMessage['uid']);
+        $imgs = $interestCircleMessage->imgs->toArray();
+        $images=[];
+        foreach($imgs as $key=>$value){
+            $images[$key]['image'] = $value['image'];
+        }
+        return [
+            'id' => $interestCircleMessage['id'],
+            'created_at' => Carbon::parse($interestCircleMessage['created_at'])->toDateTimeString(),
+            'user' => $user ? $user : new \stdClass(),
+            'good' => $interestCircleMessage['good'],
+            'bad' => $interestCircleMessage['bad'],
+            'comment_count' => $interestCircleMessage['comment_count'],
+            'content' => $interestCircleMessage['content'],
+            'imgs' => $images,
+        ];
+    }
+
+}

+ 1 - 0
app/Transformers/DetailTopicTransformer.php

@@ -31,6 +31,7 @@ class DetailTopicTransformer extends TransformerAbstract{
             'page_count' => 0,
             'created_at' => Carbon::parse($topic['created_at'])->toDateTimeString(),
             'category_list'=>$category,
+            'circle_id'=>$topic['circle_id'],
             'base_count'=>$topic['base_count'],
         ];
     }

+ 1 - 0
database/migrations/2019_10_09_062401_create_interest_circle_message_imgs_table.php

@@ -16,6 +16,7 @@ class CreateInterestCircleMessageImgsTable extends Migration
         Schema::create('interest_circle_message_imgs', function (Blueprint $table) {
             $table->bigIncrements('id');
             $table->integer('circle_id')->default(0)->comment('圈子ID');
+            $table->integer('msg_id')->default(0)->comment('留言ID');
             $table->string('image')->default('')->comment('图片地址');
             $table->timestamps();
         });

+ 2 - 0
database/migrations/2019_10_09_062552_create_interest_circle_message_comments_table.php

@@ -17,6 +17,8 @@ class CreateInterestCircleMessageCommentsTable extends Migration
             $table->bigIncrements('id');
             $table->integer('circle_id')->default(0)->comment('圈子ID');
             $table->integer('uid')->default(0)->comment('用户ID');
+            $table->string('username')->default('')->comment('用户名称');
+            $table->string('avatar')->default('')->comment('用户图像');
             $table->integer('msg_id')->default(0)->comment('留言ID');
             $table->integer('parent_id')->default(0)->comment('上级留言ID');
             $table->integer('reply_uid')->default(0)->comment('回复ID');

+ 35 - 0
database/migrations/2019_10_11_055646_add_column_circle_id_to_topic.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddColumnCircleIdToTopic extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('topic', function (Blueprint $table) {
+            //
+            $table->integer('circle_id')
+                ->default(0)
+                ->comment('圈子ID');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('topic', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 10 - 0
routes/api.php

@@ -206,5 +206,15 @@ $api->version('v1', [
         $api->put('circle/member/black', 'CircleController@setCircleBlack');
         //圈子留言列表
         $api->get('circle/messages', 'CircleController@messageList');
+        //圈子留言详情
+        $api->get('circle/message', 'CircleController@messageDetail');
+        //圈子留言推荐
+        $api->put('circle/message/recommend', 'CircleController@messageRecommend');
+        //圈子留言删除
+        $api->delete('circle/message', 'CircleController@deleteMessage');
+        //圈子留言评论列表
+        $api->get('circle/message/comments', 'CircleController@commentList');
+        //圈子留言评论删除
+        $api->delete('circle/message/comment', 'CircleController@commentDelete');
     });
 });