diff --git a/app/admin/controller/nk/Village.php b/app/admin/controller/nk/Village.php new file mode 100644 index 0000000..9f62a8f --- /dev/null +++ b/app/admin/controller/nk/Village.php @@ -0,0 +1,136 @@ +adminInfo = get_login_admin(); + $this->url=[ + '/admin/nk.village/index', + '/admin/nk.village/add', + '/admin/nk.village/edit', + '/admin/nk.village/del', + '/admin/nk.village/read', + ]; + } + /** + * 查看 + */ + public function index() + { + if (request()->isAjax()) { + $params= get_params(); + $where[]=['status','=',1]; + if (isset($params['keywords'])){ + $where[]=['title','like','%'.$params['keywords'].'%']; + } + $total = Db::table('fa_szxc_village') + ->where($where)->count(); + $list = Db::table('fa_szxc_village') + ->withAttr('is_hot',function ($value,$data){ + return $value==1?'是':'否'; + }) + ->withAttr('is_tourism',function ($value,$data){ + return $value==1?'是':'否'; + }) + ->where($where) + ->page($params['page']) + ->limit($params['limit']) + ->order('id desc') + ->select(); + $result = ['total' => $total, 'data' => $list]; + return table_assign(0, '', $result); + } + View::assign('url', $this->url); + return view(); + } + /** + * 添加 + */ + public function add() + { + if (request()->isAjax()) { + $params= get_params(); + if ($params['is_hot']=='on'){ + $params['is_hot']=1; + }else{ + $params['is_hot']=0; + } + if ($params['is_tourism']=='on'){ + $params['is_tourism']=1; + }else{ + $params['is_tourism']=0; + } + $res=Db::table('fa_szxc_village')->strict(false)->field(true)->insertGetId($params); + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + return to_assign(1, '操作失败,原因:'.$res); + }else{ + View::assign('editor', get_system_config('other','editor')); + View::assign('url', $this->url); + return view(); + } + } + /** + * 修改 + */ + public function edit() + { + $params= get_params(); + if (request()->isAjax()) { + $res=Db::table('fa_szxc_village')->where('id',$params['id'])->strict(false)->field(true)->update($params); + if ($res){ + return to_assign(); + }else{ + return to_assign(1, '操作失败,原因:'.$res); + } + } + $detail = Db::table('fa_szxc_village')->where('id',$params['id'])->find(); + + View::assign('detail', $detail); + View::assign('url', $this->url); + return view(); + } + /** + * 查看信息 + */ + public function read() + { + $params = get_params(); + $detail = Db::table('fa_szxc_village')->where('id',$params['id'])->find(); + View::assign('url', $this->url); + View::assign('detail', $detail); + return view(); + + } + /** + * 修改 + */ + public function del() + { + $param= get_params(); + $id = isset($param['id']) ? $param['id'] : 0; + $type = isset($param['type']) ? $param['type'] : 0; + $res = Db::table('fa_szxc_village')->where('id',$id)->update(['status'=>$type]); + if ($res){ + return to_assign(); + }else{ + return to_assign(1, '操作失败,原因:'.$res); + } + } +} \ No newline at end of file diff --git a/app/admin/view/nk/village/add.html b/app/admin/view/nk/village/add.html new file mode 100644 index 0000000..984e78e --- /dev/null +++ b/app/admin/view/nk/village/add.html @@ -0,0 +1,124 @@ +{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/village/edit.html b/app/admin/view/nk/village/edit.html new file mode 100644 index 0000000..99328b9 --- /dev/null +++ b/app/admin/view/nk/village/edit.html @@ -0,0 +1,122 @@ +{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/village/index.html b/app/admin/view/nk/village/index.html new file mode 100644 index 0000000..8d66918 --- /dev/null +++ b/app/admin/view/nk/village/index.html @@ -0,0 +1,152 @@ +{extend name="common/base"/} + +{block name="body"} + +标题* | +{$detail.title} | +||||||
人数* | +{$detail.people_num} | +标签(多选)* | ++ + + | +||||
简介 | ++ {$detail.info} + | +缩略图 | +
+
+
+
+
+
+ |
+ ||||
文章内容 | +|||||||
+ {$detail.introduce|raw} + | +