From 5b025e342be546c3a4f03ad21dc67cefc93e6839 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 18 Jan 2023 17:24:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=90=8E=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/nk/Townnews.php | 86 ++++++++++++++ app/admin/controller/nk/Treasure.php | 83 +++++++++++++ app/admin/middleware/Auth.php | 6 +- app/admin/view/nk/article/add.html | 102 ++++++++++++++++ app/admin/view/nk/article/edit.html | 119 +++++++++++++++++++ app/admin/view/nk/article/index.html | 148 ++++++++++++++++++++++++ app/admin/view/nk/article/read.html | 39 +++++++ app/admin/view/party/article/add.html | 102 ++++++++++++++++ app/admin/view/party/article/edit.html | 119 +++++++++++++++++++ app/admin/view/party/article/index.html | 148 ++++++++++++++++++++++++ app/admin/view/party/article/read.html | 39 +++++++ 11 files changed, 989 insertions(+), 2 deletions(-) create mode 100644 app/admin/controller/nk/Townnews.php create mode 100644 app/admin/controller/nk/Treasure.php create mode 100644 app/admin/view/nk/article/add.html create mode 100644 app/admin/view/nk/article/edit.html create mode 100644 app/admin/view/nk/article/index.html create mode 100644 app/admin/view/nk/article/read.html create mode 100644 app/admin/view/party/article/add.html create mode 100644 app/admin/view/party/article/edit.html create mode 100644 app/admin/view/party/article/index.html create mode 100644 app/admin/view/party/article/read.html diff --git a/app/admin/controller/nk/Townnews.php b/app/admin/controller/nk/Townnews.php new file mode 100644 index 0000000..954c92f --- /dev/null +++ b/app/admin/controller/nk/Townnews.php @@ -0,0 +1,86 @@ +adminInfo = get_login_admin(); + $this->category_id=304; + $this->url=[ + '/admin/nk.townnews/index?category_id='.$this->category_id, + '/admin/nk.townnews/add', + '/admin/nk.townnews/edit', + '/admin/nk.townnews/del', + '/admin/nk.townnews/read', + ]; + } + /** + * 查看 + */ + public function index() + { + if (request()->isAjax()) { + $params= get_params(); + $params['category_id']=$this->category_id; + (new Article())->index($params); + } + return view('nk/article/index',['url'=>$this->url]); + } + /** + * 添加 + */ + public function add() + { + if (request()->isAjax()) { + $params= get_params(); + $params['category_id']=$this->category_id; + (new Article())->add($params); + }else{ + View::assign('editor', get_system_config('other','editor')); + View::assign('url', $this->url); + return view('nk/article/add'); + } + } + /** + * 修改 + */ + public function edit() + { + $params= get_params(); + (new Article())->edit($params); + return view('nk/article/edit',['url'=>$this->url]); + } + /** + * 查看信息 + */ + public function read() + { + $params = get_params(); + (new Article())->read($params); + + return view('nk/article/read',['url'=>$this->url]); + + } + /** + * 修改 + */ + public function del() + { + $params= get_params(); + (new Article())->del($params); + } +} \ No newline at end of file diff --git a/app/admin/controller/nk/Treasure.php b/app/admin/controller/nk/Treasure.php new file mode 100644 index 0000000..9e22aad --- /dev/null +++ b/app/admin/controller/nk/Treasure.php @@ -0,0 +1,83 @@ +adminInfo = get_login_admin(); + $this->category_id=305; + $this->url=[ + '/admin/nk.treasure/index?category_id='.$this->category_id, + '/admin/nk.treasure/add', + '/admin/nk.treasure/edit', + '/admin/nk.treasure/del', + '/admin/nk.treasure/read', + ]; + } + /** + * 查看 + */ + public function index() + { + if (request()->isAjax()) { + $params= get_params(); + $params['category_id']=$this->category_id; + (new Article())->index($params); + } + return view('nk/article/index',['url'=>$this->url]); + } + /** + * 添加 + */ + public function add() + { + if (request()->isAjax()) { + $params= get_params(); + $params['category_id']=$this->category_id; + (new Article())->add($params); + }else{ + View::assign('editor', get_system_config('other','editor')); + View::assign('url', $this->url); + return view('nk/article/add'); + } + } + /** + * 修改 + */ + public function edit() + { + $params= get_params(); + (new Article())->edit($params); + return view('nk/article/edit',['url'=>$this->url]); + } + /** + * 查看信息 + */ + public function read() + { + $params = get_params(); + (new Article())->read($params); + + return view('nk/article/read',['url'=>$this->url]); + + } + /** + * 修改 + */ + public function del() + { + $params= get_params(); + (new Article())->del($params); + } +} \ No newline at end of file diff --git a/app/admin/middleware/Auth.php b/app/admin/middleware/Auth.php index 601748b..38678ab 100644 --- a/app/admin/middleware/Auth.php +++ b/app/admin/middleware/Auth.php @@ -19,7 +19,8 @@ class Auth { //获取模块名称 $controller = app('http')->getName(); - $pathInfo = str_replace('.' . $request->ext(), '', $request->pathInfo()); +// $pathInfo = str_replace('.' . $request->ext(), '', $request->pathInfo()); + $pathInfo = str_replace('.html', '', $request->pathInfo()); $action = explode('/', $pathInfo)[0]; //var_dump($pathInfo);exit; if ($pathInfo == '' || $action == '') { @@ -41,6 +42,8 @@ class Auth // 验证用户访问权限 if ($action !== 'index' && $action !== 'api') { if (!$this->checkAuth($controller, $pathInfo, $action, $uid)) { +// $pathUrl = $controller . '/' . $pathInfo; +// halt($pathUrl,Cache::get('RulesSrc' . $uid)); if ($request->isAjax()) { return to_assign(202, '你没有权限,请联系超级管理员!'); } else { @@ -99,7 +102,6 @@ class Auth $auth_list_all = Cache::get('RulesSrc0'); $auth_list = Cache::get('RulesSrc' . $uid); } - $pathUrl = $controller . '/' . $pathInfo; if (!in_array($pathUrl, $auth_list)) { return false; diff --git a/app/admin/view/nk/article/add.html b/app/admin/view/nk/article/add.html new file mode 100644 index 0000000..b2ce05d --- /dev/null +++ b/app/admin/view/nk/article/add.html @@ -0,0 +1,102 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

新建文章

+ + + + + + + + + + + + + + + + + + +
文章标题*
文章摘要 + + 缩略图 +
+ +
+ + +
+
+
文章内容
+ +
+
+ + +
+
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/nk/article/edit.html b/app/admin/view/nk/article/edit.html new file mode 100644 index 0000000..c590db5 --- /dev/null +++ b/app/admin/view/nk/article/edit.html @@ -0,0 +1,119 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

编辑文章表

+ + + + + + + + + + + + + + + + + +
文章标题*
摘要 + + 缩略图 +
+ +
+ + +
+
+
文章内容
+ +
+
+ + + +
+
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/nk/article/index.html b/app/admin/view/nk/article/index.html new file mode 100644 index 0000000..a79a04f --- /dev/null +++ b/app/admin/view/nk/article/index.html @@ -0,0 +1,148 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/nk/article/read.html b/app/admin/view/nk/article/read.html new file mode 100644 index 0000000..5c8280e --- /dev/null +++ b/app/admin/view/nk/article/read.html @@ -0,0 +1,39 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

文章详情

+ + + + + + + + + + + + + + + + + + + + +
文章标题{$detail.title}
创建时间{$detail.view_time}状态 + {eq name="$detail.status" value="1"}正常{/eq} + {eq name="$detail.status" value="0"}下架{/eq} +
文章摘要{$detail.describe}
文章内容 + {$detail.content|raw} +
+
+{/block} + \ No newline at end of file diff --git a/app/admin/view/party/article/add.html b/app/admin/view/party/article/add.html new file mode 100644 index 0000000..4837afa --- /dev/null +++ b/app/admin/view/party/article/add.html @@ -0,0 +1,102 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

新建文章

+ + + + + + + + + + + + + + + + + + +
文章标题*
文章摘要 + + 缩略图 +
+ +
+ + +
+
+
文章内容
+ +
+
+ + +
+
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/party/article/edit.html b/app/admin/view/party/article/edit.html new file mode 100644 index 0000000..ad639cf --- /dev/null +++ b/app/admin/view/party/article/edit.html @@ -0,0 +1,119 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

编辑文章表

+ + + + + + + + + + + + + + + + + +
文章标题*
摘要 + + 缩略图 +
+ +
+ + +
+
+
文章内容
+ +
+
+ + + +
+
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/party/article/index.html b/app/admin/view/party/article/index.html new file mode 100644 index 0000000..780ca51 --- /dev/null +++ b/app/admin/view/party/article/index.html @@ -0,0 +1,148 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/party/article/read.html b/app/admin/view/party/article/read.html new file mode 100644 index 0000000..be0a993 --- /dev/null +++ b/app/admin/view/party/article/read.html @@ -0,0 +1,39 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

文章详情

+ + + + + + + + + + + + + + + + + + + + +
文章标题{$detail.title}
创建时间{$detail.add_time}状态 + {eq name="$detail.status" value="1"}正常{/eq} + {eq name="$detail.status" value="0"}下架{/eq} +
文章摘要{$detail.describe}
文章内容 + {$detail.content|raw} +
+
+{/block} + \ No newline at end of file From 18b77ae556efe635b44ec94d89538f1028f90c42 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 18 Jan 2023 17:25:49 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=90=8E=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/nk/Article.php | 160 ++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 app/admin/controller/nk/Article.php diff --git a/app/admin/controller/nk/Article.php b/app/admin/controller/nk/Article.php new file mode 100644 index 0000000..1fd9f6a --- /dev/null +++ b/app/admin/controller/nk/Article.php @@ -0,0 +1,160 @@ +adminInfo = get_login_admin(); + } + + + public function index($params) + { + $where=[ + 'status'=>1 + ]; + if (isset($params['keywords'])){ + $where[]=['title','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where['village'] = $user_address['village_id']; + }elseif ($user_address['auth_range'] == 2){ + $where['township'] = $user_address['street_id']; + }elseif ($user_address['auth_range'] == 3){ + $where['county'] = $user_address['area_id']; + }else{ + $where['village'] = $user_address['village_id']; + } + }else{ + $where['village'] = ''; + } + } + $category_id =$params['category_id']; + + if($category_id){ + $map[] = ['category_id','in',$category_id]; + }else{ + $map = []; + } + $total = Db::table('fa_article') + ->where($where) + ->where($map) + ->count(); + + $list = Db::table('fa_article') + ->withAttr('nickname',function ($value,$data){ + return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name'); + }) + ->withAttr('area',function ($value,$data){ + return Db::table('fa_geo_area')->where('area_code',$data['county'])->value('area_name'); + }) + ->withAttr('street',function ($value,$data){ + return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name'); + }) + ->withAttr('village',function ($value,$data){ + return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name'); + }) + ->where($where) + ->where($map) + ->page($params['page']) + ->limit($params['limit']) + ->field('id,title,user_id,county,township,village,image,view_time') + + ->select(); + $result = ['total' => $total, 'data' => $list]; + return table_assign(0, '', $result); + + } + + public function add($param){ + // 检验完整性 + try { + validate(\app\admin\validate\party\Article::class)->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find(); + $param['view_time']=date('Y-m-d H:i:s'); + $param['county']=$adds['area_id']; + $param['township']=$adds['street_id']; + $param['village']=$adds['village_id']; + $param['user_id']=$adds['user_id']; + $res=Db::table('fa_article')->strict(false)->field(true)->insertGetId($param); + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + return to_assign(1, '操作失败,原因:'.$res); + } + public function edit($param){ + if (request()->isAjax()) { + try { + validate(\app\admin\validate\party\Article::class)->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $res=Db::table('fa_article')->where('id',$param['id'])->strict(false)->field(true)->update($param); + if ($res){ + return to_assign(); + }else{ + return to_assign(1, '操作失败,原因:'.$res); + } + }else{ + $id = isset($param['id']) ? $param['id'] : 0; + $detail = Db::table('fa_article')->where('id',$id)->find(); + View::assign('editor', get_system_config('other','editor')); + if (!empty($detail)) { + View::assign('detail', $detail); + } + else{ + throw new \think\exception\HttpException(404, '找不到页面'); + } + } + } + /** + * 查看信息 + */ + public function read($param) + { + $id = isset($param['id']) ? $param['id'] : 0; + $detail = Db::table('fa_article')->where('id',$id)->find(); + if (!empty($detail)) { + View::assign('detail', $detail); + } + else{ + throw new \think\exception\HttpException(404, '找不到页面'); + } + } + /** + * 删除 + */ + public function del($param) + { + $id = isset($param['id']) ? $param['id'] : 0; + $type = isset($param['type']) ? $param['type'] : 0; + $res = Db::table('fa_article')->where('id',$id)->update(['status'=>$type]); + if ($res){ + return to_assign(); + }else{ + return to_assign(1, '操作失败,原因:'.$res); + } + } +}