仓库初始化
This commit is contained in:
235
application/api/controller/UserZone.php
Normal file
235
application/api/controller/UserZone.php
Normal file
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class UserZone extends BaseCom
|
||||
{
|
||||
//发布动态
|
||||
public function publish_zone()
|
||||
{
|
||||
$key_name = "api:usezone:publish_zone:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
$images = input('images', '');
|
||||
$content = input('content', '');
|
||||
$topic_id = input('topic_id', '');
|
||||
$room_id = input('room_id', 0);
|
||||
$ip = input('ip', 0);
|
||||
$reslut = model('UserZone')->publish_zone($this->uid, $images, $content,$topic_id,$room_id,$ip);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//动态列表
|
||||
public function zone_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$reslut = model('UserZone')->get_zone_list($this->uid, $page, $page_limit);
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//动态详情
|
||||
public function zone_detail()
|
||||
{
|
||||
$zid = input('id', 0);
|
||||
$reslut = model('UserZone')->get_zone_info($zid,$this->uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//动态评论
|
||||
public function comment_zone()
|
||||
{
|
||||
$key_name = "api:usezone:comment_zone:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$zid = input('id', 0);
|
||||
$content = input('content', '');
|
||||
$pid = input('pid', 0);
|
||||
$reply_to = input('reply_to', 0);
|
||||
$reslut = model('UserZone')->comment_zone($this->uid, $zid, $content,$pid, $reply_to);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//动态评论列表
|
||||
public function get_comment_list()
|
||||
{
|
||||
$key_name = "api:usezone:get_comment_list:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$zid = input('id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
|
||||
$reslut = model('UserZone')->getCommentsWithReplies($zid, $page, $page_limit);
|
||||
|
||||
redis_unlock($key_name);
|
||||
if($reslut['code'] == 1){
|
||||
$resluts['data']['list'] = $reslut['data'];
|
||||
$total = model('UserZone')->getCommentCount($zid);
|
||||
$resluts['data']['total'] = $total;
|
||||
}
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $resluts['data']);
|
||||
}
|
||||
|
||||
//动态点赞
|
||||
public function like_zone()
|
||||
{
|
||||
$key_name = "api:usezone:praise_zone:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
$zid = input('id', '');
|
||||
$reslut = model('UserZone')->praise_zone($this->uid, $zid);
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//点赞列表
|
||||
public function like_list()
|
||||
{
|
||||
$zid = input('id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('UserZone')->get_like_list($zid, $page, $page_limit);
|
||||
return V(1, '获取成功', $reslut);
|
||||
}
|
||||
|
||||
//删除动态
|
||||
public function delete_zone()
|
||||
{
|
||||
$zid = input('id', 0);
|
||||
$reslut = model('UserZone')->delete_zone($this->uid, $zid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//删除评论
|
||||
public function delete_zone_comment()
|
||||
{
|
||||
$cid = input('id', 0);
|
||||
$reslut = model('UserZone')->delete_zone_comment($this->uid, $cid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//话题列表
|
||||
public function topic_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('Topic')->get_topic_list($page, $page_limit);
|
||||
return V(1, '获取成功', $reslut);
|
||||
}
|
||||
|
||||
//获取动态引用最多的四条话题
|
||||
public function get_zone_topic()
|
||||
{
|
||||
$reslut = model('Topic')->get_zone_topic();
|
||||
return V(1, '获取成功', $reslut);
|
||||
}
|
||||
|
||||
//引用话题的动态
|
||||
public function get_zone_topic_list()
|
||||
{
|
||||
$topic_id = input('topic_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('UserZone')->get_zone_topic_list($this->uid, $topic_id, $page, $page_limit);
|
||||
return V(1, '获取成功', $reslut);
|
||||
}
|
||||
|
||||
//用户主页的动态列表
|
||||
// public function get_user_zone_list()
|
||||
// {
|
||||
// $from_id = input('user_id',0);
|
||||
// $page = input('page', 1);
|
||||
// $page_limit = input('page_limit', 30);
|
||||
// $reslut = model('UserZone')->get_user_zone_list($this->uid, $from_id, $page, $page_limit);
|
||||
//
|
||||
// return V(1, '获取成功', $reslut);
|
||||
// }
|
||||
|
||||
|
||||
//扩列
|
||||
public function expand_zone()
|
||||
{
|
||||
$key_name = "api:usezone:expand_zone:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$type = input('type', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('UserZone')->expand_zone($this->uid, $type, $page, $page_limit);
|
||||
redis_unlock($key_name);
|
||||
//版本号
|
||||
$system = request()->header('system');
|
||||
$app_version = request()->header('App-Version');
|
||||
if(!$app_version){
|
||||
$app_version = input('App-Version');
|
||||
}
|
||||
// var_dump($app_version);
|
||||
$api_version = 0;
|
||||
if ($system == 'iOS') {
|
||||
$api_versions = db::name('version')->where(['type' => 2, 'status' => 1])->order('id', 'desc')->find();
|
||||
$result = version_compare($api_versions['oldversion'],$app_version);
|
||||
if ($result < 0) {
|
||||
$api_version = 1;
|
||||
}
|
||||
}
|
||||
return V(1, '获取成功', $reslut, $api_version);
|
||||
}
|
||||
|
||||
//动态打赏
|
||||
public function reward_zone()
|
||||
{
|
||||
$zid = input('id', 0);
|
||||
$gift_id = input('gift_id', 0);
|
||||
$num = input('num', 1);
|
||||
$is_pack = input('is_pack', 1);//2背包 1金币
|
||||
$reslut = model('GiveGift')->reward_zone($this->uid, $zid, $gift_id, $num, $is_pack);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//打赏列表
|
||||
public function reward_list()
|
||||
{
|
||||
$zid = input('id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('GiveGift')->zone_reward_list($this->uid, $zid, $page, $page_limit);
|
||||
return V(1, '获取成功', $reslut);
|
||||
}
|
||||
|
||||
//相互关注的用户(分享使用)
|
||||
public function mutual_follow()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('UserZone')->mutual_follow($this->uid, $page, $page_limit);
|
||||
return V(1, '获取成功', $reslut);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user