作者 赵彬吉

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

正在显示 48 个修改的文件 包含 809 行增加168 行删除
... ... @@ -9,42 +9,138 @@ use GuzzleHttp\Client;
*/
class AyrShare
{
public $path = 'https://app.ayrshare.com/api';
public $path = 'https://app.ayrshare.com';
//api_key
public $api_key = 'G8GQW3X-XBTMGXW-QPDDZ9A-WE1Z5SB';
//系统设置
public $config = [
'facebook'=>'#best https://www.facebook.com',
'google'=>'#best https://www.google.com',
'instagram'=>'#best https://www.instagram.com',
'linkedin'=>'#best https://www.linkedin.com',
'twitter'=>'#best https://www.twitter.com',
'telegram'=>'#best https://www.telegram.com',
'tiktok'=>'#bestvideo',
];
//profile_key
public $profile_key = "-----BEGIN RSA PRIVATE KEY-----
MIICWgIBAAKBgGFatMeBeaw7QJrqmylMLZlwuuO0FA/EZg5/g7Rrqu+FgpwvFkJq
9twEZJY+aIdDH8/RVrCZQGR/xUxKw9v4ows+sLwi4g41m8KRKDXUcJwQvSlwsHAi
h9hPGZxDsRK0Nv4pZ7XqGgh0Wb0VypX/+Q1dhX9BnXQmvEKayk8GQWQxAgMBAAEC
gYAFqOJNnudV7fPpja4LjpQwEW+sATIRYJeWTC9587ByUE6xicM/hTxouhCm82Xc
Rzi4OjFR/vbRYOQ1dTtBtIi18fdRrseQNyR/N2NZjw1X8n5aZcw5NVaa3d3YTQNa
uzjnYF5eYSOD4pNKKIDc35VHdmvGCV/JXwQKMTgu1+4AAQJBAL5jjN3kvMKFF8vG
DyYR8k+wPG9iXAdR0HjVNB3OzxKVW0MTwM32pJBXCmF1MOziL8WC48VHQL48hVRa
52xRqAECQQCC53rrrOPhPCLIb6kBfgqnxCojqlUK9paFL7NYTPtLYcOajY6+NiKT
CG1gaOwZh4r34HF7I59l/Ds98Z4nQDwxAkAC4/oIiGeBQIoK8vfZ6R3XreJNAp5J
EinrG7mN1kz4iEH5c7xSpDL9agTjU+cpQYneIs2Yeit2d+7CSBsJXvgBAkBDFsfU
yYLxCJT7DN8dOK/VU6AVL1Luj3qNP+k2tB2GgNBzAWHK8ou9t2/3HU8DtofuikUe
yx8Cccca9B4OF8nBAkAgIUZKGmVNFcGnFFo55vSJInNXFo4HCJ2o4DunBORVtQ/j
zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
-----END RSA PRIVATE KEY-----";
public $profile_key = '';
//设置请求头
public $headers = [
'Authorization' => 'Bearer ',
'Content-Type' => 'application/json',
// 'Accept-Encoding' => 'deflate, gzip',
];
//私钥
private $private_key = "-----BEGIN RSA PRIVATE KEY-----
MIICWgIBAAKBgGFatMeBeaw7QJrqmylMLZlwuuO0FA/EZg5/g7Rrqu+FgpwvFkJq
9twEZJY+aIdDH8/RVrCZQGR/xUxKw9v4ows+sLwi4g41m8KRKDXUcJwQvSlwsHAi
h9hPGZxDsRK0Nv4pZ7XqGgh0Wb0VypX/+Q1dhX9BnXQmvEKayk8GQWQxAgMBAAEC
gYAFqOJNnudV7fPpja4LjpQwEW+sATIRYJeWTC9587ByUE6xicM/hTxouhCm82Xc
Rzi4OjFR/vbRYOQ1dTtBtIi18fdRrseQNyR/N2NZjw1X8n5aZcw5NVaa3d3YTQNa
uzjnYF5eYSOD4pNKKIDc35VHdmvGCV/JXwQKMTgu1+4AAQJBAL5jjN3kvMKFF8vG
DyYR8k+wPG9iXAdR0HjVNB3OzxKVW0MTwM32pJBXCmF1MOziL8WC48VHQL48hVRa
52xRqAECQQCC53rrrOPhPCLIb6kBfgqnxCojqlUK9paFL7NYTPtLYcOajY6+NiKT
CG1gaOwZh4r34HF7I59l/Ds98Z4nQDwxAkAC4/oIiGeBQIoK8vfZ6R3XreJNAp5J
EinrG7mN1kz4iEH5c7xSpDL9agTjU+cpQYneIs2Yeit2d+7CSBsJXvgBAkBDFsfU
yYLxCJT7DN8dOK/VU6AVL1Luj3qNP+k2tB2GgNBzAWHK8ou9t2/3HU8DtofuikUe
yx8Cccca9B4OF8nBAkAgIUZKGmVNFcGnFFo55vSJInNXFo4HCJ2o4DunBORVtQ/j
zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
-----END RSA PRIVATE KEY-----";
/**
* @name :参数构建
* @name :(创建子账户配置文件)post_create_profiles
* @author :lyh
* @method :post
* @time :2023/5/5 15:16
*/
public function __construct()
{
$this->headers['Authorization'] = $this->headers['Authorization'].$this->api_key;
public function post_create_profiles($data){
$param = [
'title'=>$data['title'],
];
$url = $this->path.'/api/profiles/profile';
return $this->http_click('post',$url,$param);
}
/**
* @name :(删除子账户配置文件)deleted_profiles
* @author :lyh
* @method :post
* @time :2023/5/5 15:16
*/
public function deleted_profiles($data){
$param = [
'title'=>$data['title'],
'profileKey'=>$this->profile_key,
];
$url = $this->path.'/api/profiles/profile';
return $this->http_click('delete',$url,$param);
}
/**
* @name :(跳转第三方生成jwt令牌)post_generate_jwt
* @author :lyh
* @method :post
* @time :2023/5/5 18:07 https://app.ayrshare.com/api/profiles/generateJWT
*/
public function post_generate_jwt($data,$domain = 'globalso'){
$param = [
'domain'=>$domain,
'privateKey'=>$this->private_key,
'profileKey'=>$data['profileKey'],
// 'logout'=>true
];
$url = $this->path.'/api/profiles/generateJWT';
return $this->http_click('post',$url,$param);
}
/**
* @name :(获取指定api_key的配置文件)get_profiles_users
* @author :lyh
* @method :post
* @time :2023/5/6 16:44
*/
public function get_profiles_users($api_key){
$this->headers['Authorization'] = $this->headers['Authorization'].$api_key;
$url = $this->path.'/api/user';
return $this->http_click('get',$url,[],$this->headers);
}
/**
* @name :(发帖)post_send_msg
* @author :lyh
* @method :post
* @time :2023/5/8 9:22
* @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'],
];
//平台参数处理
$this->headers['Accept-Encoding'] = 'gzip';
$this->headers['Authorization'] = $this->headers['Authorization'].$param['profile_key'];
$url = $this->path.'/api/post';
return $this->http_click('posts',$url,$param,$this->headers);
}
/**
* @name :(上传图片或视频到ayr_share)post_media_upload
* @author :lyh
* @method :post
* @time :2023/5/8 9:47
* https://app.ayrshare.com/api/media/upload
*/
public function post_media_upload($data){
$param = [
'file'=>$data['file'],//base64编码
'fileName'=>$data['file_name'],//生成图片名称
'description'=>$data['description'],//描述
];
$this->headers['Authorization'] = $this->headers['Authorization'].$data['profile_key'];
$url = $this->path.'/api/media/upload';
return $this->http_click('posts',$url,$param,$this->headers);
}
/**
... ... @@ -133,7 +229,7 @@ class AyrShare
* @method :post
* @time :2023/5/5 15:00
*/
public function post_user($data){
public function post_profiles($data){
$param = [
'post'=>$data['post'],
'platforms'=>$data['platforms'],
... ... @@ -145,57 +241,6 @@ class AyrShare
}
/**
* @name :(创建子账户相关操作)post_create_profiles
* @author :lyh
* @method :post
* @time :2023/5/5 15:16
*/
public function post_create_profiles($data){
$param = [
'title'=>$data['title'],
];
$url = $this->path.'/profiles/profile';
return $this->http_click('post',$url,$param);
}
/**
* @name :(删除子账户相关操作)post_create_profiles
* @author :lyh
* @method :post
* @time :2023/5/5 15:16
*/
public function deleted_create_profiles($data){
$param = [
'title'=>$data['title'],
'profileKey'=>$this->profile_key,
];
$url = $this->path.'/profiles/profile';
return $this->http_click('delete',$url,$param);
}
public function put_update_profiles($data){
$param = [
'title'=>$data['title'],
'profileKey'=>$this->profile_key,
];
$url = $this->path.'/profiles/profile';
return $this->http_click('put',$url,$param);
}
/**
* @name :(获取有关用户社交资料的分析和人口统计,例如印象,视图和关注着)post_social
* @author :lyh
* @method :post
* @time :2023/5/5 10:37
*/
public function api_user(){
$post_data = [
'platforms' => ['facebook', 'instagram', 'twitter', 'linkedin', 'pinterest', 'youtube', 'tiktok'],
];
$url = $this->path.'/api/user';
return $this->http_click('post',$url,$post_data);
}
/**
* 发送http post,get,put,delete请求
* @param type $url
* @param type $post_data
... ... @@ -205,13 +250,16 @@ class AyrShare
if(!empty($param)){
$post_data['json'] = $param;
}
if(empty($header)){
$this->headers['Authorization'] = $this->headers['Authorization'].$this->api_key;
}
$post_data['headers'] = !empty($header) ? $header : $this->headers;
$client = new Client();
try {
$res = $client->request(strtoupper($method), $url, $post_data)->getBody()->getContents();
return $res;
return (array)json_decode($res);
} catch (\Exception $e) {
return json_encode(["status"=>"fail","message"=>$e->getMessage()]);
return ["status"=>"fail","message"=>$e->getMessage()];
}
}
}
... ...
<?php
namespace App\Http\Controllers\Bside\AyrShare;
use App\Enums\Common\Code;
use App\Helper\AyrShare as AyrShareHelper;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\AyrShare\AyrShareLogic;
use App\Models\AyrShare\AyrShare as AyrShareModel;
/**
* @name:社交绑定
*/
class AyrShareController extends BaseController
{
/**
* @name :(社交列表)lists
* @author :lyh
* @method :post
* @time :2023/5/5 16:06
*/
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 :(创建ayr_share账户)create_account
* @author :lyh
* @method :post
* @time :2023/5/5 16:44
*/
public function create_account(AyrShareLogic $ayrShareLogic){
$param = [
'title'=>md5(uniqid().time()),
];
//发送请求注册社交用户
$ayrShareHelper = new AyrShareHelper();
$res = $ayrShareHelper->post_create_profiles($param);
if($res['status'] == 'fail'){
$this->response('同步绑定失败');
}
//执行数据库操作
$ayrShareLogic->ayr_share_add($res);
$this->response('success');
}
/**
* @name :(删除用户账号并同步ayr_share账号)edit_account
* @author :lyh
* @method :post
* @time :2023/5/6 10:11
*/
public function del_account(AyrShareLogic $ayrShareLogic){
$this->request->validate([
'id'=>['required']
],[
'id.required' => 'ID不能为空'
]);
$info = $ayrShareLogic->ayr_share_info();
$data = [
'title'=>$info['title'],
'profileKey'=>$info['profile_key']
];
//发送请求注册社交用户
$ayrShareHelper = new AyrShareHelper();
$res = $ayrShareHelper->deleted_profiles($data);
if($res['status'] == 'fail'){
$this->response('同步删除失败');
}
$ayrShareLogic->ayr_share_del();
$this->response('success');
}
/**
* @name :(授权绑定第三方平台,生成jwt令牌)ayr_share_bind
* @author :lyh
* @method :post
* @time :2023/5/6 10:24
*/
public function bind_account(AyrShareLogic $ayrShareLogic){
$this->request->validate([
'id'=>['required']
],[
'id.required' => 'ID不能为空'
]);
$info = $ayrShareLogic->ayr_share_info();
//发送请求注册社交用户
$ayrShareHelper = new AyrShareHelper();
$data = [
'profileKey'=>$info['profile_key']
];
$res = $ayrShareHelper->post_generate_jwt($data);
if($res['status'] == 'fail'){
$this->response($res['message'],Code::USER_ERROR);
}
$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();
}
}
... ...
... ... @@ -21,7 +21,7 @@ class BlogCategoryController extends BaseController
//搜索条件
$this->map['project_id'] = $this->user['project_id'];
$lists = $blogCategoryModel->lists($this->map,$this->page,$this->row,$this->order,
['id','pid','name','num','status','sort','remark','created_at','updated_at']);
['id','pid','name','num','alias','status','sort','remark','created_at','updated_at']);
if(!empty($lists['list'])){
$blogModel = new BlogModel();
foreach ($lists['list'] as $k => $v){
... ...
... ... @@ -21,7 +21,7 @@ class NewsCategoryController extends BaseController
//搜索条件
$this->map['project_id'] = $this->user['project_id'];
$lists = $newsCategory->lists($this->map,$this->page,$this->row,$this->order,
['id','pid','name','num','status','sort','remark','created_at','updated_at']);
['id','pid','name','num','alias','status','sort','remark','created_at','updated_at']);
if(!empty($lists['list'])){
$newsModel = new NewsModel();
foreach ($lists['list'] as $k => $v){
... ...
... ... @@ -6,6 +6,9 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\ProjectCountryLogic;
/**
* @name:项目配置多语言设置
*/
class ProjectCountryController extends BaseController
{
/**
... ...
... ... @@ -6,6 +6,9 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingLogic;
/**
* @name:项目首页设置
*/
class WebSettingController extends BaseController
{
/**
... ...
... ... @@ -7,6 +7,9 @@ use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingCountryLogic;
use App\Models\Project\Country as CountryModel;
/**
* @name:多语言国家配置列
*/
class WebSettingCountryController extends BaseController
{
/**
... ...
... ... @@ -6,6 +6,9 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingFromLogic;
/**
* @name:表单设置
*/
class WebSettingFromController extends BaseController
{
/**
... ... @@ -26,30 +29,7 @@ class WebSettingFromController extends BaseController
* @time :2023/4/28 14:41
*/
public function save(WebSettingFromLogic $webSettingFromLogic){
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
}
$webSettingFromLogic->setting_from_save();
$this->response('success');
}
/**
* @name :(删除表单)del
* @author :lyh
* @method :post
* @time :2023/5/4 13:38
*/
public function del(WebSettingFromLogic $webSettingFromLogic){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$webSettingFromLogic->setting_from_del();
$this->response('success');
}
}
... ...
... ... @@ -6,6 +6,9 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingHtmlLogic;
/**
* @name:第三方代码设置
*/
class WebSettingHtmlController extends BaseController
{
/**
... ...
<?php
namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingReceivingLogic;
/**
* @name:项目收信设置
*/
class WebSettingReceivingController extends BaseController
{
/**
* @name :(收信设置列表)lists
* @author :lyh
* @method :post
* @time :2023/5/8 16:22
*/
public function lists(WebSettingReceivingLogic $webSettingReceivingLogic){
$lists = $webSettingReceivingLogic->setting_receiving_lists();
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @name :(更新)save
* @author :lyh
* @method :post
* @time :2023/5/8 16:23
*/
public function save(WebSettingReceivingLogic $webSettingReceivingLogic){
$lists = $webSettingReceivingLogic->setting_receiving_save();
$this->response('success');
}
}
... ...
... ... @@ -6,6 +6,9 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingServiceLogic;
/**
* @name:客服设置
*/
class WebSettingServiceController extends BaseController
{
/**
... ...
<?php
namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingTextLogic;
/**
* @name:描文本设置
*/
class WebSettingTextController extends BaseController
{
/**
* @name :lists
* @author :lyh
* @method :post
* @time :2023/5/4 11:28
*/
public function lists(WebSettingTextLogic $webSettingTextLogic){
$lists = $webSettingTextLogic->setting_text_lists();
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @name :save
* @author :lyh
* @method :post
* @time :2023/4/28 14:46
*/
public function save(WebSettingTextLogic $webSettingTextLogic){
$webSettingTextLogic->setting_text_save();
$this->response('success');
}
}
... ...
<?php
namespace App\Http\Controllers\file;
use App\Enums\Common\Code;
use App\Models\File\File;
class FileController
{
public $upload_img = [
//设置静态缓存参数(304)
'header' => [
'Cache-Control' => 'max-age=2592000',
'Pragma' => 'cache',
'Expires' => "%Expires%", // cache 1 month
'etag' => "%etag%",
'Last-Modified' => "%Last-Modified%",
'Content-Description' => 'File Transfer',
],
];
public $path = '';
public $config = '';
public $thr_path = '';
public $request = '';
public function __construct()
{
$this->request = request();
$this->config = config('filesystems.disks.upload');
$this->path = $this->config['root'];
}
public function index($hash = '', $w = 0 ,$h = 0){
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
header("HTTP/1.1 304 Not Modified");
exit;
}
$file_model = new File();
$info = $file_model->read(['hash'=>$hash]);
if ($info === false) {
$this->response('指定文件不存在!', Code::USER_ERROR);
}
$path = $info['path'];
if (!is_file($path)) {
$this->response('指定文件已被系统删除!', Code::USER_ERROR);
}
$content = file_get_contents($path);
$header['Content-Length'] = $info['size'];
return response($content, 200, $header);
}
}
... ...
<?php
namespace App\Http\Controllers;
namespace App\Http\Controllers\file;
use App\Enums\Common\Code;
use App\Models\Image as ImageModel;
use App\Http\Controllers\type;
use App\Http\Controllers\统一返回参数;
use App\Models\File\Image as ImageModel;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Storage;
... ... @@ -114,12 +116,12 @@ class ImageController
}
$url = $this->path;
$filename = date('ymdHis').rand(10000,99999);
$res = $this->request->file('image')->move($url,$filename);
$res = $this->request->file('image')->move($url);
if ($res === false) {
return $this->response($files->getError(), Code::USER_ERROR);
}
$data = [
'path' => $url.'/'.$filename,
'path' => $url.'/'.$res->getClientOriginalName(),
'created_at' => date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $hash,
... ...
<?php
namespace App\Http\Logic\Bside\AyrShare;
use App\Helper\AyrShare as AyrShareHelper;
use App\Http\Controllers\file\ImageController;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\AyrShare\AyrShare;
class AyrShareLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new AyrShare();
$this->param = $this->requestAll;
}
/**
* @name :(创建账号并绑定写入数据库)ayr_add
* @author :lyh
* @method :post
* @time :2023/5/6 9:19
*/
public function ayr_share_add($res){
//插入数据库
$param = [
'title'=>$res['title'],
'ref_id'=>$res['refId'],
'profile_key'=>$res['profileKey'],
'user_id'=>$this->user['id'],
'project_id'=>$this->user['project_id'],
'name'=>$this->param['name'],
];
$rs = $this->model->add($param);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @name :(获取当前数据详情)ayr_share_del
* @author :lyh
* @method :post
* @time :2023/5/6 10:16
*/
public function ayr_share_info(){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
return $this->success($info);
}
/**
* @name :(删除ayr数据并同步删除)
* @author :lyh
* @method :post
* @time :2023/5/6 10:18
*/
public function ayr_share_del(){
$this->param['id'] = ['in',$this->param['id']];
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('删出失败');
}
return $this->success();
}
/**
* @name :(向第三方平台发布帖子)api_public_msg
* @author :lyh
* @method :post
* @time :2023/5/8 9:11
*/
public function send_public_post($param){
//获取图片
$image_c = new ImageController();
$image_info = $image_c->index($param['hash']);
$param = [
'post'=>$param['text'],
'mediaUrls'=>$image_info,
'platforms'=>$this->param['platforms'],
];
//发布帖子
$ayrShareHelper = new AyrShareHelper();
$res = $ayrShareHelper->post_send_msg($param);
$this->success($res);
}
}
... ...
... ... @@ -5,7 +5,7 @@ namespace App\Http\Logic\Bside;
use App\Enums\Common\Common;
use App\Exceptions\BsideGlobalException;
use App\Http\Controllers\ImageController;
use App\Http\Controllers\file\ImageController;
use App\Http\Logic\Logic;
use Illuminate\Support\Facades\Cache;
... ...
... ... @@ -101,8 +101,9 @@ class BlogCategoryLogic extends BaseLogic
if($info !== false){
$this->fail('当前分类名称已存在');
}
$this->param['operator_id'] = $this->user['id'];
$this->edit($this->param,$this->param['id']);
$this->edit($this->param,['id'=>$this->param['id']]);
return $this->success();
}
... ...
... ... @@ -7,7 +7,6 @@ use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Blog\Blog;
use App\Models\Blog\BlogCategory as BlogCategoryModel;
use App\Models\Image;
use App\Models\RouteMap;
use Illuminate\Support\Facades\DB;
... ... @@ -105,14 +104,6 @@ class BlogLogic extends BaseLogic
try {
//是否有图片更新
if(isset($this->param['image']) && is_file($this->param['image'])){
//查看当前用户是否已有头像
if($info !== false && !empty($info['image'])){
//TODO::删除资源
$imageModel = new Image();
$image_info = $imageModel->read(['hash'=>$info['image']],['id','path']);
shell_exec('sudo rm -rf '.$image_info['path'] .' ./../uploads/images/cache_'. $info['image'] . '*');
$imageModel->del(['hash'=>$info['image']]);
}
$this->param['image'] = $this->upload();
}
RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']);
... ... @@ -173,7 +164,7 @@ class BlogLogic extends BaseLogic
*/
public function blog_status(){
$this->param['operator_id'] = $this->user['id'];
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
$rs = $this->model->edit($this->param,['id'=>['in',$this->param['id']]]);
if($rs === false){
$this->fail('error');
}
... ...
... ... @@ -5,7 +5,6 @@ namespace App\Http\Logic\Bside\News;
use App\Enums\Common\Code;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Image;
use App\Models\News\News;
use App\Models\News\NewsCategory as NewsCategoryModel;
use App\Models\RouteMap;
... ... @@ -60,19 +59,19 @@ class NewsLogic extends BaseLogic
$this->param['project_id'] = $this->user['project_id'];
$this->param['created_at'] = date('Y-m-d H:i:s',time());
$this->param['updated_at'] = date('Y-m-d H:i:s',time());
// DB::beginTransaction();
// try {
DB::beginTransaction();
try {
if(isset($this->param['image'])){
$data = $this->upload();
$this->param['image'] = $data;
}
$rs = $this->model->insertGetId($this->param);
RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']);
// DB::commit();
// }catch (\Exception $e){
// DB::rollBack();
// $this->fail('添加失败');
// }
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('添加失败');
}
return $this->success();
}
... ... @@ -134,7 +133,7 @@ class NewsLogic extends BaseLogic
*/
public function news_status(){
$this->param['operator_id'] = $this->user['id'];
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
$rs = $this->model->edit($this->param,['id'=>['in',$this->param['id']]]);
if($rs === false){
$this->fail('error');
}
... ...
... ... @@ -22,7 +22,7 @@ class WebSettingFromLogic extends BaseLogic
* @time :2023/5/4 13:43
*/
public function setting_from_info(){
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
$info = $this->model->list(['project_id'=>$this->user['project_id']],'created_at');
if($info === false){
$this->fail('当前数据不存在,或者已被删除');
}
... ... @@ -39,10 +39,9 @@ class WebSettingFromLogic extends BaseLogic
public function setting_from_save(){
try {
//删除以前的数据
$param['project_id'] = ['in',$this->user['project_id']];
$this->model->del($param);
$this->model->del(['project_id'=>$this->user['project_id']]);
//新增
$this->model->add($this->param);
$this->model->add($this->param['data']);
}catch (\Exception $e){
$this->fail('error');
}
... ...
... ... @@ -44,7 +44,6 @@ class WebSettingLogic extends BaseLogic
//查看数据是否存在
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->param['operator_id'] = $this->user['id'];
$this->param['project_id'] = $this->user['project_id'];
$rs = $this->model->add($this->param);
}else{
... ...
<?php
namespace App\Http\Logic\Bside\Setting;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\WebSetting\WebSettingReceiving;
use App\Models\WebSetting\WebSettingText;
class WebSettingReceivingLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new WebSettingReceiving();
$this->param = $this->requestAll;
}
/**
* @name :(列表数据)setting_receiving_lists
* @author :lyh
* @method :post
* @time :2023/5/8 16:17
*/
public function setting_receiving_lists(){
$lists = $this->model->list(['project_id'=>$this->user['project_id']]);
return $this->success($lists);
}
/**
* @name :(设置收信账号)setting_receiving_save
* @author :lyh
* @method :post
* @time :2023/5/8 16:26
*/
public function setting_receiving_save(){
try {
$this->model->del(['project_id'=>$this->user['project_id']]);
foreach ($this->param['data'] as $k => $v){
$v['project_id'] = $this->user['project_id'];
$this->param['data'][$k] = $v;
}
$this->model->add($this->param['data']);
}catch (\Exception $e){
$this->fail('error');
}
return $this->success();
}
}
... ...
... ... @@ -3,7 +3,7 @@
namespace App\Http\Logic\Bside\Setting;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Image;
use App\Models\File\Image;
use App\Models\WebSetting\WebSettingService;
use Illuminate\Support\Facades\DB;
... ... @@ -37,35 +37,15 @@ class WebSettingServiceLogic extends BaseLogic
public function setting_service_save(){
try {
//删除以前的数据
$param['project_id'] = $this->user['project_id'];
$this->model->del($param);
$this->model->del(['project_id'=>$this->user['project_id']]);
foreach ($this->param['data'] as $k => $v){
$v['project_id'] = $this->user['project_id'];
$this->param['data'][$k] = $v;
}
$this->model->add($this->param['data']);
}catch (\Exception $e){
$this->fail('error');
}
return $this->success();
}
/**
* @name :(删除客服图片)setting_service_del
* @author :lyh
* @method :post
* @time :2023/5/4 11:29
*/
public function setting_service_del(){
DB::beginTransaction();
try {
//获取当前图片资源
$image = new Image();
$info = $image->read(['hash'=>$this->param['hash']]);
if($info !== false){
$image->del(['id'=>$info['id']]);
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
}
}
}
... ...
<?php
namespace App\Http\Logic\Bside\Setting;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\WebSetting\WebSetting;
use App\Models\WebSetting\WebSettingText;
use Illuminate\Support\Facades\DB;
class WebSettingTextLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new WebSettingText();
$this->param = $this->requestAll;
}
/**
* @name :(查询设置详情)setting_read
* @author :lyh
* @method :post
* @time :2023/5/8 15:56
*/
public function setting_read(){
$web_setting = new WebSetting();
$setting_info = $web_setting->read(['project_id'=>$this->user['project_id']],['anchor_setting','anchor_is_enable','anchor_num']);
return $setting_info;
}
/**
* @name :(描文本详情)setting_text_lists
* @author :lyh
* @method :post
* @time :2023/5/8 14:18
*/
public function setting_text_lists(){
$lists['data'] = $this->model->list(['project_id'=>$this->user['project_id']],'created_at',['key_words','url']);
$lists['anchor_info'] = $this->setting_read();
$anchor_text = $this->model->anchor_text;
$lists['anchor_text'] = $anchor_text;
return $this->success($lists);
}
/**
* @name :(设置描文本)setting_text_save
* @author :lyh
* @method :post
* @time :2023/5/8 14:39
*/
public function setting_text_save(){
$web_setting = new WebSetting();
$setting_info = $this->setting_read();
if(count($this->param['data']) > $setting_info['anchor_num']){
$this->fail('超过最大设置限制');
}
DB::beginTransaction();
try {
//更新描文本设置
$data = [
'anchor_setting'=>$this->param['anchor_setting'],
'anchor_is_enable'=>$this->param['anchor_is_enable'],
'anchor_num'=>$this->param['anchor_num']
];
$web_setting->edit($data,['project_id'=>$this->user['project_id']]);
$this->model->del(['project_id'=>$this->user['project_id']]);
foreach ($this->param['data'] as $k => $v){
$v['project_id'] = $this->user['project_id'];
$this->param['data'][$k] = $v;
}
$this->model->add($this->param['data']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('更新失败');
}
$this->success();
}
}
... ...
... ... @@ -3,9 +3,7 @@
namespace App\Http\Logic\Bside\User;
use App\Enums\Common\Code;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Image;
use App\Models\User\User;
class UserLogic extends BaseLogic
... ...
<?php
namespace App\Http\Requests\Bside\AyrShare;
use Illuminate\Foundation\Http\FormRequest;
class AyrShareRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
}
... ...
... ... @@ -26,7 +26,7 @@ class BlogCategoryRequest extends FormRequest
return [
'name'=>'required|max:100',
'remark'=>'required|max:255',
'alias'=>'required|max:10|unique:gl_blog_category,alias',
'alias'=>'required|max:10',
];
}
... ... @@ -37,8 +37,8 @@ class BlogCategoryRequest extends FormRequest
'name.max'=>'名称最大100字',
'remark.required'=>'请填写简介',
'remark.max'=>'简介最大255字',
'remark.required'=>'请填写别名',
'remark.max'=>'别名最大10字',
'alias.required'=>'请填写别名',
'alias.max'=>'别名最大10字',
];
}
}
... ...
... ... @@ -26,7 +26,7 @@ class NewsCategoryRequest extends FormRequest
return [
'name'=>'required|max:100',
'remark'=>'required|max:255',
'alias'=>'required|max:10|unique:gl_news_category,alias',
'alias'=>'required|max:10',
];
}
... ... @@ -37,8 +37,8 @@ class NewsCategoryRequest extends FormRequest
'name.max'=>'名称最大100字',
'remark.required'=>'请填写简介',
'remark.max'=>'简介最大255字',
'remark.required'=>'请填写别名',
'remark.max'=>'别名最大10字',
'alias.required'=>'请填写一下别名',
'alias.max'=>'别名最大10字',
];
}
}
... ...
<?php
namespace App\Models\AyrShare;
use App\Models\Base;
class AyrRelease extends Base
{
protected $table = 'gl_ayr_release';
}
... ...
<?php
namespace App\Models\AyrShare;
use App\Models\Base;
class AyrShare extends Base
{
protected $table = 'gl_ayr_share';
}
... ...
... ... @@ -112,6 +112,17 @@ class Base extends Model
$info = $info->toArray();
return $info;
}
/**
* @name :(获取数据条数)count
* @author :lyh
* @method :post
* @time :2023/5/8 15:51
*/
public function get_count($condition){
$query = $this->formatQuery($condition);
$query->count();
}
/**
* @name :新增
* @return void
... ... @@ -130,6 +141,9 @@ class Base extends Model
* @method post
*/
public function edit($data,$condition){
if(isset($data['id']) && !empty($data['id'])){
unset($data['id']);
}
$query = $this->formatQuery($condition);
$data['updated_at'] = date('Y-m-d H:i:s');
return $query->update($data);
... ...
<?php
namespace App\Models\File;
use App\Models\Base;
class File extends Base
{
protected $table = 'gl_file';
}
... ...
<?php
namespace App\Models;
namespace App\Models\File;
use App\Models\Base;
class Image extends Base
{
... ...
... ... @@ -7,4 +7,5 @@ use App\Models\Base;
class WebSetting extends Base
{
protected $table = 'gl_web_setting';
}
... ...
<?php
namespace App\Models\WebSetting;
use App\Models\Base;
class WebSettingReceiving extends Base
{
protected $table = 'gl_web_setting_receiving';
}
... ...
<?php
namespace App\Models\WebSetting;
use App\Models\Base;
class WebSettingText extends Base
{
protected $table = 'gl_web_setting_text';
//定义常量参数
const TYPE_PAGE = 1;
const TYPE_PRODUCT = 2;
const TYPE_KEYWORD = 3;
const TYPE_NEWS = 4;
const TYPE_BLOG = 6;
/**
* @var :描文本设置
*/
public $anchor_text = [
self::TYPE_PAGE => '单页面',
self::TYPE_PRODUCT=>'产品页',
self::TYPE_KEYWORD=>'关键词页',
self::TYPE_NEWS=>'新闻页',
self::TYPE_BLOG=>'博客页',
];
}
... ...
<?php
return [
];
... ...
... ... @@ -131,6 +131,16 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingServiceController::class, 'lists'])->name('web_setting_service_lists');
Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingServiceController::class, 'save'])->name('web_setting_service_save');
});
//客服设置
Route::prefix('text')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingTextController::class, 'lists'])->name('web_setting_text_lists');
Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingTextController::class, 'save'])->name('web_setting_text_save');
});
//收信设置
Route::prefix('receiving')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingReceivingController::class, 'lists'])->name('web_setting_receiving_lists');
Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingReceivingController::class, 'save'])->name('web_setting_receiving_save');
});
});
//产品
... ... @@ -178,8 +188,9 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('file')->group(function () {
Route::post('/upload', [\App\Http\Controllers\Bside\FileController::class, 'upload'])->name('file_upload');
});
//图片操作
Route::prefix('images')->group(function () {
Route::post('/upload', [\App\Http\Controllers\ImageController::class, 'upload'])->name('image_upload');
Route::post('/upload', [\App\Http\Controllers\file\ImageController::class, 'upload'])->name('image_upload');
});
//精准询盘
... ... @@ -194,6 +205,14 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('route')->group(function () {
Route::any('/create', [\App\Http\Controllers\Bside\RouteController::class, 'create'])->name('create_route');
});
//社交绑定
Route::prefix('ayr')->group(function () {
Route::any('/lists', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'lists'])->name('ayr_lists');
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');
});
});
//无需登录验证的路由组
... ... @@ -201,5 +220,5 @@ 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::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download');
Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\ImageController::class,'index'])->name('image_show');
Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show');
});
... ...