Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev
正在显示
33 个修改的文件
包含
706 行增加
和
140 行删除
| @@ -44,19 +44,11 @@ class Demo extends Command | @@ -44,19 +44,11 @@ class Demo extends Command | ||
| 44 | */ | 44 | */ |
| 45 | public function handle() | 45 | public function handle() |
| 46 | { | 46 | { |
| 47 | - //切换数据库配置 | ||
| 48 | - $project = ProjectServer::useProject(1); | ||
| 49 | - //创建数据库 | ||
| 50 | - ProjectServer::createDatabase($project); | ||
| 51 | - //创建表 | ||
| 52 | - ProjectServer::initTable($project); | 47 | + preg_match_all("/\@include\(\"([a-z0-9_]+)\"\)/i",' |
| 48 | +@include("asdf")@include("")@include("asdtrw2erf") | ||
| 49 | + ',$include); | ||
| 53 | 50 | ||
| 54 | - dd(1); | ||
| 55 | - | ||
| 56 | - $sql = 'CREATE DATABASE database_name;'; | ||
| 57 | - $results = DB::select($sql); | ||
| 58 | - dd($results); | ||
| 59 | - return true; | 51 | + print_r($include); |
| 60 | } | 52 | } |
| 61 | 53 | ||
| 62 | public function printMessage() | 54 | public function printMessage() |
| @@ -97,4 +89,4 @@ class Demo extends Command | @@ -97,4 +89,4 @@ class Demo extends Command | ||
| 97 | } | 89 | } |
| 98 | dd(1); | 90 | dd(1); |
| 99 | } | 91 | } |
| 100 | -} | ||
| 92 | +} |
| @@ -68,7 +68,7 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K | @@ -68,7 +68,7 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K | ||
| 68 | public function deleted_profiles($data){ | 68 | public function deleted_profiles($data){ |
| 69 | $param = [ | 69 | $param = [ |
| 70 | 'title'=>$data['title'], | 70 | 'title'=>$data['title'], |
| 71 | - 'profileKey'=>$this->profile_key, | 71 | +// 'profileKey'=>$this->profile_key, |
| 72 | ]; | 72 | ]; |
| 73 | $url = $this->path.'/api/profiles/profile'; | 73 | $url = $this->path.'/api/profiles/profile'; |
| 74 | return $this->http_click('delete',$url,$param); | 74 | return $this->http_click('delete',$url,$param); |
| @@ -2,7 +2,10 @@ | @@ -2,7 +2,10 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Controllers\Aside; | 3 | namespace App\Http\Controllers\Aside; |
| 4 | 4 | ||
| 5 | -use App\Models\Template\AHeadFoot; | 5 | +use App\Enums\Common\Code; |
| 6 | +use App\Models\Template\ATemplate; | ||
| 7 | +use App\Models\Template\ATemplateHtml; | ||
| 8 | +use Illuminate\Validation\Rule; | ||
| 6 | 9 | ||
| 7 | /** | 10 | /** |
| 8 | * 模板 | 11 | * 模板 |
| @@ -22,22 +25,22 @@ class TemplateController extends BaseController | @@ -22,22 +25,22 @@ class TemplateController extends BaseController | ||
| 22 | */ | 25 | */ |
| 23 | public function index(){ | 26 | public function index(){ |
| 24 | 27 | ||
| 25 | - $data = AHeadFoot::all(); | ||
| 26 | - $lists = []; | ||
| 27 | - // 以名字为单位区分 | ||
| 28 | - foreach ($data as $datum){ | ||
| 29 | - if(empty($lists[$datum['name']])) $lists[$datum['name']] = []; | ||
| 30 | - $lists[$datum['name']]['name'] = $datum['name']; | ||
| 31 | - $lists[$datum['name']]['default'] = $datum['is_default']; | ||
| 32 | - $lists[$datum['name']]['sort'] = $datum['sort']; | ||
| 33 | - $lists[$datum['name']]['status'] = $datum['status']; | ||
| 34 | - $lists[$datum['name']]['created_at'] = $datum['created_at']; | ||
| 35 | -// $lists[$datum['name']]['tags'] = $datum['tags']; | ||
| 36 | - $lists[$datum['name']][$datum['type']==AHeadFoot::TYPE_HEADER?'header':'footer'] = $datum['html']; | ||
| 37 | - } | 28 | + $limit = $this->param['limit']??20; |
| 29 | + | ||
| 30 | + | ||
| 31 | + $lists = ATemplate::where(function ($query){ | ||
| 32 | + | ||
| 33 | + !empty($this->param['status']) && $query->where('status',$this->param['status']); | ||
| 34 | + !empty($this->param['name']) && $query->where('status',$this->param['name']); | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + }) | ||
| 38 | + ->select(['id','name','status','is_default','sort','thumb','url','created_at','updated_at']) | ||
| 39 | + ->orderBy('sort') | ||
| 40 | + ->paginate($limit); | ||
| 38 | 41 | ||
| 39 | - return $this->success($lists); | ||
| 40 | 42 | ||
| 43 | + return $this->success($lists->toArray()); | ||
| 41 | } | 44 | } |
| 42 | 45 | ||
| 43 | 46 | ||
| @@ -47,7 +50,7 @@ class TemplateController extends BaseController | @@ -47,7 +50,7 @@ class TemplateController extends BaseController | ||
| 47 | * @time 2023/5/4 16:19 | 50 | * @time 2023/5/4 16:19 |
| 48 | */ | 51 | */ |
| 49 | public function edit(){ | 52 | public function edit(){ |
| 50 | - | 53 | + $this->save(true); |
| 51 | } | 54 | } |
| 52 | 55 | ||
| 53 | /** | 56 | /** |
| @@ -56,12 +59,168 @@ class TemplateController extends BaseController | @@ -56,12 +59,168 @@ class TemplateController extends BaseController | ||
| 56 | * @time 2023/5/5 9:30 | 59 | * @time 2023/5/5 9:30 |
| 57 | */ | 60 | */ |
| 58 | public function insert(){ | 61 | public function insert(){ |
| 62 | + $this->save(); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * @param false $is_edit | ||
| 68 | + * @return \Illuminate\Http\JsonResponse | ||
| 69 | + * @throws \Illuminate\Validation\ValidationException | ||
| 70 | + * @throws \Psr\Container\ContainerExceptionInterface | ||
| 71 | + * @throws \Psr\Container\NotFoundExceptionInterface | ||
| 72 | + * @author:dc | ||
| 73 | + * @time 2023/5/11 10:13 | ||
| 74 | + */ | ||
| 75 | + private function save($is_edit=false){ | ||
| 76 | + | ||
| 77 | + $verify = [ | ||
| 78 | + 'role' => [ | ||
| 79 | + 'id' => ['required','integer'], | ||
| 80 | + 'name' => ['required'], | ||
| 81 | + 'status' => ['required',Rule::in(0,1)], | ||
| 82 | + 'is_default' => ['required',Rule::in(0,1)], | ||
| 83 | + 'sort' => ['required','integer'], | ||
| 84 | + 'thumb' => ['required'], | ||
| 85 | + 'url' => ['required'], | ||
| 86 | + ], | ||
| 87 | + 'message' => [ | ||
| 88 | + 'id.required' => 'id必须', | ||
| 89 | + 'id.integer' => 'id必须', | ||
| 90 | + | ||
| 91 | + 'name.required' => '名称必须', | ||
| 92 | + 'status.integer' => '状态错误', | ||
| 93 | + 'status.in' => '状态错误', | ||
| 94 | + 'is_default.integer' => '是否默认', | ||
| 95 | + 'is_default.in' => '是否默认', | ||
| 96 | + 'sort.required' => '排序必须', | ||
| 97 | + 'sort.integer' => '排序必须', | ||
| 98 | + 'thumb.required' => '缩略图必须', | ||
| 99 | + 'url.required' => '预览链接必须', | ||
| 100 | + ] | ||
| 101 | + ]; | ||
| 102 | + if(!$is_edit) unset($verify['role']['id']); | ||
| 103 | + | ||
| 104 | + $data = $this->validate(request() ,$verify['role'],$verify['message']); | ||
| 105 | + | ||
| 59 | 106 | ||
| 107 | + | ||
| 108 | + // 保存 | ||
| 109 | + $id = ATemplate::_save($data,$data['id']??0); | ||
| 110 | + | ||
| 111 | + if(!$id){ | ||
| 112 | + return $this->response('保存失败',Code::SYSTEM_ERROR); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + return $this->success(ATemplate::_find($id)); | ||
| 60 | } | 116 | } |
| 61 | 117 | ||
| 62 | 118 | ||
| 63 | - private function save($name = ''){ | 119 | + /** |
| 120 | + * 删除 | ||
| 121 | + * @author:dc | ||
| 122 | + * @time 2023/5/4 17:10 | ||
| 123 | + */ | ||
| 124 | + public function delete($id){ | ||
| 125 | + | ||
| 126 | + if(ATemplate::destroy($id)){ | ||
| 127 | + return $this->response('删除成功'); | ||
| 128 | + } | ||
| 64 | 129 | ||
| 130 | + return $this->response('删除失败',Code::SYSTEM_ERROR); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + | ||
| 134 | + | ||
| 135 | + | ||
| 136 | + | ||
| 137 | + | ||
| 138 | + /** | ||
| 139 | + * 列表 | ||
| 140 | + * @author:dc | ||
| 141 | + * @time 2023/5/4 17:10 | ||
| 142 | + */ | ||
| 143 | + public function html_index($template_id){ | ||
| 144 | + | ||
| 145 | + | ||
| 146 | + $lists = ATemplateHtml::where('template_id',$template_id)->get(); | ||
| 147 | + | ||
| 148 | + | ||
| 149 | + return $this->success($lists->toArray()); | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + | ||
| 153 | + /** | ||
| 154 | + * 编辑 | ||
| 155 | + * @author:dc | ||
| 156 | + * @time 2023/5/4 16:19 | ||
| 157 | + */ | ||
| 158 | + public function html_edit($template_id){ | ||
| 159 | + $this->html_save($template_id,true); | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + /** | ||
| 163 | + * 新增 | ||
| 164 | + * @author:dc | ||
| 165 | + * @time 2023/5/5 9:30 | ||
| 166 | + */ | ||
| 167 | + public function html_insert($template_id){ | ||
| 168 | + $this->html_save($template_id); | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + | ||
| 172 | + /** | ||
| 173 | + * @param false $is_edit | ||
| 174 | + * @return \Illuminate\Http\JsonResponse | ||
| 175 | + * @throws \Illuminate\Validation\ValidationException | ||
| 176 | + * @throws \Psr\Container\ContainerExceptionInterface | ||
| 177 | + * @throws \Psr\Container\NotFoundExceptionInterface | ||
| 178 | + * @author:dc | ||
| 179 | + * @time 2023/5/11 10:13 | ||
| 180 | + */ | ||
| 181 | + private function html_save($template_id,$is_edit=false){ | ||
| 182 | + | ||
| 183 | + $verify = [ | ||
| 184 | + 'role' => [ | ||
| 185 | + 'id' => ['required','integer'], | ||
| 186 | +// 'template_id' => ['required','integer'], | ||
| 187 | + 'name' => ['required'], | ||
| 188 | + 'type' => ['required',Rule::in(ATemplateHtml::$typeMap)], | ||
| 189 | + 'css' => [], | ||
| 190 | + 'script' => [], | ||
| 191 | + 'html' => ['required'], | ||
| 192 | + ], | ||
| 193 | + 'message' => [ | ||
| 194 | + 'id.required' => 'id必须', | ||
| 195 | + 'id.integer' => 'id必须', | ||
| 196 | + | ||
| 197 | +// 'template_id.required' => '模板选择错误', | ||
| 198 | +// 'template_id.integer' => '模板选择错误', | ||
| 199 | + | ||
| 200 | + 'name.required' => '名称必须', | ||
| 201 | + | ||
| 202 | + 'type.required' => '页面类型选择错误', | ||
| 203 | + 'type.in' => '页面类型选择错误', | ||
| 204 | + | ||
| 205 | + | ||
| 206 | + 'html.required' => 'html 代码必须', | ||
| 207 | + | ||
| 208 | + ] | ||
| 209 | + ]; | ||
| 210 | + if(!$is_edit) unset($verify['role']['id']); | ||
| 211 | + | ||
| 212 | + $data = $this->validate(request() ,$verify['role'],$verify['message']); | ||
| 213 | + | ||
| 214 | + | ||
| 215 | + | ||
| 216 | + // 保存 | ||
| 217 | + $id = ATemplateHtml::_save($template_id,$data,$data['id']??0); | ||
| 218 | + | ||
| 219 | + if(!$id){ | ||
| 220 | + return $this->response('保存失败',Code::SYSTEM_ERROR); | ||
| 221 | + } | ||
| 222 | + | ||
| 223 | + return $this->success(ATemplateHtml::_find($id)); | ||
| 65 | } | 224 | } |
| 66 | 225 | ||
| 67 | 226 | ||
| @@ -70,12 +229,28 @@ class TemplateController extends BaseController | @@ -70,12 +229,28 @@ class TemplateController extends BaseController | ||
| 70 | * @author:dc | 229 | * @author:dc |
| 71 | * @time 2023/5/4 17:10 | 230 | * @time 2023/5/4 17:10 |
| 72 | */ | 231 | */ |
| 73 | - public function delete(){ | 232 | + public function html_delete($template_id, $id){ |
| 74 | 233 | ||
| 234 | + if(ATemplateHtml::where('template_id',$template_id)->where('id',$id)->delete()){ | ||
| 235 | + return $this->response('删除成功'); | ||
| 236 | + } | ||
| 75 | 237 | ||
| 238 | + return $this->response('删除失败',Code::SYSTEM_ERROR); | ||
| 76 | } | 239 | } |
| 77 | 240 | ||
| 78 | 241 | ||
| 242 | + /** | ||
| 243 | + * 页面类型 | ||
| 244 | + * @return \Illuminate\Http\JsonResponse | ||
| 245 | + * @throws \Psr\Container\ContainerExceptionInterface | ||
| 246 | + * @throws \Psr\Container\NotFoundExceptionInterface | ||
| 247 | + * @author:dc | ||
| 248 | + * @time 2023/5/11 10:29 | ||
| 249 | + */ | ||
| 250 | + public function html_type(){ | ||
| 251 | + return $this->success(ATemplateHtml::$typeMap); | ||
| 252 | + } | ||
| 253 | + | ||
| 79 | 254 | ||
| 80 | 255 | ||
| 81 | 256 |
| @@ -14,6 +14,14 @@ use App\Models\File\Image as ImageModel; | @@ -14,6 +14,14 @@ use App\Models\File\Image as ImageModel; | ||
| 14 | 14 | ||
| 15 | /** | 15 | /** |
| 16 | * @name:社交发布 | 16 | * @name:社交发布 |
| 17 | + * Facebook Pages and Groups: 10 images, including a carousel post. | ||
| 18 | + * Instagram: 10 images. | ||
| 19 | + * Google : 1 image. | ||
| 20 | + * LinkedIn: 9 images. | ||
| 21 | + * Pinterest: 1 image. | ||
| 22 | + * Reddit: 1 image. | ||
| 23 | + * Telegram: 1 image. | ||
| 24 | + * Twitter:4 image | ||
| 17 | */ | 25 | */ |
| 18 | class AyrReleaseController extends BaseController | 26 | class AyrReleaseController extends BaseController |
| 19 | { | 27 | { |
| @@ -45,33 +53,26 @@ class AyrReleaseController extends BaseController | @@ -45,33 +53,26 @@ class AyrReleaseController extends BaseController | ||
| 45 | * @time :2023/5/9 9:36 | 53 | * @time :2023/5/9 9:36 |
| 46 | */ | 54 | */ |
| 47 | public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic,AyrShareHelper $ayrShare){ | 55 | public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic,AyrShareHelper $ayrShare){ |
| 48 | -// DB::beginTransaction(); | ||
| 49 | -// try { | ||
| 50 | - //获取发送账号详情 | ||
| 51 | - $share_info = $ayrShareLogic->ayr_share_info(); | ||
| 52 | - $data = [ | ||
| 53 | - 'images'=>$this->param['image'], | ||
| 54 | - 'files'=>$this->param['file'], | ||
| 55 | - ]; | ||
| 56 | - //参数处理 | ||
| 57 | - $image_data = $ayrReleaseLogic->image_file_param($data); | ||
| 58 | - $this->param['mediaUrls'] = array_merge($image_data['images_link'],$image_data['files_link']); | ||
| 59 | - //统一生成链接 | ||
| 60 | - $param = [ | ||
| 61 | - 'post'=>$this->param['content'], | ||
| 62 | - 'platforms'=>$this->param['platforms'], | ||
| 63 | - 'mediaUrls'=>$this->param['mediaUrls'],//参数处理 | ||
| 64 | - ]; | ||
| 65 | - //发送请求注册社交用户 | ||
| 66 | - $res = $ayrShare->post_send_msg($param,$share_info['profile_key']); | ||
| 67 | - $this->response('success',Code::SUCCESS,$res); | ||
| 68 | - //保存数据库 | ||
| 69 | - $ayrReleaseLogic->release_add(); | ||
| 70 | -// DB::commit(); | ||
| 71 | -// }catch (\Exception $e){ | ||
| 72 | -// DB::rollBack(); | ||
| 73 | -// $this->response('error',Code::USER_ERROR); | ||
| 74 | -// } | 56 | + //获取发送账号详情 |
| 57 | + $share_info = $ayrShareLogic->ayr_share_info(); | ||
| 58 | + $data = [ | ||
| 59 | + 'images'=>$this->param['images'], | ||
| 60 | + 'files'=>$this->param['video'], | ||
| 61 | + ]; | ||
| 62 | + //参数处理 | ||
| 63 | + $this->param['mediaUrls'] = $ayrReleaseLogic->image_file_param($data);; | ||
| 64 | + //统一生成发布 | ||
| 65 | + $param = [ | ||
| 66 | + 'post'=>$this->param['content'], | ||
| 67 | + 'platforms'=>$this->param['platforms'], | ||
| 68 | + 'mediaUrls'=>$this->param['mediaUrls'],//参数处理 | ||
| 69 | + 'idempotencyKey'=>$this->param['idempotency_key'],//时间(如是过去时间,立即发布) | ||
| 70 | + ]; | ||
| 71 | + //发送请求发布社交文章 | ||
| 72 | + $res = $ayrShare->post_send_msg($param,$share_info['profile_key']); | ||
| 73 | + //保存数据库 | ||
| 74 | + $ayrReleaseLogic->release_add(); | ||
| 75 | + $this->response('success',Code::SUCCESS,$res); | ||
| 75 | } | 76 | } |
| 76 | 77 | ||
| 77 | /** | 78 | /** |
| @@ -13,6 +13,8 @@ use App\Models\AyrShare\AyrShare as AyrShareModel; | @@ -13,6 +13,8 @@ use App\Models\AyrShare\AyrShare as AyrShareModel; | ||
| 13 | */ | 13 | */ |
| 14 | class AyrShareController extends BaseController | 14 | class AyrShareController extends BaseController |
| 15 | { | 15 | { |
| 16 | + //生成名称前缀 | ||
| 17 | + const TITLE = 'global_so_'; | ||
| 16 | /** | 18 | /** |
| 17 | * @name :(社交列表)lists | 19 | * @name :(社交列表)lists |
| 18 | * @author :lyh | 20 | * @author :lyh |
| @@ -20,7 +22,10 @@ class AyrShareController extends BaseController | @@ -20,7 +22,10 @@ class AyrShareController extends BaseController | ||
| 20 | * @time :2023/5/5 16:06 | 22 | * @time :2023/5/5 16:06 |
| 21 | */ | 23 | */ |
| 22 | public function lists(AyrShareModel $ayrShareModel){ | 24 | public function lists(AyrShareModel $ayrShareModel){ |
| 23 | - $lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['*']); | 25 | + //授权配置列表 |
| 26 | + $share_list = $ayrShareModel->platforms; | ||
| 27 | + $lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['id','name','bind_plat_from','operator_id','created_at','updated_at']); | ||
| 28 | + $lists['share_list'] = $share_list; | ||
| 24 | $this->response('列表',Code::SUCCESS,$lists); | 29 | $this->response('列表',Code::SUCCESS,$lists); |
| 25 | } | 30 | } |
| 26 | 31 | ||
| @@ -36,9 +41,13 @@ class AyrShareController extends BaseController | @@ -36,9 +41,13 @@ class AyrShareController extends BaseController | ||
| 36 | $share_info = $ayrShareHelper->get_profiles_users($info['profile_key']); | 41 | $share_info = $ayrShareHelper->get_profiles_users($info['profile_key']); |
| 37 | if(isset($share_info['activeSocialAccounts'])){ | 42 | if(isset($share_info['activeSocialAccounts'])){ |
| 38 | $str = json_encode($share_info['activeSocialAccounts']); | 43 | $str = json_encode($share_info['activeSocialAccounts']); |
| 39 | - $ayrShareLogic->ayr_share_edit(['bind_plat_from'=>$str]); | 44 | + if($str != $info['bind_plat_from']){ |
| 45 | + $res = $ayrShareLogic->ayr_share_edit(['bind_plat_from'=>$str]); | ||
| 46 | + }else{ | ||
| 47 | + $res = false; | ||
| 48 | + } | ||
| 40 | } | 49 | } |
| 41 | - $this->response('success'); | 50 | + $this->response('success',Code::SUCCESS,['is_true'=>$res]); |
| 42 | } | 51 | } |
| 43 | /** | 52 | /** |
| 44 | * @name :(创建ayr_share账户)create_account | 53 | * @name :(创建ayr_share账户)create_account |
| @@ -48,7 +57,7 @@ class AyrShareController extends BaseController | @@ -48,7 +57,7 @@ class AyrShareController extends BaseController | ||
| 48 | */ | 57 | */ |
| 49 | public function create_account(AyrShareLogic $ayrShareLogic){ | 58 | public function create_account(AyrShareLogic $ayrShareLogic){ |
| 50 | $param = [ | 59 | $param = [ |
| 51 | - 'title'=>'global_so:'.$this->param['name'], | 60 | + 'title'=>self::TITLE.$this->user['project_id'].':'.$this->param['name'], |
| 52 | ]; | 61 | ]; |
| 53 | //发送请求注册社交用户 | 62 | //发送请求注册社交用户 |
| 54 | $ayrShareHelper = new AyrShareHelper(); | 63 | $ayrShareHelper = new AyrShareHelper(); |
| @@ -101,12 +101,21 @@ class BaseController extends Controller | @@ -101,12 +101,21 @@ class BaseController extends Controller | ||
| 101 | */ | 101 | */ |
| 102 | public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse | 102 | public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse |
| 103 | { | 103 | { |
| 104 | - $code = Code::fromValue($code); | ||
| 105 | - $result = [ | ||
| 106 | - 'msg' => $msg == ' ' ? $code->description : $msg, | ||
| 107 | - 'code' => $code->value, | ||
| 108 | - 'data' => $this->_extents($data), | ||
| 109 | - ]; | 104 | + try { |
| 105 | + $code = Code::fromValue($code); | ||
| 106 | + $result = [ | ||
| 107 | + 'msg' => $msg == ' ' ? $code->description : $msg, | ||
| 108 | + 'code' => $code->value, | ||
| 109 | + 'data' => $this->_extents($data), | ||
| 110 | + ]; | ||
| 111 | + }catch (\Throwable $e){ | ||
| 112 | + $result = [ | ||
| 113 | + 'msg' => $msg, | ||
| 114 | + 'code' => $code, | ||
| 115 | + 'data' => $this->_extents($data), | ||
| 116 | + ]; | ||
| 117 | + } | ||
| 118 | + | ||
| 110 | $this->header['Content-Type'] = $type; | 119 | $this->header['Content-Type'] = $type; |
| 111 | $this->header['token'] = $this->token; | 120 | $this->header['token'] = $this->token; |
| 112 | $response = response($result,$result_code,$this->header);; | 121 | $response = response($result,$result_code,$this->header);; |
| @@ -26,7 +26,7 @@ class CustomController extends BaseController | @@ -26,7 +26,7 @@ class CustomController extends BaseController | ||
| 26 | 'title' => ['required','max:200'], | 26 | 'title' => ['required','max:200'], |
| 27 | 'keywords' => ['required','max:200'], | 27 | 'keywords' => ['required','max:200'], |
| 28 | 'description' => ['required','max:250'], | 28 | 'description' => ['required','max:250'], |
| 29 | - 'html' => ['required'], | 29 | +// 'html' => ['required'], |
| 30 | 'url' => ['required','max:200'], | 30 | 'url' => ['required','max:200'], |
| 31 | 'status' => ['required','in:0,1'], | 31 | 'status' => ['required','in:0,1'], |
| 32 | ], | 32 | ], |
| @@ -144,5 +144,33 @@ class CustomController extends BaseController | @@ -144,5 +144,33 @@ class CustomController extends BaseController | ||
| 144 | 144 | ||
| 145 | 145 | ||
| 146 | 146 | ||
| 147 | + /** | ||
| 148 | + * @param $id | ||
| 149 | + * @return \Illuminate\Http\JsonResponse | ||
| 150 | + * @author:dc | ||
| 151 | + * @time 2023/5/10 14:10 | ||
| 152 | + */ | ||
| 153 | + public function html($id) | ||
| 154 | + { | ||
| 155 | + $data = BCustom::_find($this->user['project_id'],$id); | ||
| 156 | + if(!$data){ | ||
| 157 | + return $this->response('数据不存在','B_CUSTOM_NOTFOUND'); | ||
| 158 | + } | ||
| 159 | + if($this->isPost()){ | ||
| 160 | + $html = $this->param['html']??''; | ||
| 161 | + | ||
| 162 | + $data->html = $html; | ||
| 163 | + | ||
| 164 | + $data->save(); | ||
| 165 | + | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + | ||
| 169 | + return $this->response('',Code::SUCCESS,$data['html']); | ||
| 170 | + | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + | ||
| 174 | + | ||
| 147 | 175 | ||
| 148 | } | 176 | } |
| @@ -189,7 +189,7 @@ class NavController extends BaseController | @@ -189,7 +189,7 @@ class NavController extends BaseController | ||
| 189 | 'name' => '单页' | 189 | 'name' => '单页' |
| 190 | ], | 190 | ], |
| 191 | [ | 191 | [ |
| 192 | - 'url' => 'goods', | 192 | + 'url' => '/goods', |
| 193 | 'name' => '商品' | 193 | 'name' => '商品' |
| 194 | ], | 194 | ], |
| 195 | ]); | 195 | ]); |
| @@ -3,8 +3,12 @@ | @@ -3,8 +3,12 @@ | ||
| 3 | namespace App\Http\Controllers\Bside; | 3 | namespace App\Http\Controllers\Bside; |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | +use App\Enums\Common\Code; | ||
| 6 | use App\Models\Template\ATemplate; | 7 | use App\Models\Template\ATemplate; |
| 8 | +use App\Models\Template\ATemplateHtml; | ||
| 7 | use App\Models\Template\BSetting; | 9 | use App\Models\Template\BSetting; |
| 10 | +use App\Models\Template\BTemplateData; | ||
| 11 | +use Illuminate\Validation\Rule; | ||
| 8 | 12 | ||
| 9 | 13 | ||
| 10 | /** | 14 | /** |
| @@ -71,5 +75,110 @@ class TemplateController extends BaseController | @@ -71,5 +75,110 @@ class TemplateController extends BaseController | ||
| 71 | } | 75 | } |
| 72 | 76 | ||
| 73 | 77 | ||
| 78 | + /** | ||
| 79 | + * 保存模板 | ||
| 80 | + * @author:dc | ||
| 81 | + * @time 2023/5/10 10:53 | ||
| 82 | + */ | ||
| 83 | + public function save(){ | ||
| 84 | + | ||
| 85 | + $html = '<header id="globalso-header" class="web_head sticky-top py-1 py-md-0" style="background-color: #318fff;">asdf</header>'; | ||
| 86 | + | ||
| 87 | + // 替换 header | ||
| 88 | + $html = preg_replace("/<header(.*)id=\"globalso-header\"(.*)>([\s\S]*)<\/header>/iU",'',$html); | ||
| 89 | + $html = preg_replace("/<main(.*)id=\"globalso-main\"(.*)>([\s\S]*)<\/main>/iU",'',$html); | ||
| 90 | + $html = preg_replace("/<footer(.*)id=\"globalso-footer\"(.*)>([\s\S]*)<\/footer>/iU",'',$html); | ||
| 91 | + | ||
| 92 | + | ||
| 93 | + | ||
| 94 | + | ||
| 95 | + | ||
| 96 | + | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + | ||
| 100 | + /** | ||
| 101 | + * 数据源 | ||
| 102 | + * @return \Illuminate\Http\JsonResponse | ||
| 103 | + * @author:dc | ||
| 104 | + * @time 2023/5/11 10:47 | ||
| 105 | + */ | ||
| 106 | + public function get_type(){ | ||
| 107 | + return $this->success(ATemplateHtml::$sourceMap); | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + | ||
| 111 | + /** | ||
| 112 | + * 获取 编辑html | ||
| 113 | + * @author:dc | ||
| 114 | + * @time 2023/5/11 9:33 | ||
| 115 | + */ | ||
| 116 | + public function get_html(){ | ||
| 117 | + $source = $this->param['source']??''; | ||
| 118 | + $source_id = $this->param['source_id']??0; | ||
| 119 | + | ||
| 120 | + | ||
| 121 | + | ||
| 122 | + return $this->success(); | ||
| 123 | + | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + /** | ||
| 127 | + * 保存 | ||
| 128 | + * @author:dc | ||
| 129 | + * @time 2023/5/11 11:00 | ||
| 130 | + */ | ||
| 131 | + public function save_html(){ | ||
| 132 | + | ||
| 133 | + $source = $this->param['source']??''; | ||
| 134 | + $source_id = $this->param['source_id']??0; | ||
| 135 | + | ||
| 136 | + $html = $this->param['html']??''; | ||
| 137 | + | ||
| 138 | + | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * 自定义块 | ||
| 144 | + * @author:dc | ||
| 145 | + * @time 2023/5/10 14:55 | ||
| 146 | + */ | ||
| 147 | + public function customChunk(){ | ||
| 148 | + | ||
| 149 | + $html = $this->param['html']??[]; | ||
| 150 | + // 那个页面 的 | ||
| 151 | + $type = $this->param['type']??''; | ||
| 152 | + | ||
| 153 | + if(!is_array($html)){ | ||
| 154 | + return $this->response('参数异常','B_CUSTOM_CHUNK_PARAMS'); | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + // 项目id | ||
| 158 | + $project_id = $this->user['project_id']; | ||
| 159 | + // 当前模板 | ||
| 160 | + $template_id = BSetting::_get($project_id)['template_id']; | ||
| 161 | + | ||
| 162 | + // 验证这个模板是否存在 | ||
| 163 | + if(!$type || !ATemplateHtml::_typeExist($template_id,$type)){ | ||
| 164 | + return $this->response('页面类型错误','B_CUSTOM_CHUNK_PARAMS_TYPE'); | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + | ||
| 168 | + $html = view("template.{$template_id}.{$type}")->render(); | ||
| 169 | + | ||
| 170 | + | ||
| 171 | + return $this->response('',Code::SUCCESS,$html); | ||
| 172 | +// $data = BTemplateData::_insert(); | ||
| 173 | + | ||
| 174 | + | ||
| 175 | + | ||
| 176 | + | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + | ||
| 180 | + | ||
| 181 | + | ||
| 182 | + | ||
| 74 | 183 | ||
| 75 | } | 184 | } |
| @@ -38,6 +38,8 @@ class AyrReleaseLogic extends BaseLogic | @@ -38,6 +38,8 @@ class AyrReleaseLogic extends BaseLogic | ||
| 38 | * @time :2023/5/9 9:38 | 38 | * @time :2023/5/9 9:38 |
| 39 | */ | 39 | */ |
| 40 | public function release_add(){ | 40 | public function release_add(){ |
| 41 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 42 | + $this->param['operator_id'] = $this->user['id']; | ||
| 41 | $rs = $this->model->add($this->param); | 43 | $rs = $this->model->add($this->param); |
| 42 | if($rs === false){ | 44 | if($rs === false){ |
| 43 | $this->fail('error'); | 45 | $this->fail('error'); |
| @@ -48,7 +48,7 @@ class AyrShareLogic extends BaseLogic | @@ -48,7 +48,7 @@ class AyrShareLogic extends BaseLogic | ||
| 48 | * @time :2023/5/6 10:16 | 48 | * @time :2023/5/6 10:16 |
| 49 | */ | 49 | */ |
| 50 | public function ayr_share_info(){ | 50 | public function ayr_share_info(){ |
| 51 | - $info = $this->model->read(['id'=>$this->param['id']]); | 51 | + $info = $this->model->read(['id'=>$this->param['share_id']]); |
| 52 | if($info === false){ | 52 | if($info === false){ |
| 53 | $this->fail('当前数据不存在或已被删除'); | 53 | $this->fail('当前数据不存在或已被删除'); |
| 54 | } | 54 | } |
| @@ -3,10 +3,12 @@ | @@ -3,10 +3,12 @@ | ||
| 3 | namespace App\Http\Logic\Bside; | 3 | namespace App\Http\Logic\Bside; |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | +use App\Enums\Common\Code; | ||
| 6 | use App\Enums\Common\Common; | 7 | use App\Enums\Common\Common; |
| 7 | use App\Exceptions\BsideGlobalException; | 8 | use App\Exceptions\BsideGlobalException; |
| 8 | use App\Http\Controllers\file\ImageController; | 9 | use App\Http\Controllers\file\ImageController; |
| 9 | use App\Http\Logic\Logic; | 10 | use App\Http\Logic\Logic; |
| 11 | +use App\Models\File\Image as ImageModel; | ||
| 10 | use Illuminate\Support\Facades\Cache; | 12 | use Illuminate\Support\Facades\Cache; |
| 11 | 13 | ||
| 12 | /** | 14 | /** |
| @@ -93,14 +95,37 @@ class BaseLogic extends Logic | @@ -93,14 +95,37 @@ class BaseLogic extends Logic | ||
| 93 | } | 95 | } |
| 94 | 96 | ||
| 95 | /** | 97 | /** |
| 96 | - * @name :上传图片 | 98 | + * @name :上传图片返回hash |
| 97 | * @return void | 99 | * @return void |
| 98 | * @author :liyuhang | 100 | * @author :liyuhang |
| 99 | * @method | 101 | * @method |
| 100 | */ | 102 | */ |
| 101 | public function upload(){ | 103 | public function upload(){ |
| 102 | - $image = new ImageController(); | ||
| 103 | - $hash = $image->upload(); | 104 | + $files = $this->request->file('image'); |
| 105 | + $hash = hash_file('md5', $files->getPathname()); | ||
| 106 | + //查看文件是否存在 | ||
| 107 | + $imageModel = new ImageModel(); | ||
| 108 | + $image_hash = $imageModel->read(['hash'=>$hash]); | ||
| 109 | + if($image_hash !== false){ | ||
| 110 | + return $hash; | ||
| 111 | + } | ||
| 112 | + $url = $this->path; | ||
| 113 | + $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension(); | ||
| 114 | + $res = $files->move($url,$fileName); | ||
| 115 | + if ($res === false) { | ||
| 116 | + return false; | ||
| 117 | + } | ||
| 118 | + $data = [ | ||
| 119 | + 'path' => $url.$fileName, | ||
| 120 | + 'created_at' => date('Y-m-d H:i:s',time()), | ||
| 121 | + 'size' => $res->getSize(), | ||
| 122 | + 'hash' => $hash, | ||
| 123 | + 'type'=>$files->getClientOriginalExtension(), | ||
| 124 | + ]; | ||
| 125 | + $rs = $imageModel->add($data); | ||
| 126 | + if ($rs === false) { | ||
| 127 | + return false; | ||
| 128 | + } | ||
| 104 | return $hash; | 129 | return $hash; |
| 105 | } | 130 | } |
| 106 | 131 |
| @@ -7,4 +7,30 @@ use App\Models\Base; | @@ -7,4 +7,30 @@ use App\Models\Base; | ||
| 7 | class AyrShare extends Base | 7 | class AyrShare extends Base |
| 8 | { | 8 | { |
| 9 | protected $table = 'gl_ayr_share'; | 9 | protected $table = 'gl_ayr_share'; |
| 10 | + | ||
| 11 | + const TYPE_FACEBOOK = 1; | ||
| 12 | + const TYPE_TWITTER = 2; | ||
| 13 | + const TYPE_LINKEDIN = 3; | ||
| 14 | + const TYPE_INSTAGRAM = 4; | ||
| 15 | + const TYPE_YOUTUBE = 5; | ||
| 16 | + const TYPE_REDDIT = 6; | ||
| 17 | + const TYPE_TELEGRAM = 7; | ||
| 18 | + const TYPE_GMB = 8; | ||
| 19 | + const TYPE_PINTEREST = 9; | ||
| 20 | + const TYPE_TIKTOK = 10; | ||
| 21 | + /** | ||
| 22 | + * @var :授权列表 | ||
| 23 | + */ | ||
| 24 | + public $platforms = [ | ||
| 25 | + self::TYPE_FACEBOOK => 'Facebook', | ||
| 26 | + self::TYPE_TWITTER => 'Twitter', | ||
| 27 | + self::TYPE_LINKEDIN => 'LinkedIn', | ||
| 28 | + self::TYPE_INSTAGRAM => 'Instagram', | ||
| 29 | + self::TYPE_YOUTUBE => 'YouTube', | ||
| 30 | + self::TYPE_REDDIT => 'Reddit', | ||
| 31 | + self::TYPE_TELEGRAM => 'Telegram', | ||
| 32 | + self::TYPE_GMB => 'Google', | ||
| 33 | + self::TYPE_PINTEREST => 'Pinterest', | ||
| 34 | + self::TYPE_TIKTOK => 'TikTok', | ||
| 35 | + ]; | ||
| 10 | } | 36 | } |
| @@ -59,7 +59,7 @@ class BCustom extends Base | @@ -59,7 +59,7 @@ class BCustom extends Base | ||
| 59 | $model->description = $data['description']; | 59 | $model->description = $data['description']; |
| 60 | $model->url = $data['url']; | 60 | $model->url = $data['url']; |
| 61 | $model->status = $data['status']; | 61 | $model->status = $data['status']; |
| 62 | - $model->html = $data['html']; | 62 | + $model->html = $data['html']??''; |
| 63 | 63 | ||
| 64 | $model->save(); | 64 | $model->save(); |
| 65 | 65 |
| @@ -8,7 +8,8 @@ use App\Models\User\User; | @@ -8,7 +8,8 @@ use App\Models\User\User; | ||
| 8 | class Blog extends Base | 8 | class Blog extends Base |
| 9 | { | 9 | { |
| 10 | protected $table = 'gl_blog'; | 10 | protected $table = 'gl_blog'; |
| 11 | - | 11 | + //连接数据库 |
| 12 | +// protected $connection = 'custom_mysql'; | ||
| 12 | public function user(){ | 13 | public function user(){ |
| 13 | return $this->hasMany(User::class,'operator_id','id'); | 14 | return $this->hasMany(User::class,'operator_id','id'); |
| 14 | } | 15 | } |
| @@ -7,4 +7,7 @@ use App\Models\Base; | @@ -7,4 +7,7 @@ use App\Models\Base; | ||
| 7 | class BlogCategory extends Base | 7 | class BlogCategory extends Base |
| 8 | { | 8 | { |
| 9 | protected $table = 'gl_blog_category'; | 9 | protected $table = 'gl_blog_category'; |
| 10 | + //连接数据库 | ||
| 11 | +// protected $connection = 'custom_mysql'; | ||
| 12 | + | ||
| 10 | } | 13 | } |
| @@ -8,20 +8,6 @@ class Image extends Base | @@ -8,20 +8,6 @@ class Image extends Base | ||
| 8 | { | 8 | { |
| 9 | protected $table = 'gl_image'; | 9 | protected $table = 'gl_image'; |
| 10 | 10 | ||
| 11 | - public $timestamps = true; | ||
| 12 | - | ||
| 13 | - /** | ||
| 14 | - * @param $hash | ||
| 15 | - * @name :(获取图片详情)image_read | ||
| 16 | - * @author :lyh | ||
| 17 | - * @method :post | ||
| 18 | - * @time :2023/5/4 11:50 | ||
| 19 | - */ | ||
| 20 | - public function image_read($hash){ | ||
| 21 | - $info = $this->read(['hash'=>$hash]); | ||
| 22 | - if(empty($info)){ | ||
| 23 | - return false; | ||
| 24 | - } | ||
| 25 | - return $info; | ||
| 26 | - } | 11 | + //连接数据库 |
| 12 | +// protected $connection = 'custom_mysql'; | ||
| 27 | } | 13 | } |
| @@ -9,4 +9,6 @@ class Mail extends Base | @@ -9,4 +9,6 @@ class Mail extends Base | ||
| 9 | protected $table = 'gl_mail'; | 9 | protected $table = 'gl_mail'; |
| 10 | //自动维护create_at创建时间 updated_at修改时间 | 10 | //自动维护create_at创建时间 updated_at修改时间 |
| 11 | public $timestamps = true; | 11 | public $timestamps = true; |
| 12 | + //连接数据库 | ||
| 13 | +// protected $connection = 'custom_mysql'; | ||
| 12 | } | 14 | } |
| @@ -9,4 +9,6 @@ class MailUser extends Base | @@ -9,4 +9,6 @@ class MailUser extends Base | ||
| 9 | protected $table = 'gl_mail_user'; | 9 | protected $table = 'gl_mail_user'; |
| 10 | //自动维护create_at创建时间 updated_at修改时间 | 10 | //自动维护create_at创建时间 updated_at修改时间 |
| 11 | public $timestamps = true; | 11 | public $timestamps = true; |
| 12 | + //连接数据库 | ||
| 13 | +// protected $connection = 'custom_mysql'; | ||
| 12 | } | 14 | } |
| @@ -7,6 +7,6 @@ use App\Models\Base; | @@ -7,6 +7,6 @@ use App\Models\Base; | ||
| 7 | class NewsCategory extends Base | 7 | class NewsCategory extends Base |
| 8 | { | 8 | { |
| 9 | protected $table = 'gl_news_category'; | 9 | protected $table = 'gl_news_category'; |
| 10 | - //数据库配置 | ||
| 11 | - protected $connection = ''; | 10 | + //连接数据库 |
| 11 | +// protected $connection = 'custom_mysql'; | ||
| 12 | } | 12 | } |
| @@ -81,5 +81,43 @@ class ATemplate extends \App\Models\Base{ | @@ -81,5 +81,43 @@ class ATemplate extends \App\Models\Base{ | ||
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | 83 | ||
| 84 | + /** | ||
| 85 | + * 查询 | ||
| 86 | + * @param $id | ||
| 87 | + * @return mixed | ||
| 88 | + * @author:dc | ||
| 89 | + * @time 2023/5/10 10:15 | ||
| 90 | + */ | ||
| 91 | + public static function _find($id) | ||
| 92 | + { | ||
| 93 | + return static::where('id',$id)->first(); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + | ||
| 97 | + /** | ||
| 98 | + * @param array $data | ||
| 99 | + * @param int $id | ||
| 100 | + * @author:dc | ||
| 101 | + * @time 2023/5/11 10:08 | ||
| 102 | + */ | ||
| 103 | + public static function _save(array $data,int $id=0){ | ||
| 104 | + if($id){ | ||
| 105 | + $model = static::where('id',$id)->first(); | ||
| 106 | + } | ||
| 107 | + if(empty($model)) $model = new static(); | ||
| 108 | + | ||
| 109 | + $model->name = $data['name']; | ||
| 110 | + $model->status = $data['status']; | ||
| 111 | + $model->is_default = $data['is_default']; | ||
| 112 | + $model->sort = $data['sort']; | ||
| 113 | + $model->thumb = $data['thumb']; | ||
| 114 | + $model->url = $data['url']; | ||
| 115 | + | ||
| 116 | + $model->save(); | ||
| 117 | + | ||
| 118 | + return $model->id; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + | ||
| 84 | 122 | ||
| 85 | } | 123 | } |
| @@ -24,6 +24,117 @@ class ATemplateHtml extends \App\Models\Base{ | @@ -24,6 +24,117 @@ class ATemplateHtml extends \App\Models\Base{ | ||
| 24 | use SoftDeletes; | 24 | use SoftDeletes; |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | + public static $sourceMap = [ | ||
| 28 | + // 数据表/数据类型 =》 模板类型/模板名称 | ||
| 29 | + 'index' => [ | ||
| 30 | + 'template' => 'index', | ||
| 31 | + 'name'=>'首页' | ||
| 32 | + ], | ||
| 33 | + 'product' => [ | ||
| 34 | + 'template' => 'product', | ||
| 35 | + 'name'=>'商品列表' | ||
| 36 | + ], | ||
| 37 | + 'product_info' => [ | ||
| 38 | + 'template' => 'product_info', | ||
| 39 | + 'name'=>'商品详情' | ||
| 40 | + ], | ||
| 41 | + 'blogs' => [ | ||
| 42 | + 'template' => 'blogs', | ||
| 43 | + 'name'=>'博客列表' | ||
| 44 | + ], | ||
| 45 | + 'blogs_info' => [ | ||
| 46 | + 'template' => 'blogs_info', | ||
| 47 | + 'name'=>'博客详情' | ||
| 48 | + ], | ||
| 49 | + 'page' => [ | ||
| 50 | + 'template' => 'page', | ||
| 51 | + 'name'=>'单页' | ||
| 52 | + ], | ||
| 53 | + 'news' => [ | ||
| 54 | + 'template' => 'news', | ||
| 55 | + 'name'=>'新闻列表' | ||
| 56 | + ], | ||
| 57 | + 'news_info' => [ | ||
| 58 | + 'template' => 'news_info', | ||
| 59 | + 'name'=>'新闻详情' | ||
| 60 | + ], | ||
| 61 | + ]; | ||
| 62 | + | ||
| 63 | + public static $typeMap = [ | ||
| 64 | + 'index' => '首页', | ||
| 65 | + 'product' => '商品列表', | ||
| 66 | + 'product_info' => '商品详情', | ||
| 67 | + 'blogs' => '博客列表', | ||
| 68 | + 'blogs_info' => '博客详情', | ||
| 69 | + 'page' => '单页', | ||
| 70 | + 'news' => '新闻列表', | ||
| 71 | + 'news_info' => '新闻详情', | ||
| 72 | + ]; | ||
| 73 | + | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * 模板中的数据 | ||
| 77 | + * @param $template_id | ||
| 78 | + * @return mixed | ||
| 79 | + * @author:dc | ||
| 80 | + * @time 2023/5/10 10:30 | ||
| 81 | + */ | ||
| 82 | + public static function _all($template_id){ | ||
| 83 | + return static::where(['template_id'=>$template_id])->get(); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + | ||
| 87 | + /** | ||
| 88 | + * 是否存在type | ||
| 89 | + * @param int $template_id | ||
| 90 | + * @param $type | ||
| 91 | + * @return mixed | ||
| 92 | + * @author:dc | ||
| 93 | + * @time 2023/5/10 16:03 | ||
| 94 | + */ | ||
| 95 | + public static function _typeExist(int $template_id,$type){ | ||
| 96 | + return static::where(['template_id'=>$template_id,'type'=>$type])->limit(1)->count(); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + | ||
| 100 | + public static function _bAll($template_id){ | ||
| 101 | + return static::where(['template_id'=>$template_id,'status'=>1])->get(); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + | ||
| 105 | + public static function _find($id){ | ||
| 106 | + return static::where('id',$id)->first(); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + /** | ||
| 110 | + * @param array $data | ||
| 111 | + * @param int $id | ||
| 112 | + * @return mixed | ||
| 113 | + * @author:dc | ||
| 114 | + * @time 2023/5/11 10:20 | ||
| 115 | + */ | ||
| 116 | + public static function _save(int $template_id, array $data,int $id = 0){ | ||
| 117 | + if($id){ | ||
| 118 | + $model = static::where('id',$id)->first(); | ||
| 119 | + } | ||
| 120 | + if(empty($model)) $model = new static(); | ||
| 121 | + | ||
| 122 | + $model->template_id = $template_id; | ||
| 123 | + | ||
| 124 | + $model->name = $data['name']; | ||
| 125 | + $model->status = $data['status']; | ||
| 126 | + $model->is_default = $data['is_default']; | ||
| 127 | + $model->sort = $data['sort']; | ||
| 128 | + $model->thumb = $data['thumb']; | ||
| 129 | + $model->url = $data['url']; | ||
| 130 | + | ||
| 131 | + $model->save(); | ||
| 132 | + | ||
| 133 | + return $model->id; | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + | ||
| 137 | + | ||
| 27 | 138 | ||
| 28 | 139 | ||
| 29 | } | 140 | } |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Models\Template; | 3 | namespace App\Models\Template; |
| 4 | 4 | ||
| 5 | use Illuminate\Database\Eloquent\SoftDeletes; | 5 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 6 | +use Illuminate\Support\Facades\DB; | ||
| 6 | 7 | ||
| 7 | /** | 8 | /** |
| 8 | * 当前用户的模板 | 9 | * 当前用户的模板 |
| @@ -71,6 +72,30 @@ class BSetting extends \App\Models\Base{ | @@ -71,6 +72,30 @@ class BSetting extends \App\Models\Base{ | ||
| 71 | 72 | ||
| 72 | $data->save(); | 73 | $data->save(); |
| 73 | 74 | ||
| 75 | + // 是否有模板 | ||
| 76 | +// if(!BTemplate::_isExist($project_id,$template_id)){ | ||
| 77 | +// // 没有模板 | ||
| 78 | +// $aData = ATemplate::_find($template_id); | ||
| 79 | +// // 保存到自己的数据中 | ||
| 80 | +// BTemplate::_insert($project_id,$aData); | ||
| 81 | +// | ||
| 82 | +// $aDataHtml = ATemplateHtml::_all($template_id); | ||
| 83 | +// DB::beginTransaction(); | ||
| 84 | +// foreach ($aDataHtml as $item){ | ||
| 85 | +// try { | ||
| 86 | +// // 插入子数据 | ||
| 87 | +// BTemplateHtml::_insert($project_id,$item); | ||
| 88 | +// }catch (\Throwable $e){ | ||
| 89 | +// DB::rollBack(); | ||
| 90 | +// | ||
| 91 | +// return $data->id; | ||
| 92 | +// break; | ||
| 93 | +// } | ||
| 94 | +// | ||
| 95 | +// } | ||
| 96 | +// DB::commit(); | ||
| 97 | +// } | ||
| 98 | + | ||
| 74 | return $data->id; | 99 | return $data->id; |
| 75 | 100 | ||
| 76 | } | 101 | } |
| @@ -11,48 +11,46 @@ namespace App\Models\Template; | @@ -11,48 +11,46 @@ namespace App\Models\Template; | ||
| 11 | */ | 11 | */ |
| 12 | class BTemplate extends \App\Models\Base{ | 12 | class BTemplate extends \App\Models\Base{ |
| 13 | 13 | ||
| 14 | - protected $table = 'gl_web_template_html'; | 14 | + protected $table = 'gl_web_template'; |
| 15 | 15 | ||
| 16 | + protected $hidden = ['project_id']; | ||
| 16 | 17 | ||
| 17 | 18 | ||
| 18 | /** | 19 | /** |
| 19 | - * @param $project_id | ||
| 20 | - * @return mixed | 20 | + * 是否存在模板 |
| 21 | + * @param int $template_id | ||
| 21 | * @author:dc | 22 | * @author:dc |
| 22 | - * @time 2023/5/4 16:13 | 23 | + * @time 2023/5/10 10:00 |
| 23 | */ | 24 | */ |
| 24 | - public static function _get($project_id){ | ||
| 25 | - return static::where(['project_id'=>$project_id])->get(['html','type'])->pluck('html','type')->toArray(); | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - | ||
| 29 | - public static function _all($project_id){ | ||
| 30 | - return static::where(['project_id'=>$project_id])->get(); | 25 | + public static function _isExist(int $project_id, int $template_id) |
| 26 | + { | ||
| 27 | + return static::where(['project_id'=>$project_id,'template_id'=>$template_id])->limit(1)->count(); | ||
| 31 | } | 28 | } |
| 32 | 29 | ||
| 33 | 30 | ||
| 34 | /** | 31 | /** |
| 35 | - * 保存 | 32 | + * 插入 |
| 36 | * @param $project_id | 33 | * @param $project_id |
| 37 | - * @param $type | ||
| 38 | - * @param $html | 34 | + * @param $data |
| 35 | + * @return mixed | ||
| 39 | * @author:dc | 36 | * @author:dc |
| 40 | - * @time 2023/5/4 17:50 | 37 | + * @time 2023/5/10 10:23 |
| 41 | */ | 38 | */ |
| 42 | - public static function _save($project_id,$type,$html){ | ||
| 43 | - $data = static::where(['project_id'=>$project_id,'type'=>$type])->first(); | ||
| 44 | - if(!$data){ | ||
| 45 | - $data = new static(); | ||
| 46 | - $data->project_id = $project_id; | ||
| 47 | - $data->type = $type; | ||
| 48 | - } | ||
| 49 | - $data->html = $html; | ||
| 50 | - | ||
| 51 | - $data->save(); | ||
| 52 | - | ||
| 53 | - return $data->id; | ||
| 54 | - } | 39 | + public static function _insert($project_id,$data) |
| 40 | + { | ||
| 41 | + $model = new static(); | ||
| 42 | + | ||
| 43 | + $model->project_id = $project_id; | ||
| 44 | + $model->template_id = $data['id']; | ||
| 45 | + $model->name = $data['name']; | ||
| 46 | + $model->thumb = $data['thumb']; | ||
| 47 | + $model->html = $data['html']; | ||
| 48 | + | ||
| 49 | + $model->save(); | ||
| 55 | 50 | ||
| 51 | + return $model->id; | ||
| 52 | + | ||
| 53 | + } | ||
| 56 | 54 | ||
| 57 | 55 | ||
| 58 | } | 56 | } |
resources/views/template/.gitignore
0 → 100644
resources/views/template/readme.md
0 → 100644
| @@ -126,10 +126,16 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w | @@ -126,10 +126,16 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w | ||
| 126 | 126 | ||
| 127 | // 自定义页面 模板,头部底部 | 127 | // 自定义页面 模板,头部底部 |
| 128 | Route::prefix('template')->group(function () { | 128 | Route::prefix('template')->group(function () { |
| 129 | - Route::get('/', [\App\Http\Controllers\Aside\TemplateController::class, 'index'])->name('admin.template_header_footer'); | ||
| 130 | - Route::get('/edit', [\App\Http\Controllers\Aside\TemplateController::class, 'edit'])->name('admin.template_header_footer_edit'); | ||
| 131 | - Route::get('/insert', [\App\Http\Controllers\Aside\TemplateController::class, 'insert'])->name('admin.template_header_footer_insert'); | ||
| 132 | - Route::get('/delete', [\App\Http\Controllers\Aside\TemplateController::class, 'delete'])->name('admin.template_header_footer_system'); | 129 | + Route::get('/', [\App\Http\Controllers\Aside\TemplateController::class, 'index'])->name('admin.template'); |
| 130 | + Route::post('/edit', [\App\Http\Controllers\Aside\TemplateController::class, 'edit'])->name('admin.template_edit'); | ||
| 131 | + Route::post('/insert', [\App\Http\Controllers\Aside\TemplateController::class, 'insert'])->name('admin.template_insert'); | ||
| 132 | + Route::delete('/delete/{id}', [\App\Http\Controllers\Aside\TemplateController::class, 'delete'])->where('id','\d+')->name('admin.template_delete'); | ||
| 133 | + | ||
| 134 | + Route::get('/html/{template_id}', [\App\Http\Controllers\Aside\TemplateController::class, 'html_index'])->where('template_id','\d+')->name('admin.template.html'); | ||
| 135 | + Route::post('/html/{template_id}/edit', [\App\Http\Controllers\Aside\TemplateController::class, 'html_edit'])->where('template_id','\d+')->name('admin.template_edit.html'); | ||
| 136 | + Route::post('/html/{template_id}/insert', [\App\Http\Controllers\Aside\TemplateController::class, 'html_insert'])->where('template_id','\d+')->name('admin.template_insert.html'); | ||
| 137 | + 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'); | ||
| 138 | + Route::get('/html/type', [\App\Http\Controllers\Aside\TemplateController::class, 'html_type'])->name('admin.template_type.html'); | ||
| 133 | }); | 139 | }); |
| 134 | 140 | ||
| 135 | 141 |
| @@ -225,15 +225,26 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -225,15 +225,26 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 225 | }); | 225 | }); |
| 226 | }); | 226 | }); |
| 227 | 227 | ||
| 228 | - // 自定义页面 | 228 | + |
| 229 | + | ||
| 230 | + | ||
| 231 | + // 模板 | ||
| 229 | Route::prefix('template')->group(function () { | 232 | Route::prefix('template')->group(function () { |
| 230 | - Route::get('/', [\App\Http\Controllers\Bside\TemplateController::class, 'index'])->name('template_header_footer'); | ||
| 231 | - Route::get('/edit', [\App\Http\Controllers\Bside\TemplateController::class, 'edit_html'])->name('template_header_footer_edit'); | ||
| 232 | - Route::post('/edit', [\App\Http\Controllers\Bside\TemplateController::class, 'edit_save'])->name('template_header_footer_edit_save'); | ||
| 233 | - Route::get('/system', [\App\Http\Controllers\Bside\TemplateController::class, 'system_all_html'])->name('template_header_footer_system'); | ||
| 234 | - Route::get('/custom', [\App\Http\Controllers\Bside\TemplateController::class, 'custom'])->name('template_custom'); | 233 | + Route::get('/', [\App\Http\Controllers\Bside\TemplateController::class, 'index'])->name('bside_template'); |
| 234 | + Route::any('/use-template', [\App\Http\Controllers\Bside\TemplateController::class, 'info'])->name('bside_template_use'); | ||
| 235 | +// Route::get('/custom-chunk', [\App\Http\Controllers\Bside\TemplateController::class, 'customChunk'])->name('bside_template_custom_chunk'); | ||
| 236 | + Route::get('/get_type', [\App\Http\Controllers\Bside\TemplateController::class, 'get_type'])->name('bside_template_type'); | ||
| 237 | + Route::get('/get_html', [\App\Http\Controllers\Bside\TemplateController::class, 'get_html'])->name('bside_template_get_html'); | ||
| 238 | + Route::get('/save_html', [\App\Http\Controllers\Bside\TemplateController::class, 'save_html'])->name('bside_template_save_html'); | ||
| 239 | + }); | ||
| 240 | + // 自定义页面,专题页 | ||
| 241 | + Route::prefix('custom')->group(function () { | ||
| 242 | + Route::get('/', [\App\Http\Controllers\Bside\CustomController::class, 'index'])->name('bside_custom'); | ||
| 243 | + Route::post('/create', [\App\Http\Controllers\Bside\CustomController::class, 'create'])->name('bside_custom_create'); | ||
| 244 | + Route::post('/update', [\App\Http\Controllers\Bside\CustomController::class, 'update'])->name('bside_custom_update'); | ||
| 245 | + Route::delete('/delete', [\App\Http\Controllers\Bside\CustomController::class, 'delete'])->name('bside_custom_delete'); | ||
| 246 | + Route::any('/html/{id}', [\App\Http\Controllers\Bside\CustomController::class, 'html'])->where('id','\d+')->name('bside_custom_delete'); | ||
| 235 | }); | 247 | }); |
| 236 | - | ||
| 237 | // 导航栏编辑 | 248 | // 导航栏编辑 |
| 238 | Route::prefix('nav')->group(function () { | 249 | Route::prefix('nav')->group(function () { |
| 239 | Route::get('/', [\App\Http\Controllers\Bside\NavController::class, 'index'])->name('bside_nav'); | 250 | Route::get('/', [\App\Http\Controllers\Bside\NavController::class, 'index'])->name('bside_nav'); |
| @@ -242,9 +253,6 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -242,9 +253,6 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 242 | Route::delete('/delete', [\App\Http\Controllers\Bside\NavController::class, 'delete'])->name('bside_nav_delete'); | 253 | Route::delete('/delete', [\App\Http\Controllers\Bside\NavController::class, 'delete'])->name('bside_nav_delete'); |
| 243 | }); | 254 | }); |
| 244 | 255 | ||
| 245 | - | ||
| 246 | - | ||
| 247 | - | ||
| 248 | }); | 256 | }); |
| 249 | 257 | ||
| 250 | //无需登录验证的路由组 | 258 | //无需登录验证的路由组 |
| @@ -253,5 +261,5 @@ Route::group([], function () { | @@ -253,5 +261,5 @@ Route::group([], function () { | ||
| 253 | // Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country'); | 261 | // Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country'); |
| 254 | Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download'); | 262 | Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download'); |
| 255 | Route::any('/image/{hash}/{type?}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show'); | 263 | Route::any('/image/{hash}/{type?}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show'); |
| 256 | - Route::any('/file_hash/{hash}/{type?}/', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show'); | 264 | + Route::any('/file_hash/{hash}/', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show'); |
| 257 | }); | 265 | }); |
-
请 注册 或 登录 后发表评论