gq 8 lat temu
rodzic
commit
5b2ac5463e

+ 245 - 3
server/app/Http/Controllers/Api/V1/HomeController.php

xqd
@@ -2,10 +2,252 @@
 
 namespace App\Http\Controllers\Api\V1;
 
+use App\Http\Controllers\Api\V1\Controller;
+use App\Models\BaseSettingsModel;
+use App\Models\DreamImages;
+use App\Models\DreamInfoModel;
+use App\Models\SystemInfoModel;
+use App\Models\UserCareUser;
+use App\Models\UserDream;
+use App\Models\UserInfoModel;
 use Illuminate\Http\Request;
-use App\Http\Controllers\Controller;
-
+use App\Services\Base\ErrorCode;
 class HomeController extends Controller
 {
-    //
+    /**
+     * @api {get} /api/user/index/ 用户信息
+     * @apiDescription 用户信息
+     * @apiGroup Auth
+     * @apiPermission Passport
+     * @apiVersion 0.1.0
+     * @apiParam {int} user_id 用户ID
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     * {
+     * "nickname": "",  名字
+     * "pic": "",   头像
+     *"tall": "",  身高
+     *"job": "",  职业
+     *"emotion": "1",  情感
+     * "address": "",地址
+     * "score": 1000,  支持分
+     * "care": 4,  关注
+     * "fens": 3,   粉丝
+     * "user_dream": [
+     *{
+     * "id": 2,
+     * "dream": "去旅游去旅游2",
+     * "about": "欧冠胡234",
+     * "money": 200,
+     * "time": 0,
+     * "get_money": 0,
+     * "dream_imgs": [
+     *  {
+     * {
+     * "id": 3,
+     *"dream": "3去旅游",
+     *"about": "",
+     * "money": 0,
+     *"time": 0,
+     * "get_money": 0,
+     * "mark": 0,
+     * "status": 0,
+     *  "created_at": null,
+     * "updated_at": null,
+     * "deleted_at": null,
+     *  "pic": [],
+     *  "pivot": {
+     *"user_id": 1,
+     * "dream_id": 3
+     * },
+     * "dream_imgs": []
+     *  },
+     * "near_dream_pic": [
+     * {
+     * "pic": "234"
+     *  },
+     *    ]
+      * }
+     *  }
+     * @apiErrorExample {json} Error-Response:
+     *HTTP/1.1 400 Bad Request
+     *{
+     *"status": false,
+     *"status_code": 1105,
+     * "message": "用户不存在",
+     *"data": null
+     *  }
+     */
+    public function index(Request $request)
+    {
+        $user_id = $request->user_id;
+        $care = UserCareUser::where('user_id',$user_id)->get();
+        $fens = UserCareUser::where('other_user_id',$user_id)->get();
+        $user = UserInfoModel::find($user_id);
+        if (count($user == 0)) return $this->error(ErrorCode::USER_DOES_NOT_EXIST);
+        $job = BaseSettingsModel::where(['category' => 'job'])->where(['key' => $user->job])->first();
+        $job = count($job) > 0 ? $job->value : '';
+        $emotion = BaseSettingsModel::where(['category' => 'emotion'])->where(['key' => $user->emotion])->first();
+        $emotion = count($emotion) > 0 ? $emotion->value : '';
+//        当前梦想
+        $near_dream_id = UserDream::where('user_id',$user_id)->orderBy('id','desc')->first()->dream_id;
+        $near_dream =DreamInfoModel::find($near_dream_id);
+//         封面图片
+        $near_dream_pic = DreamImages::where('dream_id',$near_dream_id)->select('pic')->get();
+//        曾经的梦想
+        $dreams = $user->UserDream;
+
+        foreach ($dreams as $dream){
+            $dream->pic = $dream->dreamImgs;
+        }
+
+        $user->score = 1000;//自定义 算法
+        $user->care = count($care);
+        $user->fens = count($fens);
+        $user->job = $job;
+        $user->emotion = $emotion;
+//         支持的梦想
+        $sup_dreams = $user->supDream;
+
+        foreach ($sup_dreams as $sup_dream){
+            $sup_dream->pic = $sup_dream->dreamImgs;
+        }
+
+        return $this->api(compact('user','near_dream','sup_dreams','near_dream_pic'));
+
+    }
+
+    /**
+     * @api {post} /api/user/support 支持梦想
+     * @apiDescription 支持梦想
+     * @apiGroup Auth
+     * @apiPermission Passport
+     * @apiVersion 0.1.0
+     * @apiParam {int} coin 支持梦想币数量
+     * @apiParam {int} dream_id 梦想ID
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     *{
+     * "status": true,
+     * "status_code": 0,
+     *"message": "",
+     *"data": ""
+     *}
+     * @apiErrorExample {json} Error-Response:
+     *HTTP/1.1 400 Bad Request
+     * {
+     *     "state": false,
+     *     "code": 1000,
+     *     "message": "传入参数不正确",
+     *     "data": null or []
+     * }
+     *  可能出现的代码
+     * {
+    *"status": false,
+    *"status_code": 1303,
+    *"message": "商户余额不足",
+   * "data": null
+  *  }
+     *
+     */
+    public function support(Request $request)
+    {
+        $user = $this->getUser();
+        $dream_id = $request->dream_id;
+        $dream_info = DreamInfoModel::find($dream_id);
+        $validator = \Validator::make($request->all(),
+            [
+                'coin'  => 'required',
+                'dream_id'  => 'required',
+            ],
+            [
+                'coin.required'  => '梦想币不能为空',
+                'dream_id.required'  => '支持对象不能为空',
+            ]
+        );
+
+        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
+
+        $coin = $request->coin;
+
+        if ($user->money < $coin) {
+            return $this->error(ErrorCode::MERCHANT_BALANCE_NOT_ENOUGH);
+        }else{
+            $user->money  =  $user->money - $coin;
+            $user->save();
+            $dream_info->get_money += $coin;
+            $dream_info->save();
+            $data = [
+                'user_id'=>$user->id,
+                'other_id'=>$dream_id,
+                'coin'=>$coin,
+            ];
+
+          $ok =   SystemInfoModel::create($data);
+            if (!$ok) {
+                return $this->error(ErrorCode::MERCHANT_SERVICE_STATUS_INVALID);
+            }
+            return $this->api('');
+        }
+    }
+    /**
+     * @api {post} /api/auth/bank_card/update 更新银行卡
+     * @apiDescription 更新银行卡
+     * @apiGroup Auth
+     * @apiPermission Passport
+     * @apiVersion 0.1.0
+     * @apiParam {int} user_id 用户ID
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     * {
+     *     "state": true,
+     *     "code": 0,
+     *     "message": "success",
+     *     "data": {
+     *         ....
+     *     }
+     * }
+     * @apiErrorExample {json} Error-Response:
+     *HTTP/1.1 400 Bad Request
+     * {
+     *     "state": false,
+     *     "code": 1000,
+     *     "message": "传入参数不正确",
+     *     "data": null or []
+     * }
+     */
+    public function interaction(Request $request)
+    {
+
+    }
+    /**
+     * @api {post} /api/auth/bank_card/update 更新银行卡
+     * @apiDescription 更新银行卡
+     * @apiGroup Auth
+     * @apiPermission Passport
+     * @apiVersion 0.1.0
+     * @apiParam {int} user_id 用户ID
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     * {
+     *     "state": true,
+     *     "code": 0,
+     *     "message": "success",
+     *     "data": {
+     *         ....
+     *     }
+     * }
+     * @apiErrorExample {json} Error-Response:
+     *HTTP/1.1 400 Bad Request
+     * {
+     *     "state": false,
+     *     "code": 1000,
+     *     "message": "传入参数不正确",
+     *     "data": null or []
+     * }
+     */
+    public function paihang(Request $request)
+    {
+
+    }
 }

+ 40 - 9
server/app/Http/Controllers/Api/V1/MyController.php

xqd xqd xqd xqd
@@ -2,10 +2,12 @@
 
 namespace App\Http\Controllers\Api\V1;
 
+use App\Models\DreamImages;
 use App\Models\DreamInfoModel;
 use App\Models\ReplyCommentsInfo;
+use App\Models\UserDream;
 use Illuminate\Http\Request;
-use App\Library\Protocol\ErrorCode;
+use App\Services\Base\ErrorCode;
 class MyController extends Controller
 {
     /**
@@ -352,18 +354,32 @@ class MyController extends Controller
      * @api {post} /api/my/add_dream 发布梦想(addDream)
      * @apiDescription 发布梦想(addDream)
        * @apiParam {string}  pic   梦想图片 数组
+       * @apiParam {string}  dream   梦想标题
+       * @apiParam {string}  about   梦想介绍
+       * @apiParam {int}  money   梦想币
      * @apiGroup Auth
      * @apiPermission Passport
      * @apiVersion 0.1.0
      * @apiSuccessExample {json} Success-Response:
+     * {
+     * "status": true,
+     *"status_code": 0,
+     *"message": "",
+     *"data": ""
+     *}
      * HTTP/1.1 200 OK
      * @apiErrorExample {json} Error-Response:
+     * {
+     *"status": false,
+     *"status_code": 600,
+     *"message": "保存用户数据失败",
+     *"data": null
+     * }
      * HTTP/1.1 400 Bad Request
      */
     public function addDream(Request $request)
     {
         $user = $this->getUser();
-
         $validator = \Validator::make($request->all(),
             [
                 'dream'  => 'required',
@@ -377,7 +393,6 @@ class MyController extends Controller
                 'money.integer'  => '梦想币必须是正整数',
             ]
         );
-
         if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
 
         $data = $request->except('_token','pic');
@@ -390,13 +405,29 @@ class MyController extends Controller
             $data1['user_id'] = $user->id;
             $data1['created_at'] = date('Y-m-d H:i:s');
             $data1['updated_at'] = date('Y-m-d H:i:s');
+            $ok = UserDream::create($data1);
+            $arr = $request->pic;
+            $arr1 = [];
+            if ($ok) {
+                if (is_array($arr)) {
+                    foreach ($arr as $k => $v){
+                        $arr1[] = [
+                            'dream_id'=>$dream_id,
+                            'pic' => $v,
+                            'created_at' =>date('Y-m-d H:i:s'),
+                            'updated_at' =>date('Y-m-d H:i:s'),
+                        ];
+                    }
+                    DreamImages::insert($arr1);
+                }
+                return $this->api('');
+            }else{
+                DreamInfoModel::destroy($dream_id);
+                return $this->error(ErrorCode::SAVE_USER_FAILED);
+            }
+        }else{
+            return $this->error(ErrorCode::SAVE_USER_FAILED);
         }
-        $arr = $request->pic;
-
-        if (is_array($arr)) {
-
-        }
-        return $arr;
     }
 
     /**

+ 0 - 435
server/app/Library/Logger/Logger.php

xqd
@@ -1,435 +0,0 @@
-<?php
-namespace App\Library\Logger;
-
-/**
- * Created by PhpStorm.
- * User: lhz
- * Date: 2016-5-31
- * Time: 8:50
- * 日志器
- */
-
-use Fluent\Logger\FluentLogger;
-
-class Logger {
-    //常量定义
-    const DEBUG     = 0b00000001; //Debug: debug-level messages
-    const INFO      = 0b00000010; //Informational: informational messages
-    const NOTICE    = 0b00000100; //Notice: normal but significant condition
-    const WARNING   = 0b00001000; //Warning: warning conditions
-    const ERROR     = 0b00010000; //Error: error conditions
-    const FATAL     = 0b00100000; //Critical: critical conditions
-    const ALERT     = 0b01000000; //Alert: action must be taken immediately
-    const EMERGENCY = 0b10000000; //Emergency: system is unusable
-    const PRE_DEFINE_ALL    = self::EMERGENCY | self::ALERT | self::FATAL | self::ERROR | self::WARNING | self::NOTICE | self::INFO | self::DEBUG;
-    const PRE_DEFINE_ERROR  = self::EMERGENCY | self::ALERT | self::FATAL | self::ERROR;
-    const PRE_DEFINE_WARN   = self::PRE_DEFINE_ERROR | self::WARNING;
-    const PRE_DEFINE_INFO   = self::WARNING | self::NOTICE | self::INFO | self::DEBUG;
-
-    const DEVELOP   = 'development';
-    const PRODUCT   = 'production';
-
-    //单例对象
-    static $_instance           = NULL;
-
-    //邮件
-    static $_mailer             = NULL;
-
-    //fluentd
-    private $_fluentd           = NULL;
-
-    //日志句柄
-    private $_fp                = NULL;
-
-    //日志级别
-    private $_level             = self::FATAL;
-
-    //应用环境
-    private $_env               = self::DEVELOP;
-
-    //项目ID
-    private $_project           = '';
-
-    //邮件错误通知开关
-    private $_mailSwitch        = 'auto';//auto表示自动,级别在error及以上发邮件;on表示全部发送邮件;off表示关闭邮件警告
-
-    //debug_backtrace开关
-    private $_debugBackTrace    = true;
-
-    //日志类型枚举
-    private $_TYPES      = [
-        self::DEBUG     => 'DEBUG',
-        self::INFO      => 'INFO',
-        self::NOTICE    => 'NOTICE',
-        self::WARNING   => 'WARNING',
-        self::ERROR     => 'ERROR',
-        self::FATAL     => 'FATAL',
-        self::ALERT     => 'ALERT',
-        self::EMERGENCY => 'EMERGENCY',
-    ];
-
-    //日志类型分类
-    private $_CATEGORIES    = [
-        self::DEBUG     => 'INFO',
-        self::INFO      => 'INFO',
-        self::NOTICE    => 'INFO',
-        self::WARNING   => 'INFO',
-        self::ERROR     => 'ERROR',
-        self::FATAL     => 'ERROR',
-        self::ALERT     => 'ERROR',
-        self::EMERGENCY => 'ERROR',
-    ];
-
-    public function __construct($path = NULL)
-    {
-        $this->setPath($path);
-        $this->setLevel(self::EMERGENCY | self::ALERT | self::FATAL | self::ERROR | self::WARNING);
-    }
-
-    private function __clone() {
-    }
-
-    private function _formatMsg($msg, $type, $file = null, $line = null) {
-        $extra = '';
-        if ($this->_debugBackTrace && $file === null && $line === null) {
-            $traceLevel = 10;
-            $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, $traceLevel);
-            $cnt = count($trace);
-            if ($cnt > 0) {
-                foreach ($trace as $l) {
-                    if (isset($l['file']) && isset($l['line'])) {
-                        $extra .= sprintf("%s(%d)\n", $l['file'], $l['line']);
-                    }
-                }
-                $file = $trace[$cnt-1]['file'];
-                $line = $trace[$cnt-1]['line'];
-            }
-        }
-        if ($file === null) {
-            $file = __FILE__;
-        }
-        if ($line === null) {
-            $line = __LINE__;
-        }
-
-        return sprintf("%s [%-5s] [%-25s :%5d] %s\n%s\n", date('Y-m-d H:i:s'), $this->_TYPES[$type], substr($file, -24), $line, $msg, $extra);
-    }
-
-    private function _sendFluentd($data, $type, $errFile = null, $errLine = null) {
-        $tag = sprintf("%s.%s.%s", $this->_project, $this->_CATEGORIES[$type], $this->_TYPES[$type]);
-
-        $subject = sprintf("[%s][%s]%s", $this->_project, $this->_TYPES[$type], substr($data, 0, 40));
-
-        $reqMicro = explode('.', $_SERVER['REQUEST_TIME_FLOAT']);
-        $reqTime = new \DateTime(date('Y-m-d H:i:s.' . $reqMicro[1], $_SERVER['REQUEST_TIME']));
-        $curMicro = microtime(true);
-        $tMicro = sprintf("%06d", ($curMicro - floor($curMicro)) * 1000000);
-        $curTime = new \DateTime(date('Y-m-d H:i:s.' . $tMicro, $curMicro));
-
-        $msg = [
-            'title'         => $subject,
-            'server_name'   => $_SERVER['SERVER_NAME'],
-            'server_ip'     => $_SERVER['SERVER_ADDR'],
-            'server_port'   => $_SERVER['SERVER_PORT'],
-            'client_ip'     => $_SERVER['REMOTE_ADDR'],
-            'request_uri'   => $_SERVER['REQUEST_URI'],
-            'request_time'  => $reqTime->format('Y-m-d H:i:s.u'),
-            'current_time'  => $curTime->format('Y-m-d H:i:s.u'),
-            'server_info'   => print_r($_SERVER, true),
-            'get_info'      => print_r($_GET, true),
-            'post_info'     => print_r($_POST, true),
-            'data'          => $data,
-            'trace'         => $this->_formatMsg($data, $type, $errFile, $errLine),
-        ];
-
-        $this->_fluentd->post($tag, $msg);
-    }
-
-    private function _write($msg, $type, $errFile = null, $errLine = null) {
-        if ($type & $this->_level) {
-            if (is_object($msg) || is_array($msg)) {
-                $data = print_r($msg, true);
-            } else {
-                $data = strval($msg);
-            }
-
-            //发送fluentd
-            if ($this->_fluentd !== null) {
-                $this->_sendFluentd($data, $type, $errFile, $errLine);
-            }
-
-            $data = $this->_formatMsg($data, $type, $errFile, $errLine);
-
-            //记录日志
-            fwrite($this->_fp, $data);
-
-            //发送邮件
-//            if ($this->_mailSwitch == 'on' ||
-//                ($this->_mailSwitch == 'auto' &&
-//                    ($type & self::ERROR || $type & self::FATAL))) {
-//                if (self::$_mailer !== null) {
-//                    $subject = sprintf("[ERROR_MAIL][%s][%s]Error info from logger", $this->_TYPES[$type], $this->_project);
-//                    self::$_mailer->subject($subject);
-//                    self::$_mailer->msgHTML($data);
-//                    if (!self::$_mailer->send()) {//邮件发送失败,写日志
-//                        $err = self::$_mailer->ErrorInfo();
-//                        fwrite($this->_fp, $this->_formatMsg($err, self::ERROR));
-//                    }
-//                }
-//            }
-
-        }
-    }
-
-    private function parseArgs($args) {
-        $ret = "";
-        foreach ($args as $arg) {
-            if (is_object($arg) || is_array($arg)) {
-                $data = print_r($arg, true);
-            } else {
-                $data = strval($arg);
-            }
-            $ret .= $data . " ";
-        }
-        return $ret;
-    }
-
-    /**
-     * @param string $path
-     * @return Logger|null
-     * 单例对象,参数为日志路径
-     */
-    public static function getInstance($path = '') {
-        if (!(self::$_instance instanceof self)) {
-            self::$_instance = new self($path);
-        }
-        return self::$_instance;
-    }
-
-    /**
-     * @param string $path
-     * @throws Exception
-     * 设置log路径,默认标准输出
-     */
-    public function setPath($path = '') {
-        if (empty($path)) {
-            $this->_fp = fopen('php://stdout', 'w');
-        } else {
-            if (is_dir($path)) {
-                throw new \Exception('Cannot be a path, must be a file ' . $path);
-            }
-            $dn = dirname($path);
-            if (!file_exists($dn)) {
-                @mkdir($dn, 0777, true);
-            }
-            if (!file_exists($path)) {
-                @touch($path);
-            }
-            if (!is_writable($path)) {
-                throw new \Exception('Log file cannot be written! ' . $path);
-            }
-            $this->_fp = fopen($path, 'a');
-        }
-    }
-
-    /**
-     * @param string $host
-     * @param int $port
-     * @param array $options
-     * 配置fluentd
-     */
-    public function setFluentd($host = '127.0.0.1', $port = 24224, $options = []) {
-        $this->_fluentd = new FluentLogger($host, $port, $options);
-    }
-
-    /**
-     * @param $val [development | production]
-     * 设置应用环境,默认development
-     * 关联日志级别
-     */
-    public function setEnv($val) {
-        if ($val == self::DEVELOP) {
-            $this->_env = $val;
-            $this->setLevel(self::EMERGENCY | self::ALERT | self::FATAL | self::ERROR | self::WARNING | self::NOTICE | self::INFO | self::DEBUG);
-        } elseif ($val == self::PRODUCT) {
-            $this->_env = $val;
-            $this->setLevel(self::EMERGENCY | self::ALERT | self::FATAL | self::ERROR | self::WARNING);
-        }
-    }
-
-    /**
-     * @param $val
-     * 设置日志级别,默认self::EMERGENCY | self::ALERT | self::FATAL | self::ERROR | self::WARNING
-     */
-    public function setLevel($val) {
-        $this->_level = $val;
-    }
-
-    /**
-     * @param $val true/false
-     * debug back trace开关,默认打开
-     */
-    public function setDebugBackTrace($val) {
-        $this->_debugBackTrace = $val;
-    }
-
-    public function setMailer(Mailer $mailer) {
-        self::$_mailer = $mailer;
-    }
-
-    /**
-     * @param $mail array
-     * key as mail address
-     * value as mail name
-     */
-    public function addMailTo($mail) {
-        foreach ($mail as $addr => $name) {
-            if (strpos($addr, '@') !== false) {
-                self::$_mailer->addAddress($addr, $name);
-            } elseif (strpos($name, '@') !== false) {
-                self::$_mailer->addAddress($name);
-            }
-        }
-    }
-
-    public function setProjectId($projectId) {
-        $this->_project = $projectId;
-    }
-
-    /**
-     * @param null $msg
-     * 调试输出
-     */
-    public function Debug() {
-        if (func_num_args() == 0) {
-            return;
-        }
-        $args = func_get_args();
-        $msg = $this->parseArgs($args);
-
-        $this->_write($msg, self::DEBUG);
-    }
-
-    /**
-     * @param null $msg
-     * 信息输出
-     */
-    public function Info() {
-        if (func_num_args() == 0) {
-            return;
-        }
-        $args = func_get_args();
-        $msg = $this->parseArgs($args);
-
-        $this->_write($msg, self::INFO);
-    }
-
-    /**
-     * @param null $msg
-     * 注意输出
-     */
-    public function Notice() {
-        if (func_num_args() == 0) {
-            return;
-        }
-        $args = func_get_args();
-        $msg = $this->parseArgs($args);
-
-        $this->_write($msg, self::NOTICE);
-    }
-
-    /**
-     * @param null $msg
-     * 警告输出
-     */
-    public function Warning() {
-        if (func_num_args() == 0) {
-            return;
-        }
-        $args = func_get_args();
-        $msg = $this->parseArgs($args);
-
-        $this->_write($msg, self::WARNING);
-    }
-
-    /**
-     * @param null $msg
-     * 错误输出
-     */
-    public function Error() {
-        if (func_num_args() == 0) {
-            return;
-        }
-        $args = func_get_args();
-        $msg = $this->parseArgs($args);
-
-        $this->_write($msg, self::ERROR);
-    }
-
-    /**
-     * @param null $msg
-     * 致命错误输出
-     */
-    public function Fatal() {
-        if (func_num_args() == 0) {
-            return;
-        }
-        $args = func_get_args();
-        $msg = $this->parseArgs($args);
-
-        $this->_write($msg, self::FATAL);
-    }
-
-    /**
-     * @param null $msg
-     * 警报错误输出
-     */
-    public function Alert() {
-        if (func_num_args() == 0) {
-            return;
-        }
-        $args = func_get_args();
-        $msg = $this->parseArgs($args);
-
-        $this->_write($msg, self::ALERT);
-    }
-
-    /**
-     * @param null $msg
-     * 紧急错误输出
-     */
-    public function Emergency() {
-        if (func_num_args() == 0) {
-            return;
-        }
-        $args = func_get_args();
-        $msg = $this->parseArgs($args);
-
-        $this->_write($msg, self::EMERGENCY);
-    }
-
-    /**
-     * @param $errno
-     * @param $errstr
-     * @param $errfile
-     * @param $errline
-     * 系统错误捕获器
-     */
-    public function cbErrorHandler($errno, $errstr, $errfile, $errline) {
-        switch ($errno) {
-            case E_ERROR:
-            case E_USER_ERROR:
-            case E_CORE_ERROR:
-                $errType = self::FATAL;
-                break;
-            case E_WARNING:
-            case E_USER_WARNING:
-            case E_CORE_WARNING:
-                $errType = self::ERROR;
-                break;
-            default:
-                $errType = self::WARNING;
-        }
-        $this->_write($errstr, $errType, $errfile, $errline);
-    }
-}

+ 0 - 119
server/app/Library/Protocol/ErrorCode.php

xqd
@@ -1,119 +0,0 @@
-<?php
-namespace App\Library\Protocol;
-
-final class ErrorCode {
-	//错误常量定义
-	const ATTACHMENT_DELETE_FAILED = 605;
-	const ATTACHMENT_MOVE_FAILED = 604;
-	const ATTACHMENT_RECORD_DELETE_FAILED = 606;
-	const ATTACHMENT_MKDIR_FAILED = 601;
-	const SAVE_USER_FAILED = 600;
-	const ATTACHMENT_SAVE_FAILED = 603;
-	const ATTACHMENT_UPLOAD_INVALID = 602;
-	const ATTACHMENT_SIZE_EXCEEDED = 1201;
-	const ILLEGAL_REQUEST = 701;
-	const ATTACHMENT_NOT_EXIST = 1203;
-	const ATTACHMENT_MIME_NOT_ALLOWED = 1202;
-	const MERCHANT_CREDIT_NOT_ENOUGH = 1304;
-	const MEMBER_CREDIT_NOT_ENOUGH = 1305;
-	const MERCHANT_NOT_EXIST = 1300;
-	const DREAM_NOT_EXIST = 1308;
-	const FAVORITE_NOT_EXIST = 1900;
-	const MERCHANT_ADD_MEMBER_FAILED = 1301;
-	const MERCHANT_STATUS_NOT_OK = 1302;
-	const MERCHANT_BALANCE_NOT_ENOUGH = 1303;
-	const PAY_TYPE_UNSUPPORTED = 2000;
-	const MEMBER_NOT_EXIST = 1500;
-	const MEMBER_BALANCE_NOT_ENOUGH = 1501;
-	const MERCHANT_SERVICE_NOT_EXIST = 1400;
-	const MERCHANT_SERVICE_ADD_FAILED = 1401;
-	const CONTENT_GET_DETAIL_FAILED = 1402;
-	const MERCHANT_SERVICE_STATUS_INVALID = 1403;
-	const MERCHANT_SERVICE_EXPIRED = 1404;
-	const CANT_ADD_SERVICE_SAME_MERCHANT = 1405;
-	const SERVICE_STATUS_INVALID_CHANGE = 1406;
-	const SERVICE_COST_OVERFLOW_BALANCE = 1407;
-	const CREATE_SERVICE_OVER_MAX = 1408;
-	const SAVE_MODEL_FAILED = 700;
-	const REMOVE_MODEL_FAILED = 701;
-	const MODEL_NOT_EXIST = 702;
-	const ATTACHMENT_UPLOAD_FAILED = 1200;
-	const PROTO_PATH_NOT_EXIST = 100;
-	const PROTO_TRY_TO_SET_VALUE_ON_NULL = 101;
-	const ACTIVITY_NOT_EXIST = 1700;
-	const ORDER_GENERATE_FAILED = 1800;
-	const CONSUME_LOG_NOT_EXIST = 1600;
-	const SERVICE_CODE_FAILED= 1610;
-	const PHONE_NUMBER_ALREADY_REGISTERED = 1100;
-	const INCORRECT_VERIFY_CODE = 1101;
-	const INCORRECT_USER_OR_PASS = 1102;
-	const VERIFY_CODE_TOO_MUCH = 1103;
-	const LOGOUT_FAILED = 1104;
-	const USER_DOES_NOT_EXIST = 1105;
-	const USER_DOES_EXIST = 1106;
-	const DELETE_OP_FAILED = 1001;
-	const CLIENT_WRONG_PARAMS = 1000;
-
-	//错误常量枚举
-	private static $_msg = [
-		self::ATTACHMENT_DELETE_FAILED => '删除附件文件失败',
-		self::ATTACHMENT_MOVE_FAILED => '移动附件失败',
-		self::ATTACHMENT_RECORD_DELETE_FAILED => '删除附件记录失败',
-		self::ATTACHMENT_MKDIR_FAILED => '创建附件目录失败',
-		self::SAVE_USER_FAILED => '保存用户数据失败',
-		self::ATTACHMENT_SAVE_FAILED => '保存附件失败',
-		self::ATTACHMENT_UPLOAD_INVALID => '上传附件文件无效',
-		self::ATTACHMENT_SIZE_EXCEEDED => '附件大小超过限制',
-		self::ILLEGAL_REQUEST => '非法请求',
-		self::ATTACHMENT_NOT_EXIST => '附件不存在',
-		self::ATTACHMENT_MIME_NOT_ALLOWED => '附件类型不允许',
-		self::MEMBER_CREDIT_NOT_ENOUGH => '会员卡金不足',
-		self::MERCHANT_CREDIT_NOT_ENOUGH => '商户卡金不足',
-		self::MERCHANT_NOT_EXIST => '商户不存在',
-		self::DREAM_NOT_EXIST => '商户不存在',
-		self::FAVORITE_NOT_EXIST => '收藏不存在',
-		self::MERCHANT_ADD_MEMBER_FAILED => '添加会员失败',
-		self::MERCHANT_STATUS_NOT_OK => '申请成功,客服会在3个工作日内与您取得联系!',
-		self::MERCHANT_BALANCE_NOT_ENOUGH => '商户余额不足',
-		self::PAY_TYPE_UNSUPPORTED => '不支持的支付方式',
-		self::MEMBER_NOT_EXIST => '会员不存在',
-		self::MEMBER_BALANCE_NOT_ENOUGH => '会员余额不足',
-		self::SERVICE_COST_OVERFLOW_BALANCE => '余额不足,请充值',
-		self::CREATE_SERVICE_OVER_MAX => '服务数量达到系统上限',
-		self::MERCHANT_SERVICE_STATUS_INVALID => '服务状态不正确',
-		self::CONTENT_GET_DETAIL_FAILED => '获取内容详情失败',
-		self::MERCHANT_SERVICE_ADD_FAILED => '发出服务失败',
-		self::MERCHANT_SERVICE_NOT_EXIST => '服务不存在',
-		self::SERVICE_STATUS_INVALID_CHANGE => '服务状态转换无效',
-		self::CANT_ADD_SERVICE_SAME_MERCHANT => '服务发出方与创建方一致',
-		self::MERCHANT_SERVICE_EXPIRED => '服务已过期',
-		self::SAVE_MODEL_FAILED => '保存模型失败',
-		self::REMOVE_MODEL_FAILED => '删除模型失败',
-		self::MODEL_NOT_EXIST => '模型不存在',
-		self::ATTACHMENT_UPLOAD_FAILED => '附件上传失败',
-		self::PROTO_PATH_NOT_EXIST => '指定API路径不存在',
-		self::PROTO_TRY_TO_SET_VALUE_ON_NULL => '企图操作NULL对象并赋值',
-		self::ACTIVITY_NOT_EXIST => '活动不存在',
-		self::ORDER_GENERATE_FAILED => '生成订单失败',
-		self::CONSUME_LOG_NOT_EXIST => '消费记录不存在',
-		self::LOGOUT_FAILED => '退出失败',
-		self::SERVICE_CODE_FAILED=>'验证码错误',
-		self::USER_DOES_EXIST => '手机已经注册',
-		self::USER_DOES_NOT_EXIST => '用户不存在',
-		self::INCORRECT_USER_OR_PASS => '用户名或密码不正确',
-		self::PHONE_NUMBER_ALREADY_REGISTERED => '该手机号已注册',
-		self::INCORRECT_VERIFY_CODE => '输入验证码错误',
-		self::VERIFY_CODE_TOO_MUCH => '24小时内验证码发送过多',
-		self::DELETE_OP_FAILED => '删除操作失败',
-		self::CLIENT_WRONG_PARAMS => '输入不正确',
-	];
-
-	public static function message($code) {
-		if (isset(self::$_msg[$code])) {
-			return self::$_msg[$code];
-		} else {
-			return null;
-		}
-	}
-
-}

+ 0 - 129
server/app/Library/Protocol/api.php

xqd
@@ -1,129 +0,0 @@
-<?php
-namespace App\Library\Protocol;
-
-class ApiException extends \Exception {
-    function __construct($code, $message = '')
-    {
-        if (empty($message)) {
-            $message = ErrorCode::message($code);
-            if ($message === null) {
-                $message = $code;
-                $code = 0;
-            }
-        }
-        parent::__construct($message, $code);
-    }
-}
-
-final class _Api {
-
-    public $id;
-    public $path;
-    public $method;
-    public $header;
-    public $payload;
-    public $response;
-    public $desc;
-
-    public function __construct($data) {
-        $this->id = (int) $data['id'];
-        $this->path = (string) $data['path'];
-        $this->method = (string) strtolower($data['method']);
-        if ($data['header'] == 'null') {
-            $this->header = null;
-        } else {
-            $klass = sprintf("%s\\%s", __NAMESPACE__, $data['header']);
-            $this->header = new $klass;
-        }
-        if ($data['payload'] == 'null') {
-            $this->payload = null;
-        } else {
-            $klass = sprintf("%s\\%s", __NAMESPACE__, $data['payload']);
-            $this->payload = new $klass;
-        }
-        if ($data['response'] == 'null') {
-            $this->response = null;
-        } else {
-            $klass = sprintf("%s\\%s", __NAMESPACE__, $data['response']);
-            $this->response = new $klass;
-        }
-        $this->desc = (string) $data['desc'];
-    }
-
-    public function setHeader($data) {
-        if ($this->header === null) {
-            throw new ApiException(ErrorCode::PROTO_TRY_TO_SET_VALUE_ON_NULL);
-        }
-        if (is_array($data) || $data instanceof $this->header) {
-            return $this->header->set($data);
-        }
-        return false;
-    }
-
-    public function setPayload($data) {
-        if ($this->payload === null) {
-            return false;
-        }
-        if (is_array($data) || $data instanceof $this->payload) {
-            return $this->payload->set($data);
-        }
-        return $this;
-    }
-
-    public function setResponse($data, $value = null) {
-        if ($this->response === null) {
-            throw new ApiException(ErrorCode::PROTO_TRY_TO_SET_VALUE_ON_NULL);
-        }
-        if (is_array($data) || $data instanceof $this->response) {
-            $this->response->set($data);
-        } elseif (is_string($data)) {
-            $this->response->set([$data => $value]);
-        }
-        return $this;
-    }
-
-    public function parse() {
-        return $this->response->iterate();
-    }
-}
-
-final class Api {
-	private static $api = [
-		'/api/token/get' => [
-			'payload' => 'token_req_info',
-			'header' => 'app_info',
-			'id' => '2',
-			'path' => '/api/token/get',
-			'method' => 'post',
-			'response' => 'token_info',
-			'desc' => '获取服务端token',
-		],
-		'/api/servers/list' => [
-			'payload' => 'null',
-			'header' => 'app_info',
-			'id' => '1',
-			'path' => '/api/servers/list',
-			'method' => 'post',
-			'response' => 'service_list',
-			'desc' => '获取当前客户端可用服务端列表',
-		],
-		'/api/token/refresh' => [
-			'payload' => 'token_info',
-			'header' => 'app_info',
-			'id' => '3',
-			'path' => '/api/token/refresh',
-			'method' => 'post',
-			'response' => 'token_info',
-			'desc' => '刷新服务端token',
-		],
-	];
-
-	public static function get($path) {
-		if (!isset(self::$api[$path])) {
-			throw new ApiException(ErrorCode::PROTO_PATH_NOT_EXIST);
-		}
-
-		return new _Api(self::$api[$path]);
-	}
-
-}

+ 0 - 177
server/app/Library/Protocol/proto.php

xqd
@@ -1,177 +0,0 @@
-<?php
-namespace App\Library\Protocol;
-
-abstract class _Payload {
-
-    public function __construct(array $data = null) {
-        if ($data != null) {
-            $this->set($data);
-        }
-    }
-
-    public function set($data) {
-        //TODO: recursive set data
-        if ($data === null) {
-
-            return false;
-        } elseif (is_array($data)) {
-            foreach ($data as $k => $v) {
-                if (property_exists(get_class($this), $k)) {
-                    $t = sprintf("_%s", $k);
-                    if (property_exists(get_class($this), $t)) {
-                        $tp = $this->{$t};
-                        $type = $tp['type'];
-                        $this->{$k} = $this->cast($v, $type);
-                    }
-                }
-            }
-        } elseif (is_object($data) && $data instanceof $this) {
-            foreach ($data as $k => $v) {
-                $t = sprintf("_%s", $k);
-                if (property_exists(get_class($this), $t)) {
-                    $this->{$k} = $v;
-                }
-            }
-        } else {
-
-            return false;
-        }
-        return true;
-    }
-
-    public function cast($value, $type) {
-        switch ($type) {
-            case 'integer':
-                $ret = (int) $value;
-                break;
-            case 'float':
-                $ret = (double) $value;
-                break;
-            case 'string':
-                $ret = (string) $value;
-                break;
-            case 'boolean':
-                $ret = (boolean) $value;
-                break;
-            default:
-                if (preg_match('/^(array\[([A-Za-z_]+)\]|dict\[([A-Za-z_]+)\]([A-Za-z_]+))$/', $type, $matches)) {
-                    $ret = [];
-                    if (substr($matches[0], 0, 4) === 'dict') {
-                        foreach ($value as $k => $v) {
-                            $key = $this->cast($k, $matches[3]);
-                            $value = $this->cast($v, $matches[4]);
-                            $ret[$key] = $value;
-                        }
-                    } else {
-                        foreach ($value as $k => $v) {
-                            $ret[] = $this->cast($v, $matches[2]);
-                        }
-                    }
-                } elseif (is_object($value)) {
-                    $klass = sprintf("%s\\%s", __NAMESPACE__, $type);
-                    if ($value instanceof $klass) {
-                        $ret = $this->iterate($value);
-                    } else {
-                        $ret = $value;
-                    }
-                } else {
-                    $ret = $value;
-                }
-                break;
-        }
-        return $ret;
-    }
-
-    public function iterate($object = null) {
-        $ret = [];
-        if ($object === null) {
-            $object = $this;
-        }
-        foreach ($object as $k => $v) {
-            $t = sprintf("_%s", $k);
-            if (property_exists(get_class($object), $t)) {
-                $tp = $this->{$t};
-                $type = $tp['type'];
-                $ret[$k] = $this->cast($v, $type);
-            }
-        }
-        return $ret;
-    }
-
-}
-
-/*
-#token结构
-*/
-final class token_info extends _Payload {
-	public $token = "";
-	protected $_token = [
-		'type' => 'string',
-		'required' => true,
-	];
-}
-
-/*
-#可用服务信息结构
-*/
-final class service_info extends _Payload {
-	public $name = "";
-	protected $_name = [
-		'type' => 'string',
-		'required' => true,
-	];
-	public $auth = 0;
-	protected $_auth = [
-		'type' => 'integer',
-		'required' => true,
-	];
-}
-
-/*
-#appid-appkey结构
-*/
-final class app_info extends _Payload {
-	public $appid = "";
-	protected $_appid = [
-		'type' => 'string',
-		'required' => true,
-	];
-}
-
-/*
-#单id结构
-*/
-final class struct_id extends _Payload {
-	public $id = 0;
-	protected $_id = [
-		'type' => 'integer',
-		'required' => true,
-	];
-}
-
-/*
-#可用服务列表
-*/
-final class service_list extends _Payload {
-	public $service = [];
-	protected $_service = [
-		'type' => 'array[service_info]',
-		'required' => true,
-	];
-}
-
-/*
-#请求token参数
-*/
-final class token_req_info extends _Payload {
-	public $server_id = "";
-	protected $_server_id = [
-		'type' => 'string',
-		'required' => true,
-	];
-	public $user_id = 0;
-	protected $_user_id = [
-		'type' => 'integer',
-		'required' => true,
-	];
-}

+ 1 - 1
server/app/Models/BaseSettingsModel.php

xqd
@@ -16,7 +16,7 @@ class BaseSettingsModel extends BaseModel
      * @var string
      *
      */
-    protected $table = 'base_settings';
+    protected $table = 'base_settings_info';
     /**
     主键
      */

+ 1 - 1
server/app/Models/dreamImages.php → server/app/Models/DreamImages.php

xqd
@@ -4,7 +4,7 @@ namespace App\Models;
 
 use Illuminate\Database\Eloquent\Model;
 
-class dreamImages extends Model
+class DreamImages extends Model
 {
     protected $table = 'dream_images';
     protected $fillable = ['dream_id','title','pic'];

+ 5 - 0
server/app/Models/SystemInfoModel.php

xqd
@@ -7,4 +7,9 @@ use Illuminate\Database\Eloquent\Model;
 class SystemInfoModel extends Model
 {
     protected $table = 'system_info';
+    protected $fillable = [
+        'user_id',
+        'other_id',
+        'coin',
+    ];
 }

+ 5 - 0
server/app/Models/UserDream.php

xqd
@@ -8,6 +8,11 @@ class UserDream extends Model
 {
     protected $table = 'user_dream';
 
+    protected $fillable = [
+        'user_id',
+        'dream_id',
+    ];
+
     public function DreamUser()
     {
         return $this->belongsTo('App\Models\UserInfoModel','user_id','id');

+ 5 - 0
server/app/Models/UserInfoModel.php

xqd
@@ -68,6 +68,11 @@ class UserInfoModel extends Authenticatable
         return $this->belongsToMany('App\Models\DreamInfoModel','user_dream','user_id','dream_id');
     }
 
+    public function supDream()
+    {
+        return $this->belongsToMany('App\Models\DreamInfoModel','system_info','user_id','other_id');
+    }
+
     public function myCareNum()
     {
         return $this->hasMany('App\Models\UserCareUser','user_id','id');

+ 2 - 0
server/app/Services/Base/ErrorCode.php

xqd
@@ -63,9 +63,11 @@ final class ErrorCode {
     const USER_DOES_EXIST = 1106;
     const DELETE_OP_FAILED = 1001;
     const CLIENT_WRONG_PARAMS = 1000;
+    const DREAM_NOT_EXIST = 1308;
 
     //错误常量枚举
     private static $_msg = [
+        self::DREAM_NOT_EXIST => '梦想不存在',
         self::ATTACHMENT_DELETE_FAILED => '删除附件文件失败',
         self::ATTACHMENT_MOVE_FAILED => '移动附件失败',
         self::ATTACHMENT_RECORD_DELETE_FAILED => '删除附件记录失败',

+ 1 - 1
server/config/app.php

xqd
@@ -177,7 +177,7 @@ return [
         App\Providers\EventServiceProvider::class,
         App\Providers\RouteServiceProvider::class,
 
-        Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
+//        Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
         Laravel\Passport\PassportServiceProvider::class,
         Dingo\Api\Provider\LaravelServiceProvider::class,
         Orangehill\Iseed\IseedServiceProvider::class,

+ 0 - 36
server/database/migrations/2017_06_02_062003_create_comments_info_table.php

xqd
@@ -1,36 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateCommentsInfoTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::create('comments_info', function (Blueprint $table) {
-            $table->increments('id');
-            $table->integer('dream_id')->comment('梦想ID');
-            $table->integer('user_id')->comment('评价用户');
-            $table->tinyInteger('level')->comment('评论星级');
-            $table->text('content')->comment('评论内容');
-            $table->timestamps();
-            $table->softDeletes();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::dropIfExists('comments_info');
-    }
-}

+ 0 - 36
server/database/migrations/2017_06_02_062003_create_reply_comments_info_table.php

xqd
@@ -1,36 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateReplyCommentsInfoTable extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::create('reply_comments_info', function (Blueprint $table) {
-            $table->increments('id');
-            $table->integer('comment_id')->comment('评论ID');
-            $table->integer('user_id')->comment('当前登录用户ID');
-            $table->tinyInteger('level')->comment('回复星级');
-            $table->text('content')->comment('回复内容');
-            $table->timestamps();
-            $table->softDeletes();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::dropIfExists('reply_comments_info');
-    }
-}

+ 0 - 0
server/database/migrations/2017_04_02_062004_create_comments_info_table.php → server/database/migrations/2017_06_02_062004_create_comments_info_table.php


+ 0 - 0
server/database/migrations/2017_04_02_062004_create_reply_comments_info_table.php → server/database/migrations/2017_06_02_062004_create_reply_comments_info_table.php


+ 25 - 0
server/routes/api.php

xqd
@@ -131,4 +131,29 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'my.dream_about',
         'uses' => 'MyController@dreamAbout',
     ]);
+
+//    用户信息
+    $api->get('user/index', [
+        'as' => 'user.index',
+        'uses' => 'HomeController@index',
+    ]);
+    $api->get('user/homepage', [
+        'as' => 'user.homepage',
+        'uses' => 'HomeController@homepage',
+    ]);
+    $api->post('user/support', [
+        'as' => 'user.support',
+        'uses' => 'HomeController@support',
+    ]);
+//    互动
+    $api->post('user/interaction', [
+        'as' => 'user.interaction',
+        'uses' => 'HomeController@interaction',
+    ]);
+
+    $api->get('user/paihang', [
+        'as' => 'user.paihang',
+        'uses' => 'HomeController@paihang',
+    ]);
+
 });