增加企业产品分类
This commit is contained in:
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\controller\Cms\Products;
|
||||
|
||||
use app\admin\BaseController;
|
||||
use app\model\Cms\ProductsTypes;
|
||||
use think\exception\ValidateException;
|
||||
use think\response\Json;
|
||||
|
||||
/**
|
||||
* 产品分类管理控制器
|
||||
*/
|
||||
class ProductsTypesController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 获取产品分类列表
|
||||
* @return Json
|
||||
*/
|
||||
public function productsTypesList(): Json
|
||||
{
|
||||
try {
|
||||
$page = (int)$this->request->param('page', 1);
|
||||
$limit = (int)$this->request->param('limit', 10);
|
||||
$keyword = (string)$this->request->param('keyword', '');
|
||||
|
||||
$query = ProductsTypes::where('delete_time', null)
|
||||
->where('tid', $this->getTenantId());
|
||||
|
||||
if ($keyword !== '') {
|
||||
$query->where('title', 'like', '%' . $keyword . '%');
|
||||
}
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
$list = $query->order('sort', 'asc')
|
||||
->order('id', 'desc')
|
||||
->page($page, $limit)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => 'success',
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'total' => $total
|
||||
]
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return json([
|
||||
'code' => 500,
|
||||
'msg' => '获取失败:' . $e->getMessage(),
|
||||
'data' => [
|
||||
'list' => [],
|
||||
'total' => 0
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加产品分类
|
||||
* @return Json
|
||||
*/
|
||||
public function addProductsTypes(): Json
|
||||
{
|
||||
try {
|
||||
$data = $this->request->param();
|
||||
|
||||
$title = (string)($data['title'] ?? '');
|
||||
if ($title === '') {
|
||||
return json([
|
||||
'code' => 400,
|
||||
'msg' => '分类名称不能为空'
|
||||
]);
|
||||
}
|
||||
|
||||
$type = new ProductsTypes();
|
||||
$type->tid = $this->getTenantId();
|
||||
$type->pid = isset($data['pid']) ? (int)$data['pid'] : 0;
|
||||
$type->title = $title;
|
||||
$type->desc = (string)($data['desc'] ?? '');
|
||||
$type->sort = isset($data['sort']) ? (int)$data['sort'] : 0;
|
||||
$type->create_time = date('Y-m-d H:i:s');
|
||||
$type->update_time = date('Y-m-d H:i:s');
|
||||
$type->save();
|
||||
|
||||
$this->logSuccess('产品分类管理', '添加分类', ['id' => $type->id]);
|
||||
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '添加成功',
|
||||
'data' => $type->toArray()
|
||||
]);
|
||||
} catch (ValidateException $e) {
|
||||
return json([
|
||||
'code' => 400,
|
||||
'msg' => $e->getError()
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
$this->logFail('产品分类管理', '添加分类', $e->getMessage());
|
||||
return json([
|
||||
'code' => 500,
|
||||
'msg' => '添加失败:' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新产品分类
|
||||
* @param int $id
|
||||
* @return Json
|
||||
*/
|
||||
public function editProductsTypes(int $id): Json
|
||||
{
|
||||
try {
|
||||
$data = $this->request->param();
|
||||
|
||||
$type = ProductsTypes::where('id', $id)
|
||||
->where('tid', $this->getTenantId())
|
||||
->where('delete_time', null)
|
||||
->find();
|
||||
|
||||
if (!$type) {
|
||||
return json([
|
||||
'code' => 404,
|
||||
'msg' => '分类不存在'
|
||||
]);
|
||||
}
|
||||
|
||||
if (isset($data['title'])) $type->title = (string)$data['title'];
|
||||
if (isset($data['pid'])) $type->pid = (int)$data['pid'];
|
||||
if (isset($data['desc'])) $type->desc = (string)$data['desc'];
|
||||
if (isset($data['sort'])) $type->sort = (int)$data['sort'];
|
||||
|
||||
if ((string)$type->title === '') {
|
||||
return json([
|
||||
'code' => 400,
|
||||
'msg' => '分类名称不能为空'
|
||||
]);
|
||||
}
|
||||
|
||||
$type->update_time = date('Y-m-d H:i:s');
|
||||
$type->save();
|
||||
|
||||
$this->logSuccess('产品分类管理', '更新分类', ['id' => $id]);
|
||||
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '更新成功',
|
||||
'data' => $type->toArray()
|
||||
]);
|
||||
} catch (ValidateException $e) {
|
||||
return json([
|
||||
'code' => 400,
|
||||
'msg' => $e->getError()
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
$this->logFail('产品分类管理', '更新分类', $e->getMessage());
|
||||
return json([
|
||||
'code' => 500,
|
||||
'msg' => '更新失败:' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除产品分类(软删除)
|
||||
* @param int $id
|
||||
* @return Json
|
||||
*/
|
||||
public function deleteProductsTypes(int $id): Json
|
||||
{
|
||||
try {
|
||||
$type = ProductsTypes::where('id', $id)
|
||||
->where('tid', $this->getTenantId())
|
||||
->where('delete_time', null)
|
||||
->find();
|
||||
|
||||
if (!$type) {
|
||||
return json([
|
||||
'code' => 404,
|
||||
'msg' => '分类不存在'
|
||||
]);
|
||||
}
|
||||
|
||||
$type->delete();
|
||||
|
||||
$this->logSuccess('产品分类管理', '删除分类', ['id' => $id]);
|
||||
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '删除成功'
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
$this->logFail('产品分类管理', '删除分类', $e->getMessage());
|
||||
return json([
|
||||
'code' => 500,
|
||||
'msg' => '删除失败:' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ class MenuController extends BaseController
|
||||
$menus = SystemMenu::where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->whereIn('id', $allMenuIds)
|
||||
->field('id,pid,title,path,component_path,icon,sort')
|
||||
->field('id,pid,title,path,component_path,icon,sort,is_visible')
|
||||
->order('sort', 'asc')
|
||||
->select();
|
||||
|
||||
@@ -261,6 +261,7 @@ class MenuController extends BaseController
|
||||
'title|菜单名称' => 'require|max:50',
|
||||
'type|菜单类型' => 'require|in:1,2,3',
|
||||
'status|菜单状态' => 'require|in:0,1',
|
||||
'is_visible|是否显示' => 'require|in:0,1',
|
||||
'sort|排序号' => 'integer',
|
||||
'path|路由路径' => 'max:200',
|
||||
'icon|菜单图标' => 'max:100',
|
||||
@@ -274,6 +275,7 @@ class MenuController extends BaseController
|
||||
'title' => $data['title'],
|
||||
'type' => $data['type'],
|
||||
'status' => $data['status'] ?? 1,
|
||||
'is_visible' => $data['is_visible'] ?? 1,
|
||||
'sort' => $data['sort'] ?? 0,
|
||||
'path' => $data['path'] ?? '',
|
||||
'component_path' => $data['component_path'] ?? '',
|
||||
@@ -329,6 +331,7 @@ class MenuController extends BaseController
|
||||
'pid|上级菜单ID' => 'integer',
|
||||
'type|菜单类型' => 'require|in:1,2,3',
|
||||
'status|菜单状态' => 'require|in:0,1',
|
||||
'is_visible|是否显示' => 'require|in:0,1',
|
||||
'sort|排序号' => 'integer',
|
||||
'path|路由路径' => 'max:200',
|
||||
'icon|菜单图标' => 'max:100',
|
||||
@@ -346,6 +349,7 @@ class MenuController extends BaseController
|
||||
'icon' => $data['icon'] ?? null,
|
||||
'sort' => $data['sort'] ?? 0,
|
||||
'status' => $data['status'],
|
||||
'is_visible' => $data['is_visible'],
|
||||
'permission' => $data['permission'] ?? null,
|
||||
'remark' => $data['remark'] ?? null,
|
||||
'update_time' => date('Y-m-d H:i:s')
|
||||
|
||||
@@ -6,3 +6,9 @@ Route::get('productsList', 'app\admin\controller\Cms\Products\ProductsController
|
||||
Route::post('addProducts', 'app\admin\controller\Cms\Products\ProductsController@addProducts');
|
||||
Route::put('editProducts/:id', 'app\admin\controller\Cms\Products\ProductsController@editProducts');
|
||||
Route::delete('deleteProducts/:id', 'app\admin\controller\Cms\Products\ProductsController@deleteProducts');
|
||||
|
||||
// 产品分类
|
||||
Route::get('productsTypesList', 'app\admin\controller\Cms\Products\ProductsTypesController@productsTypesList');
|
||||
Route::post('addProductsTypes', 'app\admin\controller\Cms\Products\ProductsTypesController@addProductsTypes');
|
||||
Route::put('editProductsTypes/:id', 'app\admin\controller\Cms\Products\ProductsTypesController@editProductsTypes');
|
||||
Route::delete('deleteProductsTypes/:id', 'app\admin\controller\Cms\Products\ProductsTypesController@deleteProductsTypes');
|
||||
|
||||
@@ -103,11 +103,18 @@ class ArticleController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文章分类列表
|
||||
* 获取文章分类列表(mete_articles_category:当前租户 tid、启用状态)
|
||||
* 支持 baseUrl=租户前台域名,与 getCenterNews 一致,便于 api 域名跨域调用时解析 tid
|
||||
*
|
||||
* @return Json
|
||||
*/
|
||||
public function getArticleCategories(): Json
|
||||
{
|
||||
$baseUrl = $this->request->get('baseUrl', '');
|
||||
if (!empty($baseUrl)) {
|
||||
$this->tenantId = BaseController::getTenantIdByDomain($baseUrl);
|
||||
}
|
||||
|
||||
$tid = $this->getTenantId();
|
||||
|
||||
if (empty($tid)) {
|
||||
@@ -120,6 +127,9 @@ class ArticleController extends BaseController
|
||||
|
||||
$articleCategories = ArticlesCategory::where('delete_time', null)
|
||||
->where('tid', $tid)
|
||||
->where('status', 1)
|
||||
->order('sort', 'asc')
|
||||
->order('id', 'asc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
||||
@@ -14,19 +14,22 @@ use think\db\exception\DbException;
|
||||
|
||||
use app\model\Cms\Articles;
|
||||
use app\model\Cms\ArticlesCategory;
|
||||
|
||||
use tidy;
|
||||
|
||||
class NewsCenterController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 根据域名获取新闻数据
|
||||
*
|
||||
* 返回字段:list 列表;total 当前租户下已发布新闻总数;count 当前筛选(全部或 cate)下的条数,翻页按 count 与 page_size。
|
||||
*
|
||||
* @return Json
|
||||
*/
|
||||
public function getCenterNews(): Json
|
||||
{
|
||||
$baseUrl = $this->request->get('baseUrl', '');
|
||||
|
||||
if (!empty($baseUrl)) {
|
||||
$baseUrl = (string) $this->request->param('baseUrl', '');
|
||||
|
||||
if ($baseUrl !== '') {
|
||||
$this->tenantId = BaseController::getTenantIdByDomain($baseUrl);
|
||||
}
|
||||
|
||||
@@ -40,15 +43,67 @@ class NewsCenterController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
// 查询该租户下的文章
|
||||
$articles = Articles::published()
|
||||
// param 合并 GET,避免个别环境下仅 get 取不到查询串
|
||||
$cateId = (int) $this->request->param('cate', 0);
|
||||
$listPage = (int) $this->request->param('page', 0);
|
||||
$pageSizeReq = (int) $this->request->param('page_size', 0);
|
||||
|
||||
// 点击左侧分类:文章 cate 可能挂在子分类上,需包含「该分类 + 其下所有子分类」id
|
||||
$categoryIdsForFilter = [];
|
||||
if ($cateId > 0) {
|
||||
$categoryIdsForFilter = $this->resolveCategoryBranchIds($cateId, $tid);
|
||||
if ($categoryIdsForFilter === []) {
|
||||
$categoryIdsForFilter = [$cateId];
|
||||
}
|
||||
}
|
||||
|
||||
$baseQuery = static function () use ($tid, $cateId, $categoryIdsForFilter) {
|
||||
$q = Articles::published()
|
||||
->where('tid', $tid)
|
||||
->where('delete_time', null);
|
||||
if ($cateId > 0 && $categoryIdsForFilter !== []) {
|
||||
$q->whereIn('cate', $categoryIdsForFilter);
|
||||
}
|
||||
|
||||
return $q;
|
||||
};
|
||||
|
||||
// 当前租户下「全部」已发布新闻数(不受 cate 筛选影响)
|
||||
$totalTenantNews = (int) Articles::published()
|
||||
->where('tid', $tid)
|
||||
->where('delete_time', null)
|
||||
->order('publish_date', 'desc')
|
||||
->limit(8)
|
||||
->select();
|
||||
->count();
|
||||
|
||||
// 处理图片:如果文章image为空,则取分类的image
|
||||
// 当前列表条件下的总数:tid +(可选)cate,用于翻页总页数 = ceil(count / page_size)
|
||||
$countFiltered = (int) $baseQuery()->count();
|
||||
|
||||
$useListPagination = $listPage > 0 && $pageSizeReq > 0;
|
||||
|
||||
if ($useListPagination) {
|
||||
// 新闻中心列表页:服务端分页;不要用查询参数名 page,避免与路由占位符冲突
|
||||
$pageSizeReq = max(1, min($pageSizeReq, 50));
|
||||
$listPage = max(1, $listPage);
|
||||
$articles = $baseQuery()
|
||||
->order('publish_date', 'desc')
|
||||
->page($listPage, $pageSizeReq)
|
||||
->select();
|
||||
} else {
|
||||
// 首页等:按 limit 取前 N 条(默认 8)
|
||||
$limit = (int) $this->request->param('limit', 8);
|
||||
if ($limit < 1) {
|
||||
$limit = 8;
|
||||
}
|
||||
if ($limit > 200) {
|
||||
$limit = 200;
|
||||
}
|
||||
|
||||
$articles = $baseQuery()
|
||||
->order('publish_date', 'desc')
|
||||
->limit($limit)
|
||||
->select();
|
||||
}
|
||||
|
||||
// 处理图片:如果文章 image 为空,则取分类的 image
|
||||
foreach ($articles as &$article) {
|
||||
if (empty($article['image']) && !empty($article['cate'])) {
|
||||
$category = ArticlesCategory::where('id', $article['cate'])
|
||||
@@ -59,14 +114,96 @@ class NewsCenterController extends BaseController
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($article);
|
||||
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => 'success',
|
||||
'list' => $articles,
|
||||
'code' => 200,
|
||||
'msg' => 'success',
|
||||
'list' => $articles,
|
||||
// 当前租户下新闻总条数(全部状态为已发布)
|
||||
'total' => $totalTenantNews,
|
||||
// 当前筛选(全部或某分类)下的条数,列表翻页按 count 与 page_size 计算
|
||||
'count' => $countFiltered,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析分类筛选用的 id 列表:自身 + mete_articles_category 中 cid=该 id 的所有子孙(同 tid、未删除)
|
||||
*/
|
||||
private function resolveCategoryBranchIds(int $rootId, int $tid): array
|
||||
{
|
||||
if ($rootId <= 0 || $tid <= 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$root = ArticlesCategory::where('id', $rootId)
|
||||
->where('tid', $tid)
|
||||
->where('delete_time', null)
|
||||
->find();
|
||||
if (!$root) {
|
||||
return [$rootId];
|
||||
}
|
||||
|
||||
$ids = [$rootId];
|
||||
$queue = [$rootId];
|
||||
while ($queue !== []) {
|
||||
$pid = array_shift($queue);
|
||||
$children = ArticlesCategory::where('cid', $pid)
|
||||
->where('tid', $tid)
|
||||
->where('delete_time', null)
|
||||
->column('id');
|
||||
foreach ($children as $id) {
|
||||
$id = (int) $id;
|
||||
if ($id > 0 && !in_array($id, $ids, true)) {
|
||||
$ids[] = $id;
|
||||
$queue[] = $id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取新闻详情
|
||||
* @param int $id 文章ID
|
||||
* @return Json
|
||||
*/
|
||||
public function getNewsDetail(int $id): Json
|
||||
{
|
||||
try {
|
||||
$baseUrl = $this->request->get('baseUrl', '');
|
||||
if (!empty($baseUrl)) {
|
||||
$this->tenantId = BaseController::getTenantIdByDomain($baseUrl);
|
||||
}
|
||||
|
||||
$tid = $this->getTenantId();
|
||||
$query = Articles::published()->where('id', $id);
|
||||
if ($tid > 0) {
|
||||
$query->where('tid', $tid);
|
||||
}
|
||||
$article = $query->find();
|
||||
if (!$article) {
|
||||
return json([
|
||||
'code' => 404,
|
||||
'msg' => '文章不存在',
|
||||
'list' => [],
|
||||
]);
|
||||
}
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => 'success',
|
||||
'list' => $article,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return json([
|
||||
'code' => 500,
|
||||
'msg' => '获取新闻详情失败:' . $e->getMessage(),
|
||||
'list' => [],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上一篇下一篇
|
||||
* @param int $id 文章ID
|
||||
|
||||
@@ -18,6 +18,8 @@ use app\model\Cms\Friendlink;
|
||||
use app\model\Cms\Services;
|
||||
use app\model\Cms\Products;
|
||||
use app\model\Tenant\Tenant;
|
||||
use app\model\Cms\Articles;
|
||||
use app\model\Cms\ArticlesCategory;
|
||||
|
||||
class Index extends BaseController
|
||||
{
|
||||
@@ -154,6 +156,12 @@ class Index extends BaseController
|
||||
die('tenantId未获取到,请检查域名解析');
|
||||
}
|
||||
|
||||
// 与 NewsCenterController::getNewsDetail 一致:已发布 + 当前租户(网页直出,非 JSON)
|
||||
$templateVars = $this->buildArticleDetailTemplateVars($id, $tid);
|
||||
if ($templateVars === null) {
|
||||
return response('文章不存在', 404, ['Content-Type' => 'text/html; charset=utf-8']);
|
||||
}
|
||||
|
||||
// 获取租户选择的模板
|
||||
$themeKey = 'default';
|
||||
if ($tid > 0) {
|
||||
@@ -176,13 +184,13 @@ class Index extends BaseController
|
||||
|
||||
// 优先使用 article_detail 模板
|
||||
if (is_file($templateFile)) {
|
||||
return $this->renderPhpTemplate($templateFile, $themeUrlPath);
|
||||
return $this->renderPhpTemplate($templateFile, $themeUrlPath, $templateVars);
|
||||
} elseif (is_file($templateHtmlFile)) {
|
||||
$content = file_get_contents($templateHtmlFile);
|
||||
$content = $this->fixTemplateAssets($content, $themeUrlPath);
|
||||
return response($content, 200, ['Content-Type' => 'text/html; charset=utf-8']);
|
||||
} elseif (is_file($blogDetailsFile)) {
|
||||
return $this->renderPhpTemplate($blogDetailsFile, $themeUrlPath);
|
||||
return $this->renderPhpTemplate($blogDetailsFile, $themeUrlPath, $templateVars);
|
||||
} elseif (is_file($blogDetailsHtmlFile)) {
|
||||
$content = file_get_contents($blogDetailsHtmlFile);
|
||||
$content = $this->fixTemplateAssets($content, $themeUrlPath);
|
||||
@@ -192,6 +200,81 @@ class Index extends BaseController
|
||||
return response('文章不存在', 404, ['Content-Type' => 'text/html; charset=utf-8']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装文章详情页模板变量(数据源与 getNewsDetail 一致,并限定租户 + 已发布)
|
||||
*
|
||||
* @return array<string, mixed>|null
|
||||
*/
|
||||
private function buildArticleDetailTemplateVars(int $id, int $tid): ?array
|
||||
{
|
||||
$article = Articles::published()
|
||||
->where('id', $id)
|
||||
->where('tid', $tid)
|
||||
->find();
|
||||
|
||||
if (!$article) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$row = $article->toArray();
|
||||
|
||||
$categoryName = '未分类';
|
||||
if (!empty($row['cate'])) {
|
||||
$cat = ArticlesCategory::where('id', $row['cate'])
|
||||
->where('delete_time', null)
|
||||
->find();
|
||||
if ($cat) {
|
||||
$categoryName = (string) $cat['name'];
|
||||
}
|
||||
}
|
||||
|
||||
$coverPath = $row['image'] ?? '';
|
||||
if ($coverPath === '' && !empty($row['cate'])) {
|
||||
$category = ArticlesCategory::where('id', $row['cate'])
|
||||
->where('delete_time', null)
|
||||
->find();
|
||||
if ($category && !empty($category['image'])) {
|
||||
$coverPath = (string) $category['image'];
|
||||
}
|
||||
}
|
||||
|
||||
$apiUrl = rtrim((string) (Env::get('app.api_url', '') ?: 'https://api.yunzer.cn'), '/');
|
||||
$articleCoverUrl = $this->resolveArticleMediaUrl($coverPath, $apiUrl);
|
||||
|
||||
$descPlain = strip_tags((string) ($row['desc'] ?? ''));
|
||||
$title = (string) ($row['title'] ?? '详情');
|
||||
$descShort = $descPlain !== ''
|
||||
? (function_exists('mb_substr') ? mb_substr($descPlain, 0, 160) : substr($descPlain, 0, 160))
|
||||
: $title;
|
||||
|
||||
return [
|
||||
'article' => $row,
|
||||
'articleCoverUrl' => $articleCoverUrl,
|
||||
'articleCategoryName' => $categoryName,
|
||||
'pageTitle' => $title . ' - 新闻详情',
|
||||
'pageDescription' => $descShort,
|
||||
'pageKeywords' => $title,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章封面等资源 URL(与列表页逻辑一致:相对路径拼 API 域名)
|
||||
*/
|
||||
private function resolveArticleMediaUrl(string $path, string $apiUrl): string
|
||||
{
|
||||
if ($path === '') {
|
||||
return '';
|
||||
}
|
||||
if (strpos($path, 'http://') === 0 || strpos($path, 'https://') === 0) {
|
||||
return $path;
|
||||
}
|
||||
if (strpos($path, '/') === 0) {
|
||||
return $apiUrl . $path;
|
||||
}
|
||||
|
||||
return $apiUrl . '/' . $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修复模板中的资源路径
|
||||
* 将相对路径 (assets/, css/, js/, images/) 转换为绝对路径 (/themes/xxx/)
|
||||
@@ -223,7 +306,7 @@ class Index extends BaseController
|
||||
/**
|
||||
* 渲染PHP模板文件
|
||||
*/
|
||||
private function renderPhpTemplate(string $templateFile, string $themeUrlPath = '')
|
||||
private function renderPhpTemplate(string $templateFile, string $themeUrlPath = '', array $templateVars = [])
|
||||
{
|
||||
// 定义模板基础URL常量,供模板使用
|
||||
if (!defined('THEME_URL')) {
|
||||
@@ -234,6 +317,7 @@ class Index extends BaseController
|
||||
// 获取URL参数
|
||||
$getParams = Request::get();
|
||||
extract($getParams, EXTR_OVERWRITE);
|
||||
extract($templateVars, EXTR_OVERWRITE);
|
||||
include $templateFile;
|
||||
$content = ob_get_clean();
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ Route::get('companyInfos', 'app\index\controller\Index@getCompanyInfos');
|
||||
Route::post('requirement', 'app\index\controller\Index@requirement');
|
||||
Route::get('homeData', 'app\index\controller\Index@getHomeData');
|
||||
|
||||
// --- 客户需求路由 ---
|
||||
|
||||
// --- 新闻中心列表路由 ---
|
||||
Route::get('getCenterNews', 'app\index\controller\Article\NewsCenterController@getCenterNews');
|
||||
Route::get('getNewsDetail/:id', 'app\index\controller\Article\NewsCenterController@getNewsDetail');
|
||||
|
||||
|
||||
// --- 文章分类路由 ---
|
||||
Route::get('getArticleCategories', 'app\index\controller\Article\ArticleController@getArticleCategories');
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\model\Cms;
|
||||
|
||||
use think\Model;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
/**
|
||||
* 特色服务模型
|
||||
*/
|
||||
class ProductsTypes extends Model
|
||||
{
|
||||
// 启用软删除
|
||||
use SoftDelete;
|
||||
|
||||
// 数据库表名
|
||||
protected $name = 'mete_apps_cms_products_types';
|
||||
|
||||
// 字段类型转换
|
||||
protected $type = [
|
||||
'id' => 'integer',
|
||||
'tid' => 'integer',
|
||||
'pid' => 'integer',
|
||||
'title' => 'string',
|
||||
'desc' => 'string',
|
||||
'sort' => 'integer',
|
||||
'create_time' => 'datetime',
|
||||
'update_time' => 'datetime',
|
||||
'delete_time' => 'datetime',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
@@ -35,6 +35,7 @@ class SystemMenu extends Model
|
||||
'icon' => 'string',
|
||||
'sort' => 'integer',
|
||||
'status' => 'integer',
|
||||
'is_visible' => 'integer',
|
||||
'type' => 'integer',
|
||||
'permission' => 'string',
|
||||
'remark' => 'string',
|
||||
|
||||
Reference in New Issue
Block a user