作者 张关杰

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

... ... @@ -124,27 +124,4 @@ class BaseController extends Controller
$response = response($result,$result_code,$this->header);
throw new HttpResponseException($response);
}
/**
* @remark :返回json
* @name :success
* @author :lyh
* @method :post
* @time :2023/8/28 10:18
*/
function success(array $data = [], string $code = Code::SUCCESS, bool $objectData = false): JsonResponse
{
if ($objectData) {
$data = (object)$data;
}
$code = Code::fromValue($code);
$response = [
'code' => $code->value,
'data' => $data,
'message' => $code->description,
];
$this->header['token'] = $this->token;
return response()->json($response,200,$this->header);
}
}
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Http\Controllers\Aside\Collect;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\CollectLogic;
... ... @@ -22,6 +23,6 @@ class CollectController extends BaseController
public function index(CollectLogic $collectLogic)
{
$data = $collectLogic->collect_data();
return $this->success($data);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -7,6 +7,8 @@ use App\Exceptions\BsideGlobalException;
use App\Helper\Common;
use App\Http\Controllers\Controller;
use App\Http\Requests\Scene;
use App\Models\Template\BTemplate;
use App\Models\Template\Setting;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Exceptions\HttpResponseException;
... ... @@ -170,4 +172,53 @@ class BaseController extends Controller
return \Illuminate\Support\Facades\Request::isMethod('post');
}
/**
* @remark :获取当前用户选择的模版
* @name :getTemplateId
* @author :lyh
* @method :post
* @time :2024/1/3 10:52
*/
public function getTemplateId($source,$is_list){
$template_id = 0;
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array($type, $page_array)) {//是定制界面
return $this->success($template_id);
}
}
$bSettingModel = new Setting();
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->fail('请先选择模版');
}
$template_id = $info['template_id'];
return $this->success($template_id);
}
/**
* @remark :查看是否已装修
* @name :getIsRenovation
* @author :lyh
* @method :post
* @time :2023/9/13 14:02
*/
public function getIsRenovation($source,$is_list,$template_id,$id){
$webTemplateModel = new BTemplate();
$param = [
'source'=>$source,
'project_id'=>$this->user['project_id'],
'source_id'=>$id,
'template_id'=>$template_id,
'is_list'=>$is_list
];
$templateInfo = $webTemplateModel->read($param);
if($templateInfo !== false){
return 1;
}
return 0;
}
}
... ...
... ... @@ -9,6 +9,7 @@ use App\Http\Requests\Bside\Blog\BlogCategoryRequest;
use App\Models\Blog\Blog as BlogModel;
use App\Models\Blog\BlogCategory as BlogCategoryModel;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
class BlogCategoryController extends BaseController
{
... ... @@ -25,9 +26,11 @@ class BlogCategoryController extends BaseController
$data = [];
if(!empty($lists)){
$blogModel = new BlogModel();
$template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_LIST);
foreach ($lists as $k => $v){
$v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
$v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG_CATE,$v['id']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_LIST,$template_id,$v['id']);
$lists[$k] = $v;
}
if(!isset($this->map['name'])){
... ...
... ... @@ -32,18 +32,15 @@ class BlogController extends BaseController
$lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page);
if(!empty($lists)){
$lists = $lists->toArray();
// //获取当前项目的所有分类
$data = $this->getCategoryList();
//获取当前用户选择的模版
$templateSettingModel = new Setting();
$info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
$template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL);
$user = new User();
foreach ($lists['list'] as $k => $v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG,$v['id']);
$v['image_link'] = getImageUrl($v['image']);
$v['operator_name'] = $user->getName($v['operator_id']);
$v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL,$template_id,$v['id']);
$lists['list'][$k] = $v;
}
}
... ... @@ -51,31 +48,6 @@ class BlogController extends BaseController
}
/**
* @remark :查看产品是否已装修
* @name :getProductIsRenovation
* @author :lyh
* @method :post
* @time :2023/9/13 14:02
*/
public function getProductIsRenovation($info,$id){
if($info !== false){
$webTemplateModel = new BTemplate();
$param = [
'source'=>BTemplate::SOURCE_BLOG,
'project_id'=>$this->user['project_id'],
'source_id'=>$id,
'template_id'=>$info['template_id'],
'is_list'=>0
];
$templateInfo = $webTemplateModel->read($param);
if($templateInfo !== false){
return 1;
}
}
return 0;
}
/**
* @remark :处理列表返回参数
* @name :handleReturnParam
* @author :lyh
... ...
... ... @@ -9,6 +9,7 @@ use App\Http\Requests\Bside\News\NewsCategoryRequest;
use App\Models\News\News as NewsModel;
use App\Models\News\NewsCategory as NewsCategoryModel;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
class NewsCategoryController extends BaseController
{
... ... @@ -25,9 +26,11 @@ class NewsCategoryController extends BaseController
$data = [];
if(!empty($lists)){
$newsModel = new NewsModel();
$template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_LIST);
foreach ($lists as $k => $v){
$v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
$v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS_CATE,$v['id']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_LIST,$template_id,$v['id']);
$lists[$k] = $v;
}
if(!isset($this->map['name'])){
... ...
... ... @@ -36,15 +36,14 @@ class NewsController extends BaseController
// //获取当前项目的所有分类
$data = $this->getCategoryList();
//获取当前用户选择的模版
$templateSettingModel = new Setting();
$info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
$template_id = $this->getTemplateId(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL);//获取模版id
$user = new User();
foreach ($lists['list'] as $k => $v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS,$v['id']);
$v['image_link'] = getImageUrl($v['image']);
$v['operator_name'] = $user->getName($v['operator_id']);
$v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL,$template_id,$v['id']);
$lists['list'][$k] = $v;
}
}
... ... @@ -52,31 +51,6 @@ class NewsController extends BaseController
}
/**
* @remark :查看产品是否已装修
* @name :getProductIsRenovation
* @author :lyh
* @method :post
* @time :2023/9/13 14:02
*/
public function getProductIsRenovation($info,$id){
if($info !== false){
$webTemplateModel = new BTemplate();
$param = [
'source'=>4,
'project_id'=>$this->user['project_id'],
'source_id'=>$id,
'template_id'=>$info['template_id'],
'is_list'=>0
];
$templateInfo = $webTemplateModel->read($param);
if($templateInfo !== false){
return 1;
}
}
return 0;
}
/**
* @remark :处理列表返回参数
* @name :handleReturnParam
* @author :lyh
... ...
... ... @@ -10,6 +10,7 @@ use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
use App\Rules\Ids;
use Illuminate\Http\Request;
... ... @@ -36,10 +37,12 @@ class CategoryController extends BaseController
$list = $category->list($this->map,['sort','id'],$filed);
$data = [];
if(!empty($list)){
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id
foreach ($list as $k =>$v){
$v['url'] = $this->user['domain'] . $v['route'].'/';
$v['product_num'] = Category::getProductNum($v['id']);
$v['image_link'] = getImageUrl($v['image']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
$list[$k] = $v;
}
if(!isset($this->map['title'])){
... ...
... ... @@ -7,6 +7,7 @@ use App\Exceptions\BsideGlobalException;
use App\Helper\Arr;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BTemplate\BTemplateLogic;
use App\Http\Logic\Bside\Product\ProductLogic;
use App\Http\Requests\Bside\Product\ProductRequest;
use App\Models\Product\Category;
... ... @@ -52,15 +53,13 @@ class ProductController extends BaseController
$lists = $lists->toArray();
$cate_data = $this->getCategoryList();//分类
$key_data = $this->getKeywordsList();//关键字
//获取当前用户选择的模版
$templateSettingModel = new Setting();
$info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id
$userModel = new User();
foreach ($lists['list'] as $k=>$v){
$v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data);
$v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
$v['created_uid_text'] = $userModel->getName($v['created_uid']);
$v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']);
$v['is_renovation'] = $this->getIsRenovation(Bemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id']);
$v['url'] = $this->user['domain'].$v['route'].'/';
$lists['list'][$k] = $v;
}
... ... @@ -119,31 +118,6 @@ class ProductController extends BaseController
}
/**
* @remark :查看产品是否已装修
* @name :getProductIsRenovation
* @author :lyh
* @method :post
* @time :2023/9/13 14:02
*/
public function getProductIsRenovation($info,$id){
if($info !== false){
$webTemplateModel = new BTemplate();
$param = [
'source'=>2,
'project_id'=>$this->user['project_id'],
'source_id'=>$id,
'template_id'=>$info['template_id'],
'is_list'=>0
];
$templateInfo = $webTemplateModel->read($param);
if($templateInfo !== false){
return 1;
}
}
return 0;
}
/**
* @remark :获取所有分类
* @name :getCategoryList
* @author :lyh
... ... @@ -266,9 +240,8 @@ class ProductController extends BaseController
}
$v['status_text'] = Product::statusMap()[$v['status']] ?? '';
//获取当前用户选择的模版
$templateSettingModel = new Setting();
$templateInfo = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
$v['is_renovation'] = $this->getProductIsRenovation($templateInfo,$v['id']);
$template_id = $this->getTemplateId(Bemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);
$v['is_renovation'] = $this->getIsRenovation(Bemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id']);
$v['url'] = $this->user['domain'].$v['route'];
//获取当前数据扩展字段及值
$v['extend'] = $this->getExtendInfo($v['id']);
... ...
... ... @@ -7,9 +7,7 @@ use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BTemplate\BTemplateLogic;
use App\Http\Requests\Bside\Template\TemplateRequest;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateMain;
use App\Models\Template\Setting;
use App\Models\Template\Template;
class BTemplateController extends BaseController
{
... ...
... ... @@ -150,6 +150,7 @@ class DomainInfoLogic extends BaseLogic
*/
public function setDomainSsl($initDomain,$domain,$rewrite,$other_domain)
{
$this->fail('当前功能,占时无法使用,如有紧急需要上线项目,请联系管理人员');
if($this->param['type'] == 2){
if(empty($this->param['key'])){
$this->fail('证书KEY值不能为空');
... ...
... ... @@ -88,7 +88,7 @@ class CountLogic extends BaseLogic
* @time :2023/5/24 14:03
*/
public function keyword_data_count(){
$yesterday = Carbon::yesterday()->toDateString();
$yesterday = date('Y-m-d');
$rankDataModel = new RankDataModel();
$param = [
'updated_date' => $yesterday,
... ...
... ... @@ -27,19 +27,5 @@ class EnableCrossRequestMiddleware
exit;
}
return $response;
// 指定允许其他域名访问
// $http_origin = "*";
// if(isset($_SERVER['HTTP_ORIGIN'])){
// $http_origin = $_SERVER['HTTP_ORIGIN'];
// }
// header("Access-Control-Allow-Origin:".$http_origin);
// header('Access-Control-Allow-Methods:POST,GET'); //支持的http 动作
// header('Access-Control-Allow-Credentials: true');
// header('Access-Control-Max-Age: 1000');
// header('Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept, Authorization, token'); //响应头 请按照自己需求添加。
// if (strtolower($_SERVER['REQUEST_METHOD']) == 'options') {
// exit;
// }
// return $next($request);
}
}
... ...
... ... @@ -45,6 +45,7 @@ class BTemplate extends Base
* 其他相关定义
*/
const IS_LIST = 1;//列表页
const IS_DETAIL = 0;//详情页
const IS_HEADER = 1;//独立头部底部
const IS_NO_HEADER = 0;//非独立头部底部
const IS_CUSTOM = 1;//为扩展模块
... ...