作者 Your Name

Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev

... ... @@ -140,6 +140,11 @@ class Handler extends ExceptionHandler
'code' => $code,
'message' => $message
];
// 调试模式
if(env('app_debug')){
$response['trace'] = $exception->getTrace();
}
//加密返回
if (config('app.params_encrypt')) {
$k = config('app.params_encrypt_key');
... ...
... ... @@ -111,16 +111,10 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
* @param :platforms: "facebook", "fbg", "twitter",
* "linkedin", "instagram","youtube", "reddit" ,"telegram""
*/
public function post_send_msg($param){
$param = [
'post'=>$param['post'],//内容(帖子文本)
'platforms'=>$param['platforms'],//平台
'idempotencyKey'=>$param['idempotencyKey'],//帖子唯一id
'mediaUrls'=>$param['mediaUrls'],
];
public function post_send_msg($param,$api_key){
//平台参数处理
$this->headers['Accept-Encoding'] = 'gzip';
$this->headers['Authorization'] = $this->headers['Authorization'].$param['profile_key'];
$this->headers['Authorization'] = $this->headers['Authorization'].$api_key;
$url = $this->path.'/api/post';
return $this->http_click('posts',$url,$param,$this->headers);
}
... ...
... ... @@ -120,4 +120,17 @@ class Common
}
return true;
}
/**
* @name :(多维数组去重)array_deduplication
* @author :lyh
* @method :post
* @time :2023/5/9 10:47
*/
public static function uniqueMultiArray($arr) {
$arr = array_map('serialize', $arr);
$arr = array_unique($arr);
$arr = array_map('unserialize', $arr);
return $arr;
}
}
... ...
... ... @@ -21,14 +21,26 @@ class AyrShareController extends BaseController
*/
public function lists(AyrShareModel $ayrShareModel){
$lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['*']);
$ayrShareHelper = new AyrShareHelper();
foreach ($lists['list'] as $k=>$v){
$lists['list'][$k]['ayr'] = $ayrShareHelper->get_profiles_users($v['profile_key']);
}
$this->response('列表',Code::SUCCESS,$lists);
}
/**
* @name :(定时更新)save_account
* @author :lyh
* @method :post
* @time :2023/5/9 14:39
*/
public function save_account(AyrShareLogic $ayrShareLogic){
$info = $ayrShareLogic->ayr_share_info();
$ayrShareHelper = new AyrShareHelper();
$share_info = $ayrShareHelper->get_profiles_users($info['profile_key']);
if(isset($share_info['activeSocialAccounts'])){
$str = json_encode($share_info['activeSocialAccounts']);
$ayrShareLogic->ayr_share_edit(['bind_plat_from'=>$str]);
}
$this->response('success');
}
/**
* @name :(创建ayr_share账户)create_account
* @author :lyh
* @method :post
... ... @@ -66,7 +78,7 @@ class AyrShareController extends BaseController
'title'=>$info['title'],
'profileKey'=>$info['profile_key']
];
//发送请求注册社交用户
//发送请求删除社交用户
$ayrShareHelper = new AyrShareHelper();
$res = $ayrShareHelper->deleted_profiles($data);
if($res['status'] == 'fail'){
... ... @@ -101,54 +113,4 @@ class AyrShareController extends BaseController
$this->response('success',Code::SUCCESS,$res);
}
/**
* @name :(获取当前用户的配置文件)get_profiles
* @author :lyh
* @method :post
* @time :2023/5/6 16:39
*/
public function get_profiles(AyrShareLogic $ayrShareLogic){
$this->request->validate([
'id'=>['required']
],[
'id.required' => 'ID不能为空'
]);
$info = $ayrShareLogic->ayr_share_info();
//发送请求注册社交用户
$ayrShareHelper = new AyrShareHelper();
$data = [
'title'=>$info['title'],
'refId'=>$info['ref_id'],
'profileKeys'=>$info['profile_keys']
];
$res = $ayrShareHelper->post_generate_jwt($data);
if($res['status'] == 'fail'){
$this->response($res['message'],Code::USER_ERROR);
}
$this->response('success',Code::SUCCESS,$res);
}
/**
* @name :(上传图片到第三方)post_uploads
* @author :lyh
* @method :post
* @time :2023/5/8 13:45
*/
public function post_uploads(){
}
/**
* @name :(发布推文到第三方平台)send_api_post
* @author :lyh
* @method :post
* @time :2023/5/8 13:37
*/
public function send_api_post(AyrShareLogic $ayrShareLogic){
$this->request->validate([
'id'=>['required']
],[
'id.required' => 'ID不能为空'
]);
$info = $ayrShareLogic->ayr_share_info();
}
}
... ...
... ... @@ -43,6 +43,15 @@ class BaseController extends Controller
}
/**
* @name :ceshi
* @author :lyh
* @method :post
* @time :2023/5/9 11:43
*/
public function ceshi(){
}
/**
* @name 参数过滤
* @return void
* @author :liyuhang
... ... @@ -142,7 +151,7 @@ class BaseController extends Controller
* @author :liyuhang
* @method
*/
protected function _extents($data) {
public function _extents($data) {
if (empty($data) || !is_array($data)) {
return empty($data) ? is_array($data) ? [] : '' : $data;
... ... @@ -160,6 +169,15 @@ class BaseController extends Controller
case 'image':
$data['image_link'] = url('/b/image/' . $v);
break;
case 'images':
$v = explode(',',$v);
foreach ($v as $k1=>$v1){
$data['images_link'][$k1] = url('/b/image/' . $v1);
}
break;
case 'file':
$data['file_link'] = url('/b/file_hash/' . $v);
break;
case 'operator_id':
if(!empty($v)){
$name = (new UserModel())->read(['operator_id'=>$v],['id','name']);
... ...
... ... @@ -11,6 +11,7 @@ use App\Http\Logic\Bside\Setting\WebSettingServiceLogic;
*/
class WebSettingServiceController extends BaseController
{
const TYPE_CODE = 6;
/**
* @name :lists
* @author :lyh
... ... @@ -19,6 +20,12 @@ class WebSettingServiceController extends BaseController
*/
public function lists(WebSettingServiceLogic $webSettingServiceLogic){
$lists = $webSettingServiceLogic->setting_service_list();
foreach ($lists as $k => $v){
if($v['type'] == self::TYPE_CODE){
$v['values_link'] = url('/b/image/' . $v['values']);
$lists[$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
... ...
... ... @@ -9,9 +9,7 @@ use App\Http\Controllers\Bside\json;
use App\Http\Logic\Bside\ProjectGroupLogic;
use App\Http\Logic\Bside\User\GroupLogic;
use App\Http\Requests\Bside\User\ProjectGroupRequest;
use App\Models\ProjectGroup as ProjectGroupModel;
use App\Models\User\User as UserModel;
use Illuminate\Http\Request;
use App\Models\User\ProjectGroup;
/**
... ... @@ -25,10 +23,18 @@ class ProjectGroupController extends BaseController
* @author :liyuhang
* @method
*/
public function lists(ProjectGroupModel $projectGroupModel)
public function lists(ProjectGroup $projectGroup)
{
$lists = $projectGroupModel->lists($this->map,$this->page,$this->row);
$this->response('success',Code::SUCCESS,$lists);
$lists = $projectGroup->list($this->map,'id',['name','user_list','pid','id']);
$menu = [];
foreach ($lists as $k => $v){
$v = (array)$v;
if ($v['pid'] == 0) {
$v['sub'] = _get_child($v['id'], $lists);
$menu[] = $v;
}
}
$this->response('success',Code::SUCCESS,$menu);
}
/**
... ...
... ... @@ -4,6 +4,9 @@ namespace App\Http\Controllers\file;
use App\Enums\Common\Code;
use App\Models\File\File;
use App\Models\File\Image as ImageModel;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\JsonResponse;
class FileController
{
... ... @@ -30,10 +33,17 @@ class FileController
{
$this->request = request();
$this->config = config('filesystems.disks.upload');
$this->path = $this->config['root'];
$this->path = $this->config['root'].'/file/';
}
public function index($hash = '', $w = 0 ,$h = 0){
/**
* @param :(获取文件)$hash
* @name :index
* @author :lyh
* @method :post
* @time :2023/5/9 9:15
*/
public function index($hash = ''){
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
header("HTTP/1.1 304 Not Modified");
exit;
... ... @@ -51,4 +61,112 @@ class FileController
$header['Content-Length'] = $info['size'];
return response($content, 200, $header);
}
/**
* 图片上传
*/
public function upload() {
$this->request->validate([
'image'=>['required'],
],[
'image.required'=>'图片必须填写',
]);
$files = $this->request->file('file');
if (empty($files)) {
$this->response('没有上传的文件!', 400);
}
$type = $this->request->post('type', 'single');
if ($type == 'multi') {
return $this->multi($files);
} else {
return $this->single($files);
}
}
/**
* @name :上传
* @return void
* @author :liyuhang
* @method
*/
public function single($files){
$hash = hash_file('md5', $files->getPathname());
//查看文件是否存在
$fileModel = new File();
$file_hash = $fileModel->read(['hash'=>$hash]);
if($file_hash !== false){
return $hash;
}
$url = $this->path;
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
$res = $files->move($url,$fileName);
if ($res === false) {
return $this->response($files->getError(), Code::USER_ERROR);
}
$data = [
'path' => $url.'/'.$fileName,
'created_at' => date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $hash,
'type'=>$files->getClientOriginalExtension(),
];
$rs = $fileModel->add($data);
if ($rs === false) {
return $this->response('添加失败', Code::USER_ERROR);
}
return $hash;
}
/**
* 多文件上传
* @param type $files file对象集合
* @return type
*/
private function multi($files) {
if (!is_array($files)) {
$files = [$files];
}
$save_data = [];
$data = [];
foreach ($files as $file) {
$fileModel = new File();
$hash = hash_file('md5', $file->getPathname());
$file_hash = $fileModel->read(['hash'=>$hash]);
if($file_hash !== false){
$data[] = $hash;
continue;
}
$url = $this->path;
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
$res = $file->move($url,$fileName);
if ($res === false) {
return $this->response($file->getError(), Code::USER_ERROR);
}
$save_data[] = [
'path' => $url.'/'.$fileName,
'created_at' => date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $hash,
'type'=>$files->getClientOriginalExtension(),
];
$data[] = $hash;
}
$fileModel->insert($save_data);
return $data;
}
/**
* @name 统一返回参数
* @return JsonResponse
* @author :liyuhang
* @method
*/
public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse
{
$code = Code::fromValue($code);
$result = [
'msg' => $msg == ' ' ? $code->description : $msg,
'code' => $code->value,
'data' => $data,
];
$this->header['Content-Type'] = $type;
$response = response($result,$result_code,$this->header);
throw new HttpResponseException($response);
}
}
... ...
... ... @@ -80,6 +80,7 @@ class ImageController
$img_base64 = 'data:image/' . $img_type . ';base64,' . $content;
return response($img_base64, 200, $header);
}
/**
* 图片上传
*/
... ... @@ -100,6 +101,7 @@ class ImageController
return $this->single($files);
}
}
/**
* @name :上传图片
* @return void
... ... @@ -115,13 +117,13 @@ class ImageController
return $hash;
}
$url = $this->path;
$filename = date('ymdHis').rand(10000,99999);
$res = $this->request->file('image')->move($url);
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
$res = $files->move($url,$fileName);
if ($res === false) {
return $this->response($files->getError(), Code::USER_ERROR);
}
$data = [
'path' => $url.'/'.$res->getClientOriginalName(),
'path' => $url.'/'.$fileName,
'created_at' => date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $hash,
... ... @@ -153,6 +155,7 @@ class ImageController
* @return type
*/
private function multi($files) {
if (!is_array($files)) {
$files = [$files];
}
... ... @@ -167,17 +170,18 @@ class ImageController
continue;
}
$url = $this->path;
$filename = date('ymdHis').rand(10000,99999);
$res = $file->move($url,$filename);
$fileName = uniqid().rand(10000,99999).'.'.$file->getClientOriginalExtension();
$res = $file->move($url,$fileName);
if ($res === false) {
return $this->response($file->getError(), Code::USER_ERROR);
}
$save_data[] = [
'path' => $url.'/'.$filename,
'path' => $url.'/'.$fileName,
'created_at' => date('Y-m-d H:i:s',time()),
'updated_at'=>date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $hash,
'type'=>$files->getClientOriginalExtension(),
'type'=>$file->getClientOriginalExtension(),
];
$data[] = $hash;
}
... ...
... ... @@ -9,10 +9,11 @@ use App\Models\AyrShare\AyrShare;
class AyrShareLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new AyrShare();
$this->param = $this->requestAll;
}
... ... @@ -55,6 +56,19 @@ class AyrShareLogic extends BaseLogic
}
/**
* @name :(更新)ayr_share_edit
* @author :lyh
* @method :post
* @time :2023/5/9 14:44
*/
public function ayr_share_edit($param){
$rs = $this->model->edit($param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @name :(删除ayr数据并同步删除)
* @author :lyh
* @method :post
... ...
... ... @@ -40,6 +40,12 @@ class WebSettingFromLogic extends BaseLogic
try {
//删除以前的数据
$this->model->del(['project_id'=>$this->user['project_id']]);
foreach ($this->param['data'] as $k => $v){
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$v['project_id'] = $this->user['project_id'];
$this->param['data'][$k] = $v;
}
//新增
$this->model->add_all($this->param['data']);
}catch (\Exception $e){
... ...
... ... @@ -37,6 +37,8 @@ class WebSettingReceivingLogic extends BaseLogic
$this->model->del(['project_id'=>$this->user['project_id']]);
foreach ($this->param['data'] as $k => $v){
$v['project_id'] = $this->user['project_id'];
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$this->param['data'][$k] = $v;
}
$this->model->add_all($this->param['data']);
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Http\Logic\Bside\Setting;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\File\Image;
use App\Models\WebSetting\WebSettingService;
... ... @@ -35,17 +36,20 @@ class WebSettingServiceLogic extends BaseLogic
* @time :2023/5/4 11:10
*/
public function setting_service_save(){
try {
// try {
$this->param['data'] = Common::uniqueMultiArray($this->param['data']);
//删除以前的数据
$this->model->del(['project_id'=>$this->user['project_id']]);
foreach ($this->param['data'] as $k => $v){
$v['project_id'] = $this->user['project_id'];
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$this->param['data'][$k] = $v;
}
$this->model->add_all($this->param['data']);
}catch (\Exception $e){
$this->fail('error');
}
// }catch (\Exception $e){
// $this->fail('error');
// }
return $this->success();
}
}
... ...
... ... @@ -15,5 +15,22 @@ class AyrShareRequest extends FormRequest
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name'=>'required||unique:gl_ayr_share,name',
];
}
public function messages()
{
return [
'name.required'=>'请填写名称',
];
}
}
... ...
... ... @@ -136,17 +136,12 @@ class Base extends Model
}
/**
* @name :(批量插入)add_all
* @name :(批量插入(data二维数组))add_all
* @author :lyh
* @method :post
* @time :2023/5/8 17:41
*/
public function add_all($data){
foreach ($data as $k => $v){
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$data[$k] = $v;
}
return $this->insert($data);
}
/**
... ...
<?php
namespace App\Models;
namespace App\Models\User;
use App\Models\Base;
class ProjectGroup extends Base
{
... ...
... ... @@ -11,7 +11,11 @@ define('LARAVEL_START', microtime(true));
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
<<<<<<< HEAD
| loading of any of our classes manually. It's great to relax.
=======
| loading of any our classes "manually". Feels great to relax.
>>>>>>> db84ec9e0ac005907f6868b371df2ccf8defd114
|
*/
... ...
... ... @@ -124,6 +124,16 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w
});
});
// 自定义页面 模板,头部底部
Route::prefix('template')->group(function () {
Route::get('/', [\App\Http\Controllers\Aside\TemplateController::class, 'index'])->name('admin.template_header_footer');
Route::get('/edit', [\App\Http\Controllers\Aside\TemplateController::class, 'edit'])->name('admin.template_header_footer_edit');
Route::get('/insert', [\App\Http\Controllers\Aside\TemplateController::class, 'insert'])->name('admin.template_header_footer_insert');
Route::get('/delete', [\App\Http\Controllers\Aside\TemplateController::class, 'delete'])->name('admin.template_header_footer_system');
});
});
//无需登录验证的路由组
... ...
... ... @@ -192,7 +192,10 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('images')->group(function () {
Route::post('/upload', [\App\Http\Controllers\file\ImageController::class, 'upload'])->name('image_upload');
});
//文件上传第三方操作
Route::prefix('files')->group(function () {
Route::post('/upload', [\App\Http\Controllers\file\FileController::class, 'upload'])->name('files_upload');
});
//精准询盘
Route::prefix('inquiry')->group(function () {
Route::get('/', [\App\Http\Controllers\Bside\InquiryController::class, 'index'])->name('inquiry');
... ... @@ -208,17 +211,47 @@ Route::middleware(['bloginauth'])->group(function () {
//社交绑定
Route::prefix('ayr')->group(function () {
Route::any('/lists', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'lists'])->name('ayr_lists');
Route::any('/', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'lists'])->name('ayr_lists');
Route::any('/save', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'save_account'])->name('ayr_save_account');
Route::any('/create', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'create_account'])->name('ayr_create_account');
Route::any('/del', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'del_account'])->name('ayr_del_account');
Route::any('/bind', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'bind_account'])->name('ayr_bind_account');
//社交绑定
Route::prefix('release')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\AyrShare\AyrReleaseController::class, 'info'])->name('ayr_release_info');
});
});
// 自定义页面
Route::prefix('template')->group(function () {
Route::get('/', [\App\Http\Controllers\Bside\TemplateController::class, 'index'])->name('template_header_footer');
Route::get('/edit', [\App\Http\Controllers\Bside\TemplateController::class, 'edit_html'])->name('template_header_footer_edit');
Route::post('/edit', [\App\Http\Controllers\Bside\TemplateController::class, 'edit_save'])->name('template_header_footer_edit_save');
Route::get('/system', [\App\Http\Controllers\Bside\TemplateController::class, 'system_all_html'])->name('template_header_footer_system');
Route::get('/custom', [\App\Http\Controllers\Bside\TemplateController::class, 'custom'])->name('template_custom');
});
// 导航栏编辑
Route::prefix('nav')->group(function () {
Route::get('/', [\App\Http\Controllers\Bside\NavController::class, 'index'])->name('bside_nav');
Route::post('/create', [\App\Http\Controllers\Bside\NavController::class, 'create'])->name('bside_nav_create');
Route::post('/update', [\App\Http\Controllers\Bside\NavController::class, 'update'])->name('bside_nav_update');
Route::delete('/delete', [\App\Http\Controllers\Bside\NavController::class, 'delete'])->name('bside_nav_delete');
});
});
//无需登录验证的路由组
Route::group([], function () {
Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login');
Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country');
// Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country');
Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download');
Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show');
Route::any('/file_hash/{hash}', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show');
});
... ...