作者 Your Name

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

... ... @@ -44,19 +44,11 @@ class Demo extends Command
*/
public function handle()
{
//切换数据库配置
$project = ProjectServer::useProject(1);
//创建数据库
ProjectServer::createDatabase($project);
//创建表
ProjectServer::initTable($project);
preg_match_all("/\@include\(\"([a-z0-9_]+)\"\)/i",'
@include("asdf")@include("")@include("asdtrw2erf")
',$include);
dd(1);
$sql = 'CREATE DATABASE database_name;';
$results = DB::select($sql);
dd($results);
return true;
print_r($include);
}
public function printMessage()
... ...
... ... @@ -68,7 +68,7 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
public function deleted_profiles($data){
$param = [
'title'=>$data['title'],
'profileKey'=>$this->profile_key,
// 'profileKey'=>$this->profile_key,
];
$url = $this->path.'/api/profiles/profile';
return $this->http_click('delete',$url,$param);
... ...
... ... @@ -2,7 +2,10 @@
namespace App\Http\Controllers\Aside;
use App\Models\Template\AHeadFoot;
use App\Enums\Common\Code;
use App\Models\Template\ATemplate;
use App\Models\Template\ATemplateHtml;
use Illuminate\Validation\Rule;
/**
* 模板
... ... @@ -22,22 +25,22 @@ class TemplateController extends BaseController
*/
public function index(){
$data = AHeadFoot::all();
$lists = [];
// 以名字为单位区分
foreach ($data as $datum){
if(empty($lists[$datum['name']])) $lists[$datum['name']] = [];
$lists[$datum['name']]['name'] = $datum['name'];
$lists[$datum['name']]['default'] = $datum['is_default'];
$lists[$datum['name']]['sort'] = $datum['sort'];
$lists[$datum['name']]['status'] = $datum['status'];
$lists[$datum['name']]['created_at'] = $datum['created_at'];
// $lists[$datum['name']]['tags'] = $datum['tags'];
$lists[$datum['name']][$datum['type']==AHeadFoot::TYPE_HEADER?'header':'footer'] = $datum['html'];
}
$limit = $this->param['limit']??20;
$lists = ATemplate::where(function ($query){
!empty($this->param['status']) && $query->where('status',$this->param['status']);
!empty($this->param['name']) && $query->where('status',$this->param['name']);
})
->select(['id','name','status','is_default','sort','thumb','url','created_at','updated_at'])
->orderBy('sort')
->paginate($limit);
return $this->success($lists);
return $this->success($lists->toArray());
}
... ... @@ -47,7 +50,7 @@ class TemplateController extends BaseController
* @time 2023/5/4 16:19
*/
public function edit(){
$this->save(true);
}
/**
... ... @@ -56,12 +59,168 @@ class TemplateController extends BaseController
* @time 2023/5/5 9:30
*/
public function insert(){
$this->save();
}
/**
* @param false $is_edit
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author:dc
* @time 2023/5/11 10:13
*/
private function save($is_edit=false){
$verify = [
'role' => [
'id' => ['required','integer'],
'name' => ['required'],
'status' => ['required',Rule::in(0,1)],
'is_default' => ['required',Rule::in(0,1)],
'sort' => ['required','integer'],
'thumb' => ['required'],
'url' => ['required'],
],
'message' => [
'id.required' => 'id必须',
'id.integer' => 'id必须',
'name.required' => '名称必须',
'status.integer' => '状态错误',
'status.in' => '状态错误',
'is_default.integer' => '是否默认',
'is_default.in' => '是否默认',
'sort.required' => '排序必须',
'sort.integer' => '排序必须',
'thumb.required' => '缩略图必须',
'url.required' => '预览链接必须',
]
];
if(!$is_edit) unset($verify['role']['id']);
$data = $this->validate(request() ,$verify['role'],$verify['message']);
// 保存
$id = ATemplate::_save($data,$data['id']??0);
if(!$id){
return $this->response('保存失败',Code::SYSTEM_ERROR);
}
return $this->success(ATemplate::_find($id));
}
private function save($name = ''){
/**
* 删除
* @author:dc
* @time 2023/5/4 17:10
*/
public function delete($id){
if(ATemplate::destroy($id)){
return $this->response('删除成功');
}
return $this->response('删除失败',Code::SYSTEM_ERROR);
}
/**
* 列表
* @author:dc
* @time 2023/5/4 17:10
*/
public function html_index($template_id){
$lists = ATemplateHtml::where('template_id',$template_id)->get();
return $this->success($lists->toArray());
}
/**
* 编辑
* @author:dc
* @time 2023/5/4 16:19
*/
public function html_edit($template_id){
$this->html_save($template_id,true);
}
/**
* 新增
* @author:dc
* @time 2023/5/5 9:30
*/
public function html_insert($template_id){
$this->html_save($template_id);
}
/**
* @param false $is_edit
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author:dc
* @time 2023/5/11 10:13
*/
private function html_save($template_id,$is_edit=false){
$verify = [
'role' => [
'id' => ['required','integer'],
// 'template_id' => ['required','integer'],
'name' => ['required'],
'type' => ['required',Rule::in(ATemplateHtml::$typeMap)],
'css' => [],
'script' => [],
'html' => ['required'],
],
'message' => [
'id.required' => 'id必须',
'id.integer' => 'id必须',
// 'template_id.required' => '模板选择错误',
// 'template_id.integer' => '模板选择错误',
'name.required' => '名称必须',
'type.required' => '页面类型选择错误',
'type.in' => '页面类型选择错误',
'html.required' => 'html 代码必须',
]
];
if(!$is_edit) unset($verify['role']['id']);
$data = $this->validate(request() ,$verify['role'],$verify['message']);
// 保存
$id = ATemplateHtml::_save($template_id,$data,$data['id']??0);
if(!$id){
return $this->response('保存失败',Code::SYSTEM_ERROR);
}
return $this->success(ATemplateHtml::_find($id));
}
... ... @@ -70,12 +229,28 @@ class TemplateController extends BaseController
* @author:dc
* @time 2023/5/4 17:10
*/
public function delete(){
public function html_delete($template_id, $id){
if(ATemplateHtml::where('template_id',$template_id)->where('id',$id)->delete()){
return $this->response('删除成功');
}
return $this->response('删除失败',Code::SYSTEM_ERROR);
}
/**
* 页面类型
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author:dc
* @time 2023/5/11 10:29
*/
public function html_type(){
return $this->success(ATemplateHtml::$typeMap);
}
... ...
... ... @@ -14,6 +14,14 @@ use App\Models\File\Image as ImageModel;
/**
* @name:社交发布
* Facebook Pages and Groups: 10 images, including a carousel post.
* Instagram: 10 images.
* Google : 1 image.
* LinkedIn: 9 images.
* Pinterest: 1 image.
* Reddit: 1 image.
* Telegram: 1 image.
* Twitter:4 image
*/
class AyrReleaseController extends BaseController
{
... ... @@ -45,33 +53,26 @@ class AyrReleaseController extends BaseController
* @time :2023/5/9 9:36
*/
public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic,AyrShareHelper $ayrShare){
// DB::beginTransaction();
// try {
//获取发送账号详情
$share_info = $ayrShareLogic->ayr_share_info();
$data = [
'images'=>$this->param['image'],
'files'=>$this->param['file'],
'images'=>$this->param['images'],
'files'=>$this->param['video'],
];
//参数处理
$image_data = $ayrReleaseLogic->image_file_param($data);
$this->param['mediaUrls'] = array_merge($image_data['images_link'],$image_data['files_link']);
//统一生成链接
$this->param['mediaUrls'] = $ayrReleaseLogic->image_file_param($data);;
//统一生成发布
$param = [
'post'=>$this->param['content'],
'platforms'=>$this->param['platforms'],
'mediaUrls'=>$this->param['mediaUrls'],//参数处理
'idempotencyKey'=>$this->param['idempotency_key'],//时间(如是过去时间,立即发布)
];
//发送请求注册社交用户
//发送请求发布社交文章
$res = $ayrShare->post_send_msg($param,$share_info['profile_key']);
$this->response('success',Code::SUCCESS,$res);
//保存数据库
$ayrReleaseLogic->release_add();
// DB::commit();
// }catch (\Exception $e){
// DB::rollBack();
// $this->response('error',Code::USER_ERROR);
// }
$this->response('success',Code::SUCCESS,$res);
}
/**
... ...
... ... @@ -13,6 +13,8 @@ use App\Models\AyrShare\AyrShare as AyrShareModel;
*/
class AyrShareController extends BaseController
{
//生成名称前缀
const TITLE = 'global_so_';
/**
* @name :(社交列表)lists
* @author :lyh
... ... @@ -20,7 +22,10 @@ class AyrShareController extends BaseController
* @time :2023/5/5 16:06
*/
public function lists(AyrShareModel $ayrShareModel){
$lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['*']);
//授权配置列表
$share_list = $ayrShareModel->platforms;
$lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['id','name','bind_plat_from','operator_id','created_at','updated_at']);
$lists['share_list'] = $share_list;
$this->response('列表',Code::SUCCESS,$lists);
}
... ... @@ -36,9 +41,13 @@ class AyrShareController extends BaseController
$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]);
if($str != $info['bind_plat_from']){
$res = $ayrShareLogic->ayr_share_edit(['bind_plat_from'=>$str]);
}else{
$res = false;
}
$this->response('success');
}
$this->response('success',Code::SUCCESS,['is_true'=>$res]);
}
/**
* @name :(创建ayr_share账户)create_account
... ... @@ -48,7 +57,7 @@ class AyrShareController extends BaseController
*/
public function create_account(AyrShareLogic $ayrShareLogic){
$param = [
'title'=>'global_so:'.$this->param['name'],
'title'=>self::TITLE.$this->user['project_id'].':'.$this->param['name'],
];
//发送请求注册社交用户
$ayrShareHelper = new AyrShareHelper();
... ...
... ... @@ -101,12 +101,21 @@ class BaseController extends Controller
*/
public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse
{
try {
$code = Code::fromValue($code);
$result = [
'msg' => $msg == ' ' ? $code->description : $msg,
'code' => $code->value,
'data' => $this->_extents($data),
];
}catch (\Throwable $e){
$result = [
'msg' => $msg,
'code' => $code,
'data' => $this->_extents($data),
];
}
$this->header['Content-Type'] = $type;
$this->header['token'] = $this->token;
$response = response($result,$result_code,$this->header);;
... ...
... ... @@ -26,7 +26,7 @@ class CustomController extends BaseController
'title' => ['required','max:200'],
'keywords' => ['required','max:200'],
'description' => ['required','max:250'],
'html' => ['required'],
// 'html' => ['required'],
'url' => ['required','max:200'],
'status' => ['required','in:0,1'],
],
... ... @@ -144,5 +144,33 @@ class CustomController extends BaseController
/**
* @param $id
* @return \Illuminate\Http\JsonResponse
* @author:dc
* @time 2023/5/10 14:10
*/
public function html($id)
{
$data = BCustom::_find($this->user['project_id'],$id);
if(!$data){
return $this->response('数据不存在','B_CUSTOM_NOTFOUND');
}
if($this->isPost()){
$html = $this->param['html']??'';
$data->html = $html;
$data->save();
}
return $this->response('',Code::SUCCESS,$data['html']);
}
}
... ...
... ... @@ -189,7 +189,7 @@ class NavController extends BaseController
'name' => '单页'
],
[
'url' => 'goods',
'url' => '/goods',
'name' => '商品'
],
]);
... ...
... ... @@ -3,8 +3,12 @@
namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
use App\Models\Template\ATemplate;
use App\Models\Template\ATemplateHtml;
use App\Models\Template\BSetting;
use App\Models\Template\BTemplateData;
use Illuminate\Validation\Rule;
/**
... ... @@ -71,5 +75,110 @@ class TemplateController extends BaseController
}
/**
* 保存模板
* @author:dc
* @time 2023/5/10 10:53
*/
public function save(){
$html = '<header id="globalso-header" class="web_head sticky-top py-1 py-md-0" style="background-color: #318fff;">asdf</header>';
// 替换 header
$html = preg_replace("/<header(.*)id=\"globalso-header\"(.*)>([\s\S]*)<\/header>/iU",'',$html);
$html = preg_replace("/<main(.*)id=\"globalso-main\"(.*)>([\s\S]*)<\/main>/iU",'',$html);
$html = preg_replace("/<footer(.*)id=\"globalso-footer\"(.*)>([\s\S]*)<\/footer>/iU",'',$html);
}
/**
* 数据源
* @return \Illuminate\Http\JsonResponse
* @author:dc
* @time 2023/5/11 10:47
*/
public function get_type(){
return $this->success(ATemplateHtml::$sourceMap);
}
/**
* 获取 编辑html
* @author:dc
* @time 2023/5/11 9:33
*/
public function get_html(){
$source = $this->param['source']??'';
$source_id = $this->param['source_id']??0;
return $this->success();
}
/**
* 保存
* @author:dc
* @time 2023/5/11 11:00
*/
public function save_html(){
$source = $this->param['source']??'';
$source_id = $this->param['source_id']??0;
$html = $this->param['html']??'';
}
/**
* 自定义块
* @author:dc
* @time 2023/5/10 14:55
*/
public function customChunk(){
$html = $this->param['html']??[];
// 那个页面 的
$type = $this->param['type']??'';
if(!is_array($html)){
return $this->response('参数异常','B_CUSTOM_CHUNK_PARAMS');
}
// 项目id
$project_id = $this->user['project_id'];
// 当前模板
$template_id = BSetting::_get($project_id)['template_id'];
// 验证这个模板是否存在
if(!$type || !ATemplateHtml::_typeExist($template_id,$type)){
return $this->response('页面类型错误','B_CUSTOM_CHUNK_PARAMS_TYPE');
}
$html = view("template.{$template_id}.{$type}")->render();
return $this->response('',Code::SUCCESS,$html);
// $data = BTemplateData::_insert();
}
}
... ...
... ... @@ -38,6 +38,8 @@ class AyrReleaseLogic extends BaseLogic
* @time :2023/5/9 9:38
*/
public function release_add(){
$this->param['project_id'] = $this->user['project_id'];
$this->param['operator_id'] = $this->user['id'];
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('error');
... ...
... ... @@ -48,7 +48,7 @@ class AyrShareLogic extends BaseLogic
* @time :2023/5/6 10:16
*/
public function ayr_share_info(){
$info = $this->model->read(['id'=>$this->param['id']]);
$info = $this->model->read(['id'=>$this->param['share_id']]);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
... ...
... ... @@ -3,10 +3,12 @@
namespace App\Http\Logic\Bside;
use App\Enums\Common\Code;
use App\Enums\Common\Common;
use App\Exceptions\BsideGlobalException;
use App\Http\Controllers\file\ImageController;
use App\Http\Logic\Logic;
use App\Models\File\Image as ImageModel;
use Illuminate\Support\Facades\Cache;
/**
... ... @@ -93,14 +95,37 @@ class BaseLogic extends Logic
}
/**
* @name :上传图片
* @name :上传图片返回hash
* @return void
* @author :liyuhang
* @method
*/
public function upload(){
$image = new ImageController();
$hash = $image->upload();
$files = $this->request->file('image');
$hash = hash_file('md5', $files->getPathname());
//查看文件是否存在
$imageModel = new ImageModel();
$image_hash = $imageModel->read(['hash'=>$hash]);
if($image_hash !== false){
return $hash;
}
$url = $this->path;
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
$res = $files->move($url,$fileName);
if ($res === false) {
return false;
}
$data = [
'path' => $url.$fileName,
'created_at' => date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $hash,
'type'=>$files->getClientOriginalExtension(),
];
$rs = $imageModel->add($data);
if ($rs === false) {
return false;
}
return $hash;
}
... ...
... ... @@ -7,4 +7,30 @@ use App\Models\Base;
class AyrShare extends Base
{
protected $table = 'gl_ayr_share';
const TYPE_FACEBOOK = 1;
const TYPE_TWITTER = 2;
const TYPE_LINKEDIN = 3;
const TYPE_INSTAGRAM = 4;
const TYPE_YOUTUBE = 5;
const TYPE_REDDIT = 6;
const TYPE_TELEGRAM = 7;
const TYPE_GMB = 8;
const TYPE_PINTEREST = 9;
const TYPE_TIKTOK = 10;
/**
* @var :授权列表
*/
public $platforms = [
self::TYPE_FACEBOOK => 'Facebook',
self::TYPE_TWITTER => 'Twitter',
self::TYPE_LINKEDIN => 'LinkedIn',
self::TYPE_INSTAGRAM => 'Instagram',
self::TYPE_YOUTUBE => 'YouTube',
self::TYPE_REDDIT => 'Reddit',
self::TYPE_TELEGRAM => 'Telegram',
self::TYPE_GMB => 'Google',
self::TYPE_PINTEREST => 'Pinterest',
self::TYPE_TIKTOK => 'TikTok',
];
}
... ...
... ... @@ -59,7 +59,7 @@ class BCustom extends Base
$model->description = $data['description'];
$model->url = $data['url'];
$model->status = $data['status'];
$model->html = $data['html'];
$model->html = $data['html']??'';
$model->save();
... ...
... ... @@ -2,7 +2,6 @@
namespace App\Models;
use App\Helper\Common;
use Illuminate\Database\Eloquent\Model;
class Base extends Model
{
... ...
... ... @@ -8,7 +8,8 @@ use App\Models\User\User;
class Blog extends Base
{
protected $table = 'gl_blog';
//连接数据库
// protected $connection = 'custom_mysql';
public function user(){
return $this->hasMany(User::class,'operator_id','id');
}
... ...
... ... @@ -7,4 +7,7 @@ use App\Models\Base;
class BlogCategory extends Base
{
protected $table = 'gl_blog_category';
//连接数据库
// protected $connection = 'custom_mysql';
}
... ...
... ... @@ -7,4 +7,6 @@ use App\Models\Base;
class BlogLabel extends Base
{
protected $table = 'gl_blog_label';
//连接数据库
// protected $connection = 'custom_mysql';
}
... ...
... ... @@ -7,4 +7,6 @@ use App\Models\Base;
class File extends Base
{
protected $table = 'gl_file';
//连接数据库
// protected $connection = 'custom_mysql';
}
... ...
... ... @@ -8,20 +8,6 @@ class Image extends Base
{
protected $table = 'gl_image';
public $timestamps = true;
/**
* @param $hash
* @name :(获取图片详情)image_read
* @author :lyh
* @method :post
* @time :2023/5/4 11:50
*/
public function image_read($hash){
$info = $this->read(['hash'=>$hash]);
if(empty($info)){
return false;
}
return $info;
}
//连接数据库
// protected $connection = 'custom_mysql';
}
... ...
... ... @@ -9,4 +9,6 @@ class Mail extends Base
protected $table = 'gl_mail';
//自动维护create_at创建时间 updated_at修改时间
public $timestamps = true;
//连接数据库
// protected $connection = 'custom_mysql';
}
... ...
... ... @@ -9,4 +9,6 @@ class MailUser extends Base
protected $table = 'gl_mail_user';
//自动维护create_at创建时间 updated_at修改时间
public $timestamps = true;
//连接数据库
// protected $connection = 'custom_mysql';
}
... ...
... ... @@ -8,5 +8,5 @@ class News extends Base
{
protected $table = 'gl_news';
//连接数据库
protected $connection = 'custom_mysql';
// protected $connection = 'custom_mysql';
}
... ...
... ... @@ -7,6 +7,6 @@ use App\Models\Base;
class NewsCategory extends Base
{
protected $table = 'gl_news_category';
//数据库配置
protected $connection = '';
//连接数据库
// protected $connection = 'custom_mysql';
}
... ...
... ... @@ -7,4 +7,6 @@ use App\Models\Base;
class NewsLabel extends Base
{
protected $table = 'gl_news_label';
//连接数据库
// protected $connection = 'custom_mysql';
}
... ...
... ... @@ -81,5 +81,43 @@ class ATemplate extends \App\Models\Base{
}
/**
* 查询
* @param $id
* @return mixed
* @author:dc
* @time 2023/5/10 10:15
*/
public static function _find($id)
{
return static::where('id',$id)->first();
}
/**
* @param array $data
* @param int $id
* @author:dc
* @time 2023/5/11 10:08
*/
public static function _save(array $data,int $id=0){
if($id){
$model = static::where('id',$id)->first();
}
if(empty($model)) $model = new static();
$model->name = $data['name'];
$model->status = $data['status'];
$model->is_default = $data['is_default'];
$model->sort = $data['sort'];
$model->thumb = $data['thumb'];
$model->url = $data['url'];
$model->save();
return $model->id;
}
}
... ...
... ... @@ -24,6 +24,117 @@ class ATemplateHtml extends \App\Models\Base{
use SoftDeletes;
public static $sourceMap = [
// 数据表/数据类型 =》 模板类型/模板名称
'index' => [
'template' => 'index',
'name'=>'首页'
],
'product' => [
'template' => 'product',
'name'=>'商品列表'
],
'product_info' => [
'template' => 'product_info',
'name'=>'商品详情'
],
'blogs' => [
'template' => 'blogs',
'name'=>'博客列表'
],
'blogs_info' => [
'template' => 'blogs_info',
'name'=>'博客详情'
],
'page' => [
'template' => 'page',
'name'=>'单页'
],
'news' => [
'template' => 'news',
'name'=>'新闻列表'
],
'news_info' => [
'template' => 'news_info',
'name'=>'新闻详情'
],
];
public static $typeMap = [
'index' => '首页',
'product' => '商品列表',
'product_info' => '商品详情',
'blogs' => '博客列表',
'blogs_info' => '博客详情',
'page' => '单页',
'news' => '新闻列表',
'news_info' => '新闻详情',
];
/**
* 模板中的数据
* @param $template_id
* @return mixed
* @author:dc
* @time 2023/5/10 10:30
*/
public static function _all($template_id){
return static::where(['template_id'=>$template_id])->get();
}
/**
* 是否存在type
* @param int $template_id
* @param $type
* @return mixed
* @author:dc
* @time 2023/5/10 16:03
*/
public static function _typeExist(int $template_id,$type){
return static::where(['template_id'=>$template_id,'type'=>$type])->limit(1)->count();
}
public static function _bAll($template_id){
return static::where(['template_id'=>$template_id,'status'=>1])->get();
}
public static function _find($id){
return static::where('id',$id)->first();
}
/**
* @param array $data
* @param int $id
* @return mixed
* @author:dc
* @time 2023/5/11 10:20
*/
public static function _save(int $template_id, array $data,int $id = 0){
if($id){
$model = static::where('id',$id)->first();
}
if(empty($model)) $model = new static();
$model->template_id = $template_id;
$model->name = $data['name'];
$model->status = $data['status'];
$model->is_default = $data['is_default'];
$model->sort = $data['sort'];
$model->thumb = $data['thumb'];
$model->url = $data['url'];
$model->save();
return $model->id;
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Models\Template;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
/**
* 当前用户的模板
... ... @@ -71,6 +72,30 @@ class BSetting extends \App\Models\Base{
$data->save();
// 是否有模板
// if(!BTemplate::_isExist($project_id,$template_id)){
// // 没有模板
// $aData = ATemplate::_find($template_id);
// // 保存到自己的数据中
// BTemplate::_insert($project_id,$aData);
//
// $aDataHtml = ATemplateHtml::_all($template_id);
// DB::beginTransaction();
// foreach ($aDataHtml as $item){
// try {
// // 插入子数据
// BTemplateHtml::_insert($project_id,$item);
// }catch (\Throwable $e){
// DB::rollBack();
//
// return $data->id;
// break;
// }
//
// }
// DB::commit();
// }
return $data->id;
}
... ...
... ... @@ -11,48 +11,46 @@ namespace App\Models\Template;
*/
class BTemplate extends \App\Models\Base{
protected $table = 'gl_web_template_html';
protected $table = 'gl_web_template';
protected $hidden = ['project_id'];
/**
* @param $project_id
* @return mixed
* 是否存在模板
* @param int $template_id
* @author:dc
* @time 2023/5/4 16:13
* @time 2023/5/10 10:00
*/
public static function _get($project_id){
return static::where(['project_id'=>$project_id])->get(['html','type'])->pluck('html','type')->toArray();
}
public static function _all($project_id){
return static::where(['project_id'=>$project_id])->get();
public static function _isExist(int $project_id, int $template_id)
{
return static::where(['project_id'=>$project_id,'template_id'=>$template_id])->limit(1)->count();
}
/**
* 保存
* 插入
* @param $project_id
* @param $type
* @param $html
* @param $data
* @return mixed
* @author:dc
* @time 2023/5/4 17:50
* @time 2023/5/10 10:23
*/
public static function _save($project_id,$type,$html){
$data = static::where(['project_id'=>$project_id,'type'=>$type])->first();
if(!$data){
$data = new static();
$data->project_id = $project_id;
$data->type = $type;
}
$data->html = $html;
public static function _insert($project_id,$data)
{
$model = new static();
$data->save();
$model->project_id = $project_id;
$model->template_id = $data['id'];
$model->name = $data['name'];
$model->thumb = $data['thumb'];
$model->html = $data['html'];
return $data->id;
}
$model->save();
return $model->id;
}
}
... ...
*
!.gitignore
!readme.md
... ...
此目录为自动创建
不可手动操作
... ...
... ... @@ -126,10 +126,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');
Route::get('/', [\App\Http\Controllers\Aside\TemplateController::class, 'index'])->name('admin.template');
Route::post('/edit', [\App\Http\Controllers\Aside\TemplateController::class, 'edit'])->name('admin.template_edit');
Route::post('/insert', [\App\Http\Controllers\Aside\TemplateController::class, 'insert'])->name('admin.template_insert');
Route::delete('/delete/{id}', [\App\Http\Controllers\Aside\TemplateController::class, 'delete'])->where('id','\d+')->name('admin.template_delete');
Route::get('/html/{template_id}', [\App\Http\Controllers\Aside\TemplateController::class, 'html_index'])->where('template_id','\d+')->name('admin.template.html');
Route::post('/html/{template_id}/edit', [\App\Http\Controllers\Aside\TemplateController::class, 'html_edit'])->where('template_id','\d+')->name('admin.template_edit.html');
Route::post('/html/{template_id}/insert', [\App\Http\Controllers\Aside\TemplateController::class, 'html_insert'])->where('template_id','\d+')->name('admin.template_insert.html');
Route::delete('/html/{template_id}/delete/{id}', [\App\Http\Controllers\Aside\TemplateController::class, 'html_delete'])->where('template_id','\d+')->where('id','\d+')->name('admin.template_delete.html');
Route::get('/html/type', [\App\Http\Controllers\Aside\TemplateController::class, 'html_type'])->name('admin.template_type.html');
});
... ...
... ... @@ -225,15 +225,26 @@ Route::middleware(['bloginauth'])->group(function () {
});
});
// 自定义页面
// 模板
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::get('/', [\App\Http\Controllers\Bside\TemplateController::class, 'index'])->name('bside_template');
Route::any('/use-template', [\App\Http\Controllers\Bside\TemplateController::class, 'info'])->name('bside_template_use');
// Route::get('/custom-chunk', [\App\Http\Controllers\Bside\TemplateController::class, 'customChunk'])->name('bside_template_custom_chunk');
Route::get('/get_type', [\App\Http\Controllers\Bside\TemplateController::class, 'get_type'])->name('bside_template_type');
Route::get('/get_html', [\App\Http\Controllers\Bside\TemplateController::class, 'get_html'])->name('bside_template_get_html');
Route::get('/save_html', [\App\Http\Controllers\Bside\TemplateController::class, 'save_html'])->name('bside_template_save_html');
});
// 自定义页面,专题页
Route::prefix('custom')->group(function () {
Route::get('/', [\App\Http\Controllers\Bside\CustomController::class, 'index'])->name('bside_custom');
Route::post('/create', [\App\Http\Controllers\Bside\CustomController::class, 'create'])->name('bside_custom_create');
Route::post('/update', [\App\Http\Controllers\Bside\CustomController::class, 'update'])->name('bside_custom_update');
Route::delete('/delete', [\App\Http\Controllers\Bside\CustomController::class, 'delete'])->name('bside_custom_delete');
Route::any('/html/{id}', [\App\Http\Controllers\Bside\CustomController::class, 'html'])->where('id','\d+')->name('bside_custom_delete');
});
// 导航栏编辑
Route::prefix('nav')->group(function () {
Route::get('/', [\App\Http\Controllers\Bside\NavController::class, 'index'])->name('bside_nav');
... ... @@ -242,9 +253,6 @@ Route::middleware(['bloginauth'])->group(function () {
Route::delete('/delete', [\App\Http\Controllers\Bside\NavController::class, 'delete'])->name('bside_nav_delete');
});
});
//无需登录验证的路由组
... ... @@ -253,5 +261,5 @@ Route::group([], function () {
// 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}/{type?}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show');
Route::any('/file_hash/{hash}/{type?}/', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show');
Route::any('/file_hash/{hash}/', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show');
});
... ...