即时系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

47 lines
1.1 KiB

<?php
namespace app\enterprise\model;
use think\Model;
class MessageView extends Model
{
public static function addView($msg_id, $user_id, $file_id, $src)
{
$where = [
'compress_img' => $src,
'file_id' => $file_id
];
$fileRes = File::where($where)->find();
if (!$fileRes) {
return false;
}
$data = [
'msg_id' => $msg_id,
'user_id' => $user_id,
];
$query = self::where($data)->field('id')->find();
if ($query) {
return false;
}
$data['type'] = 1;
$data['status'] = 1;
$data['create_time'] = time();
$data['view_time'] = time();
(new self())->save($data);
return true;
}
public static function isView($msg_id, $user_id)
{
$where = [
'msg_id' => $msg_id,
'user_id' => $user_id,
'type' => 1,
'status' => 1
];
$query = self::where($where)->field('id')->find();
return $query ? 1 : 0;
}
}