Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev
正在显示
56 个修改的文件
包含
1219 行增加
和
228 行删除
| @@ -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() |
| @@ -146,6 +146,71 @@ if (!function_exists('checkDomain')) { | @@ -146,6 +146,71 @@ if (!function_exists('checkDomain')) { | ||
| 146 | } | 146 | } |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | + | ||
| 150 | + | ||
| 151 | +/** | ||
| 152 | + * 把返回的数据集转换成Tree | ||
| 153 | + * @param $list array 数据列表 | ||
| 154 | + * @param string|int $pk 主键|root | ||
| 155 | + * @param string $pid 父id | ||
| 156 | + * @param string $child 子键 | ||
| 157 | + * @param int $root 获取哪个id下面 | ||
| 158 | + * @param bool $empty_child 当子数据不存在,是否要返回空子数据 | ||
| 159 | + * @return array | ||
| 160 | + */ | ||
| 161 | +function list_to_tree($list, $pk='id',$pid = 'pid',$child = '_child',$root=0,$empty_child=true) { | ||
| 162 | + // 如果是数字,则是root | ||
| 163 | + if(is_numeric($pk)){ | ||
| 164 | + $root = $pk; | ||
| 165 | + $pk = 'id'; | ||
| 166 | + } | ||
| 167 | + // 创建Tree | ||
| 168 | + $tree = array(); | ||
| 169 | + if(is_array($list)) { | ||
| 170 | + // 创建基于主键的数组引用 | ||
| 171 | + $refer = array(); | ||
| 172 | + foreach ($list as $key => $data) { | ||
| 173 | + if($empty_child){ | ||
| 174 | + $list[$key][$child] = []; | ||
| 175 | + } | ||
| 176 | + $refer[$data[$pk]] =& $list[$key]; | ||
| 177 | + } | ||
| 178 | + foreach ($list as $key => $data) { | ||
| 179 | + // 判断是否存在parent | ||
| 180 | + $parentId = $data[$pid]; | ||
| 181 | + if ($root == $parentId) { | ||
| 182 | + $tree[] =& $list[$key]; | ||
| 183 | + }else{ | ||
| 184 | + if (isset($refer[$parentId])) { | ||
| 185 | + $refer[$parentId][$child][] = & $list[$key]; | ||
| 186 | + } | ||
| 187 | + } | ||
| 188 | + } | ||
| 189 | + } | ||
| 190 | + return $tree; | ||
| 191 | +} | ||
| 192 | + | ||
| 193 | +/** | ||
| 194 | + * tree数据转list | ||
| 195 | + * @param $tree | ||
| 196 | + * @param string $child | ||
| 197 | + * @return array | ||
| 198 | + * @author:dc | ||
| 199 | + * @time 2022/1/11 10:13 | ||
| 200 | + */ | ||
| 201 | +function tree_to_list($tree, $child='_child'){ | ||
| 202 | + $lists = []; | ||
| 203 | + foreach ($tree as $item){ | ||
| 204 | + $c = $item[$child]??[]; | ||
| 205 | + unset($item[$child]); | ||
| 206 | + $lists[] = $item; | ||
| 207 | + if ($c){ | ||
| 208 | + $lists = array_merge($lists,tree_to_list($c, $child)); | ||
| 209 | + } | ||
| 210 | + } | ||
| 211 | + return $lists; | ||
| 212 | +} | ||
| 213 | + | ||
| 149 | if (!function_exists('getThisWeekStarDate')) { | 214 | if (!function_exists('getThisWeekStarDate')) { |
| 150 | /** | 215 | /** |
| 151 | * 获取本周一的日期 | 216 | * 获取本周一的日期 |
| @@ -32,8 +32,8 @@ class AiCommandController extends BaseController | @@ -32,8 +32,8 @@ class AiCommandController extends BaseController | ||
| 32 | * @author :liyuhang | 32 | * @author :liyuhang |
| 33 | * @method | 33 | * @method |
| 34 | */ | 34 | */ |
| 35 | - public function info(Request $request,AiCommandLogic $aiCommandLogic){ | ||
| 36 | - $request->validate([ | 35 | + public function info(AiCommandLogic $aiCommandLogic){ |
| 36 | + $this->request->validate([ | ||
| 37 | 'id'=>'required' | 37 | 'id'=>'required' |
| 38 | ],[ | 38 | ],[ |
| 39 | 'id.required' => 'ID不能为空' | 39 | 'id.required' => 'ID不能为空' |
| @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Aside; | @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Aside; | ||
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Controllers\Controller; | 6 | use App\Http\Controllers\Controller; |
| 7 | +use App\Http\Requests\Aside\Template\TemplateRequest; | ||
| 8 | +use App\Http\Requests\Scene; | ||
| 7 | use Illuminate\Http\JsonResponse; | 9 | use Illuminate\Http\JsonResponse; |
| 8 | use Illuminate\Http\Request; | 10 | use Illuminate\Http\Request; |
| 9 | use Illuminate\Http\Exceptions\HttpResponseException; | 11 | use Illuminate\Http\Exceptions\HttpResponseException; |
| @@ -155,4 +157,21 @@ class BaseController extends Controller | @@ -155,4 +157,21 @@ class BaseController extends Controller | ||
| 155 | } | 157 | } |
| 156 | return $data; | 158 | return $data; |
| 157 | } | 159 | } |
| 160 | + | ||
| 161 | + | ||
| 162 | + /** | ||
| 163 | + * 验证 | ||
| 164 | + * @param $c | ||
| 165 | + * @param $scene | ||
| 166 | + * @return array | ||
| 167 | + * @author:dc | ||
| 168 | + * @time 2023/5/11 14:56 | ||
| 169 | + */ | ||
| 170 | + protected final function verify($c,$scene=null){ | ||
| 171 | + return app($c)->setScene($scene?:Scene::$CREATE)->validated(); | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + | ||
| 175 | + | ||
| 176 | + | ||
| 158 | } | 177 | } |
| @@ -2,7 +2,13 @@ | @@ -2,7 +2,13 @@ | ||
| 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\Http\Logic\Aside\Template\TemplateLogic; | ||
| 7 | +use App\Http\Requests\Aside\Template\TemplateRequest; | ||
| 8 | +use App\Http\Requests\Scene; | ||
| 9 | +use App\Models\Template\ATemplate; | ||
| 10 | +use App\Models\Template\ATemplateHtml; | ||
| 11 | +use Illuminate\Validation\Rule; | ||
| 6 | 12 | ||
| 7 | /** | 13 | /** |
| 8 | * 模板 | 14 | * 模板 |
| @@ -22,21 +28,8 @@ class TemplateController extends BaseController | @@ -22,21 +28,8 @@ class TemplateController extends BaseController | ||
| 22 | */ | 28 | */ |
| 23 | public function index(){ | 29 | public function index(){ |
| 24 | 30 | ||
| 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 | - } | ||
| 38 | - | ||
| 39 | - return $this->success($lists); | 31 | + $lists = (new ATemplate)->lists($this->map,$this->page,$this->row,$this->order,['id','name','status','is_default','sort','thumb','url','created_at','updated_at']); |
| 32 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 40 | 33 | ||
| 41 | } | 34 | } |
| 42 | 35 | ||
| @@ -47,7 +40,7 @@ class TemplateController extends BaseController | @@ -47,7 +40,7 @@ class TemplateController extends BaseController | ||
| 47 | * @time 2023/5/4 16:19 | 40 | * @time 2023/5/4 16:19 |
| 48 | */ | 41 | */ |
| 49 | public function edit(){ | 42 | public function edit(){ |
| 50 | - | 43 | + $this->save(Scene::$UPDATE); |
| 51 | } | 44 | } |
| 52 | 45 | ||
| 53 | /** | 46 | /** |
| @@ -56,12 +49,134 @@ class TemplateController extends BaseController | @@ -56,12 +49,134 @@ class TemplateController extends BaseController | ||
| 56 | * @time 2023/5/5 9:30 | 49 | * @time 2023/5/5 9:30 |
| 57 | */ | 50 | */ |
| 58 | public function insert(){ | 51 | public function insert(){ |
| 52 | + $this->save(Scene::$CREATE); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * @param false $is_edit | ||
| 58 | + * @return \Illuminate\Http\JsonResponse | ||
| 59 | + * @throws \Illuminate\Validation\ValidationException | ||
| 60 | + * @throws \Psr\Container\ContainerExceptionInterface | ||
| 61 | + * @throws \Psr\Container\NotFoundExceptionInterface | ||
| 62 | + * @author:dc | ||
| 63 | + * @time 2023/5/11 10:13 | ||
| 64 | + */ | ||
| 65 | + private function save($scene){ | ||
| 66 | + | ||
| 67 | + | ||
| 68 | + $data = $this->verify(TemplateRequest::class,$scene); | ||
| 69 | + | ||
| 70 | + | ||
| 71 | + TemplateLogic::instance()->save($data); | ||
| 72 | + | ||
| 73 | + | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * 删除 | ||
| 79 | + * @author:dc | ||
| 80 | + * @time 2023/5/4 17:10 | ||
| 81 | + */ | ||
| 82 | + public function delete($id){ | ||
| 83 | + | ||
| 84 | + if(ATemplate::destroy($id)){ | ||
| 85 | + return $this->response('删除成功'); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + return $this->response('删除失败',Code::SYSTEM_ERROR); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + | ||
| 92 | + | ||
| 93 | + | ||
| 94 | + | ||
| 95 | + | ||
| 96 | + /** | ||
| 97 | + * 列表 | ||
| 98 | + * @author:dc | ||
| 99 | + * @time 2023/5/4 17:10 | ||
| 100 | + */ | ||
| 101 | + public function html_index($template_id){ | ||
| 59 | 102 | ||
| 103 | + $lists = (new ATemplate)->list($this->map,$this->order,['id','name','status','is_default','sort','thumb','url','created_at','updated_at']); | ||
| 104 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 105 | + | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + | ||
| 109 | + /** | ||
| 110 | + * 编辑 | ||
| 111 | + * @author:dc | ||
| 112 | + * @time 2023/5/4 16:19 | ||
| 113 | + */ | ||
| 114 | + public function html_edit($template_id){ | ||
| 115 | + $this->html_save($template_id,true); | ||
| 60 | } | 116 | } |
| 61 | 117 | ||
| 118 | + /** | ||
| 119 | + * 新增 | ||
| 120 | + * @author:dc | ||
| 121 | + * @time 2023/5/5 9:30 | ||
| 122 | + */ | ||
| 123 | + public function html_insert($template_id){ | ||
| 124 | + $this->html_save($template_id); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + | ||
| 128 | + /** | ||
| 129 | + * @param false $is_edit | ||
| 130 | + * @return \Illuminate\Http\JsonResponse | ||
| 131 | + * @throws \Illuminate\Validation\ValidationException | ||
| 132 | + * @throws \Psr\Container\ContainerExceptionInterface | ||
| 133 | + * @throws \Psr\Container\NotFoundExceptionInterface | ||
| 134 | + * @author:dc | ||
| 135 | + * @time 2023/5/11 10:13 | ||
| 136 | + */ | ||
| 137 | + private function html_save($template_id,$is_edit=false){ | ||
| 138 | + | ||
| 139 | + $verify = [ | ||
| 140 | + 'role' => [ | ||
| 141 | + 'id' => ['required','integer'], | ||
| 142 | +// 'template_id' => ['required','integer'], | ||
| 143 | + 'name' => ['required'], | ||
| 144 | + 'type' => ['required',Rule::in(ATemplateHtml::$typeMap)], | ||
| 145 | + 'css' => [], | ||
| 146 | + 'script' => [], | ||
| 147 | + 'html' => ['required'], | ||
| 148 | + ], | ||
| 149 | + 'message' => [ | ||
| 150 | + 'id.required' => 'id必须', | ||
| 151 | + 'id.integer' => 'id必须', | ||
| 152 | + | ||
| 153 | +// 'template_id.required' => '模板选择错误', | ||
| 154 | +// 'template_id.integer' => '模板选择错误', | ||
| 155 | + | ||
| 156 | + 'name.required' => '名称必须', | ||
| 157 | + | ||
| 158 | + 'type.required' => '页面类型选择错误', | ||
| 159 | + 'type.in' => '页面类型选择错误', | ||
| 160 | + | ||
| 161 | + | ||
| 162 | + 'html.required' => 'html 代码必须', | ||
| 163 | + | ||
| 164 | + ] | ||
| 165 | + ]; | ||
| 166 | + if(!$is_edit) unset($verify['role']['id']); | ||
| 167 | + | ||
| 168 | + $data = $this->validate(request() ,$verify['role'],$verify['message']); | ||
| 169 | + | ||
| 62 | 170 | ||
| 63 | - private function save($name = ''){ | ||
| 64 | 171 | ||
| 172 | + // 保存 | ||
| 173 | + $id = ATemplateHtml::_save($template_id,$data,$data['id']??0); | ||
| 174 | + | ||
| 175 | + if(!$id){ | ||
| 176 | + return $this->response('保存失败',Code::SYSTEM_ERROR); | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + return $this->success(ATemplateHtml::_find($id)); | ||
| 65 | } | 180 | } |
| 66 | 181 | ||
| 67 | 182 | ||
| @@ -70,12 +185,28 @@ class TemplateController extends BaseController | @@ -70,12 +185,28 @@ class TemplateController extends BaseController | ||
| 70 | * @author:dc | 185 | * @author:dc |
| 71 | * @time 2023/5/4 17:10 | 186 | * @time 2023/5/4 17:10 |
| 72 | */ | 187 | */ |
| 73 | - public function delete(){ | 188 | + public function html_delete($template_id, $id){ |
| 74 | 189 | ||
| 190 | + if(ATemplateHtml::where('template_id',$template_id)->where('id',$id)->delete()){ | ||
| 191 | + return $this->response('删除成功'); | ||
| 192 | + } | ||
| 75 | 193 | ||
| 194 | + return $this->response('删除失败',Code::SYSTEM_ERROR); | ||
| 76 | } | 195 | } |
| 77 | 196 | ||
| 78 | 197 | ||
| 198 | + /** | ||
| 199 | + * 页面类型 | ||
| 200 | + * @return \Illuminate\Http\JsonResponse | ||
| 201 | + * @throws \Psr\Container\ContainerExceptionInterface | ||
| 202 | + * @throws \Psr\Container\NotFoundExceptionInterface | ||
| 203 | + * @author:dc | ||
| 204 | + * @time 2023/5/11 10:29 | ||
| 205 | + */ | ||
| 206 | + public function html_type(){ | ||
| 207 | + return $this->success(ATemplateHtml::$typeMap); | ||
| 208 | + } | ||
| 209 | + | ||
| 79 | 210 | ||
| 80 | 211 | ||
| 81 | 212 |
| @@ -6,9 +6,10 @@ use App\Enums\Common\Code; | @@ -6,9 +6,10 @@ use App\Enums\Common\Code; | ||
| 6 | use App\Helper\AyrShare as AyrShareHelper; | 6 | use App\Helper\AyrShare as AyrShareHelper; |
| 7 | use App\Http\Controllers\Bside\BaseController; | 7 | use App\Http\Controllers\Bside\BaseController; |
| 8 | use App\Http\Controllers\Bside\FileController; | 8 | use App\Http\Controllers\Bside\FileController; |
| 9 | -use App\Http\Controllers\file\ImageController; | 9 | +use App\Http\Controllers\File\ImageController; |
| 10 | use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic; | 10 | use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic; |
| 11 | use App\Http\Logic\Bside\AyrShare\AyrShareLogic; | 11 | use App\Http\Logic\Bside\AyrShare\AyrShareLogic; |
| 12 | +use App\Http\Requests\Bside\AyrRelease\AyrReleaseRequest; | ||
| 12 | use App\Models\File\Image; | 13 | use App\Models\File\Image; |
| 13 | use App\Models\File\Image as ImageModel; | 14 | use App\Models\File\Image as ImageModel; |
| 14 | 15 | ||
| @@ -43,6 +44,11 @@ class AyrReleaseController extends BaseController | @@ -43,6 +44,11 @@ class AyrReleaseController extends BaseController | ||
| 43 | * @time :2023/5/9 16:00 | 44 | * @time :2023/5/9 16:00 |
| 44 | */ | 45 | */ |
| 45 | public function share_info(AyrShareLogic $ayrShareLogic){ | 46 | public function share_info(AyrShareLogic $ayrShareLogic){ |
| 47 | + $this->request->validate([ | ||
| 48 | + 'share_id'=>['required'] | ||
| 49 | + ],[ | ||
| 50 | + 'share_id.required' => 'SHARE_ID不能为空' | ||
| 51 | + ]); | ||
| 46 | $info = $ayrShareLogic->ayr_share_info(); | 52 | $info = $ayrShareLogic->ayr_share_info(); |
| 47 | $this->response('success',Code::SUCCESS,$info); | 53 | $this->response('success',Code::SUCCESS,$info); |
| 48 | } | 54 | } |
| @@ -52,7 +58,10 @@ class AyrReleaseController extends BaseController | @@ -52,7 +58,10 @@ class AyrReleaseController extends BaseController | ||
| 52 | * @method :post | 58 | * @method :post |
| 53 | * @time :2023/5/9 9:36 | 59 | * @time :2023/5/9 9:36 |
| 54 | */ | 60 | */ |
| 55 | - public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic,AyrShareHelper $ayrShare){ | 61 | + public function send_post(AyrReleaseRequest $ayrReleaseRequest,AyrReleaseLogic $ayrReleaseLogic, |
| 62 | + AyrShareLogic $ayrShareLogic,AyrShareHelper $ayrShare){ | ||
| 63 | + $ayrReleaseRequest->validated(); | ||
| 64 | + //验证发送平台 | ||
| 56 | //获取发送账号详情 | 65 | //获取发送账号详情 |
| 57 | $share_info = $ayrShareLogic->ayr_share_info(); | 66 | $share_info = $ayrShareLogic->ayr_share_info(); |
| 58 | $data = [ | 67 | $data = [ |
| @@ -82,21 +91,26 @@ class AyrReleaseController extends BaseController | @@ -82,21 +91,26 @@ class AyrReleaseController extends BaseController | ||
| 82 | * @time :2023/5/10 14:07 | 91 | * @time :2023/5/10 14:07 |
| 83 | */ | 92 | */ |
| 84 | public function send_media(AyrShareLogic $ayrShareLogic,AyrShareHelper $ayrShare){ | 93 | public function send_media(AyrShareLogic $ayrShareLogic,AyrShareHelper $ayrShare){ |
| 94 | + $this->request->validate([ | ||
| 95 | + 'share_id'=>['required'], | ||
| 96 | + 'hash'=>['required'] | ||
| 97 | + ],[ | ||
| 98 | + 'share_id.required' => 'SHARE_ID不能为空', | ||
| 99 | + 'hash.required' => 'HASH不能为空' | ||
| 100 | + ]); | ||
| 85 | $image_info = $ayrShareLogic->save_img_info($this->param['hash']); | 101 | $image_info = $ayrShareLogic->save_img_info($this->param['hash']); |
| 86 | if(empty($image_info['ayr_id'])){ | 102 | if(empty($image_info['ayr_id'])){ |
| 87 | //获取发送账号详情 | 103 | //获取发送账号详情 |
| 88 | $share_info = $ayrShareLogic->ayr_share_info(); | 104 | $share_info = $ayrShareLogic->ayr_share_info(); |
| 89 | - //获取当前图片数据是否已上传到第三方 | ||
| 90 | - $arr = (new ImageController())->index($this->param['hash']); | ||
| 91 | //向第三方存储图片 | 105 | //向第三方存储图片 |
| 92 | $param = [ | 106 | $param = [ |
| 93 | - 'file'=>($arr->original),//base64编码 | 107 | + 'file'=>$ayrShareLogic->base_img_content($this->param['hash']),//base64编码 |
| 94 | ]; | 108 | ]; |
| 95 | $param_data = $ayrShare->post_media_upload($param,$share_info['profile_key']); | 109 | $param_data = $ayrShare->post_media_upload($param,$share_info['profile_key']); |
| 96 | //更新图片库 | 110 | //更新图片库 |
| 97 | $ayrShareLogic->save_img($param_data); | 111 | $ayrShareLogic->save_img($param_data); |
| 98 | } | 112 | } |
| 99 | - $this->response('success'); | 113 | + $this->response('success',Code::SUCCESS,$image_info); |
| 100 | } | 114 | } |
| 101 | 115 | ||
| 102 | /** | 116 | /** |
| @@ -106,15 +120,20 @@ class AyrReleaseController extends BaseController | @@ -106,15 +120,20 @@ class AyrReleaseController extends BaseController | ||
| 106 | * @time :2023/5/10 14:07 | 120 | * @time :2023/5/10 14:07 |
| 107 | */ | 121 | */ |
| 108 | public function send_media_file(AyrShareLogic $ayrShareLogic,AyrShareHelper $ayrShare){ | 122 | public function send_media_file(AyrShareLogic $ayrShareLogic,AyrShareHelper $ayrShare){ |
| 123 | + $this->request->validate([ | ||
| 124 | + 'share_id'=>['required'], | ||
| 125 | + 'hash'=>['required'] | ||
| 126 | + ],[ | ||
| 127 | + 'share_id.required' => 'SHARE_ID不能为空', | ||
| 128 | + 'hash.required' => 'HASH不能为空' | ||
| 129 | + ]); | ||
| 109 | $image_info = $ayrShareLogic->save_file_info($this->param['hash']); | 130 | $image_info = $ayrShareLogic->save_file_info($this->param['hash']); |
| 110 | if(empty($image_info['ayr_id'])){ | 131 | if(empty($image_info['ayr_id'])){ |
| 111 | //获取发送账号详情 | 132 | //获取发送账号详情 |
| 112 | $share_info = $ayrShareLogic->ayr_share_info(); | 133 | $share_info = $ayrShareLogic->ayr_share_info(); |
| 113 | - //获取当前图片数据是否已上传到第三方 | ||
| 114 | - $arr = (new FileController())->index($this->param['hash']); | ||
| 115 | //向第三方存储图片 | 134 | //向第三方存储图片 |
| 116 | $param = [ | 135 | $param = [ |
| 117 | - 'file'=>($arr->original),//base64编码 | 136 | + 'file'=>$ayrShareLogic->base_img_content($this->param['hash']),//base64编码 |
| 118 | ]; | 137 | ]; |
| 119 | $param_data = $ayrShare->post_media_upload($param,$share_info['profile_key']); | 138 | $param_data = $ayrShare->post_media_upload($param,$share_info['profile_key']); |
| 120 | //更新图片库 | 139 | //更新图片库 |
| @@ -6,6 +6,7 @@ use App\Enums\Common\Code; | @@ -6,6 +6,7 @@ use App\Enums\Common\Code; | ||
| 6 | use App\Helper\AyrShare as AyrShareHelper; | 6 | use App\Helper\AyrShare as AyrShareHelper; |
| 7 | use App\Http\Controllers\Bside\BaseController; | 7 | use App\Http\Controllers\Bside\BaseController; |
| 8 | use App\Http\Logic\Bside\AyrShare\AyrShareLogic; | 8 | use App\Http\Logic\Bside\AyrShare\AyrShareLogic; |
| 9 | +use App\Http\Requests\Bside\AyrShare\AyrShareRequest; | ||
| 9 | use App\Models\AyrShare\AyrShare as AyrShareModel; | 10 | use App\Models\AyrShare\AyrShare as AyrShareModel; |
| 10 | 11 | ||
| 11 | /** | 12 | /** |
| @@ -36,6 +37,11 @@ class AyrShareController extends BaseController | @@ -36,6 +37,11 @@ class AyrShareController extends BaseController | ||
| 36 | * @time :2023/5/9 14:39 | 37 | * @time :2023/5/9 14:39 |
| 37 | */ | 38 | */ |
| 38 | public function save_account(AyrShareLogic $ayrShareLogic){ | 39 | public function save_account(AyrShareLogic $ayrShareLogic){ |
| 40 | + $this->request->validate([ | ||
| 41 | + 'share_id'=>['required'], | ||
| 42 | + ],[ | ||
| 43 | + 'share_id.required' => 'SHARE_ID不能为空', | ||
| 44 | + ]); | ||
| 39 | $info = $ayrShareLogic->ayr_share_info(); | 45 | $info = $ayrShareLogic->ayr_share_info(); |
| 40 | $ayrShareHelper = new AyrShareHelper(); | 46 | $ayrShareHelper = new AyrShareHelper(); |
| 41 | $share_info = $ayrShareHelper->get_profiles_users($info['profile_key']); | 47 | $share_info = $ayrShareHelper->get_profiles_users($info['profile_key']); |
| @@ -55,7 +61,8 @@ class AyrShareController extends BaseController | @@ -55,7 +61,8 @@ class AyrShareController extends BaseController | ||
| 55 | * @method :post | 61 | * @method :post |
| 56 | * @time :2023/5/5 16:44 | 62 | * @time :2023/5/5 16:44 |
| 57 | */ | 63 | */ |
| 58 | - public function create_account(AyrShareLogic $ayrShareLogic){ | 64 | + public function create_account(AyrShareRequest $ayrShareRequest,AyrShareLogic $ayrShareLogic){ |
| 65 | + $ayrShareRequest->validated(); | ||
| 59 | $param = [ | 66 | $param = [ |
| 60 | 'title'=>self::TITLE.$this->user['project_id'].':'.$this->param['name'], | 67 | 'title'=>self::TITLE.$this->user['project_id'].':'.$this->param['name'], |
| 61 | ]; | 68 | ]; |
| @@ -5,11 +5,14 @@ namespace App\Http\Controllers\Bside; | @@ -5,11 +5,14 @@ namespace App\Http\Controllers\Bside; | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Helper\Common; | 6 | use App\Helper\Common; |
| 7 | use App\Http\Controllers\Controller; | 7 | use App\Http\Controllers\Controller; |
| 8 | +use App\Http\Requests\Bside\Nav\NavRequest; | ||
| 9 | +use App\Http\Requests\Scene; | ||
| 8 | use App\Models\User\User as UserModel; | 10 | use App\Models\User\User as UserModel; |
| 9 | use Illuminate\Http\JsonResponse; | 11 | use Illuminate\Http\JsonResponse; |
| 10 | use Illuminate\Http\Request; | 12 | use Illuminate\Http\Request; |
| 11 | use Illuminate\Http\Exceptions\HttpResponseException; | 13 | use Illuminate\Http\Exceptions\HttpResponseException; |
| 12 | use Illuminate\Support\Facades\Cache; | 14 | use Illuminate\Support\Facades\Cache; |
| 15 | +use Illuminate\Support\Facades\Validator; | ||
| 13 | 16 | ||
| 14 | class BaseController extends Controller | 17 | class BaseController extends Controller |
| 15 | { | 18 | { |
| @@ -207,4 +210,5 @@ class BaseController extends Controller | @@ -207,4 +210,5 @@ class BaseController extends Controller | ||
| 207 | } | 210 | } |
| 208 | 211 | ||
| 209 | 212 | ||
| 213 | + | ||
| 210 | } | 214 | } |
| @@ -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 | ], |
| @@ -114,7 +114,7 @@ class CustomController extends BaseController | @@ -114,7 +114,7 @@ class CustomController extends BaseController | ||
| 114 | $id = BCustom::_save($this->user['project_id'],$data,$data['id']??0); | 114 | $id = BCustom::_save($this->user['project_id'],$data,$data['id']??0); |
| 115 | 115 | ||
| 116 | if($id===-1){ | 116 | if($id===-1){ |
| 117 | - return $this->response('数据不存在','B_CUSTOM_NOTFOUND'); | 117 | + return $this->response('数据不存在',Code::SYSTEM_ERROR); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | return $this->success(BCustom::_find($this->user['project_id'],$id,true)); | 120 | return $this->success(BCustom::_find($this->user['project_id'],$id,true)); |
| @@ -132,7 +132,7 @@ class CustomController extends BaseController | @@ -132,7 +132,7 @@ class CustomController extends BaseController | ||
| 132 | $data = BCustom::_find($this->user['project_id'],$id); | 132 | $data = BCustom::_find($this->user['project_id'],$id); |
| 133 | 133 | ||
| 134 | if(empty($data)){ | 134 | if(empty($data)){ |
| 135 | - return $this->response('数据不存在','B_CUSTOM_NOTFOUND'); | 135 | + return $this->response('数据不存在',Code::SYSTEM_ERROR); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | 138 | ||
| @@ -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('数据不存在',Code::SYSTEM_ERROR); | ||
| 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 | } |
| @@ -119,14 +119,14 @@ class NavController extends BaseController | @@ -119,14 +119,14 @@ class NavController extends BaseController | ||
| 119 | // 验证是否存在上级 | 119 | // 验证是否存在上级 |
| 120 | $all = BNav::_all($this->user['project_id'],$data['location']); | 120 | $all = BNav::_all($this->user['project_id'],$data['location']); |
| 121 | if(!$all->where('id',$data['pid'])->count()){ | 121 | if(!$all->where('id',$data['pid'])->count()){ |
| 122 | - return $this->response('上级栏目不存在','B_NAV_PID_NOTFOUND'); | 122 | + return $this->response('上级栏目不存在',Code::SYSTEM_ERROR); |
| 123 | } | 123 | } |
| 124 | // 上级不允许是自己的下级 | 124 | // 上级不允许是自己的下级 |
| 125 | if(!empty($data['id'])){ | 125 | if(!empty($data['id'])){ |
| 126 | $all = list_to_tree($all->toArray(),$data['id']); | 126 | $all = list_to_tree($all->toArray(),$data['id']); |
| 127 | $all = tree_to_list($all); | 127 | $all = tree_to_list($all); |
| 128 | if(in_array($data['pid'],array_column($all,'id'))){ | 128 | if(in_array($data['pid'],array_column($all,'id'))){ |
| 129 | - return $this->response('上级栏目不允许为本身的下级','B_NAV_PID_IS_CHILD'); | 129 | + return $this->response('上级栏目不允许为本身的下级',Code::SYSTEM_ERROR); |
| 130 | } | 130 | } |
| 131 | } | 131 | } |
| 132 | } | 132 | } |
| @@ -135,7 +135,7 @@ class NavController extends BaseController | @@ -135,7 +135,7 @@ class NavController extends BaseController | ||
| 135 | $id = BNav::_save($this->user['project_id'],$data,$data['id']??0); | 135 | $id = BNav::_save($this->user['project_id'],$data,$data['id']??0); |
| 136 | 136 | ||
| 137 | if($id===-1){ | 137 | if($id===-1){ |
| 138 | - return $this->response('导航菜单不存在','B_NAV_NOTFOUND'); | 138 | + return $this->response('导航菜单不存在',Code::SYSTEM_ERROR); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | return $this->success(BNav::_find($this->user['project_id'],$id,true)); | 141 | return $this->success(BNav::_find($this->user['project_id'],$id,true)); |
| @@ -153,12 +153,12 @@ class NavController extends BaseController | @@ -153,12 +153,12 @@ class NavController extends BaseController | ||
| 153 | $data = BNav::_find($this->user['project_id'],$id); | 153 | $data = BNav::_find($this->user['project_id'],$id); |
| 154 | 154 | ||
| 155 | if(empty($data)){ | 155 | if(empty($data)){ |
| 156 | - return $this->response('导航菜单不存在','B_NAV_NOTFOUND'); | 156 | + return $this->response('导航菜单不存在',Code::SYSTEM_ERROR); |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | 159 | ||
| 160 | if(BNav::isChild($data['id'],$this->user['project_id'])){ | 160 | if(BNav::isChild($data['id'],$this->user['project_id'])){ |
| 161 | - return $this->response('存在下级无法删除','B_NAV_DELETE_CHILD'); | 161 | + return $this->response('存在下级无法删除',Code::SYSTEM_ERROR); |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | 164 | ||
| @@ -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 | /** |
| @@ -53,7 +57,7 @@ class TemplateController extends BaseController | @@ -53,7 +57,7 @@ class TemplateController extends BaseController | ||
| 53 | if($template_id && ATemplate::_bFind($template_id)){ | 57 | if($template_id && ATemplate::_bFind($template_id)){ |
| 54 | BSetting::_save($this->user['project_id'],$template_id); | 58 | BSetting::_save($this->user['project_id'],$template_id); |
| 55 | }else{ | 59 | }else{ |
| 56 | - return $this->response('无法使用不存在的模板','B_TEMPLATE_NOTFOUND'); | 60 | + return $this->response('无法使用不存在的模板',Code::SYSTEM_ERROR); |
| 57 | } | 61 | } |
| 58 | } | 62 | } |
| 59 | 63 | ||
| @@ -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('参数异常',Code::SYSTEM_ERROR); | ||
| 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('页面类型错误',Code::SYSTEM_ERROR); | ||
| 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 | } |
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | -namespace App\Http\Controllers\file; | 3 | +namespace App\Http\Controllers\File; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Controllers\type; | 6 | use App\Http\Controllers\type; |
| 7 | -use App\Http\Controllers\统一返回参数; | ||
| 8 | use App\Models\File\Image as ImageModel; | 7 | use App\Models\File\Image as ImageModel; |
| 9 | -use App\Models\User\User as UserModel; | ||
| 10 | use Illuminate\Http\Exceptions\HttpResponseException; | 8 | use Illuminate\Http\Exceptions\HttpResponseException; |
| 11 | use Illuminate\Http\JsonResponse; | 9 | use Illuminate\Http\JsonResponse; |
| 12 | use Illuminate\Support\Facades\Storage; | 10 | use Illuminate\Support\Facades\Storage; |
| @@ -43,7 +41,16 @@ class ImageController | @@ -43,7 +41,16 @@ class ImageController | ||
| 43 | $this->path = $this->config['root'].$this->uploads['path'].'/'; | 41 | $this->path = $this->config['root'].$this->uploads['path'].'/'; |
| 44 | } | 42 | } |
| 45 | 43 | ||
| 46 | - public function index($hash = '',$type = self::TYPE, $w = 0 ,$h = 0 ){ | 44 | + /** |
| 45 | + * @param $hash | ||
| 46 | + * @param $w | ||
| 47 | + * @param $h | ||
| 48 | + * @name :index | ||
| 49 | + * @author :lyh | ||
| 50 | + * @method :post | ||
| 51 | + * @time :2023/5/11 17:19 | ||
| 52 | + */ | ||
| 53 | + public function index($hash = '', $w = 0 ,$h = 0 ){ | ||
| 47 | if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { | 54 | if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { |
| 48 | header("HTTP/1.1 304 Not Modified"); | 55 | header("HTTP/1.1 304 Not Modified"); |
| 49 | exit; | 56 | exit; |
| @@ -54,14 +61,13 @@ class ImageController | @@ -54,14 +61,13 @@ class ImageController | ||
| 54 | $this->response('指定图片不存在!', Code::USER_ERROR); | 61 | $this->response('指定图片不存在!', Code::USER_ERROR); |
| 55 | } | 62 | } |
| 56 | //查看缩略图是否存在 | 63 | //查看缩略图是否存在 |
| 57 | -// $header['Content-Type'] = 'image/'.$info['type']; | ||
| 58 | $filename = $this->path . $info['hash'] . $w . '_' . $h; | 64 | $filename = $this->path . $info['hash'] . $w . '_' . $h; |
| 59 | if(is_file($filename)){ | 65 | if(is_file($filename)){ |
| 60 | $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT"; | 66 | $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT"; |
| 61 | $header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'], | 67 | $header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'], |
| 62 | - [$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 2, $last_modified_time], $this->upload_img['header']); | 68 | + [$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 1, $last_modified_time], $this->upload_img['header']); |
| 63 | $content = file_get_contents($filename); | 69 | $content = file_get_contents($filename); |
| 64 | - $header['Content-Length'] = $info['size']; | 70 | + $header['Content-Length'] = strlen($content); |
| 65 | }else{ | 71 | }else{ |
| 66 | $path = $info['path']; | 72 | $path = $info['path']; |
| 67 | if (!is_file($path)) { | 73 | if (!is_file($path)) { |
| @@ -70,25 +76,18 @@ class ImageController | @@ -70,25 +76,18 @@ class ImageController | ||
| 70 | $content = ''; | 76 | $content = ''; |
| 71 | $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT"; | 77 | $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT"; |
| 72 | $header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'], | 78 | $header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'], |
| 73 | - [$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 2, $last_modified_time], $this->upload_img['header']); | 79 | + [$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 1, $last_modified_time], $this->upload_img['header']); |
| 74 | if ($w > 0 && $h > 0) { | 80 | if ($w > 0 && $h > 0) { |
| 75 | $path = $this->cacheImage($info, $w, $h); | 81 | $path = $this->cacheImage($info, $w, $h); |
| 76 | $content = file_get_contents($path); | 82 | $content = file_get_contents($path); |
| 77 | $header['Content-Length'] = strlen($content); | 83 | $header['Content-Length'] = strlen($content); |
| 78 | } else { | 84 | } else { |
| 79 | $content = file_get_contents($path); | 85 | $content = file_get_contents($path); |
| 80 | - $header['Content-Length'] = $info['size']; | ||
| 81 | - } | 86 | + $header['Content-Length'] = strlen($content); |
| 82 | } | 87 | } |
| 83 | - $img_type = $info['type']; | ||
| 84 | - $content = base64_encode($content); | ||
| 85 | - $img_base64 = 'data:image/' . $img_type . ';base64,' . $content; | ||
| 86 | - if($type != self::TYPE){ | ||
| 87 | - header('Content-Type: image/' . $img_type); | ||
| 88 | - echo base64_decode($content); | ||
| 89 | - exit; | ||
| 90 | } | 88 | } |
| 91 | - return response($img_base64,200,$header); | 89 | + $header['Content-Type'] = 'image/'.$info['type']; |
| 90 | + return response($content,200,$header); | ||
| 92 | } | 91 | } |
| 93 | 92 | ||
| 94 | /** | 93 | /** |
| @@ -51,6 +51,7 @@ class LoginLogic extends BaseLogic | @@ -51,6 +51,7 @@ class LoginLogic extends BaseLogic | ||
| 51 | 51 | ||
| 52 | public static function manage($field = ''){ | 52 | public static function manage($field = ''){ |
| 53 | $manage = Session::get('manage'); | 53 | $manage = Session::get('manage'); |
| 54 | + $manage = Manage::find(1)->toArray(); | ||
| 54 | if($field){ | 55 | if($field){ |
| 55 | return $manage[$field] ?? ''; | 56 | return $manage[$field] ?? ''; |
| 56 | } | 57 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Aside\Template; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Http\Logic\Aside\BaseLogic; | ||
| 7 | +use App\Models\Template\ATemplate; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * @author:dc | ||
| 11 | + * @time 2023/5/11 14:35 | ||
| 12 | + * Class TemplateLogic | ||
| 13 | + * @package App\Http\Logic\Aside\Template | ||
| 14 | + */ | ||
| 15 | +class TemplateLogic extends BaseLogic { | ||
| 16 | + | ||
| 17 | + public function __construct() | ||
| 18 | + { | ||
| 19 | + parent::__construct(); | ||
| 20 | + | ||
| 21 | + $this->model = new ATemplate(); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + | ||
| 28 | +} |
| @@ -69,102 +69,8 @@ class AyrReleaseLogic extends BaseLogic | @@ -69,102 +69,8 @@ class AyrReleaseLogic extends BaseLogic | ||
| 69 | return $this->success($arr); | 69 | return $this->success($arr); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | - /** | ||
| 73 | - * @name :(发布到推特)post_twitter | ||
| 74 | - * @author :lyh | ||
| 75 | - * @method :post | ||
| 76 | - * @time :2023/5/9 13:42 | ||
| 77 | - */ | ||
| 78 | - public function post_twitter($param){ | ||
| 79 | - $param['post'] = '描述'; | ||
| 80 | - $param['platforms'] = ['twitter']; | ||
| 81 | - $param['twitterOptions'] = [ | ||
| 82 | - 'thread'=> true, | ||
| 83 | - 'threadNumber'=> true, | ||
| 84 | - 'mediaUrls'=>[ | ||
| 85 | - //图片地址 | ||
| 86 | - ], | ||
| 87 | - ]; | ||
| 88 | - return $this->success($param); | ||
| 89 | - } | ||
| 90 | - /** | ||
| 91 | - * @name :(发布到youtube)post_facebook | ||
| 92 | - * @author :lyh | ||
| 93 | - * @method :post | ||
| 94 | - * @time :2023/5/9 10:05 | ||
| 95 | - */ | ||
| 96 | - public function post_facebook(){ | ||
| 97 | - $param['post'] = '视频描述'; | ||
| 98 | - $param['platforms'] = ['facebook']; | ||
| 99 | - $param['faceBookOptions'] = [ | ||
| 100 | - 'reels'=> true, | ||
| 101 | - 'title'=>'Super title for the Reel' | ||
| 102 | - ]; | ||
| 103 | - return $this->success($param); | ||
| 104 | - } | ||
| 105 | 72 | ||
| 106 | - /** | ||
| 107 | - * @name :(发布到fbg,)post_youtube | ||
| 108 | - * @author :lyh | ||
| 109 | - * @method :post | ||
| 110 | - * @time :2023/5/9 10:22 | ||
| 111 | - * @TODO::只能发布一张图片和一张视频 | ||
| 112 | - */ | ||
| 113 | - public function post_gmb(){ | ||
| 114 | - $param['post'] = '描述'; | ||
| 115 | - $param['platforms'] = ['gmb']; | ||
| 116 | - $param['mediaUrls'] = [];//图片链接 | ||
| 117 | - $param['gmbOptions'] = [ | ||
| 118 | - //视屏设置 | ||
| 119 | - 'isPhotoVideo' => true, | ||
| 120 | - 'category'=> 'cate',//分类 | ||
| 121 | - ]; | ||
| 122 | - return $this->success($param); | ||
| 123 | - } | ||
| 124 | - | ||
| 125 | - /** | ||
| 126 | - * @name :(发布到instagram)post_google | ||
| 127 | - * @author :lyh | ||
| 128 | - * @method :post | ||
| 129 | - * @time :2023/5/9 11:54 | ||
| 130 | - */ | ||
| 131 | - public function post_instagram(){ | ||
| 132 | - $param['post'] = '视频描述'; | ||
| 133 | - $param['platforms'] = ['instagram']; | ||
| 134 | - $param['faceBookOptions'] = [ | ||
| 135 | - 'reels'=> true, | ||
| 136 | - 'title'=>'Super title for the Reel' | ||
| 137 | - ]; | ||
| 138 | - return $this->success(); | ||
| 139 | - } | ||
| 140 | - | ||
| 141 | - /** | ||
| 142 | - * @name :(领英)post_linkedin | ||
| 143 | - * @author :lyh | ||
| 144 | - * @method :post | ||
| 145 | - * @time :2023/5/9 11:56 | ||
| 146 | - */ | ||
| 147 | - public function post_linkedin(){ | ||
| 148 | - return $this->success(); | ||
| 149 | - } | ||
| 150 | - | ||
| 151 | - /** | ||
| 152 | - * @name :(红迪网)post_reddit | ||
| 153 | - * @author :lyh | ||
| 154 | - * @method :post | ||
| 155 | - * @time :2023/5/9 13:40 | ||
| 156 | - */ | ||
| 157 | - public function post_reddit(){ | ||
| 158 | - return $this->success(); | ||
| 159 | - } | ||
| 160 | - | ||
| 161 | - /** | ||
| 162 | - * @name :(抖音)post_tiktok | ||
| 163 | - * @author :lyh | ||
| 164 | - * @method :post | ||
| 165 | - * @time :2023/5/9 13:44 | ||
| 166 | - */ | ||
| 167 | - public function post_tiktok(){ | 73 | + public function platforms_request(){ |
| 168 | 74 | ||
| 169 | } | 75 | } |
| 170 | } | 76 | } |
| @@ -94,7 +94,7 @@ class AyrShareLogic extends BaseLogic | @@ -94,7 +94,7 @@ class AyrShareLogic extends BaseLogic | ||
| 94 | if($info === false){ | 94 | if($info === false){ |
| 95 | $this->fail('error'); | 95 | $this->fail('error'); |
| 96 | } | 96 | } |
| 97 | - return $this->success(); | 97 | + return $this->success($info); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | /** | 100 | /** |
| @@ -109,7 +109,7 @@ class AyrShareLogic extends BaseLogic | @@ -109,7 +109,7 @@ class AyrShareLogic extends BaseLogic | ||
| 109 | if($info === false){ | 109 | if($info === false){ |
| 110 | $this->fail('error'); | 110 | $this->fail('error'); |
| 111 | } | 111 | } |
| 112 | - return $this->success(); | 112 | + return $this->success($info); |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | /** | 115 | /** |
| @@ -134,6 +134,24 @@ class AyrShareLogic extends BaseLogic | @@ -134,6 +134,24 @@ class AyrShareLogic extends BaseLogic | ||
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | /** | 136 | /** |
| 137 | + * @name :(获取图片的base64)base_img_content | ||
| 138 | + * @author :lyh | ||
| 139 | + * @method :post | ||
| 140 | + * @time :2023/5/12 9:28 | ||
| 141 | + */ | ||
| 142 | + public function base_img_content($hash){ | ||
| 143 | + $imageModel = new ImageModel(); | ||
| 144 | + $info = $imageModel->read(['hash'=>$hash]); | ||
| 145 | + if($info === false){ | ||
| 146 | + $this->fail('当前数据不存在'); | ||
| 147 | + } | ||
| 148 | + $content = file_get_contents($info['path']); | ||
| 149 | + $img_type = $info['type']; | ||
| 150 | + $content = base64_encode($content); | ||
| 151 | + $img_base64 = 'data:image/' . $img_type . ';base64,' . $content; | ||
| 152 | + return $img_base64; | ||
| 153 | + } | ||
| 154 | + /** | ||
| 137 | * @name :(更新文件库)save_img | 155 | * @name :(更新文件库)save_img |
| 138 | * @author :lyh | 156 | * @author :lyh |
| 139 | * @method :post | 157 | * @method :post |
| @@ -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 | /** |
| @@ -99,9 +101,35 @@ class BaseLogic extends Logic | @@ -99,9 +101,35 @@ class BaseLogic extends Logic | ||
| 99 | * @method | 101 | * @method |
| 100 | */ | 102 | */ |
| 101 | public function upload(){ | 103 | public function upload(){ |
| 102 | - $image = new ImageController(); | ||
| 103 | - $data = $image->upload(); | ||
| 104 | - return $data['data']['image']; | 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 | + $this->config = config('filesystems.disks.upload'); | ||
| 113 | + $this->uploads = config('upload.default_image'); | ||
| 114 | + $this->path = $this->config['root'].$this->uploads['path'].'/'; | ||
| 115 | + $url = $this->path; | ||
| 116 | + $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension(); | ||
| 117 | + $res = $files->move($url,$fileName); | ||
| 118 | + if ($res === false) { | ||
| 119 | + return false; | ||
| 120 | + } | ||
| 121 | + $data = [ | ||
| 122 | + 'path' => $url.$fileName, | ||
| 123 | + 'created_at' => date('Y-m-d H:i:s',time()), | ||
| 124 | + 'size' => $res->getSize(), | ||
| 125 | + 'hash' => $hash, | ||
| 126 | + 'type'=>$files->getClientOriginalExtension(), | ||
| 127 | + ]; | ||
| 128 | + $rs = $imageModel->add($data); | ||
| 129 | + if ($rs === false) { | ||
| 130 | + return false; | ||
| 131 | + } | ||
| 132 | + return $hash; | ||
| 105 | } | 133 | } |
| 106 | 134 | ||
| 107 | /** | 135 | /** |
| @@ -67,6 +67,7 @@ class BlogLogic extends BaseLogic | @@ -67,6 +67,7 @@ class BlogLogic extends BaseLogic | ||
| 67 | $this->param['project_id'] = $this->user['project_id']; | 67 | $this->param['project_id'] = $this->user['project_id']; |
| 68 | $this->param['created_at'] = date('Y-m-d H:i:s',time()); | 68 | $this->param['created_at'] = date('Y-m-d H:i:s',time()); |
| 69 | $this->param['updated_at'] = date('Y-m-d H:i:s',time()); | 69 | $this->param['updated_at'] = date('Y-m-d H:i:s',time()); |
| 70 | + $this->param['category_id'] = ','.$this->param['category_id'].','; | ||
| 70 | DB::beginTransaction(); | 71 | DB::beginTransaction(); |
| 71 | try { | 72 | try { |
| 72 | if(isset($this->param['image'])){ | 73 | if(isset($this->param['image'])){ |
| @@ -100,6 +101,7 @@ class BlogLogic extends BaseLogic | @@ -100,6 +101,7 @@ class BlogLogic extends BaseLogic | ||
| 100 | $this->fail('当前名称已存在'); | 101 | $this->fail('当前名称已存在'); |
| 101 | } | 102 | } |
| 102 | $this->param['operator_id'] = $this->user['id']; | 103 | $this->param['operator_id'] = $this->user['id']; |
| 104 | + $this->param['category_id'] = ','.trim($this->param['category_id'],',').','; | ||
| 103 | DB::beginTransaction(); | 105 | DB::beginTransaction(); |
| 104 | try { | 106 | try { |
| 105 | //是否有图片更新 | 107 | //是否有图片更新 |
app/Http/Logic/Bside/Nav/NavLogic.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Bside; | ||
| 4 | + | ||
| 5 | +use App\Helper\Arr; | ||
| 6 | +use App\Models\BNav; | ||
| 7 | +use App\Models\Inquiry; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * @author:dc | ||
| 11 | + * @time 2023/5/11 16:51 | ||
| 12 | + * Class NavLogic | ||
| 13 | + * @package App\Http\Logic\Bside | ||
| 14 | + */ | ||
| 15 | +class NavLogic extends BaseLogic | ||
| 16 | +{ | ||
| 17 | + public function __construct() | ||
| 18 | + { | ||
| 19 | + parent::__construct(); | ||
| 20 | + | ||
| 21 | + $this->model = new BNav(); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * @param $ids | ||
| 27 | + * @return array | ||
| 28 | + * @throws \App\Exceptions\AsideGlobalException | ||
| 29 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 30 | + * @author:dc | ||
| 31 | + * @time 2023/5/11 16:59 | ||
| 32 | + */ | ||
| 33 | + public function delete($ids,$map = []) | ||
| 34 | + { | ||
| 35 | + if(BNav::isChild($ids,$this->user['project_id'])){ | ||
| 36 | + $this->fail('存在下级无法删除','B_NAV_DELETE_CHILD'); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + return parent::delete($ids,$map); // TODO: Change the autogenerated stub | ||
| 40 | + | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | +} |
| @@ -59,6 +59,7 @@ class NewsLogic extends BaseLogic | @@ -59,6 +59,7 @@ class NewsLogic extends BaseLogic | ||
| 59 | $this->param['project_id'] = $this->user['project_id']; | 59 | $this->param['project_id'] = $this->user['project_id']; |
| 60 | $this->param['created_at'] = date('Y-m-d H:i:s',time()); | 60 | $this->param['created_at'] = date('Y-m-d H:i:s',time()); |
| 61 | $this->param['updated_at'] = date('Y-m-d H:i:s',time()); | 61 | $this->param['updated_at'] = date('Y-m-d H:i:s',time()); |
| 62 | + $this->param['category_id'] = ','.trim($this->param['category_id'],',').','; | ||
| 62 | DB::beginTransaction(); | 63 | DB::beginTransaction(); |
| 63 | try { | 64 | try { |
| 64 | if(isset($this->param['image'])){ | 65 | if(isset($this->param['image'])){ |
| @@ -91,6 +92,7 @@ class NewsLogic extends BaseLogic | @@ -91,6 +92,7 @@ class NewsLogic extends BaseLogic | ||
| 91 | $this->fail('当前名称已存在'); | 92 | $this->fail('当前名称已存在'); |
| 92 | } | 93 | } |
| 93 | $this->param['operator_id'] = $this->user['id']; | 94 | $this->param['operator_id'] = $this->user['id']; |
| 95 | + $this->param['category_id'] = ','.trim($this->param['category_id'],',').','; | ||
| 94 | DB::beginTransaction(); | 96 | DB::beginTransaction(); |
| 95 | try { | 97 | try { |
| 96 | //上传图片 | 98 | //上传图片 |
| @@ -99,7 +101,7 @@ class NewsLogic extends BaseLogic | @@ -99,7 +101,7 @@ class NewsLogic extends BaseLogic | ||
| 99 | } | 101 | } |
| 100 | //设置路由 | 102 | //设置路由 |
| 101 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']); | 103 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']); |
| 102 | - $this->model->edit($this->param,['id'=>$this->param['id']]); | 104 | + $this->edit($this->param,['id'=>$this->param['id']]); |
| 103 | DB::commit(); | 105 | DB::commit(); |
| 104 | }catch (\exception $e){ | 106 | }catch (\exception $e){ |
| 105 | DB::rollBack(); | 107 | DB::rollBack(); |
| @@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
| 3 | namespace App\Http\Logic\Bside\User; | 3 | namespace App\Http\Logic\Bside\User; |
| 4 | 4 | ||
| 5 | use App\Http\Logic\Bside\BaseLogic; | 5 | use App\Http\Logic\Bside\BaseLogic; |
| 6 | -use App\Models\ProjectGroup; | 6 | +use App\Models\User\ProjectGroup; |
| 7 | 7 | ||
| 8 | class GroupLogic extends BaseLogic | 8 | class GroupLogic extends BaseLogic |
| 9 | { | 9 | { |
| @@ -25,6 +25,7 @@ class GroupLogic extends BaseLogic | @@ -25,6 +25,7 @@ class GroupLogic extends BaseLogic | ||
| 25 | $this->param['admin_id'] = $this->user['admin_id']; | 25 | $this->param['admin_id'] = $this->user['admin_id']; |
| 26 | $this->param['create_id'] = $this->user['create_id']; | 26 | $this->param['create_id'] = $this->user['create_id']; |
| 27 | $this->param['operator_id'] = $this->user['operator_id']; | 27 | $this->param['operator_id'] = $this->user['operator_id']; |
| 28 | + $this->param['user_list'] = ','.trim($this->param['user_list'],',').','; | ||
| 28 | $rs = $this->model->add($this->param); | 29 | $rs = $this->model->add($this->param); |
| 29 | if($rs === false){ | 30 | if($rs === false){ |
| 30 | $this->fail('error'); | 31 | $this->fail('error'); |
| @@ -39,6 +40,7 @@ class GroupLogic extends BaseLogic | @@ -39,6 +40,7 @@ class GroupLogic extends BaseLogic | ||
| 39 | * @method | 40 | * @method |
| 40 | */ | 41 | */ |
| 41 | public function group_edit(){ | 42 | public function group_edit(){ |
| 43 | + $this->param['user_list'] = ','.trim($this->param['user_list'],',').','; | ||
| 42 | $rs = $this->edit($this->param,['id'=>$this->param['id']]); | 44 | $rs = $this->edit($this->param,['id'=>$this->param['id']]); |
| 43 | if($rs === false){ | 45 | if($rs === false){ |
| 44 | $this->fail('error'); | 46 | $this->fail('error'); |
| @@ -54,7 +56,6 @@ class GroupLogic extends BaseLogic | @@ -54,7 +56,6 @@ class GroupLogic extends BaseLogic | ||
| 54 | */ | 56 | */ |
| 55 | public function group_info(){ | 57 | public function group_info(){ |
| 56 | $info = $this->info($this->param); | 58 | $info = $this->info($this->param); |
| 57 | - | ||
| 58 | return $this->success($info); | 59 | return $this->success($info); |
| 59 | } | 60 | } |
| 60 | 61 |
| @@ -384,4 +384,17 @@ class Logic | @@ -384,4 +384,17 @@ class Logic | ||
| 384 | } | 384 | } |
| 385 | return $this->success($info); | 385 | return $this->success($info); |
| 386 | } | 386 | } |
| 387 | + | ||
| 388 | + | ||
| 389 | + | ||
| 390 | + /** | ||
| 391 | + * 获取实例 | ||
| 392 | + * @param mixed ...$params | ||
| 393 | + * @return static | ||
| 394 | + * @author:dc | ||
| 395 | + * @time 2023/5/11 15:23 | ||
| 396 | + */ | ||
| 397 | + public static function instance(...$params){ | ||
| 398 | + return new static(...$params); | ||
| 399 | + } | ||
| 387 | } | 400 | } |
| @@ -31,7 +31,7 @@ class LoginAuthMiddleware | @@ -31,7 +31,7 @@ class LoginAuthMiddleware | ||
| 31 | } | 31 | } |
| 32 | // 设置数据信息 | 32 | // 设置数据信息 |
| 33 | // $project = ProjectServer::useProject($info['project_id']); | 33 | // $project = ProjectServer::useProject($info['project_id']); |
| 34 | -// if($project){ | 34 | +// if(empty($project)){ |
| 35 | // return response(['code'=>Code::USER_ERROR,'msg'=>'数据库未配置']); | 35 | // return response(['code'=>Code::USER_ERROR,'msg'=>'数据库未配置']); |
| 36 | // } | 36 | // } |
| 37 | //操作权限设置 | 37 | //操作权限设置 |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Aside\Template; | ||
| 4 | + | ||
| 5 | +use App\Http\Requests\Scene; | ||
| 6 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 7 | +use Illuminate\Validation\Rule; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * @author:dc | ||
| 11 | + * @time 2023/5/11 14:38 | ||
| 12 | + * Class TemplateRequest | ||
| 13 | + * @package App\Http\Requests\Aside\Template | ||
| 14 | + */ | ||
| 15 | +class TemplateRequest extends FormRequest | ||
| 16 | +{ | ||
| 17 | +// use Scene; | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * Determine if the user is authorized to make this request. | ||
| 21 | + * | ||
| 22 | + * @return bool | ||
| 23 | + */ | ||
| 24 | + public function authorize() | ||
| 25 | + { | ||
| 26 | + return true; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Get the validation rules that apply to the request. | ||
| 31 | + * | ||
| 32 | + * @return array | ||
| 33 | + */ | ||
| 34 | + public function rules() | ||
| 35 | + { | ||
| 36 | + $rule = [ | ||
| 37 | + 'id' => ['required','integer'], | ||
| 38 | + 'name' => ['required'], | ||
| 39 | + 'status' => ['required',Rule::in(0,1)], | ||
| 40 | + 'is_default' => ['required',Rule::in(0,1)], | ||
| 41 | + 'sort' => ['required','integer'], | ||
| 42 | + 'thumb' => ['required'], | ||
| 43 | + 'url' => ['required'], | ||
| 44 | + ]; | ||
| 45 | + | ||
| 46 | + // 更新场景 | ||
| 47 | +// if(!$this->isScene(Scene::$CREATE)){ | ||
| 48 | +// unset($rule['id']); | ||
| 49 | +// } | ||
| 50 | + | ||
| 51 | + return $rule; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + | ||
| 56 | + public function messages() | ||
| 57 | + { | ||
| 58 | + return [ | ||
| 59 | + 'id.required' => 'id必须', | ||
| 60 | + 'id.integer' => 'id必须', | ||
| 61 | + | ||
| 62 | + 'name.required' => '名称必须', | ||
| 63 | + 'status.integer' => '状态错误', | ||
| 64 | + 'status.in' => '状态错误', | ||
| 65 | + 'is_default.integer' => '是否默认', | ||
| 66 | + 'is_default.in' => '是否默认', | ||
| 67 | + 'sort.required' => '排序必须', | ||
| 68 | + 'sort.integer' => '排序必须', | ||
| 69 | + 'thumb.required' => '缩略图必须', | ||
| 70 | + 'url.required' => '预览链接必须', | ||
| 71 | + ]; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | +} |
app/Http/Requests/Bside/Nav/NavRequest.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Bside\Nav; | ||
| 4 | + | ||
| 5 | +use App\Http\Requests\Scene; | ||
| 6 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 导航 c端的 nav | ||
| 10 | + * @author:dc | ||
| 11 | + * @time 2023/5/11 15:20 | ||
| 12 | + * Class NavRequest | ||
| 13 | + * @package App\Http\Requests\Bside\Nav | ||
| 14 | + */ | ||
| 15 | +class NavRequest extends FormRequest | ||
| 16 | +{ | ||
| 17 | + use Scene; | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * Determine if the user is authorized to make this request. | ||
| 21 | + * | ||
| 22 | + * @return bool | ||
| 23 | + */ | ||
| 24 | + public function authorize() | ||
| 25 | + { | ||
| 26 | + return true; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Get the validation rules that apply to the request. | ||
| 31 | + * | ||
| 32 | + * @return array | ||
| 33 | + */ | ||
| 34 | + public function rules() | ||
| 35 | + { | ||
| 36 | + $rule = [ | ||
| 37 | + 'pid' => ['required','integer','gte:0'], | ||
| 38 | + 'name' => ['required','max:100'], | ||
| 39 | + 'location' => ['required','in:header,footer'], | ||
| 40 | + 'url' => ['required','max:200'], | ||
| 41 | + 'status' => ['required','in:0,1'], | ||
| 42 | + 'target' => ['required','in:0,1'], | ||
| 43 | + 'sort' => ['required','integer','gte:0'] | ||
| 44 | + ]; | ||
| 45 | + | ||
| 46 | + // 修改 | ||
| 47 | + if($this->isScene(static::$UPDATE)){ | ||
| 48 | + $rule['id'] = ['required','integer']; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + // 删除 | ||
| 52 | + if($this->isScene(static::$DELETE)){ | ||
| 53 | + $rule = ['id' => ['required','integer']]; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + return $rule; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public function messages() | ||
| 60 | + { | ||
| 61 | + return [ | ||
| 62 | + 'id.required' => '编辑导航数据不存在', | ||
| 63 | + 'id.integer' => '编辑导航数据不存在', | ||
| 64 | + 'pid.required' => '上级选择错误', | ||
| 65 | + 'pid.gte' => '上级选择错误', | ||
| 66 | + 'pid.integer' => '上级选择错误', | ||
| 67 | + 'name.required' => '名称必须', | ||
| 68 | + 'name.max' => '名称不能超过100个字符', | ||
| 69 | + 'location.required' => '位置选择错误', | ||
| 70 | + 'location.in' => '位置选择错误', | ||
| 71 | + 'url.required' => '链接必须', | ||
| 72 | + 'url.max' => '链接不能超过200个字符', | ||
| 73 | + 'status.required' => '状态选择错误', | ||
| 74 | + 'status.in' => '状态必须是显示/隐藏', | ||
| 75 | + 'target.required' => '打开方式必须', | ||
| 76 | + 'target.in' => '打开方式选择错误', | ||
| 77 | + 'sort.required' => '排序必须', | ||
| 78 | + 'sort.integer' => '排序必须是一个数字', | ||
| 79 | + 'sort.gte' => '排序必须大于等于0', | ||
| 80 | + ]; | ||
| 81 | + } | ||
| 82 | +} |
app/Http/Requests/Scene.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * @author:dc | ||
| 7 | + * @time 2023/5/11 14:49 | ||
| 8 | + * Class Scene | ||
| 9 | + * @package App\Http\Requests | ||
| 10 | + */ | ||
| 11 | +trait Scene { | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * 更新场景 | ||
| 15 | + */ | ||
| 16 | + static $UPDATE = 1; | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 创建场景 | ||
| 20 | + */ | ||
| 21 | + static $CREATE = 0; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 删除场景 | ||
| 25 | + */ | ||
| 26 | + static $DELETE = -1; | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + private $scene; | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * @param $scene | ||
| 34 | + * @return $this | ||
| 35 | + * @author:dc | ||
| 36 | + * @time 2023/5/11 17:14 | ||
| 37 | + */ | ||
| 38 | + public function setScene($scene){ | ||
| 39 | + var_dump($scene); | ||
| 40 | + $this->scene = $scene; | ||
| 41 | + | ||
| 42 | + return $this; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * @return mixed | ||
| 48 | + */ | ||
| 49 | + public function getScene() | ||
| 50 | + { | ||
| 51 | + return $this->scene; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * @param $scene | ||
| 57 | + * @return bool | ||
| 58 | + * @author:dc | ||
| 59 | + * @time 2023/5/11 17:14 | ||
| 60 | + */ | ||
| 61 | + public function isScene($scene){ | ||
| 62 | + return $this->scene === $scene; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | +} |
| @@ -33,4 +33,20 @@ class AyrShare extends Base | @@ -33,4 +33,20 @@ class AyrShare extends Base | ||
| 33 | self::TYPE_PINTEREST => 'Pinterest', | 33 | self::TYPE_PINTEREST => 'Pinterest', |
| 34 | self::TYPE_TIKTOK => 'TikTok', | 34 | self::TYPE_TIKTOK => 'TikTok', |
| 35 | ]; | 35 | ]; |
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * @var :发布图片数量 | ||
| 39 | + */ | ||
| 40 | + public $image = [ | ||
| 41 | + self::TYPE_FACEBOOK => 10, | ||
| 42 | + self::TYPE_TWITTER => 4, | ||
| 43 | + self::TYPE_LINKEDIN => 9, | ||
| 44 | + self::TYPE_INSTAGRAM => 10, | ||
| 45 | + self::TYPE_YOUTUBE => 1, | ||
| 46 | + self::TYPE_REDDIT => 1, | ||
| 47 | + self::TYPE_TELEGRAM => 1, | ||
| 48 | + self::TYPE_GMB => 1, | ||
| 49 | + self::TYPE_PINTEREST => 1, | ||
| 50 | + self::TYPE_TIKTOK => 1, | ||
| 51 | + ]; | ||
| 36 | } | 52 | } |
| @@ -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 |
| @@ -9,7 +9,7 @@ class Blog extends Base | @@ -9,7 +9,7 @@ class Blog extends Base | ||
| 9 | { | 9 | { |
| 10 | protected $table = 'gl_blog'; | 10 | protected $table = 'gl_blog'; |
| 11 | //连接数据库 | 11 | //连接数据库 |
| 12 | - protected $connection = 'custom_mysql'; | 12 | +// protected $connection = 'custom_mysql'; |
| 13 | public function user(){ | 13 | public function user(){ |
| 14 | return $this->hasMany(User::class,'operator_id','id'); | 14 | return $this->hasMany(User::class,'operator_id','id'); |
| 15 | } | 15 | } |
| @@ -8,6 +8,6 @@ class BlogCategory extends Base | @@ -8,6 +8,6 @@ class BlogCategory extends Base | ||
| 8 | { | 8 | { |
| 9 | protected $table = 'gl_blog_category'; | 9 | protected $table = 'gl_blog_category'; |
| 10 | //连接数据库 | 10 | //连接数据库 |
| 11 | - protected $connection = 'custom_mysql'; | 11 | +// protected $connection = 'custom_mysql'; |
| 12 | 12 | ||
| 13 | } | 13 | } |
| @@ -10,5 +10,5 @@ class Mail extends Base | @@ -10,5 +10,5 @@ class Mail extends Base | ||
| 10 | //自动维护create_at创建时间 updated_at修改时间 | 10 | //自动维护create_at创建时间 updated_at修改时间 |
| 11 | public $timestamps = true; | 11 | public $timestamps = true; |
| 12 | //连接数据库 | 12 | //连接数据库 |
| 13 | - protected $connection = 'custom_mysql'; | 13 | +// protected $connection = 'custom_mysql'; |
| 14 | } | 14 | } |
| @@ -10,5 +10,5 @@ class MailUser extends Base | @@ -10,5 +10,5 @@ class MailUser extends Base | ||
| 10 | //自动维护create_at创建时间 updated_at修改时间 | 10 | //自动维护create_at创建时间 updated_at修改时间 |
| 11 | public $timestamps = true; | 11 | public $timestamps = true; |
| 12 | //连接数据库 | 12 | //连接数据库 |
| 13 | - protected $connection = 'custom_mysql'; | 13 | +// protected $connection = 'custom_mysql'; |
| 14 | } | 14 | } |
| @@ -8,5 +8,5 @@ class NewsCategory extends Base | @@ -8,5 +8,5 @@ class NewsCategory extends Base | ||
| 8 | { | 8 | { |
| 9 | protected $table = 'gl_news_category'; | 9 | protected $table = 'gl_news_category'; |
| 10 | //连接数据库 | 10 | //连接数据库 |
| 11 | - protected $connection = 'custom_mysql'; | 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; | 39 | + public static function _insert($project_id,$data) |
| 40 | + { | ||
| 41 | + $model = new static(); | ||
| 50 | 42 | ||
| 51 | - $data->save(); | 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']; | ||
| 52 | 48 | ||
| 53 | - return $data->id; | ||
| 54 | - } | 49 | + $model->save(); |
| 55 | 50 | ||
| 51 | + return $model->id; | ||
| 52 | + | ||
| 53 | + } | ||
| 56 | 54 | ||
| 57 | 55 | ||
| 58 | } | 56 | } |
app/Models/Template/BTemplateData.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Template; | ||
| 4 | + | ||
| 5 | +use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * @author:dc | ||
| 9 | + * @time 2023/5/10 14:31 | ||
| 10 | + * Class BTemplateData | ||
| 11 | + * @package App\Models\Template | ||
| 12 | + */ | ||
| 13 | +class BTemplateData extends \App\Models\Base{ | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + protected $table = 'gl_web_template_data'; | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + protected $hidden = ['project_id']; | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 插入/修改 | ||
| 25 | + * @param int $project_id | ||
| 26 | + * @param array $data | ||
| 27 | + * @return mixed | ||
| 28 | + * @author:dc | ||
| 29 | + * @time 2023/5/10 10:23 | ||
| 30 | + */ | ||
| 31 | + public static function _save(int $project_id, array $data) | ||
| 32 | + { | ||
| 33 | + | ||
| 34 | + $model = static::where([ | ||
| 35 | + 'project_id'=>$project_id, | ||
| 36 | + 'template_id'=>$data['template_id'], | ||
| 37 | + 'type' => $data['type'], | ||
| 38 | + 'tag' => $data['tag'], | ||
| 39 | + ])->first(); | ||
| 40 | + | ||
| 41 | + if(!$model){ | ||
| 42 | + $model = new static(); | ||
| 43 | + $model->project_id = $project_id; | ||
| 44 | + $model->template_id = $data['template_id']; | ||
| 45 | + $model->type = $data['type']; | ||
| 46 | + $model->tag = $data['tag']; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + $model->css = $data['css']??''; | ||
| 50 | + $model->script = $data['script']??''; | ||
| 51 | + $model->html = $data['html']??''; | ||
| 52 | + $model->data_ext = $data['data_ext']??''; | ||
| 53 | + $model->data_source = $data['data_source']??'all'; | ||
| 54 | + $model->data_source_id = $data['data_source_id']??0; | ||
| 55 | + | ||
| 56 | + $model->save(); | ||
| 57 | + | ||
| 58 | + return $model->id; | ||
| 59 | + | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + | ||
| 63 | +} |
app/Models/Template/BTemplateHtml.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Template; | ||
| 4 | + | ||
| 5 | +use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * | ||
| 9 | + * 模板 | ||
| 10 | + * @author:dc | ||
| 11 | + * @time 2023/5/9 13:56 | ||
| 12 | + * Class ATemplate | ||
| 13 | + * @package App\Models\Template | ||
| 14 | + */ | ||
| 15 | +class BTemplateHtml extends \App\Models\Base{ | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + protected $table = 'gl_web_template_html'; | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + protected $hidden = ['deleted_at','project_id']; | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + use SoftDeletes; | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 插入 | ||
| 31 | + * @param $project_id | ||
| 32 | + * @param $data | ||
| 33 | + * @return mixed | ||
| 34 | + * @author:dc | ||
| 35 | + * @time 2023/5/10 10:23 | ||
| 36 | + */ | ||
| 37 | + public static function _insert($project_id,$data) | ||
| 38 | + { | ||
| 39 | + | ||
| 40 | + $model = new static(); | ||
| 41 | + | ||
| 42 | + $model->project_id = $project_id; | ||
| 43 | + | ||
| 44 | + $model->template_id = $data['template_id']; | ||
| 45 | + | ||
| 46 | + $model->name = $data['name']; | ||
| 47 | + $model->type = $data['type']; | ||
| 48 | + $model->is_edit = $data['is_edit']; | ||
| 49 | + $model->css = $data['css']; | ||
| 50 | + $model->script = $data['script']; | ||
| 51 | + $model->html = $data['html']; | ||
| 52 | + $model->data_ext = $data['data_ext']; | ||
| 53 | + | ||
| 54 | + $model->save(); | ||
| 55 | + | ||
| 56 | + return $model->id; | ||
| 57 | + | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + | ||
| 61 | +} |
| @@ -7,4 +7,7 @@ use App\Models\Base; | @@ -7,4 +7,7 @@ use App\Models\Base; | ||
| 7 | class WebSettingCountry extends Base | 7 | class WebSettingCountry extends Base |
| 8 | { | 8 | { |
| 9 | protected $table = 'gl_web_setting_country'; | 9 | protected $table = 'gl_web_setting_country'; |
| 10 | + | ||
| 11 | + //连接数据库 | ||
| 12 | +// protected $connection = 'custom_mysql'; | ||
| 10 | } | 13 | } |
| @@ -7,4 +7,7 @@ use App\Models\Base; | @@ -7,4 +7,7 @@ use App\Models\Base; | ||
| 7 | class WebSettingForm extends Base | 7 | class WebSettingForm extends Base |
| 8 | { | 8 | { |
| 9 | protected $table = 'gl_web_setting_from'; | 9 | protected $table = 'gl_web_setting_from'; |
| 10 | + | ||
| 11 | + //连接数据库 | ||
| 12 | +// protected $connection = 'custom_mysql'; | ||
| 10 | } | 13 | } |
| @@ -7,4 +7,7 @@ use App\Models\Base; | @@ -7,4 +7,7 @@ use App\Models\Base; | ||
| 7 | class WebSettingHtml extends Base | 7 | class WebSettingHtml extends Base |
| 8 | { | 8 | { |
| 9 | protected $table = 'gl_web_setting_html'; | 9 | protected $table = 'gl_web_setting_html'; |
| 10 | + | ||
| 11 | + //连接数据库 | ||
| 12 | +// protected $connection = 'custom_mysql'; | ||
| 10 | } | 13 | } |
| @@ -7,4 +7,7 @@ use App\Models\Base; | @@ -7,4 +7,7 @@ use App\Models\Base; | ||
| 7 | class WebSettingReceiving extends Base | 7 | class WebSettingReceiving extends Base |
| 8 | { | 8 | { |
| 9 | protected $table = 'gl_web_setting_receiving'; | 9 | protected $table = 'gl_web_setting_receiving'; |
| 10 | + | ||
| 11 | + //连接数据库 | ||
| 12 | +// protected $connection = 'custom_mysql'; | ||
| 10 | } | 13 | } |
| @@ -7,4 +7,7 @@ use App\Models\Base; | @@ -7,4 +7,7 @@ use App\Models\Base; | ||
| 7 | class WebSettingService extends Base | 7 | class WebSettingService extends Base |
| 8 | { | 8 | { |
| 9 | protected $table = 'gl_web_setting_service'; | 9 | protected $table = 'gl_web_setting_service'; |
| 10 | + | ||
| 11 | + //连接数据库 | ||
| 12 | +// protected $connection = 'custom_mysql'; | ||
| 10 | } | 13 | } |
| @@ -8,6 +8,9 @@ class WebSettingText extends Base | @@ -8,6 +8,9 @@ class WebSettingText extends Base | ||
| 8 | { | 8 | { |
| 9 | protected $table = 'gl_web_setting_text'; | 9 | protected $table = 'gl_web_setting_text'; |
| 10 | 10 | ||
| 11 | + //连接数据库 | ||
| 12 | +// protected $connection = 'custom_mysql'; | ||
| 13 | + | ||
| 11 | //定义常量参数 | 14 | //定义常量参数 |
| 12 | const TYPE_PAGE = 1; | 15 | const TYPE_PAGE = 1; |
| 13 | const TYPE_PRODUCT = 2; | 16 | const TYPE_PRODUCT = 2; |
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 |
| @@ -190,11 +190,11 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -190,11 +190,11 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 190 | }); | 190 | }); |
| 191 | //图片操作 | 191 | //图片操作 |
| 192 | Route::prefix('images')->group(function () { | 192 | Route::prefix('images')->group(function () { |
| 193 | - Route::post('/upload', [\App\Http\Controllers\file\ImageController::class, 'upload'])->name('image_upload'); | 193 | + Route::post('/upload', [\App\Http\Controllers\File\ImageController::class, 'upload'])->name('image_upload'); |
| 194 | }); | 194 | }); |
| 195 | //文件上传第三方操作 | 195 | //文件上传第三方操作 |
| 196 | Route::prefix('files')->group(function () { | 196 | Route::prefix('files')->group(function () { |
| 197 | - Route::post('/upload', [\App\Http\Controllers\file\FileController::class, 'upload'])->name('files_upload'); | 197 | + Route::post('/upload', [\App\Http\Controllers\File\FileController::class, 'upload'])->name('files_upload'); |
| 198 | }); | 198 | }); |
| 199 | //精准询盘 | 199 | //精准询盘 |
| 200 | Route::prefix('inquiry')->group(function () { | 200 | Route::prefix('inquiry')->group(function () { |
| @@ -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'); |
| @@ -256,6 +267,6 @@ Route::group([], function () { | @@ -256,6 +267,6 @@ Route::group([], function () { | ||
| 256 | Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login'); | 267 | Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login'); |
| 257 | // Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country'); | 268 | // Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country'); |
| 258 | Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download'); | 269 | Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download'); |
| 259 | - Route::any('/image/{hash}/{type?}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show'); | ||
| 260 | - Route::any('/file_hash/{hash}/', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show'); | 270 | + Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\File\ImageController::class,'index'])->name('image_show'); |
| 271 | + Route::any('/file_hash/{hash}/', [\App\Http\Controllers\File\FileController::class,'index'])->name('file_show'); | ||
| 261 | }); | 272 | }); |
-
请 注册 或 登录 后发表评论