public function postChorogCai()
{
is_login();
$data['cid'] = input('cid');
$data['uid'] = input('uid');
$iscai = input("iscai") != 1 ? 0 : 1;
//判断是否登陆
if (empty($data['cid']) || empty($data['uid'])) {
return error("缺少必要参数!");
}
if (!$f = Db::name("chorog")->where(array("id" => $data['cid']))->cache(true)->find()) {
return error("不存在这条地方志");
}
if ($iscai) {
if (db("chorog_cai")->where($data)->count()) {
return error("您已经点踩过了");
}
$data['create_time'] = time();
$data['cuid'] = $f['uid'];
if (db('chorog')->where(array('id' => $data['cid']))->setInc('cai_num', 1) && db('chorog_cai')->insert($data)) {
return success("", "点踩成功");
} else {
error("点踩失败");
}
} else {
if (!db("chorog_cai")->where($data)->count()) {
error("您还没点踩呢,怎么取消!");
}
if (db("chorog")->where(array('id' => $data['cid']))->setDec('cai_num', 1) && db("chorog_cai")->where($data)->delete()) {
return success("", "取消点踩成功");
} else {
return error("取消点踩失败");
}
}
}
thinkphp点赞取消赞连贯操作
最新推荐文章于 2021-03-11 00:34:46 发布