修改结构

This commit is contained in:
liyukun 2021-06-26 15:13:52 +08:00
parent 8dfa7bbd04
commit 2b4328baef
74 changed files with 247 additions and 677 deletions

View File

@ -7,5 +7,4 @@ return [
// 过期时间
'expire' => 1440,
// 前缀
'prefix' => 'zz_admin',
];

View File

@ -2,8 +2,8 @@
namespace app\admin\controller;
use app\admin\model\Admin as aModel;
use app\admin\model\AdminRole as rModel;
use app\common\model\Admin as aModel;
use app\common\model\AdminRole as rModel;
use app\Request;
use app\admin\services\UtilService as Util;
use FormBuilder\Factory\Elm;

View File

@ -2,7 +2,7 @@
namespace app\admin\controller;
use app\admin\model\AdminAuth as aModel;
use app\common\model\AdminAuth as aModel;
use app\Request;
use FormBuilder\Exception\FormBuilderException;
use app\admin\services\UtilService as Util;

View File

@ -1,16 +0,0 @@
<?php
namespace app\admin\controller;
/**
* 图标
* Class AdminIcon
* @package app\admin\controller\admin
*/
class AdminIcon extends AuthController
{
public function index()
{
return $this->fetch();
}
}

View File

@ -2,7 +2,7 @@
namespace app\admin\controller;
use app\admin\model\AdminLog as lModel;
use app\common\model\AdminLog as lModel;
use app\Request;
use app\admin\services\UtilService as Util;

View File

@ -3,7 +3,7 @@
namespace app\admin\controller;
use app\admin\services\UtilService as Util;
use app\admin\model\AdminNotify as nModel;
use app\common\model\AdminNotify as nModel;
/**
* 消息提醒
* Class AdminNotify

View File

@ -2,8 +2,8 @@
namespace app\admin\controller;
use app\admin\model\AdminRole as rModel;
use app\admin\model\AdminAuth as aModel;
use app\common\model\AdminRole as rModel;
use app\common\model\AdminAuth as aModel;
use app\Request;
use FormBuilder\Exception\FormBuilderException;
use app\admin\services\UtilService as Util;

View File

@ -2,9 +2,9 @@
namespace app\admin\controller;
use app\admin\model\Document as aModel;
use app\admin\model\DocumentCategory as cModel;
use app\admin\model\DocumentArticle;
use app\common\model\Document as aModel;
use app\common\model\DocumentCategory as cModel;
use app\common\model\DocumentArticle;
use app\Request;
use app\admin\services\UtilService as Util;
use think\Exception;

View File

@ -2,8 +2,8 @@
namespace app\admin\controller;
use app\admin\model\AdminAuth;
use app\admin\model\AdminRole;
use app\common\model\AdminAuth;
use app\common\model\AdminRole;
use think\facade\App;
use think\facade\Lang;
use think\facade\Session;

View File

@ -2,8 +2,8 @@
namespace app\admin\controller;
use app\admin\model\DocumentCategory as aModel;
use app\admin\model\DocumentCategoryContent;
use app\common\model\DocumentCategory as aModel;
use app\common\model\DocumentCategoryContent;
use app\Request;
use app\admin\services\UtilService as Util;

View File

@ -3,7 +3,7 @@
namespace app\admin\controller;
use app\admin\model\Attachment;
use app\common\model\Attachment;
use app\admin\services\storage\QcloudCoService;
use app\admin\services\UtilService as Util;
use think\exception\ValidateException;

View File

@ -2,7 +2,7 @@
namespace app\admin\controller;
use app\admin\model\FriendLink as aModel;
use app\common\model\FriendLink as aModel;
use app\admin\services\FormBuilderService as Form;
use app\Request;
use app\admin\services\UtilService as Util;

View File

@ -3,8 +3,8 @@
namespace app\admin\controller;
use app\admin\model\Attachment;
use app\admin\model\AttachmentCategory;
use app\common\model\Attachment;
use app\common\model\AttachmentCategory;
use FormBuilder\Factory\Elm;
use app\admin\services\FormBuilderService as Form;
use app\admin\services\storage\QcloudCoService;

View File

@ -2,8 +2,8 @@
namespace app\admin\controller;
use app\admin\model\AdminAuth;
use app\admin\model\AdminNotify;
use app\common\model\AdminAuth;
use app\common\model\AdminNotify;
use app\Request;
use app\admin\services\UtilService as Util;

View File

@ -2,7 +2,7 @@
namespace app\admin\controller;
use app\admin\model\InvitationCode as aModel;
use app\common\model\InvitationCode as aModel;
use app\Request;
use app\admin\services\UtilService as Util;

View File

@ -3,8 +3,8 @@
namespace app\admin\controller;
use app\admin\model\Admin;
use app\admin\model\Admin as adminModel;
use app\common\model\Admin;
use app\common\model\Admin as adminModel;
use app\admin\services\UtilService as Util;
class Login extends AuthController

View File

@ -2,7 +2,7 @@
namespace app\admin\controller;
use app\admin\model\Slides as aModel;
use app\common\model\Slides as aModel;
use app\admin\services\FormBuilderService as Form;
use app\Request;
use app\admin\services\UtilService as Util;

View File

@ -2,8 +2,8 @@
namespace app\admin\controller;
use app\admin\model\SystemConfig as cModel;
use app\admin\model\SystemConfigTab as tModel;
use app\common\model\SystemConfig as cModel;
use app\common\model\SystemConfigTab as tModel;
use app\Request;
use FormBuilder\Factory\Elm;
use app\admin\services\FormBuilderService as Form;

View File

@ -7,8 +7,8 @@ use app\Request;
use FormBuilder\Factory\Elm;
use app\admin\services\FormBuilderService as Form;
use app\admin\services\UtilService as Util;
use app\admin\model\SystemConfigTab as tModel;
use app\admin\model\SystemConfig as cModel;
use app\common\model\SystemConfigTab as tModel;
use app\common\model\SystemConfig as cModel;
/**
* 管理员配置

View File

@ -2,7 +2,7 @@
namespace app\admin\controller;
use app\admin\model\SystemConfig as cModel;
use app\common\model\SystemConfig as cModel;
use app\Request;
use app\admin\services\UtilService as Util;

View File

@ -2,7 +2,7 @@
namespace app\admin\controller;
use app\admin\model\User as aModel;
use app\common\model\User as aModel;
use app\Request;
use app\admin\services\UtilService as Util;
use FormBuilder\Factory\Elm;

View File

@ -3,7 +3,7 @@
namespace app\admin\subscribes;
use app\admin\model\AdminLog;
use app\common\model\AdminLog;
/**
* 操作员日志记录

View File

@ -1,15 +0,0 @@
<?php
namespace app\common\exceptions;
use Throwable;
/**
* Class AuthException
* @package app\common\exceptions
*/
class AuthException extends \Exception
{
}

View File

@ -1,16 +0,0 @@
<?php
namespace app\common\interfaces;
use app\Request;
/**
* Interface MiddlewareInterface
* @package app\common\interfaces
*/
interface MiddlewareInterface
{
public function handle(Request $request, \Closure $next);
}

View File

@ -1,35 +0,0 @@
<?php
namespace app\common\middleware;
use app\Request;
use app\common\interfaces\MiddlewareInterface;
use think\Response;
/**
* Class AllowOriginMiddleware
* @package app\http\middleware
*/
class AllowOriginMiddleware implements MiddlewareInterface
{
/**
* @param Request $request
* @param \Closure $next
* @return mixed|Response
*/
public function handle(Request $request, \Closure $next)
{
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Authori-zation, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With');
header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE');
header('Access-Control-Max-Age: 1728000');
if ($request->isOptions()) {
$response = Response::create("ok");
} else {
$response = $next($request);
}
return $response;
}
}

View File

@ -1,49 +0,0 @@
<?php
namespace app\common\middleware;
use app\admin\model\User;
use app\Request;
use app\common\exceptions\AuthException;
use app\common\interfaces\MiddlewareInterface;
/**
* token验证
* Class AuthTokenMiddleware
* @package app\common\middleware
*/
class AuthTokenMiddleware implements MiddlewareInterface
{
/**
* @param Request $request
* @param \Closure $next
* @param bool $force
* @return mixed
*/
public function handle(Request $request, \Closure $next, bool $force = true)
{
$authInfo = null;
$token = $request->header('Authori-zation');
if(!$token) $token = $request->header('Authorization');
try {
$authInfo = User::parseToken($token);
} catch (AuthException $e) {
if ($force)
return app('json')->make($e->getCode(), $e->getMessage());
}
if (!is_null($authInfo)) {
Request::macro('user', function () use (&$authInfo) {
return $authInfo;
});
}
Request::macro('isLogin', function () use (&$authInfo) {
return !is_null($authInfo);
});
Request::macro('uid', function () use (&$authInfo) {
return is_null($authInfo) ? 0 : $authInfo['uid'];
});
return $next($request);
}
}

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;
use think\facade\Cache;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use think\facade\Db;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
/**
* Class Document

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use think\Model;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use app\admin\model\BaseModel;

View File

@ -1,7 +1,7 @@
<?php
namespace app\admin\model;
namespace app\common\model;
use think\facade\Cache;
use think\facade\Session;

View File

@ -19,7 +19,7 @@ class Zz extends TagLib{
'arclist'=> ['attr' => 'typeid,orderby,row,void,model,type,where,display,ids,limit', 'close' => 1],
'type'=> ['attr' => 'typeid', 'close' => 1],
'list'=> ['attr' => 'orderby,pagesize,type,typeid,void,model,where,display', 'close' => 1],
'prenext'=> ['attr' => 'get,cid,void', 'close' => 1],
'prenext'=> ['attr' => 'get,cid,void,none', 'close' => 1],
'flink'=> ['attr' => 'type,row,void', 'close' => 1],
'banner'=> ['attr' => 'type,row,void', 'close' => 1],
'sql'=> ['attr' => 'sql', 'close' => 1],
@ -40,7 +40,7 @@ class Zz extends TagLib{
$row=isset($tag['row'])?$tag['row']:100;
$void=isset($tag['void'])?$tag['void']:'field';
$where=isset($tag['where'])?$tag['where']:'';
$orderby=isset($tag['orderby'])?$tag['orderby']:'sort desc';
$orderby=isset($tag['orderby'])?$tag['orderby']:'sort asc';
$display=isset($tag['display'])?$tag['display']:1;
$display=$display==1?1:0;
@ -157,9 +157,10 @@ class Zz extends TagLib{
$get=isset($tag['get'])?$tag['get']:'pre';
$cid=isset($tag['cid'])?$tag['cid']:'$cid';
$void=isset($tag['void'])?$tag['void']:'field';
$none=isset($tag['none'])?$tag['none']:'没有了';
$parse = '<?php ';
$parse .= '$__LIST__ =[];array_push($__LIST__,'."tpl_get_prenext(\"$get\",$cid));";
$parse .= '$__LIST__ =[];array_push($__LIST__,'."tpl_get_prenext(\"$get\",$cid,\"$none\"));";
$parse .= ' ?>';
$parse .= '{volist name="__LIST__" id="'.$void.'"}';
$parse .= $content;

View File

@ -0,0 +1,30 @@
<?php
// +----------------------------------------------------------------------
// | hulacwms 3.0 呼啦企业网站管理系统
// +----------------------------------------------------------------------
// | Copyright (c) 2021 https://www.kaifashu.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 开发树
// +----------------------------------------------------------------------
namespace app\common\validate;
use think\Validate;
/**
* 管理员验证器
*/
class AdminMemberEdit extends Validate {
protected $rule = [
'username' => 'require|max:16',
'nickname' => 'max:10',
];
protected $message = [
'username.require' => '请输入用户名',
'username.max' => '用户名最多不能超过16个字符',
'nickname.max' => '用户名最多不能超过10个字符',
];
}

View File

@ -1,10 +1,10 @@
<?php
// +----------------------------------------------------------------------
// | HulaCWMS 呼啦企业网站管理系统
// | hulacwms 3.0 呼啦企业网站管理系统
// +----------------------------------------------------------------------
// | Copyright (c) 2019 http://www.zhuopro.com All rights reserved.
// | Copyright (c) 2021 https://www.kaifashu.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 灼灼文化
// | Author: 开发树
// +----------------------------------------------------------------------
namespace app\common\validate;

View File

@ -20,8 +20,7 @@ class Adminaction extends Validate {
'name' => 'require|max:30',
'title' => 'require|max:80',
'remark' => 'max:140',
'type' => 'number',
'status' => 'number',
];
protected $message = [
@ -30,8 +29,7 @@ class Adminaction extends Validate {
'title.max' => '行为名称最多输入80个字符',
'name.max' => '行为标识最多输入30个字符',
'remark.max' => '行为描述最多输入140个字符',
'type.number' => '行为类型只能为数字',
'status.number' => '行为状态只能为数字',
];
}

View File

@ -1,10 +1,10 @@
<?php
// +----------------------------------------------------------------------
// | HulaCWMS 呼啦企业网站管理系统
// | hulacwms 3.0 呼啦企业网站管理系统
// +----------------------------------------------------------------------
// | Copyright (c) 2019 http://www.zhuopro.com All rights reserved.
// | Copyright (c) 2021 https://www.kaifashu.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 灼灼文化
// | Author: 开发树
// +----------------------------------------------------------------------
namespace app\common\validate;
@ -14,19 +14,17 @@ use think\Validate;
* 后台菜单验证器
*/
class Adminauthgroup extends Validate {
class AdminAuthGroup extends Validate {
protected $rule = [
'title' => 'require|max:20',
'type' => 'number',
'description' => 'max:80',
];
protected $message = [
'title.require' => '请输入用户组名称!',
'title.max' => '用户组名称最多输入20个字符',
'type.number' => '组类型只能为数字',
'description.max' => '描述信息最多输入80个字符',
'remark.max' => '描述信息最多输入80个字符',
];
}

View File

@ -1,20 +1,20 @@
<?php
// +----------------------------------------------------------------------
// | HulaCWMS 呼啦企业网站管理系统
// | hulacwms 3.0 呼啦企业网站管理系统
// +----------------------------------------------------------------------
// | Copyright (c) 2019 http://www.zhuopro.com All rights reserved.
// | Copyright (c) 2021 https://www.kaifashu.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 灼灼文化
// | Author: 开发树
// +----------------------------------------------------------------------
namespace app\common\validate;
use think\Validate;
/**
* 后台菜单验证器
* 管理员验证器
*/
class Adminmember extends Validate {
class AdminMember extends Validate {
protected $rule = [
'username' => 'require|max:16',
@ -30,8 +30,6 @@ class Adminmember extends Validate {
'password.min' => '密码最少不能低于4个字符',
'password.max' => '密码最多不能超过30个字符',
];
protected $scene = [
'editpwd' => ['password']//修改密码
];

View File

@ -1,10 +1,10 @@
<?php
// +----------------------------------------------------------------------
// | HulaCWMS 呼啦企业网站管理系统
// | hulacwms 3.0 呼啦企业网站管理系统
// +----------------------------------------------------------------------
// | Copyright (c) 2019 http://www.zhuopro.com All rights reserved.
// | Copyright (c) 2021 https://www.kaifashu.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 灼灼文化
// | Author: 开发树
// +----------------------------------------------------------------------
namespace app\common\validate;

View File

@ -1,54 +1,65 @@
<?php
// +----------------------------------------------------------------------
// | HulaCWMS 呼啦企业网站管理系统
// +----------------------------------------------------------------------
// | Copyright (c) 2019 http://www.zhuopro.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 灼灼文化
// +----------------------------------------------------------------------
namespace app\common\validate;
use think\Validate;
/**
* 后台菜单验证器
* 文章内容验证器
*/
class Document extends Validate
{
class Document extends Validate {
protected $rule = [
'title' => 'require|max:80',
'uid' => 'number|max:10',
'name' => 'max:40',
'category_id' => 'require|number',
'keywords' => 'max:255',
'description' => 'max:255',
'type' => 'number',
'sort' => 'require|number',
'link_str' => 'max:255',
'cover_path' => 'max:255',
];
protected $message = [
'title.require' => '请输入文章标题!',
'title.max' => '文章标题最多输入80个字符',
'uid.number' => '用户id只能是数字',
'uid.max' => '用户id最多输入10个字符',
'name.max' => '标识最多输入40个字符',
'category_id' => '请选择文章分类',
'category_id.number' => '文章分类只能是数字',
'keywords.max' => '关键字最多输入255个字符',
'description.max' => '描述最多输入255个字符',
'link_str.max' => '外链最多输入255个字符',
'cover_path.max' => '封面最多输入255个字符',
'type.number' => '内容类型只能是数字',
'sort.require' => '请输入排序序号',
'sort.number' => '排序序号只能是数字',
protected $rule = [
'writer|作者' => [
'require',
'max' => 50,
],
'title|标题' => [
'require',
'max' => 500,
],
'category_id|所属分类' => [
'require',
'number',
],
'keywords|网站关键词' => [
'max' => 500,
],
'description|网站描述' => [
'max' => 65535,
],
'isrecommend|是否推荐' => [
'require',
'number'
],
'istop|是否置顶' => [
'require',
'number',
],
'link_str|外链' => [
'max' => 500,
],
'cover_path|封面' => [
'max' => 500,
],
'display|是否显示' => [
'require',
'number',
],
'view|浏览量' => [
'number',
],
'sort|排序' => [
'require',
'number',
],
'content|文章内容' => [
'max' => 65535,
],
];
//更新排序
protected $scene = [
'sort' => ['sort']
'sort' => ['sort']
];
}

View File

@ -1,53 +1,42 @@
<?php
// +----------------------------------------------------------------------
// | HulaCWMS 呼啦企业网站管理系统
// +----------------------------------------------------------------------
// | Copyright (c) 2019 http://www.zhuopro.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 灼灼文化
// +----------------------------------------------------------------------
namespace app\common\validate;
use think\Validate;
/**
* 后台菜单验证器
* 文章分类验证器
*/
class Documentcategory extends Validate {
protected $rule = [
'title' => 'require|max:50',
'name' => 'max:30',
'pid'=>'require|number',
'display'=>'require|number',
'type' => 'require|number',
'sort' => 'require|number',
'link_str' => 'max:255',
'keywords' => 'max:255',
'description' => 'max:255',
'meta_title' => 'max:50',
'template_index'=>['regex' => '/^[a-zA-Z0-9]/'],
'template_lists'=>['regex' => '/^[a-zA-Z0-9]/'],
'template_detail'=>['regex' => '/^[a-zA-Z0-9]/'],
];
protected $message = [
'title.require' => '请输入文章标题!',
'title.max' => '文章标题最多输入50个字符',
'name.max' => '标识最多输入30个字符',
'type.number' => '分类类别只能是数字',
'sort.number' => '排序只能是数字!',
'link_str.max' => '外链最多输入255个字符',
'keywords.max' => '关键字最多输入255个字符',
'description.max' => '描述最多输入255个字符',
'meta_title.max' => 'SEO的网页标题最多输入50个字符',
'template_index'=>'模板文件名必须以字母或数字开头!',
'template_lists'=>'模板文件名必须以字母或数字开头!',
'template_detail'=>'模板文件名必须以字母或数字开头!'
class DocumentCategory extends Validate
{
protected $rule = [
'title|标题' => [
'require',
'max' => 50,
],
'pid|上级分类ID' => [
'require',
'number',
],
'sort|排序' => [
'require',
'number',
],
'meta_title|标题' => [
'max' => 500,
],
'keywords|网页关键字' => [
'max' => 500,
],
'link_str|外链' => [
'max' => 500,
],
'icon|分类图标' => [
'max' => 500,
],
];
//更新排序
protected $scene = [
'sort' => ['sort']
'sort' => ['sort']
];
}

View File

@ -2,9 +2,9 @@
// +----------------------------------------------------------------------
// | HulaCWMS 呼啦企业网站管理系统
// +----------------------------------------------------------------------
// | Copyright (c) 2019 http://www.zhuopro.com All rights reserved.
// | Copyright (c) 2021 https://www.kaifashu.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 灼灼文化
// | Author: 开发树
// +----------------------------------------------------------------------
namespace app\common\validate;
@ -20,15 +20,12 @@ class Friendlink extends Validate {
'title' => 'require|max:255',
'url' => 'require|max:255',
'sort' => 'require|number',
'uid' => 'max:10|number',
];
protected $message = [
'title.require' => '请输入链接名称!',
'url.require' => '请选择链接地址!',
'url.require' => '请输入链接地址!',
'sort' => '请输入排序序号',
'sort.number' => '排序序号只能是数字',
'uid.number' => '添加者ID只能是数字',
'uid.max' => '添加者ID最多不超过10个字符',
'title.max' => '链接名称最多输入255个字符',
'url.max' => '链接地址最多输入255个字符',
];

View File

@ -2,9 +2,9 @@
// +----------------------------------------------------------------------
// | HulaCWMS 呼啦企业网站管理系统
// +----------------------------------------------------------------------
// | Copyright (c) 2019 http://www.zhuopro.com All rights reserved.
// | Copyright (c) 2021 https://www.kaifashu.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 灼灼文化
// | Author: 开发树
// +----------------------------------------------------------------------
namespace app\common\validate;
@ -14,7 +14,7 @@ use think\Validate;
* 后台菜单验证器
*/
class Messageform extends Validate {
class MessageForm extends Validate {
protected $rule = [
'content' => 'require',

View File

@ -30,7 +30,7 @@ function html2text($str){
function get_type_content($id,$strip=false){
$dc=Db::name('document_category_content')->find($id);
if(!$dc){
throw new Exception('分类不存在或已删除!');
return '';
}
if($strip){
return html2text($dc['content']);
@ -44,7 +44,7 @@ function get_document_category_list(){
//缓存文章菜单
$docuemtCategory=cache('DATA_DOCUMENT_CATEGORY_LIST');
if($docuemtCategory===null){
$docuemtCategoryList=Db::name('document_category')->order('sort desc')->select();
$docuemtCategoryList=Db::name('document_category')->where('status',1)->order('sort asc')->select();
//转换让id作为数组的键
$docuemtCategory=[];
foreach ($docuemtCategoryList as $key=>$item){
@ -67,41 +67,17 @@ function get_document_category($x,$field=false){
}
//获取缓存的文章菜单
$docuemtCategoryList=get_document_category_list();
$docuemtCategory=$docuemtCategoryList[$x]??'';
if(!$docuemtCategory){
throw new Exception('分类不存在或已删除!');
if(!isset($docuemtCategoryList[$x])){
return false;
}
if($field){
return $docuemtCategory[$field];
return $docuemtCategoryList[$x][$field];
}
else{
return $docuemtCategory;
return $docuemtCategoryList[$x];
}
}
/**
* 获取栏目子元素
* @param $cid int|array 栏目分类
* @param bool $field
* @return mixed|string
* @throws Exception
* @author 李玉坤
* @date 2021-04-06 9:43
*/
function get_document_category_children($cid){
if(!$cid){
throw new Exception('请指定要获取的栏目分类id');
}
if (!is_array($cid)){
$cid = explode(',',$cid);
}
$children = Db::name('document_category')->where('pid','in',$cid)->column('id');
if(!empty($children)){
$children = array_merge($children,get_document_category_children($children));
}
return $children;
}
/**
* 获取一个文章分类-通个分类标识
*/
@ -119,7 +95,7 @@ function get_document_category_by_name($name,$field=false){
}
}
if(!$docuemtCategory){
throw new Exception('分类不存在或已删除!');
return false;
}
if($field){
return $docuemtCategory[$field];
@ -132,7 +108,7 @@ function get_document_category_by_name($name,$field=false){
/**
* 模板-获取文章分类
*/
function tpl_get_channel($type,$typeid,$row,$where='',$orderby='',$display=1){
function tpl_get_channel($type,$typeid,$row=100,$where='',$orderby='',$display=1){
switch($type){
case 'top':
@ -153,7 +129,7 @@ function tpl_get_channel($type,$typeid,$row,$where='',$orderby='',$display=1){
}
$dc=get_document_category($typeid);
if(!$dc){
throw new Exception('分类不存在或已删除!');
return false;
}
return get_document_category_by_parent($dc['pid'],$row,$display);;
break;
@ -166,7 +142,7 @@ function tpl_get_channel($type,$typeid,$row,$where='',$orderby='',$display=1){
if(!$dc){
throw new Exception('分类不存在或已删除!');
}
$tempArr=Db::name('document_category')->where('id','in',$dc['child'])->select();
$tempArr=Db::name('document_category')->where('id','in',$dc['child'])->where('status',1)->limit($row);
if($display){
$tempArr=$tempArr->where('display',1);
}
@ -197,8 +173,8 @@ function tpl_get_channel($type,$typeid,$row,$where='',$orderby='',$display=1){
$dc=get_document_category($typeid);
if($dc['pid']!=0){
//获取根分类,此操作读取数据库,非缓存!
$dc=Db::name('document_category')->where('pid',0)
->where("CONCAT(',',child,',') like '%,$typeid,%'");
$dc=Db::name('document_category')-where('pid',0)->where('status',1)
-> where("CONCAT(',',child,',') like '%,$typeid,%'")->limit($row);
if($display){
$dc=$dc->where('display',1);
}
@ -214,7 +190,7 @@ function tpl_get_channel($type,$typeid,$row,$where='',$orderby='',$display=1){
break;
case 'where':
//根据自定义条件获取分类where语句此操作读取数据库非缓存
$tempArr=Db::name('document_category')-> where($where)->order($orderby);
$tempArr=Db::name('document_category')->where('status',1)-> where($where)->order($orderby)->limit($row);
if($display){
$tempArr=$tempArr->where('display',1);
}
@ -228,7 +204,7 @@ function tpl_get_channel($type,$typeid,$row,$where='',$orderby='',$display=1){
break;
case 'ids':
//根据多个栏目id逗号隔开的那种获得栏目列表
$tempArr=Db::name('document_category')-> where('id','in',$typeid)->order($orderby);
$tempArr=Db::name('document_category')->where('status',1)-> where('id','in',$typeid)->order($orderby)->limit($row);
if($display){
$tempArr=$tempArr->where('display',1);
}
@ -261,11 +237,7 @@ function get_document_category_by_parent($pid,$row,$display=1){
}
if($item['pid']==$pid&&($display?$item['display']==1:true)){
$x=$x+1;
$tempArr[$item['id']] = $item;
}
//判断是否有子元素,子元素则为其父元素的child字段设置为1
if ($item['pid'] > 0 && !empty($tempArr[$item['pid']])){
$tempArr[$item['pid']]['child'] = 1;
array_push($tempArr,$item);
}
}
return $tempArr;
@ -275,7 +247,7 @@ function get_document_category_by_parent($pid,$row,$display=1){
* $get=上一篇|下一篇
* $cid=栏目分类id
*/
function tpl_get_prenext($get,$cid=false){
function tpl_get_prenext($get,$cid=false,$none){
//文档id
$id=input('id');
if(!$get){
@ -297,7 +269,7 @@ function tpl_get_prenext($get,$cid=false){
else{
$document['id']=false;
$document['url']='javascript:void(0)';
$document['title']='没有了';
$document['title']=$none;
}
return $document;
@ -317,9 +289,10 @@ function tpl_get_list($orderby,$pagesize,$cid,$type,$table='article',$where=fals
$docmentListModel=Db::name('document')
->alias('a')
->join(config('database.prefix').'document_category b','a.category_id=b.id','LEFT')
->join(config('database.prefix')."document_$table c",'a.id=c.id','RIGHT')
->join(config('database.prefix')."document_$table c",'a.id=c.id','LEFT')
->where("a.type='$table'")
->where('a.status',1)
->where('b.status',1)
->field('a.*,b.title as category_title,c.*');
if($display){
@ -335,11 +308,9 @@ function tpl_get_list($orderby,$pagesize,$cid,$type,$table='article',$where=fals
case 'find':
//获取栏目下文章以及所有子孙分类文章
$dc=get_document_category($cid);
$children = get_document_category_children($cid);
if(!empty($children)){
array_push($children,$cid);
$children = implode('.',$children);
$docmentListModel=$docmentListModel->where('a.category_id','in',$children);
$child=$dc['child'];
if($child){
$docmentListModel=$docmentListModel->where('a.category_id','in',"$cid,$child");
}
else{
$docmentListModel=$docmentListModel->where('a.category_id',$cid);
@ -374,7 +345,7 @@ function tpl_get_list($orderby,$pagesize,$cid,$type,$table='article',$where=fals
//获取当前请求的请求参数,以确定分页是否要带上这些请求参数
$query=request()->query();
if($query){
$docmentListModel=$docmentListModel->paginate( ['list_rows'=>$pagesize,'query' => request()->param()]);
$docmentListModel=$docmentListModel->paginate($pagesize,false,['query' => getRouteQuery()]);
}
else{
$docmentListModel=$docmentListModel->paginate($pagesize);
@ -394,6 +365,17 @@ function tpl_get_list($orderby,$pagesize,$cid,$type,$table='article',$where=fals
return $re;
}
/**
* 获得当前路由及参数列表
* @return mixed
*/
function getRouteQuery(){
$request=request();
$queryArr=$request->param();
$queryArr['s']=$request->pathinfo();
return $queryArr;
}
/**
* 根据栏目类型生成栏目url
*/
@ -431,8 +413,8 @@ function tpl_get_article($id,$table){
->alias('a')
->join(config('database.prefix').'document_category b','a.category_id=b.id','LEFT')
->join(config('database.prefix')."document_$table c",'a.id=c.id','LEFT')
->where('a.status',1)->where('a.display',1)->where('a.id',$id)->where("a.type='article'")
->field('a.*,b.title as category_title,c.content');
->where('a.status',1)->where('a.id',$id)->where("a.type='$table'")
->field('a.*,b.title as category_title,c.*');
$doc=$docmentModel->find();
@ -461,8 +443,7 @@ function tpl_get_article_list($cid,$row,$orderby,$table='article',$type='son',$w
->alias('a')
->join(config('database.prefix').'document_category b','a.category_id=b.id','LEFT')
->join(config('database.prefix')."document_$table c",'a.id=c.id','RIGHT')
->where("a.type='$table'")
->where('a.status',1)
->where("a.type='$table'")->where('a.status',1)->where('b.status',1)
->limit($row)
->field('a.*,b.title as category_title,c.*');
@ -615,7 +596,7 @@ function tpl_get_position($dc,$positionList=array()){
$htmlstr='<a href="/">首页</a>';
$positionListCount=count($positionList);
for ($x=$positionListCount-1;$x>=0;$x--){
$htmlstr=$htmlstr.'><a href="'.$positionList[$x]['url'].'">'.$positionList[$x]['title'].'</a>';
$htmlstr=$htmlstr.'<span>&gt;</span><a href="'.$positionList[$x]['url'].'">'.$positionList[$x]['title'].'</a>';
}
return $htmlstr;
}

View File

@ -50,13 +50,13 @@ class Article extends Base
//读取列表页模板
$listTmp='';
if($dc['type']==0){
$listTmp=$dc['template'];
$listTmp=$dc['template_lists'];
if(!$listTmp){
$this->error('请在栏目分类中,指定当前栏目的列表模板!');
}
}
elseif($dc['type']==1){
$listTmp=$dc['template'];
$listTmp=$dc['template_index'];
if(!$listTmp){
$this->error('请在栏目分类中,指定当前栏目的单篇模板!');
}
@ -114,7 +114,7 @@ class Article extends Base
//添加当前页面的位置信息
$article['position']=tpl_get_position($dc);
//更新浏览次数
Db::name('document')->where('id', $article['id'])->inc('view', 1);
Db::name('document')->where('id', $article['id'])->inc('view')->update();
//读取详情页模板
$detailTmp=$dc['template_detail'];
if(!$detailTmp){

View File

@ -16,11 +16,6 @@ use app\admin\model\SystemConfig;
*/
class Base extends BaseController
{
/**
* 控制器中间件
* @var array
*/
protected $middleware = [];
//系统配置
protected $systemConfig = [];
@ -47,6 +42,8 @@ class Base extends BaseController
}
//判断是否开启了伪静态
if ($systemConfig['web_rewrite']) {
$this->request->setRoot('/?s=');
} elseif(web_config('WEB_REWRITE')=='1') {
$this->request->setRoot('/');
} else {
$this->request->setRoot('/index.php');

View File

@ -1,17 +0,0 @@
<?php
namespace app\index\model;
use think\Model;
/**
* Class Document
* @package app\admin\model\system
* @author 李玉坤
* @date 2021-02-15 23:22
*/
class Document extends Model
{
}

View File

@ -1,36 +0,0 @@
<?php
namespace app\index\model;
use think\Model;
/**
* Class DocumentArticle
* @package app\admin\model\system
* @author 李玉坤
* @date 2021-02-15 23:22
*/
class DocumentArticle extends Model
{
/**
* 列表
* @param $where
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 李玉坤
* @date 2021-02-15 23:24
*/
public static function systemPage($where): array
{
$model = new self;
$count = self::counts($model);
if ($where['page'] && $where['limit']) $model = $model->page((int)$where['page'],(int)$where['limit']);
$data = $model->select();
if ($data) $data = $data->toArray();
return compact('data','count');
}
}

View File

@ -1,17 +0,0 @@
<?php
namespace app\index\model;
use think\Model;
/**
* Class DocumentCategory
* @package app\admin\model\system
* @author 李玉坤
* @date 2021-02-15 23:22
*/
class DocumentCategory extends Model
{
}

View File

@ -1,17 +0,0 @@
<?php
namespace app\index\model;
use think\Model;
/**
* Class DocumentCategoryContent
* @package app\admin\model\system
* @author 李玉坤
* @date 2021-02-15 23:22
*/
class DocumentCategoryContent extends Model
{
}

View File

@ -1,17 +0,0 @@
<?php
namespace app\index\model;
use think\Model;
/**
* Class DocumentProduct
* @package app\admin\model\system
* @author 李玉坤
* @date 2021-02-15 23:22
*/
class DocumentProduct extends Model
{
}

View File

@ -1,17 +0,0 @@
<?php
namespace app\index\model;
use think\Model;
/**
* Class FriendLink
* @package app\admin\model\system
* @author 李玉坤
* @date 2021-02-15 23:22
*/
class FriendLink extends Model
{
}

View File

@ -1,17 +0,0 @@
<?php
namespace app\index\model;
use think\Model;
/**
* Class Document
* @package app\admin\model\system
* @author 李玉坤
* @date 2021-02-15 23:22
*/
class MessageForm extends Model
{
}

View File

@ -1,50 +0,0 @@
<?php
namespace app\index\model;
use think\Model;
/**
* Class PvLog
* @package app\index\model
* @author 李玉坤
* @date 2021-05-09 23:28
*/
class PvLog extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
/**
* 增加pv信息
* @author 李玉坤
* @date 2021-05-09 23:31
*/
public function addLog(){
//pv表 栏目存在 点击进入页面后
//判断 时间 0-1点 为time=0 H 24小时制
$model = new self();
$date_data = date("Y-m-d");
$hour = date('H');
$pvInfo = $model->where('date',$date_data)
->where('time','=',$hour)
->value('id');
if ($pvInfo) {
$model->where('id', $pvInfo)
->inc('view')
->update();
} else {
$pvData = [
'view' => 1,
'time' => $hour,
'date' => $date_data
];
$model->save($pvData);
}
}
}

View File

@ -1,17 +0,0 @@
<?php
namespace app\index\model;
use think\Model;
/**
* Class Slides
* @package app\admin\model\system
* @author 李玉坤
* @date 2021-02-15 23:22
*/
class Slides extends Model
{
}

View File

@ -1,50 +0,0 @@
<?php
namespace app\index\model;
use think\Model;
/**
* Class UrlLog
* @package app\index\model
* @author 李玉坤
* @date 2021-05-09 23:04
*/
class UrlLog extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
/**
* url访问记录
* @author 李玉坤
* @date 2021-05-09 23:40
*/
public function addLog($title){
$model = new self();
$date_data = date("Y-m-d");
//获取url
$urlInfo = request()->url(true);
//根据url和date字段判断数据库中是否存在该页面的记录
$url_data = $model->where('date',$date_data)
->where('url',$urlInfo)
->field('id')
->find();
if ($url_data) {
$model->where('id',$url_data['id'])->inc('pv')->update();
} else {
$dataUrl = [
'url' => $urlInfo,
'pv' => 1,
'title' => $title,
'date' => $date_data
];
$model->save($dataUrl);
}
}
}

View File

@ -1,51 +0,0 @@
<?php
namespace app\index\model;
use think\facade\Db;
use think\Model;
/**
* Class UvLog
* @package app\index\model
* @author 李玉坤
* @date 2021-05-09 23:27
*/
class UvLog extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
/**
* 增加pv信息
* @author 李玉坤
* @date 2021-05-09 23:31
*/
public function addLog(){
$model = new self();
//uv表
//获取ip
$date_data = date("Y-m-d");
$hour = date('H');
$ipData = request()->ip();
//查询该ip今天是否存在过
$uvInfo = $model->where('date',$date_data)
->where('ip',$ipData)
->field('id')
->find();
//不存在 添加数据
if (!$uvInfo) {
$uvData = [
'ip' => $ipData,
'time' => $hour,
'date' => $date_data
];
$model->save($uvData);
}
}
}

View File

@ -4,7 +4,10 @@
// +----------------------------------------------------------------------
return [
//应用调试模式
'app_debug' => env('app_debug', false),
// 应用Trace调试
'app_trace' => env('app_debug', false),
// 应用地址
'app_host' => env('app.host', ''),
// 应用的命名空间
@ -15,6 +18,8 @@ return [
'with_event' => true,
// 默认应用
'default_app' => 'index',
// 开启应用快速访问
'app_express' => true,
// 默认时区
'default_timezone' => 'Asia/Shanghai',
// 快捷访问
@ -22,14 +27,17 @@ return [
// 自动多应用模式
'auto_multi_app' => true,
// 应用映射(自动多应用模式有效)
'app_map' => ['*'=>'', 'api'=>'api', 'admin'=>'admin', 'index'=>'index'],
'app_map' => ['*'=>'', 'admin'=>'admin', 'index'=>'index'],
// 域名绑定(自动多应用模式有效)
'domain_bind' => [],
// 禁止URL访问的应用列表自动多应用模式有效
'deny_app_list' => [],
'deny_app_list' => ['common','addons'],
// 异常页面的模板文件
'exception_tmpl' => app()->getThinkPath() . 'tpl/think_exception.tpl',
// 默认跳转页面对应的模板文件
'dispatch_success_tmpl' => root_path(). 'extend/tpl/dispatch_jump.tpl',
'dispatch_error_tmpl' => root_path(). 'extend/tpl/dispatch_jump.tpl',
// 错误显示信息,非调试模式有效
'error_message' => '页面错误!请稍后再试~',

View File

@ -57,7 +57,7 @@
</style>
<div class="index-top-postcard-plane">
<div class="index-top-postcard-body">
{zz:list pagesize="4" typeid="2"}
{zz:list orderby="create_time desc"}
<div class="index-top-postcard-item">
<div class="index-top-postcard-main">
<div class="post-item-thumbnail">
@ -81,7 +81,7 @@
</div>
</div>
<ul class="post-list">
{zz:arclist pagesize="3" typeid="$cid" type="find" orderby="create_time desc"}
{zz:list orderby="create_time desc"}
<li class="post-item ">
<div class="post-item-container">
<div class="post-item-thumbnail">