|
@@ -0,0 +1,39 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\api\controller;
|
|
|
+
|
|
|
+use app\common\controller\Api;
|
|
|
+use think\Db;
|
|
|
+/**
|
|
|
+ * 漂流瓶
|
|
|
+ */
|
|
|
+class Piaoliuping extends Api
|
|
|
+{
|
|
|
+ protected $noNeedLogin = [];
|
|
|
+ protected $noNeedRight = ['*'];
|
|
|
+
|
|
|
+ //捡一个
|
|
|
+ public function getone(){
|
|
|
+ $rs = Db::name('piaoliuping')->where('user_id','NEQ',$this->auth->id)->orderRaw('rand()')->find();
|
|
|
+ $this->success('success',$rs);
|
|
|
+ }
|
|
|
+
|
|
|
+ //扔一个
|
|
|
+ public function addone(){
|
|
|
+ $content = input('content','','trim,strip_tags,htmlspecialchars');
|
|
|
+ $cityname = input('cityname','','trim');
|
|
|
+ if(empty($content)){
|
|
|
+ $this->error('写点什么吧...');
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'content' => $content,
|
|
|
+ 'createtime' => time(),
|
|
|
+ 'cityname' => $cityname,
|
|
|
+ ];
|
|
|
+
|
|
|
+ Db::name('piaoliuping')->insertGetId($data);
|
|
|
+ $this->success('成功');
|
|
|
+ }
|
|
|
+}
|