正在显示
17 个修改的文件
包含
335 行增加
和
631 行删除
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Aside\Template; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Http\Controllers\Aside\BaseController; | ||
| 7 | +use App\Http\Logic\Aside\Template\ATemplateLogic; | ||
| 8 | +use App\Http\Requests\Aside\Template\ATemplateRequest; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * @remark :A端主题模板管理 | ||
| 12 | + * @name :ATemplateController | ||
| 13 | + * @author :lyh | ||
| 14 | + * @time :2023/6/28 16:33 | ||
| 15 | + */ | ||
| 16 | +class ATemplateController extends BaseController | ||
| 17 | +{ | ||
| 18 | + /** | ||
| 19 | + * @remark :公共模板详情 | ||
| 20 | + * @name :lists | ||
| 21 | + * @author :lyh | ||
| 22 | + * @method :post | ||
| 23 | + * @time :2023/6/28 16:34 | ||
| 24 | + */ | ||
| 25 | + public function lists(ATemplateLogic $aTemplateLogic){ | ||
| 26 | + $lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order); | ||
| 27 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 28 | + } | ||
| 29 | + /** | ||
| 30 | + * @remark :保存主题模块 | ||
| 31 | + * @name :save | ||
| 32 | + * @author :lyh | ||
| 33 | + * @method :post | ||
| 34 | + * @time :2023/6/28 16:40 | ||
| 35 | + */ | ||
| 36 | + public function save(ATemplateRequest $aTemplateRequest,ATemplateLogic $aTemplateLogic){ | ||
| 37 | + if(isset($this->param['id'])){ | ||
| 38 | + $this->request->validate([ | ||
| 39 | + 'id'=>'required' | ||
| 40 | + ],[ | ||
| 41 | + 'id.required' => 'ID不能为空' | ||
| 42 | + ]); | ||
| 43 | + } | ||
| 44 | + $aTemplateRequest->validated(); | ||
| 45 | + $aTemplateLogic->aTemplateSave(); | ||
| 46 | + $this->response('success'); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * @remark :修改模块状态 | ||
| 51 | + * @name :status | ||
| 52 | + * @author :lyh | ||
| 53 | + * @method :post | ||
| 54 | + * @time :2023/6/28 16:41 | ||
| 55 | + */ | ||
| 56 | + public function status(ATemplateLogic $aTemplateLogic){ | ||
| 57 | + $this->request->validate([ | ||
| 58 | + 'id'=>'required' | ||
| 59 | + ],[ | ||
| 60 | + 'id.required' => 'ID不能为空' | ||
| 61 | + ]); | ||
| 62 | + $aTemplateLogic->aTemplateStatus(); | ||
| 63 | + $this->response('success'); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * @remark :执行逻辑删除 | ||
| 68 | + * @name :del | ||
| 69 | + * @author :lyh | ||
| 70 | + * @method :post | ||
| 71 | + * @time :2023/6/28 16:41 | ||
| 72 | + */ | ||
| 73 | + public function del(ATemplateLogic $aTemplateLogic){ | ||
| 74 | + $this->request->validate([ | ||
| 75 | + 'id'=>'required' | ||
| 76 | + ],[ | ||
| 77 | + 'id.required' => 'ID不能为空' | ||
| 78 | + ]); | ||
| 79 | + $aTemplateLogic->aTemplateDel(); | ||
| 80 | + $this->response('success'); | ||
| 81 | + } | ||
| 82 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Aside\Template; | ||
| 4 | + | ||
| 5 | +use App\Http\Controllers\Aside\BaseController; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * @remark :左侧模块管理 | ||
| 9 | + * @name :ATemplateModuleController | ||
| 10 | + * @author :lyh | ||
| 11 | + * @time :2023/6/28 16:54 | ||
| 12 | + */ | ||
| 13 | +class ATemplateModuleController extends BaseController | ||
| 14 | +{ | ||
| 15 | + /** | ||
| 16 | + * @remark :左侧模块列表 | ||
| 17 | + * @name :lists | ||
| 18 | + * @author :lyh | ||
| 19 | + * @method :post | ||
| 20 | + * @time :2023/6/28 16:54 | ||
| 21 | + */ | ||
| 22 | + public function lists(){ | ||
| 23 | + | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * @remark :左侧模块保存 | ||
| 28 | + * @name :save | ||
| 29 | + * @author :lyh | ||
| 30 | + * @method :post | ||
| 31 | + * @time :2023/6/28 16:55 | ||
| 32 | + */ | ||
| 33 | + public function save(){ | ||
| 34 | + | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * @remark :编辑状态 | ||
| 40 | + * @name :status | ||
| 41 | + * @author :lyh | ||
| 42 | + * @method :post | ||
| 43 | + * @time :2023/6/28 16:55 | ||
| 44 | + */ | ||
| 45 | + public function status(){ | ||
| 46 | + | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * @remark :逻辑删除模块 | ||
| 51 | + * @name :del | ||
| 52 | + * @author :lyh | ||
| 53 | + * @method :post | ||
| 54 | + * @time :2023/6/28 16:55 | ||
| 55 | + */ | ||
| 56 | + public function del(){ | ||
| 57 | + | ||
| 58 | + } | ||
| 59 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Aside\Template; | ||
| 4 | + | ||
| 5 | +use App\Http\Logic\Aside\BaseLogic; | ||
| 6 | +use App\Models\Template\ATemplate; | ||
| 7 | +use App\Models\Template\BSetting; | ||
| 8 | + | ||
| 9 | +class ATemplateLogic extends BaseLogic | ||
| 10 | +{ | ||
| 11 | + public function __construct() | ||
| 12 | + { | ||
| 13 | + parent::__construct(); | ||
| 14 | + $this->model = new ATemplate(); | ||
| 15 | + $this->param = $this->requestAll; | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * @remark :公共模块模板 | ||
| 20 | + * @name :aTemplateList | ||
| 21 | + * @author :lyh | ||
| 22 | + * @method :post | ||
| 23 | + * @time :2023/6/28 17:03 | ||
| 24 | + */ | ||
| 25 | + public function aTemplateList($map,$page,$row,$order = ['created_at'],$filed = ['*']){ | ||
| 26 | + $lists = $this->model->lists($map,$page,$row,$order,$filed); | ||
| 27 | + return $this->success($lists); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * @remark :添加或编辑模块 | ||
| 32 | + * @name :aTemplateSave | ||
| 33 | + * @author :lyh | ||
| 34 | + * @method :post | ||
| 35 | + * @time :2023/6/28 17:13 | ||
| 36 | + */ | ||
| 37 | + public function aTemplateSave(){ | ||
| 38 | + if(isset($this->param['id'])){ | ||
| 39 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 40 | + }else{ | ||
| 41 | + $rs = $this->model->add($this->param); | ||
| 42 | + } | ||
| 43 | + if($rs === false){ | ||
| 44 | + $this->fail('error'); | ||
| 45 | + } | ||
| 46 | + return $this->success(); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * @remark :修改模块状态 | ||
| 51 | + * @name :aTemplateStatus | ||
| 52 | + * @author :lyh | ||
| 53 | + * @method :post | ||
| 54 | + * @time :2023/6/28 17:15 | ||
| 55 | + */ | ||
| 56 | + public function aTemplateStatus(){ | ||
| 57 | + $rs = $this->model->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]); | ||
| 58 | + if($rs === false){ | ||
| 59 | + $this->fail('error'); | ||
| 60 | + } | ||
| 61 | + return $this->success(); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * @remark :逻辑删除模板数据 | ||
| 67 | + * @name :aTemplateDel | ||
| 68 | + * @author :lyh | ||
| 69 | + * @method :post | ||
| 70 | + * @time :2023/6/28 17:17 | ||
| 71 | + */ | ||
| 72 | + public function aTemplateDel(){ | ||
| 73 | + //查看当前模板是否有模板在使用 | ||
| 74 | + $BSettingModel = new BSetting(); | ||
| 75 | + $info = $BSettingModel->read(['template_id'=>$this->param['id']]); | ||
| 76 | + if($info !== false){ | ||
| 77 | + $this->fail('当前模板有项目在使用,不允许删除'); | ||
| 78 | + } | ||
| 79 | + $rs = $this->model->edit(['deleted_status'=>$this->param['deleted_status'],'deleted_at'=>date('Y-m-d H:i:s')],['id'=>$this->param['id']]); | ||
| 80 | + if($rs === false){ | ||
| 81 | + $this->fail('error'); | ||
| 82 | + } | ||
| 83 | + return $this->success(); | ||
| 84 | + } | ||
| 85 | +} |
| @@ -2,27 +2,21 @@ | @@ -2,27 +2,21 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Logic\Aside\Template; | 3 | namespace App\Http\Logic\Aside\Template; |
| 4 | 4 | ||
| 5 | - | ||
| 6 | use App\Http\Logic\Aside\BaseLogic; | 5 | use App\Http\Logic\Aside\BaseLogic; |
| 7 | -use App\Models\Template\ATemplate; | 6 | +use App\Models\Template\ATemplateModule; |
| 8 | 7 | ||
| 9 | /** | 8 | /** |
| 10 | - * @author:dc | ||
| 11 | - * @time 2023/5/11 14:35 | ||
| 12 | - * Class TemplateLogic | ||
| 13 | - * @package App\Http\Logic\Aside\Template | 9 | + * @remark :左侧模块管理 |
| 10 | + * @name :ATemplateModuleLogic | ||
| 11 | + * @author :lyh | ||
| 12 | + * @time :2023/6/28 16:58 | ||
| 14 | */ | 13 | */ |
| 15 | -class TemplateLogic extends BaseLogic { | ||
| 16 | - | 14 | +class ATemplateModuleLogic extends BaseLogic |
| 15 | +{ | ||
| 17 | public function __construct() | 16 | public function __construct() |
| 18 | { | 17 | { |
| 19 | parent::__construct(); | 18 | parent::__construct(); |
| 20 | - | ||
| 21 | - $this->model = new ATemplate(); | 19 | + $this->model = new ATemplateModule(); |
| 20 | + $this->param = $this->requestAll; | ||
| 22 | } | 21 | } |
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - | ||
| 28 | } | 22 | } |
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Logic\Aside\Template; | ||
| 4 | - | ||
| 5 | - | ||
| 6 | -use App\Http\Logic\Aside\BaseLogic; | ||
| 7 | -use App\Models\Template\ATemplateChunk; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * 自定义块 模板 | ||
| 11 | - * @author:dc | ||
| 12 | - * @time 2023/5/29 10:46 | ||
| 13 | - * Class TemplateChunkLogic | ||
| 14 | - * @package App\Http\Logic\Aside\Template | ||
| 15 | - */ | ||
| 16 | -class TemplateChunkLogic extends BaseLogic { | ||
| 17 | - | ||
| 18 | - public function __construct() | ||
| 19 | - { | ||
| 20 | - parent::__construct(); | ||
| 21 | - | ||
| 22 | - $this->model = new ATemplateChunk(); | ||
| 23 | - } | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - | ||
| 28 | - public function save($param) | ||
| 29 | - { | ||
| 30 | - | ||
| 31 | - $param['images'] = is_array($param['images']??'') ? json_encode($param['images']): '[]'; | ||
| 32 | - $param['video'] = is_array($param['video']??'') ? json_encode($param['video']): '[]'; | ||
| 33 | - | ||
| 34 | - | ||
| 35 | - return parent::save($param); // TODO: Change the autogenerated stub | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | - | ||
| 39 | -} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Bside\BTemplate; | ||
| 4 | + | ||
| 5 | +use App\Http\Logic\Bside\BaseLogic; | ||
| 6 | +use App\Models\Template\BTemplate; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * @remark :b端模块 | ||
| 10 | + * @name :BTemplateLogic | ||
| 11 | + * @author :lyh | ||
| 12 | + * @time :2023/6/28 17:00 | ||
| 13 | + */ | ||
| 14 | +class BTemplateLogic extends BaseLogic | ||
| 15 | +{ | ||
| 16 | + public function __construct() | ||
| 17 | + { | ||
| 18 | + parent::__construct(); | ||
| 19 | + $this->model = new BTemplate(); | ||
| 20 | + $this->param = $this->requestAll; | ||
| 21 | + } | ||
| 22 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Aside\Template; | ||
| 4 | + | ||
| 5 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 6 | + | ||
| 7 | +class ATemplateRequest extends FormRequest | ||
| 8 | +{ | ||
| 9 | + /** | ||
| 10 | + * Determine if the user is authorized to make this request. | ||
| 11 | + * | ||
| 12 | + * @return bool | ||
| 13 | + */ | ||
| 14 | + public function authorize() | ||
| 15 | + { | ||
| 16 | + return true; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * Get the validation rules that apply to the request. | ||
| 21 | + * | ||
| 22 | + * @return array | ||
| 23 | + */ | ||
| 24 | + public function rules() | ||
| 25 | + { | ||
| 26 | + return [ | ||
| 27 | + 'name'=>'required', | ||
| 28 | + 'image'=>'required', | ||
| 29 | + 'html'=>'required', | ||
| 30 | + ]; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public function messages() | ||
| 34 | + { | ||
| 35 | + return [ | ||
| 36 | + 'name.required'=>'名称不能为空', | ||
| 37 | + 'image.required' => '图片不能为空', | ||
| 38 | + 'html.required'=>'代码不能为空', | ||
| 39 | + ]; | ||
| 40 | + } | ||
| 41 | +} |
| @@ -10,7 +10,7 @@ use Illuminate\Validation\Rule; | @@ -10,7 +10,7 @@ use Illuminate\Validation\Rule; | ||
| 10 | * @author:dc | 10 | * @author:dc |
| 11 | * @time 2023/5/29 10:57 | 11 | * @time 2023/5/29 10:57 |
| 12 | * Class TemplateChunkRequest | 12 | * Class TemplateChunkRequest |
| 13 | - * @package App\Http\Requests\Aside\Template | 13 | + * @package App\Http\Requests\Aside\BTemplate |
| 14 | */ | 14 | */ |
| 15 | class TemplateChunkRequest extends FormRequest | 15 | class TemplateChunkRequest extends FormRequest |
| 16 | { | 16 | { |
| @@ -9,7 +9,7 @@ use Illuminate\Validation\Rule; | @@ -9,7 +9,7 @@ use Illuminate\Validation\Rule; | ||
| 9 | * @author:dc | 9 | * @author:dc |
| 10 | * @time 2023/5/11 14:38 | 10 | * @time 2023/5/11 14:38 |
| 11 | * Class TemplateRequest | 11 | * Class TemplateRequest |
| 12 | - * @package App\Http\Requests\Aside\Template | 12 | + * @package App\Http\Requests\Aside\BTemplate |
| 13 | */ | 13 | */ |
| 14 | class TemplateRequest extends FormRequest | 14 | class TemplateRequest extends FormRequest |
| 15 | { | 15 | { |
| @@ -3,122 +3,14 @@ | @@ -3,122 +3,14 @@ | ||
| 3 | namespace App\Models\Template; | 3 | namespace App\Models\Template; |
| 4 | 4 | ||
| 5 | use App\Models\Base; | 5 | use App\Models\Base; |
| 6 | -use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 7 | 6 | ||
| 8 | /** | 7 | /** |
| 9 | - * 由 A端增删改 | ||
| 10 | - * 模板 | ||
| 11 | - * @author:dc | ||
| 12 | - * @time 2023/5/9 13:56 | ||
| 13 | - * Class ATemplate | ||
| 14 | - * @package App\Models\Template | 8 | + * @remark :公共模块 |
| 9 | + * @name :ATemplate | ||
| 10 | + * @author :lyh | ||
| 11 | + * @time :2023/6/28 16:51 | ||
| 15 | */ | 12 | */ |
| 16 | -class ATemplate extends Base{ | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - protected $table = 'gl_aside_template'; | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - protected $hidden = ['deleted_at']; | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - use SoftDeletes; | ||
| 26 | - | ||
| 27 | - /** | ||
| 28 | - * 显示 | ||
| 29 | - */ | ||
| 30 | - const STATUS_ACTIVE = 1; | ||
| 31 | - | ||
| 32 | - /** | ||
| 33 | - * 隐藏 | ||
| 34 | - */ | ||
| 35 | - const STATUS_DISABLED = 0; | ||
| 36 | - | ||
| 37 | - | ||
| 38 | - /** | ||
| 39 | - * b 端调用 | ||
| 40 | - * @param int $limit | ||
| 41 | - * @return mixed | ||
| 42 | - * @author:dc | ||
| 43 | - * @time 2023/5/9 14:14 | ||
| 44 | - */ | ||
| 45 | - public static function _bAll(int $limit = 20) | ||
| 46 | - { | ||
| 47 | - return static::where(function ($query){ | ||
| 48 | - | ||
| 49 | - $query->where('status',static::STATUS_ACTIVE); | ||
| 50 | - | ||
| 51 | - }) | ||
| 52 | - ->select(['id','name','url','thumb','created_at','updated_at']) | ||
| 53 | - ->orderBy('sort') | ||
| 54 | - ->paginate($limit); | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - /** | ||
| 58 | - * @param $id | ||
| 59 | - * @return array | ||
| 60 | - * @author:dc | ||
| 61 | - * @time 2023/5/9 15:16 | ||
| 62 | - */ | ||
| 63 | - public static function _bFind($id) | ||
| 64 | - { | ||
| 65 | - $data = static::where('id',$id)->first(); | ||
| 66 | - if(!$data || $data->status === static::STATUS_DISABLED){ | ||
| 67 | - return []; | ||
| 68 | - } | ||
| 69 | - return $data; | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - | ||
| 73 | - /** | ||
| 74 | - * 获取默认模板 | ||
| 75 | - * @return mixed | ||
| 76 | - * @author:dc | ||
| 77 | - * @time 2023/5/9 15:09 | ||
| 78 | - */ | ||
| 79 | - public static function _default() | ||
| 80 | - { | ||
| 81 | - return static::where(['status'=>static::STATUS_ACTIVE,'is_default'=>1])->first(); | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - | ||
| 85 | - /** | ||
| 86 | - * 查询 | ||
| 87 | - * @param $id | ||
| 88 | - * @return mixed | ||
| 89 | - * @author:dc | ||
| 90 | - * @time 2023/5/10 10:15 | ||
| 91 | - */ | ||
| 92 | - public static function _find($id) | ||
| 93 | - { | ||
| 94 | - return static::where('id',$id)->first(); | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - | ||
| 98 | -// /** | ||
| 99 | -// * @param array $data | ||
| 100 | -// * @param int $id | ||
| 101 | -// * @author:dc | ||
| 102 | -// * @time 2023/5/11 10:08 | ||
| 103 | -// */ | ||
| 104 | -// public static function _save(array $data,int $id=0){ | ||
| 105 | -// if($id){ | ||
| 106 | -// $model = static::where('id',$id)->first(); | ||
| 107 | -// } | ||
| 108 | -// if(empty($model)) $model = new static(); | ||
| 109 | -// | ||
| 110 | -// $model->name = $data['name']; | ||
| 111 | -// $model->status = $data['status']; | ||
| 112 | -// $model->is_default = $data['is_default']; | ||
| 113 | -// $model->sort = $data['sort']; | ||
| 114 | -// $model->thumb = $data['thumb']; | ||
| 115 | -// $model->url = $data['url']; | ||
| 116 | -// | ||
| 117 | -// $model->save(); | ||
| 118 | -// | ||
| 119 | -// return $model->id; | ||
| 120 | -// } | ||
| 121 | - | ||
| 122 | - | ||
| 123 | - | 13 | +class ATemplate extends Base |
| 14 | +{ | ||
| 15 | + protected $table = 'gl_public_template'; | ||
| 124 | } | 16 | } |
app/Models/Template/ATemplateChunk.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Models\Template; | ||
| 4 | - | ||
| 5 | -use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 6 | - | ||
| 7 | -/** | ||
| 8 | - * 自定义块 模板块 | ||
| 9 | - * @author:dc | ||
| 10 | - * @time 2023/5/29 10:39 | ||
| 11 | - * Class ATemplateChunk | ||
| 12 | - * @package App\Models\Template | ||
| 13 | - */ | ||
| 14 | -class ATemplateChunk extends \App\Models\Base{ | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - protected $table = 'gl_aside_template_chunk'; | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - protected $hidden = ['deleted_at']; | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - use SoftDeletes; | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - public static $typeMap = [ | ||
| 27 | - 'index' => '首页', | ||
| 28 | - 'product' => '商品列表', | ||
| 29 | - 'product_info' => '商品详情', | ||
| 30 | - 'blogs' => '博客列表', | ||
| 31 | - 'blogs_info' => '博客详情', | ||
| 32 | - 'page' => '单页', | ||
| 33 | - 'news' => '新闻列表', | ||
| 34 | - 'news_info' => '新闻详情', | ||
| 35 | - ]; | ||
| 36 | - | ||
| 37 | - | ||
| 38 | - | ||
| 39 | - public function getImagesAttribute($val) | ||
| 40 | - { | ||
| 41 | - return $val ? json_decode($val,true) : []; | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - public function getVideoAttribute($val) | ||
| 45 | - { | ||
| 46 | - return $val ? json_decode($val,true) : []; | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - | ||
| 50 | -} |
app/Models/Template/ATemplateHtml.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Models\Template; | ||
| 4 | - | ||
| 5 | -use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 6 | - | ||
| 7 | -/** | ||
| 8 | - * 由 A端增删改 | ||
| 9 | - * 模板 | ||
| 10 | - * @author:dc | ||
| 11 | - * @time 2023/5/9 13:56 | ||
| 12 | - * Class ATemplate | ||
| 13 | - * @package App\Models\Template | ||
| 14 | - */ | ||
| 15 | -class ATemplateHtml extends \App\Models\Base{ | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - protected $table = 'gl_aside_template_html'; | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - protected $hidden = ['deleted_at']; | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - use SoftDeletes; | ||
| 25 | - | ||
| 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 | - $data = static::where('id',$id)->first(); | ||
| 107 | - return $data ? $data->toArray() : []; | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - /** | ||
| 111 | - * @param array $data | ||
| 112 | - * @param int $id | ||
| 113 | - * @return mixed | ||
| 114 | - * @author:dc | ||
| 115 | - * @time 2023/5/11 10:20 | ||
| 116 | - */ | ||
| 117 | - public static function _save(int $template_id, array $data,int $id = 0){ | ||
| 118 | - if($id){ | ||
| 119 | - $model = static::where('id',$id)->first(); | ||
| 120 | - } | ||
| 121 | - if(empty($model)) $model = new static(); | ||
| 122 | - | ||
| 123 | - $model->template_id = $template_id; | ||
| 124 | - | ||
| 125 | - $model->name = $data['name']; | ||
| 126 | - $model->type = $data['type']; | ||
| 127 | - $model->css = $data['css']; | ||
| 128 | - $model->script = $data['script']; | ||
| 129 | - $model->html = $data['html']; | ||
| 130 | - | ||
| 131 | - | ||
| 132 | - $model->save(); | ||
| 133 | - | ||
| 134 | - return $model->id; | ||
| 135 | - } | ||
| 136 | - | ||
| 137 | - | ||
| 138 | - | ||
| 139 | - | ||
| 140 | - | ||
| 141 | -} |
app/Models/Template/ATemplateModule.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Template; | ||
| 4 | + | ||
| 5 | +use App\Models\Base; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * @remark :左侧模块管理 | ||
| 9 | + * @name :ATemplateModuleController | ||
| 10 | + * @author :lyh | ||
| 11 | + * @time :2023/6/28 16:51 | ||
| 12 | + */ | ||
| 13 | +class ATemplateModule extends Base | ||
| 14 | +{ | ||
| 15 | + protected $table = 'gl_public_template_module'; | ||
| 16 | +} |
| @@ -3,105 +3,14 @@ | @@ -3,105 +3,14 @@ | ||
| 3 | namespace App\Models\Template; | 3 | namespace App\Models\Template; |
| 4 | 4 | ||
| 5 | use App\Models\Base; | 5 | use App\Models\Base; |
| 6 | -use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 7 | -use Illuminate\Support\Facades\DB; | ||
| 8 | 6 | ||
| 9 | /** | 7 | /** |
| 10 | - * 当前用户的模板 | ||
| 11 | - * @author:dc | ||
| 12 | - * @time 2023/5/9 15:03 | ||
| 13 | - * Class BSetting | ||
| 14 | - * @package App\Models\Template | 8 | + * @remark :默认主题 |
| 9 | + * @name :BSetting | ||
| 10 | + * @author :lyh | ||
| 11 | + * @time :2023/6/28 16:51 | ||
| 15 | */ | 12 | */ |
| 16 | -class BSetting extends Base { | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | 13 | +class BSetting extends Base |
| 14 | +{ | ||
| 20 | protected $table = 'gl_web_setting_template'; | 15 | protected $table = 'gl_web_setting_template'; |
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - /** | ||
| 25 | - * b 端调用 | ||
| 26 | - * @param int $limit | ||
| 27 | - * @return mixed | ||
| 28 | - * @author:dc | ||
| 29 | - * @time 2023/5/9 14:14 | ||
| 30 | - */ | ||
| 31 | - public static function _get(int $project_id) | ||
| 32 | - { | ||
| 33 | - $data = static::where('project_id',$project_id)->first(); | ||
| 34 | - | ||
| 35 | - if($data){ | ||
| 36 | - return [ | ||
| 37 | - 'template_id' => $data['template_id'], | ||
| 38 | - 'time' => $data['updated_at'] | ||
| 39 | - ]; | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - // 米有数据 | ||
| 43 | - // 读取默认的模板 | ||
| 44 | - $temp = ATemplate::_default(); | ||
| 45 | - // 保存 | ||
| 46 | - self::_save($project_id,$temp['id']); | ||
| 47 | - | ||
| 48 | - return [ | ||
| 49 | - 'template_id' => $temp['id'], | ||
| 50 | - 'time' => date('Y-m-d H:i:s') | ||
| 51 | - ]; | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - | ||
| 55 | - /** | ||
| 56 | - * 模板保存 | ||
| 57 | - * @param int $project_id | ||
| 58 | - * @param int $template_id | ||
| 59 | - * @return mixed | ||
| 60 | - * @author:dc | ||
| 61 | - * @time 2023/5/9 15:13 | ||
| 62 | - */ | ||
| 63 | - public static function _save(int $project_id, int $template_id) | ||
| 64 | - { | ||
| 65 | - | ||
| 66 | - $data = static::where('project_id',$project_id)->first(); | ||
| 67 | - if(!$data){ | ||
| 68 | - $data = new static(); | ||
| 69 | - $data->project_id = $project_id; | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - $data->template_id = $template_id; | ||
| 73 | - | ||
| 74 | - $data->save(); | ||
| 75 | - | ||
| 76 | - // 是否有模板 | ||
| 77 | -// if(!BTemplate::_isExist($project_id,$template_id)){ | ||
| 78 | -// // 没有模板 | ||
| 79 | -// $aData = ATemplate::_find($template_id); | ||
| 80 | -// // 保存到自己的数据中 | ||
| 81 | -// BTemplate::_insert($project_id,$aData); | ||
| 82 | -// | ||
| 83 | -// $aDataHtml = ATemplateHtml::_all($template_id); | ||
| 84 | -// DB::beginTransaction(); | ||
| 85 | -// foreach ($aDataHtml as $item){ | ||
| 86 | -// try { | ||
| 87 | -// // 插入子数据 | ||
| 88 | -// BTemplateHtml::_insert($project_id,$item); | ||
| 89 | -// }catch (\Throwable $e){ | ||
| 90 | -// DB::rollBack(); | ||
| 91 | -// | ||
| 92 | -// return $data->id; | ||
| 93 | -// break; | ||
| 94 | -// } | ||
| 95 | -// | ||
| 96 | -// } | ||
| 97 | -// DB::commit(); | ||
| 98 | -// } | ||
| 99 | - | ||
| 100 | - return $data->id; | ||
| 101 | - | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | - | ||
| 105 | - | ||
| 106 | - | ||
| 107 | } | 16 | } |
| @@ -5,54 +5,12 @@ namespace App\Models\Template; | @@ -5,54 +5,12 @@ namespace App\Models\Template; | ||
| 5 | use App\Models\Base; | 5 | use App\Models\Base; |
| 6 | 6 | ||
| 7 | /** | 7 | /** |
| 8 | - * 自定义 界面 | ||
| 9 | - * @author:dc | ||
| 10 | - * @time 2023/5/8 13:52 | ||
| 11 | - * Class BTemplate | ||
| 12 | - * @package App\Models\Template | 8 | + * @remark :用户模块 |
| 9 | + * @name :BTemplate | ||
| 10 | + * @author :lyh | ||
| 11 | + * @time :2023/6/28 16:52 | ||
| 13 | */ | 12 | */ |
| 14 | -class BTemplate extends Base { | ||
| 15 | - | 13 | +class BTemplate extends Base |
| 14 | +{ | ||
| 16 | protected $table = 'gl_web_template'; | 15 | protected $table = 'gl_web_template'; |
| 17 | - | ||
| 18 | - protected $hidden = ['project_id']; | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - /** | ||
| 22 | - * 是否存在模板 | ||
| 23 | - * @param int $template_id | ||
| 24 | - * @author:dc | ||
| 25 | - * @time 2023/5/10 10:00 | ||
| 26 | - */ | ||
| 27 | - public static function _isExist(int $project_id, int $template_id) | ||
| 28 | - { | ||
| 29 | - return static::where(['project_id'=>$project_id,'template_id'=>$template_id])->limit(1)->count(); | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - | ||
| 33 | - /** | ||
| 34 | - * 插入 | ||
| 35 | - * @param $project_id | ||
| 36 | - * @param $data | ||
| 37 | - * @return mixed | ||
| 38 | - * @author:dc | ||
| 39 | - * @time 2023/5/10 10:23 | ||
| 40 | - */ | ||
| 41 | - public static function _insert($project_id,$data) | ||
| 42 | - { | ||
| 43 | - $model = new static(); | ||
| 44 | - | ||
| 45 | - $model->project_id = $project_id; | ||
| 46 | - $model->template_id = $data['id']; | ||
| 47 | - $model->name = $data['name']; | ||
| 48 | - $model->thumb = $data['thumb']; | ||
| 49 | - $model->html = $data['html']; | ||
| 50 | - | ||
| 51 | - $model->save(); | ||
| 52 | - | ||
| 53 | - return $model->id; | ||
| 54 | - | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - | ||
| 58 | } | 16 | } |
app/Models/Template/BTemplateData.php
已删除
100644 → 0
| 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
已删除
100644 → 0
| 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 | -} |
-
请 注册 或 登录 后发表评论