Commit 5eea3fff by mushishixian

转移初始化完成

parent 52a7d769
[submodule "common"]
path = common
url = ssh://git@119.23.72.7:22611/yyc/Common.git
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/app" isTestSource="false" packagePrefix="App\" /> <sourceFolder url="file://$MODULE_DIR$/app" isTestSource="false" packagePrefix="App\" />
<sourceFolder url="file://$MODULE_DIR$/common" isTestSource="false" packagePrefix="Common\" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" /> <excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
...@@ -6,5 +6,78 @@ use Laravel\Lumen\Routing\Controller as BaseController; ...@@ -6,5 +6,78 @@ use Laravel\Lumen\Routing\Controller as BaseController;
class Controller extends BaseController class Controller extends BaseController
{ {
//
const SUCCESS = 0;
//请求参数错误
const INVALID_PARAMETER = 109004;
public function Export($Errcode = 0, $ErrMsg = '', $dataArr = [])
{
return Export($Errcode, $ErrMsg, $dataArr);
}
/**
* 内部免验证通过
* @return [type] [description]
*/
protected function auth($request)
{
$k1 = $request->input('k1', '');
$k2 = $request->input('k2', '');
$key = Config('alioss.SUPER_AUTH_KEY');
if (!empty($k1) && $k1 < time() - 600) {
return false;
}
$pwd = pwdhash($k1, $key);
if ($k2 == $pwd) {
return true;
} else {
return false;
}
}
// 登录校验
protected function checkLogin($request)
{
$token = $request->input('token', '');
if (empty($token)) {
return $this->_json(ErrorCode(001, 1));
}
try {
$url = config('website.authapi') . '/hprose/service';
$user = new Client($url, false);
$user->setHeader("Authorization", 'Bearer ' . $token);
$res = $user->getUserInfo();
$user->close();
} catch (Exception $e) {
return $this->_json(ErrorCode(002, 1));
}
if ($res['errcode'] != 0) {
return $this->_json(ErrorCode(003, 1));
}
return $this->_json(0, '', $res['data']);
}
/**
* 返回数据
* @param [Integer] $code [状态码]
* @param [String] $message [信息]
* @param [String] $data [数据]
* @return [Json]
*/
public function _json($code, $message = '', $data = [])
{
if ($code != 0) {
ErrorLog($code, $message); // 记录到logreport
}
return ['errcode' => $code, 'errmsg' => $message, 'data' => $data];
}
} }
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Common\Model\RedisModel;
class ExampleController extends Controller class ExampleController extends Controller
{ {
/** /**
...@@ -14,5 +16,10 @@ class ExampleController extends Controller ...@@ -14,5 +16,10 @@ class ExampleController extends Controller
// //
} }
public function index()
{
$redisModel = new RedisModel();
}
// //
} }
<?php
namespace App\Http\Middleware;
use Closure;
use Hprose\Http\Client;
class CheckLogin
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
//获取token
$Token = $request->input('token');
if(empty($Token))
return Response(Export(-1,'no access'));
$Url = config('website.authapi').'/hprose/service';
$user = new Client($Url,false);
$user->setHeader("Authorization",'Bearer '.$Token);
$result = $user->getUserInfo();
if(!$result || !isset($result['errcode']))
return Response(Export(-3,'登录信息获取失败'));
if($result['errcode'] !== 0)
return Response(Export($result['errcode'],$result['errmsg']));//原样返回到前端
if(empty($result['data']['user_id']))
return Response(Export(-4,'登录信息获取失败'));
$request->user = '';
$User = $result['data'];
$request->user = (object)$User;
return $next($request);
}
}
<?php
namespace App\Http\Middleware;
use Closure;
use App\Model\TokenModel;
class UniqueMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
//设置唯一追踪值
$request->offsetSet('unique', getUnique(true));
return $next($request);
}
}
<?php
namespace App\Http\Middleware;
use Closure;
class web
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$request->user = '';
$response = $next($request);
$origin = $request->server('HTTP_ORIGIN') ? $request->server('HTTP_ORIGIN') : '';
$allow_origin = config('website.allow_origin');
if (in_array($origin, $allow_origin)) {
$response->header('Access-Control-Allow-Origin', $origin);
$response->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Cookie, X-CSRF-TOKEN, Accept, Authorization, X-XSRF-TOKEN');
$response->header('Access-Control-Expose-Headers', 'Authorization, authenticated');
$response->header('Access-Control-Allow-Methods', 'GET, POST, PATCH, PUT, OPTIONS');
$response->header('Access-Control-Allow-Credentials', 'true');
}
return $response;
}
}
<?php
/**
* Created by PhpStorm.
* User: ICHUNT
* Date: 2019-06-18
* Time: 16:51
*/
function ErrorCode($code = 0, $level = 1){
$systemcode = config('website.SystemCode');
return errCode($code , $level , $systemcode);
}
function Export($Errcode=0, $ErrMsg='', $dataArr=[]){
if(!empty($dataArr) && !is_array($dataArr)) {
$Errcode = -2;
$ErrMsg = '系统错误';
}
$domain = \Illuminate\Support\Facades\Request::server('HTTP_HOST');//获取当前域名
$cofig = config('website.language');
if(!empty($cofig[$domain])) //配置了域名的版本
$language = $cofig[$domain];
else
$language = 'cn';
if (!$ErrMsg) { // 若不存在,则查找配置文件
$errInfo = config('language.'.$language.'.'.$Errcode);
if(!empty($errInfo)) $ErrMsg = $errInfo;
}
$data=['errcode'=>$Errcode, 'errmsg'=>$ErrMsg];
if(($data['errcode'] < 10000 || $data['errcode'] >= 50000) && $data['errcode'] !==0 )//非正常返回码,上报
ErrorLog($Errcode,$ErrMsg);
if(!empty($dataArr)) foreach ($dataArr as $k=>$v) $data[$k]=$v;
$callback = \Illuminate\Support\Facades\Request::only('callback');
$data = json_encode($data);
if(!empty($callback['callback']))
return $callback['callback'].'('.$data.')';
$IE8 = \Illuminate\Support\Facades\Request::only('ie8');
if(!empty($IE8['ie8']))
$data = '<script>document.domain="'.$IE8['ie8'].'"</script>'.$data;
return $data;
}
/**
* 取得根域名
* @param type $domain 域名
* @return string 返回根域名
*/
function GetUrlToDomain($domain='') {
if(empty($domain))
$domain = \Illuminate\Support\Facades\Request::server('HTTP_HOST');
$domain_postfix_cn_array = array("com", "net", "org", "gov", "edu", "com.cn", "cn");
$array_domain = explode(".", $domain);
$array_num = count($array_domain) - 1;
if ($array_domain[$array_num] == 'cn') {
if (in_array($array_domain[$array_num - 1], $domain_postfix_cn_array)) {
$re_domain = $array_domain[$array_num - 2] . "." . $array_domain[$array_num - 1] . "." . $array_domain[$array_num];
} else {
$re_domain = $array_domain[$array_num - 1] . "." . $array_domain[$array_num];
}
} else {
$re_domain = $array_domain[$array_num - 1] . "." . $array_domain[$array_num];
}
return $re_domain;
}
/**
* 统一密码加密
* @param [type] $pwd [description]
* @return [type] [description]
*/
function pwdhash($pwd, $salt)
{
return md5(md5($pwd) . $salt);
}
//生成的文件上传到OSS
function SaveDownFile($path=''){
if(empty($path)) return false;
$result=json_decode(UploadToOss($path),true);
if(empty($result['code']) || $result['code'] != 200 || empty($result['data'][0])) return false;
return $result['data'][0];
}
/**
* php上传文件到oss
* @param string $Path 文件路径
* @param array $data
* @return array
* Created on 2018-03-15
*/
function UploadToOss($Path='',$data=[]){
if(empty($Path)) return false;
$field=new CurlFile($Path);
if(!$field) return false;
$data['upload']=$field;
$url=config('website.UploadUrl');
$data['source']=1;
$data['k1']=time();
$data['k2']=MD5(MD5($data['k1']).config('website.UploadKey'));
$data['FileType']='csv';
$result=curlCurlFile($url,$data);
return $result;
}
function curlCurlFile($url, $params = false, $ispost = 1, $header=[], &$httpInfo = [])
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // 对认证证书来源的检查
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); // 从证书中检查SSL加密算法是否存在
if(!empty($header)){
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
}
if ($ispost) {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_URL, $url);
} else {
if ($params) {
curl_setopt($ch, CURLOPT_URL, $url . '?' . $params);
} else {
curl_setopt($ch, CURLOPT_URL, $url);
}
}
$response = curl_exec($ch);
$httpInfo = curl_getinfo($ch);
if ($response === FALSE) {
// echo "cURL Error: " . curl_error($ch);
return false;
}
curl_close($ch);
return $response;
}
\ No newline at end of file
...@@ -14,3 +14,5 @@ ...@@ -14,3 +14,5 @@
$app->get('/', function () use ($app) { $app->get('/', function () use ($app) {
return $app->version(); return $app->version();
}); });
$app->get('/test','ExampleController@index');
...@@ -23,9 +23,9 @@ $app = new Laravel\Lumen\Application( ...@@ -23,9 +23,9 @@ $app = new Laravel\Lumen\Application(
realpath(__DIR__.'/../') realpath(__DIR__.'/../')
); );
// $app->withFacades(); $app->withFacades();
// $app->withEloquent(); $app->withEloquent();
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
...@@ -40,7 +40,9 @@ $app = new Laravel\Lumen\Application( ...@@ -40,7 +40,9 @@ $app = new Laravel\Lumen\Application(
$app->singleton( $app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class, Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class // App\Exceptions\Handler::class
Common\Exceptions\Handler::class
); );
$app->singleton( $app->singleton(
...@@ -59,13 +61,16 @@ $app->singleton( ...@@ -59,13 +61,16 @@ $app->singleton(
| |
*/ */
// $app->middleware([ $app->middleware([
// App\Http\Middleware\ExampleMiddleware::class // App\Http\Middleware\ExampleMiddleware::class
// ]); App\Http\Middleware\web::class,
App\Http\Middleware\UniqueMiddleware::class
]);
// $app->routeMiddleware([ $app->routeMiddleware([
// 'auth' => App\Http\Middleware\Authenticate::class, 'web' => App\Http\Middleware\web::class,
// ]); 'login' => App\Http\Middleware\CheckLogin::class,
]);
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
...@@ -81,7 +86,8 @@ $app->singleton( ...@@ -81,7 +86,8 @@ $app->singleton(
// $app->register(App\Providers\AppServiceProvider::class); // $app->register(App\Providers\AppServiceProvider::class);
// $app->register(App\Providers\AuthServiceProvider::class); // $app->register(App\Providers\AuthServiceProvider::class);
// $app->register(App\Providers\EventServiceProvider::class); // $app->register(App\Providers\EventServiceProvider::class);
$app->register(Illuminate\Redis\RedisServiceProvider::class);
class_alias(\Illuminate\Support\Facades\App::class, 'App');
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Load The Application Routes | Load The Application Routes
...@@ -92,7 +98,16 @@ $app->singleton( ...@@ -92,7 +98,16 @@ $app->singleton(
| can respond to, as well as the controllers that may handle them. | can respond to, as well as the controllers that may handle them.
| |
*/ */
$app->configure('website');
$app->configure('database');
$app->configure('alioss');
$app->configure('language');
$app->configure('excel');
$app->configure('config');
LogReport::$suffix = '_'.env('LARAVELS_LISTEN_PORT', '');
LogReport::$app_name = 'ic_goods_api';
LogReport::$log_path = realpath(__DIR__ . '/../').'/storage/logs/LogReport/';
require_once __DIR__.'/../app/Http/function.php';
$app->group(['namespace' => 'App\Http\Controllers'], function ($app) { $app->group(['namespace' => 'App\Http\Controllers'], function ($app) {
require __DIR__.'/../app/Http/routes.php'; require __DIR__.'/../app/Http/routes.php';
}); });
......
common @ f9a581c7
Subproject commit f9a581c7c0c3542af4c79b9cf19482f4df700989
...@@ -15,8 +15,13 @@ ...@@ -15,8 +15,13 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"App\\": "app/" "App\\": "app/",
} "Common\\": "common/"
},
"files": [
"common/function.php",
"common/LogReport.php"
]
}, },
"autoload-dev": { "autoload-dev": {
"classmap": [ "classmap": [
......
<?php
return [
'SUPER_AUTH_KEY' => 'fh6y5t4rr351d2c3bryi',
'OSS_URL' => 'http://img.icsales.com/',
'AccessKeyId' => 'LTAIoG57wX1XfyCn',
'AccessKeySecret' => 'ZurpnMpFAq3ap7MhduGTgJq4GxglCE',
'EndPoint' => 'http://oss-cn-shenzhen.aliyuncs.com',
'Bucket' => 'icsales-files-2019',
// 内部、外部上传文件数量限制
'InternalNum' => 10,
'ExternalNum' => 5,
];
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ICHUNT
* Date: 2019-06-27
* Time: 10:39
*/
return [
];
\ No newline at end of file
<?php
return [
/*
|--------------------------------------------------------------------------
| PDO Fetch Style
|--------------------------------------------------------------------------
|
| By default, database results will be returned as instances of the PHP
| stdClass object; however, you may desire to retrieve records in an
| array format for simplicity. Here you can tweak the fetch style.
|
*/
'fetch' => PDO::FETCH_CLASS,
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'testing' => [
'driver' => 'sqlite',
'database' => ':memory:',
],
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', base_path('database/database.sqlite')),
'prefix' => env('DB_PREFIX', ''),
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 3306),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
'prefix' => env('DB_PREFIX', ''),
'timezone' => env('DB_TIMEZONE', '+00:00'),
'strict' => env('DB_STRICT_MODE', false),
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 5432),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => env('DB_PREFIX', ''),
'schema' => env('DB_SCHEMA', 'public'),
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => env('DB_PREFIX', ''),
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'cluster' => env('REDIS_CLUSTER', false),
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0
],
'read' =>[
'host' => env('REDIS_READ_HOST', ''),
'password' => env('REDIS_READ_PASSWORD', null),
'port' => env('REDIS_READ_PORT', 6379),
'database' => 0
]
],
];
<?php
/**
* Created by PhpStorm.
* User: ICHUNT
* Date: 2019-06-20
* Time: 17:55
*/
return [
'cn' => [
109001 => '非法操作',
109002 => 'Hprose请求失败',
109003 => '登录失败',
109004 => '请求参数不正确',
109005 => '用户无法兑换,用户未认证',
109006 => '红包码无效',
109007 => '已经兑换过红包码,不能再兑换',
109008 => '自己不能助力自己',
109009 => '助力人数已满或者您已经助力过',
109010 => '自己不能邀请自己',
109011 => '助力类型只允许用于微信转账',
109012 => '助力人数不足',
109100 => '今天已经兑换过了,请明天再来吧',
109101 => '兑换名额被抢光了',
109102 => '红包余额不足',
109103 => '当前提现不可用',
509000 => '超过操作类型的限额',
509001 => '签到失败',
509002 => '报价失败',
509003 => '上传商品失败',
509004 => '邀请好友失败',
509005 => '分享失败',
509006 => '兑换红包码失败',
509007 => '好友助力失败',
],
'us' => [
109001 => 'Illegal operation',
109002 => 'Hprose request failed, please check it',
109003 => 'Login failed',
// oss 错误码
109100 => 'Parameter missing, please check the passed parameters',
109101 => 'Checked in today and can not sign in again.',
109102 => 'Check in failed.',
],
];
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ICHUNT
* Date: 2019-06-18
* Time: 11:46
*/
return [
'SystemCode' => env('SYSTEM_CODE', '00'),//系统编码,需要在tapd维护,请勿占用已使用的编码
'SystemName' => env('SYSTEM_NAME', '这家伙没设置系统'),//系统名称
'server_url' => env('ServerUrl', ''),
'allow_origin' => [
'http://goods.sensorhunt.cc',
'http://search.sensorhunt.cc',
'http://home.sensorhunt.cc',
'http://www.sensorhunt.cc',
'http://item.sensorhunt.cc',
'http://goods.sensorhunt.com',
'http://search.sensorhunt.com',
'http://home.sensorhunt.com',
'http://item.sensorhunt.com',
'http://www.sensorhunt.com',
],
'language' => [
'',
],
];
\ No newline at end of file
{"msg":"Class 'PHPExcel_Shared_Font' not found","msgCode":903003,"ts":1586940035,"dateStr":"2020-04-15 16:40:35","app":"api","serverIp":"127.0.0.1","fileName":"C:\\laragon\\www\\liexin_api_initial\\config\\excel.php","lineNo":182,"method":"require","apiUrl":"http:\/\/apiinit.liexin.net","unique":"b68b9bc5cd736c85892b088574c20e85","request":"","response":"","useTime":""}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment