message send

This commit is contained in:
toogee 2020-03-28 22:03:25 +08:00
parent f49a8f2394
commit 65f36dd441
2 changed files with 38 additions and 1 deletions

1
app/.gitignore vendored
View File

@ -1,2 +1 @@
/api
/home

View File

@ -0,0 +1,38 @@
<?php
namespace app\api\controller;
use think\facade\Db;
use think\facade\Session;
use think\facade\Request;
use app\common\model\Message as MessageModel;
use app\common\model\MessageTo;
class Message
{
//send msg
public function sendMsg($sendId,$receveId,$data)
{
$msg = MessageModel::create($data);
$msgId = $msg->id;
$result = MessageTo::create(['send_id'=>$sendId,'receve_id'=>$receveId,'message_id'=>$msgId]);
if($result){
return true;
}
}
//receve msg
public function receveMsg($uid)
{
$msg = Db::name('message_to')
->alias('t')
->join('message m','t.message_id = m.id' )
->join('user u','t.send_id = u.id')
->field('t.id as id,name,title,link,receve_id,t.create_time as create_time')
->where('t.receve_id',$uid)
->where('t.delete_time',0)
->select();
return $msg;
}
}