diff --git a/application/admincpp/common.php b/application/admincpp/common.php new file mode 100644 index 0000000..6fd199e --- /dev/null +++ b/application/admincpp/common.php @@ -0,0 +1 @@ +redirect('login/index'); + return $this->error('您还未登录',url('Login/logoutJump')); + //Response::create(['status' => '0','msg'=> '还未登录,验证失败'], 'json')->send(); + exit; + }else{ + //登录信息超时 + $log_time=session('admincpp_user_login_time')-time(); + if($log_time < 0){ + Session::clear(); + //Response::create(['status' => '0','msg'=> '登录超时,需重新登陆'], 'json')->send(); + return $this->error('登录超时',url('Login/logoutJump')); + exit; + } + } + } + //简单的token生成函数 + /* protected function create_token() + { + $str = md5(uniqid(md5(microtime(true)), true)); //生成一个不会重复的字符串 + $str = sha1($str); //加密 + return $str; + } + //验证Token + public function checkToken($token) + { + $user = Db::name('user')->where('token', $token)->find(); + if (empty($user)) { + return ['status'=>0,'msg'=>'token错误,验证失败']; + }else{ + if (time() - $user['time_out'] > 0) { + return ['status'=>0,'msg'=>'token长时间未使用而过期,需重新登陆']; + } + return ['status'=>1,'msg'=>'成功!','data'=>$user]; + } + } + //通过分组id获取分组名称 + public function getGroupName($id){ + $res = Db::name('group')->field('group_name')->where('group_id',$id)->find(); + if($res){ + return $res['group_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'分组匹配不到']); + return ''; + } + } + //通过城市id获取城市名称 + public function getCityName($id){ + $res = Db::name('city')->field('city_name')->where('city_id',$id)->find(); + if($res){ + return $res['city_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'城市匹配不到']); + return ''; + } + } + //通过工厂id获取工厂名称 + public function getFirmName($id){ + $res = Db::name('firm')->field('firm_name')->where('firm_id',$id)->find(); + if($res){ + return $res['firm_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'工厂匹配不到']); + return ''; + } + } + //通过品牌id获取品牌名称 + public function getBrandName($id){ + $res = Db::name('brand')->field('brand_name')->where('brand_id',$id)->find(); + if($res){ + return $res['brand_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'品牌匹配不到']); + return ''; + } + } + //通过代理商id获取代理商名称 + public function getVenderName($id){ + $res = Db::name('vender')->field('vender_name')->where('vender_id',$id)->find(); + if($res){ + return $res['vender_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'代理商匹配不到']); + return ''; + } + } + //通过角色id获取角色名称 + public function getRoleName($id){ + $res = Db::name('role')->field('role_name')->where('role_id',$id)->find(); + if($res){ + return $res['role_name']; + }else{ + // return json_encode(['status'=>0,'msg'=>'角色匹配不到']); + return ''; + } + }*/ +} diff --git a/application/admincpp/config.php b/application/admincpp/config.php new file mode 100644 index 0000000..d36ae2b --- /dev/null +++ b/application/admincpp/config.php @@ -0,0 +1,5 @@ +view->fetch("dashboard/index"); + } + + public function getStatistics() + { + try { + $userCount = Db::name("wechat_user")->count(); + $todayUserCount = Db::name("wechat_user") + ->where("create_time", ">=", date("Y-m-d") . " 00:00:00") + ->count(); + $recordCount = Db::name("cpp_calculate_record")->count(); + $infoCount = Db::name("wechat_real_time_info")->count(); + $lastCalculate = Db::name("cpp_calculate_record") + ->order("create_time desc")->value("create_time"); + + return json([ + "status" => 1, + "data" => [ + "user_count" => $userCount, + "today_user_count" => $todayUserCount, + "total_calculate_count" => $recordCount, + "info_count" => $infoCount, + "last_calculate_time" => $lastCalculate ?: "暂无", + ] + ]); + } catch (\Exception $e) { + return json(["status" => 0, "msg" => $e->getMessage()]); + } + } +} diff --git a/application/admincpp/controller/Files.php b/application/admincpp/controller/Files.php new file mode 100644 index 0000000..04564e3 --- /dev/null +++ b/application/admincpp/controller/Files.php @@ -0,0 +1,118 @@ +"-1","error"=>"图片不能为空")); + exit; + } + $type = strtolower(substr(strrchr($name, '.'), 1)); //获取文件类型 + + if (!in_array($type, $typeArr)) { + return json(array("status"=>"-1","error"=>"请上传jpg,png,或jpeg类型的文件!"));//mov,webm + exit; + } + if ($size > (2 * 1024 * 1024)) { + return json(array("status"=>"-1","error"=>"文件大小已超过2MB!")); + exit; + } + + /* if($_GET['type'] == 'cx'){ + $imageType = 'cx'; + }*/ + $imageType=''; + $pic_name = $imageType.time() . rand(10000, 99999) . "." . $type;//图片名称 + $pic_url =$path . $pic_name;//上传后图片路径+名称 + + if (move_uploaded_file($name_tmp, $pic_url)) { //临时文件转移到目标文件夹 + /* $_POST['name'] = $pic_name; + $_POST['topic'] = $imageType; + $_POST['albumPath'] = $pic_url;*/ + return json(array("status"=>"0","file_name"=>$pic_name,"file_path"=>$request->domain().'/'.$pic_url)); + die(); + } else { + return json(array("status"=>"-1","error"=>"上传有误,请检查服务器配置!")); + die(); + } + }else{ + return json(array("status"=>"-1","error"=>"系统错误!")); + die(); + } + } + /** + *上传视频 + */ + public function uploadVideo(Request $request){ + $typeArr = array("mp4","wkv");//官方推荐 mp4 + $path = "uploadnv/" . date('Y/m/d/');//上传路径 + if(!file_exists($path)){ + //创建文件 + mkdir($path,0777,true); + } + // if ($_FILES) { + $name = $_FILES['file']['name']; + $size = $_FILES['file']['size']; + $name_tmp = $_FILES['file']['tmp_name']; + if (empty($name)) { + // return json_encode(['status'=>0,'msg'=>'查询失败']); + echo json_encode(array("error"=>"您还未选择文件")); + exit; + } + $type = strtolower(substr(strrchr($name, '.'), 1)); //获取文件类型 + + if (!in_array($type, $typeArr)) { + echo json_encode(array("error"=>"请上传mp4,wkv类型的文件!"));//mov,webm + exit; + } + if ($size > (15 * 1024 * 1024)) { + echo json_encode(array("error"=>"文件大小已超过30MB!")); + exit; + } + + /* if($_GET['type'] == 'cx'){ + $imageType = 'cx'; + }*/ + $imageType=''; + $pic_name = $imageType.time() . rand(10000, 99999) . "." . $type;//图片名称 + $pic_url =$path . $pic_name;//上传后图片路径+名称 + + if (move_uploaded_file($name_tmp, $pic_url)) { //临时文件转移到目标文件夹 + /* $_POST['name'] = $pic_name; + $_POST['topic'] = $imageType; + $_POST['albumPath'] = $pic_url;*/ + echo json_encode(array("status"=>"0","file_name"=>$pic_name,"file_path"=>$request->domain().'/'.$pic_url)); + die(); + } else { + echo json_encode(array("error"=>"上传有误,请检查服务器配置!")); + die(); + } + //} + } +} diff --git a/application/admincpp/controller/Index.php b/application/admincpp/controller/Index.php new file mode 100644 index 0000000..4770459 --- /dev/null +++ b/application/admincpp/controller/Index.php @@ -0,0 +1,196 @@ +send(); + exit; + } + } + /** + * 获取菜单列表 + * @author hjc + * @date 2024-05-14 + */ + public function getMenuList(Request $request){ + $data=$request->param(); + // $this->checkToken($data['Token']); + //升序获取菜单列表 + $result = Db::name('menu') + ->field('id,pid,menu_name,url,seq_on,menu_icon') + ->order('seq_on') + ->select(); + //找二级菜单 + $second=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + //二级 + $second[]=$value; + unset($result[$key]); + } + } + //二级组装到一级 + $result=array_values($result); + foreach ($result as $key => $value) { + $result[$key]['type']=1; + $result[$key]['No']=$key+1; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + $v['type']=2; + $result[$key]['children'][]=$v; + } + } + } + if($result){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + /** + * 权限菜单列表 + * @author hjc + * @date 2024-05-14 + */ + public function getPermissionMenu(Request $request){ + $data=$request->param(); + //$this->checkToken($data['Token']); + //升序获取菜单列表 + $result=Db::name('menu')->field('id,pid,menu_name,url,seq_on,menu_icon')->order('seq_on')->select(); + //找二级三级菜单 + $second=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + $second[]=$value; + unset($result[$key]); + } + } + //二级组装到一级 + foreach ($result as $key => $value) { + $result[$key]['type']=1; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + $v['type']=2; + $result[$key]['second'][]=$v; + } + } + } + if($result){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + + public function getMenuOption(Request $request){ + $data=$request->param(); + // $this->checkToken($data['Token']); + //升序获取菜单列表 + $result = Db::name('menu') + ->field('id,pid,menu_name') + //->where('status',0) + ->order('seq_on') + ->select(); + //找二级三级菜单 + $second=[]; + // $third=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + //二级 + $second[$key]['value']=$value['id']; + $second[$key]['label']=$value['menu_name']; + $second[$key]['pid']=$value['pid']; + unset($result[$key]); + } + } + //二级组装到一级 + $first=[]; + foreach ($result as $key => $value) { + $first[$key]['value']=$value['id']; + $first[$key]['label']=$value['menu_name']; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + unset($v['pid']); + $first[$key]['children'][]=$v; + } + } + } + if($first){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$first]); + } + //获取当前菜单最大序号 + public function getMaxSeq($map){ + $result=Db::name('menu')->field('seq_on')->where($map)->order('seq_on','desc')->find(); + if($result){ + return $result['seq_on']+1; + }else{ + return 1; + } + } + //添加菜单 + public function doaddMenu(Request $request){ + //获取一下表单提交的数据,并保存在变量中 + $data=$request->param(); + // $this->checkToken($data['Token']); + unset($data['Token']); + $menu_id=md5(uniqid(''));//一级菜单id + $create_time=date('Y-m-d H:i:s');//插入时间 + $data1=[]; + //添加一级菜单 + if(empty($data['father'])){ + $map['pid']=''; + }else{ + $map['pid']=$data['father']; + } + //获取一级菜单最大序号 + $seq_on=$this->getMaxSeq($map); + $data1=$map; + if(!empty($data['urs'])){ + $data1['url']=$data['url']; + } + if(!empty($data['menu_icon'])){ + $data1['menu_icon']=$data['menu_icon']; + } + $data1['id']=$menu_id; + $data1['menu_name']=$data['title']; + $data1['seq_on']=$seq_on; + $data1['create_time']=$create_time; + $res=Db::name('menu')->insert($data1); + if($res){ + $status=1; + $msg='添加菜单成功!!'; + }else{ + $status=0; + $msg='添加菜单失败!!'; + } + return json_encode(['status'=>$status,'msg'=>$msg]); + } +} diff --git a/application/admincpp/controller/Login.php b/application/admincpp/controller/Login.php new file mode 100644 index 0000000..a06e815 --- /dev/null +++ b/application/admincpp/controller/Login.php @@ -0,0 +1,92 @@ +view->fetch('login'); + }else{ + //登录信息超时 + $log_time=session('admincpp_user_login_time')-time(); + if($log_time < 0){ + return $this->view->fetch('login'); + } + } + return $this->view->fetch('nav'); + } + /** + * 验证用户身份. + * + * @return \think\Response + */ + public function login(Request $request) + { + //判断是否是post方法发送的数据:如果是则开始登陆 + if(Request::instance()->isPost()){ + $user_name=Request::instance()->param("username"); + $password=Request::instance()->param('password'); + if(empty($user_name) || empty($password)){ + $result=['status'=>0,'msg'=>'用户名或密码为空']; + return json($result); + } + //数据查询 + $infor=Db::name("user") + ->field('id,user_name,user_head') + ->where('phone',$user_name) + ->where('password',md5($password)) + ->where("status",1) + ->where('type',1) + ->find(); + if(empty($infor)){ + $result=['status'=>0,'msg'=>'用户不存在或密码不正确']; + }else{ + //Session::set('admin_user_type',$infor['role_id']); + Session::set('admincpp_user_id',$infor['id']); + //Session::set('admin_mechanism_id',$infor['mechanism_id']); + $time_out=time()+3600; + Session::set('admincpp_user_login_time',$time_out); + $result=['status'=>1,'msg'=>'登录成功','token'=>1]; + } + return json($result); + } + //如果不是post,则返回登陆界面 + else{ + $result=['status'=>0,'msg'=>'未获取到参数']; + return json($result); + } + } + /** + * 退出登录 + * + * @param \think\Request $request + * @return \think\Response + */ + public function logout(Request $request) + { + Session::clear(); + return json(['status'=>1,'msg'=>'退出成功']); + } + /** + * 超时登录推出跳转页面 + * + * @param \think\Request $request + * @return \think\Response + */ + public function logoutJump(Request $request) + { + return $this->view->fetch('logoutJump'); + } +} diff --git a/application/admincpp/controller/Menu.php b/application/admincpp/controller/Menu.php new file mode 100644 index 0000000..2d9dc63 --- /dev/null +++ b/application/admincpp/controller/Menu.php @@ -0,0 +1,326 @@ +send(); + exit; + }*/ + } + public function index() + { + // $this->alreadyLogin(); + return $this->view->fetch('index'); + } + public function nav() + { + // $this->alreadyLogin(); + return $this->view->fetch('nav'); + } + public function getUserInfor(){ + $data=Db::name("user") + ->field('user_name,user_head') + // admincpp 模块登录写入的是 admincpp_user_id(否则这里会变成 id IS NULL) + ->where('id',session('admincpp_user_id')) + ->find(); + $result=['status'=>1,'msg'=>'查询成功','infro'=>$data]; + return json($result); + } + /** + * 获取菜单列表 + * @author hjc + * @date 2024-05-14 + */ + public function getMenuList(Request $request){ + $data=$request->param(); + // $this->checkToken($data['Token']); + //升序获取菜单列表 + $result = Db::name('menu') + ->field('id,pid,menu_name,url,seq_on,menu_icon') + ->order('seq_on') + ->select(); + //找二级菜单 + $second=[]; + foreach ($result as $key => $value) { + if($value['pid'] != '' && $value['pid'] != 0){ + //二级 + $value['grade']="二级菜单"; + $second[]=$value; + unset($result[$key]); + }else{ + $result[$key]['grade']="一级菜单"; + } + } + //二级组装到一级 + $result=array_values($result); + foreach ($result as $key => $value) { + $result[$key]['type']=1; + $result[$key]['No']=$key+1; + foreach ($second as $k => $v) { + if($value['id']==$v['pid']){ + $v['type']=2; + $result[$key]['children'][]=$v; + } + } + } + if($result){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + /** + * 权限菜单列表 + * @author hjc + * @date 2024-05-14 + */ + public function getPermissionMenu(Request $request){ + $data=$request->param(); + //$this->checkToken($data['Token']); + //升序获取菜单列表 + $result=Db::name('menu')->field('id,pid,menu_name,url,seq_on,menu_icon')->order('seq_on')->select(); + //找二级三级菜单 + $second=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + $second[]=$value; + unset($result[$key]); + } + } + //二级组装到一级 + foreach ($result as $key => $value) { + $result[$key]['type']=1; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + $v['type']=2; + $result[$key]['second'][]=$v; + } + } + } + if($result){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + + public function getMenuOption(Request $request){ + $data=$request->param(); + // $this->checkToken($data['Token']); + //升序获取菜单列表 + $result = Db::name('menu') + ->field('id,pid,menu_name') + //->where('status',0) + ->order('seq_on') + ->select(); + //找二级三级菜单 + $second=[]; + // $third=[]; + foreach ($result as $key => $value) { + if($value['pid'] != ''){ + //二级 + $second[$key]['value']=$value['id']; + $second[$key]['label']=$value['menu_name']; + $second[$key]['pid']=$value['pid']; + unset($result[$key]); + } + } + //二级组装到一级 + $first=[]; + foreach ($result as $key => $value) { + $first[$key]['value']=$value['id']; + $first[$key]['label']=$value['menu_name']; + foreach ($second as $k => $v) { + if($value['menu_id']==$v['pid']){ + unset($v['pid']); + $first[$key]['children'][]=$v; + } + } + } + if($first){ + $status=1; + $msg="获取数据成功!!"; + } + else{ + $status=0; + $msg="获取数据失败!!"; + } + return json(['status'=>$status,'msg'=>$msg,'data'=>$first]); + } + //获取当前菜单最大序号 + public function getMaxSeq($map){ + $result=Db::name('menu')->field('seq_on')->where($map)->order('seq_on','desc')->find(); + if($result){ + return $result['seq_on']+1; + }else{ + return 1; + } + } + //添加菜单 + public function doaddMenu(Request $request){ + //获取一下表单提交的数据,并保存在变量中 + $data=$request->param(); + // $this->checkToken($data['Token']); + unset($data['Token']); + $menu_id=md5(uniqid(''));//一级菜单id + $create_time=date('Y-m-d H:i:s');//插入时间 + $data1=[]; + //添加一级菜单 + if(empty($data['father'])){ + $map['pid']=''; + }else{ + $map['pid']=$data['father']; + } + //获取一级菜单最大序号 + $seq_on=$this->getMaxSeq($map); + $data1=$map; + if(!empty($data['urs'])){ + $data1['url']=$data['url']; + } + if(!empty($data['menu_icon'])){ + $data1['menu_icon']=$data['menu_icon']; + } + $data1['id']=$menu_id; + $data1['menu_name']=$data['title']; + $data1['seq_on']=$seq_on; + $data1['create_time']=$create_time; + $res=Db::name('menu')->insert($data1); + if($res){ + $status=1; + $msg='添加菜单成功!!'; + }else{ + $status=0; + $msg='添加菜单失败!!'; + } + return json(['status'=>$status,'msg'=>$msg]); + } + /** + * 修改菜单详情 + * @param $data 菜单id(一级菜单、二级菜单) + * @param $data 菜单详情 + * @author hjc + * @date 2024-05-14 + */ + public function updMenu(Request $request){ + $data=$request->param(); + $result=Db::name('menu')->field('id,pid,menu_name,url,menu_icon')->where('menu_id',$data['menu_id'])->find(); + $result['type']=1; + if(!empty($result['pid'])){ + $result['type']=2; + $result['father']=$result['pid']; + } + unset($result['pid']); + if($result){ + $status=1; + $msg="获取数据成功!!"; + }else{ + $status=0; + $msg="获取数据失败!!"; + } + return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$result]); + } + public function doupdMenu(Request $request){ + $data=$request->param(); + $data1=[]; + //添加一级菜单 + if(empty($data['father'])){ + $data1['pid']=''; + if(!empty($data['menu_icon'])){ + $data1['menu_icon']=$data['menu_icon']; + } + }else{ + $data1['pid']=$data['father']; + //获取一级菜单最大序号 + if(!empty($data['url'])){ + $data1['url']=$data['url']; + } + } + $data1['menu_name']=$data['menu_name']; + $res=Db::name('menu')->where('id',$data['id'])->update($data1); + if($res){ + $status=1; + $msg='修改菜单成功!!'; + }else{ + $status=0; + $msg='修改菜单失败!!'; + } + return json_encode(['status'=>$status,'msg'=>$msg]); + } + /** + * 设置菜单状态 + * @param $data 一级菜单id、二级菜单id + * @author hjc + * @date 2024-05-14 + */ + public function setMenuStatus(Request $request){ + $data=$request->param(); + $this->checkToken($data['Token']); + $res=Db::name('menu')->where('id',$data['id'])->update(['status'=>$data['status']]); + if($res){ + $status=1; + $msg='设置成功!!'; + }else{ + $status=0; + $msg='设置失败!!'; + } + return json_encode(['status'=>$status,'msg'=>$msg]); + } + /** + * 删除菜单 + * @param $data 一级菜单id、二级菜单id + *@author hjc + * @date 2024-05-14 + */ + public function delMenu(Request $request){ + $data=$request->param(); + $res=Db::name('menu')->where('id',$data['id'])->find(); + //一级菜单 + if($res['pid']==''){ + $map1['id|pid']=$data['id']; + $map2['id']=['in',[$data['id'],$res['pid']]]; + }else{ + $map1['id']=$data['id']; + $map2['id']=$data['id']; + } + // 启动事务 + Db::startTrans(); + try{ + //删除二级菜单 + Db::name('menu')->where($map1)->delete(); + // Db::table('t_nv_role_menu')->where($map2)->delete(); + // 提交事务 + Db::commit(); + $status=1; + $msg='删除菜单成功!!'; + } catch (\Exception $e) { + Log::record($e->getMessage(),'error'); + // 回滚事务 + Db::rollback(); + $status=0; + $msg='删除菜单失败!!'; + } + return json_encode(['status'=>$status,'msg'=>$msg]); + } +} diff --git a/application/admincpp/controller/Wechatinfro.php b/application/admincpp/controller/Wechatinfro.php new file mode 100644 index 0000000..2bf1ac1 --- /dev/null +++ b/application/admincpp/controller/Wechatinfro.php @@ -0,0 +1,106 @@ +view->fetch('userList'); + } + + public function getWechatUserList(Request $request){ + $post=$request->param(); + $page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1; + $page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30; + $where=[]; + if(isset($post['title']) && !empty($post['title'])){ + $where['nickname']=['like','%'.$post['title'].'%']; + } + $res = Db::name('wechat_user') + ->field('uid,nickname,headimg,create_time') + ->where($where) + ->order('create_time desc') + ->paginate($page_size,false,['page'=>$page]); + $lists=$res->items(); + $start=($page-1)*$page_size; + foreach($lists as $k=>$v){ + $start+=1; + $lists[$k]['no_id']=$start; + } + $result['lists'] =$lists; + $result['lastPage'] = $res->lastPage(); + $result['currentPage'] = $res->currentPage(); + $result['erro'] = 0; + $result['msg'] = '查询成功'; + return json($result); + } + + public function wechatRecordList() + { + return $this->view->fetch('wechatRecordList'); + } + + public function getWechatRecordList(Request $request){ + $post=$request->param(); + $page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1; + $page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30; + $where=[]; + if(isset($post['title']) && !empty($post['title'])){ + $where['name']=['like','%'.$post['title'].'%']; + } + $res = Db::name('cpp_calculate_record') + ->field('id,name,bone_age,uterus_length,uterus_width,lh_peak,fsh_peak,fsh_3m,igf1,calculate_result,risk_level,create_time') + ->where($where) + ->order('create_time desc') + ->paginate($page_size,false,['page'=>$page]); + $lists=$res->items(); + $start=($page-1)*$page_size; + foreach($lists as $k=>$v){ + $start+=1; + $lists[$k]['no_id']=$start; + } + $result = array(); + $result['lists'] =$lists; + $result['lastPage'] = $res->lastPage(); + $result['currentPage'] = $res->currentPage(); + $result['erro'] = 0; + $result['msg'] = '查询成功'; + return json($result); + } + + public function feedbackList() + { + return $this->view->fetch('feedbackList'); + } + + public function getFeedbackList(Request $request){ + $post=$request->param(); + $page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1; + $page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30; + $res = Db::name('cpp_feedback') + ->field('id,uid,content,create_time') + ->order('create_time desc') + ->paginate($page_size,false,['page'=>$page]); + $lists=$res->items(); + $start=($page-1)*$page_size; + foreach($lists as $k=>$v){ + $start+=1; + $lists[$k]['no_id']=$start; + } + $result = array(); + $result['lists'] =$lists; + $result['lastPage'] = $res->lastPage(); + $result['currentPage'] = $res->currentPage(); + $result['erro'] = 0; + $result['msg'] = '查询成功'; + return json($result); + } +} diff --git a/application/admincpp/controller/Wechatset.php b/application/admincpp/controller/Wechatset.php new file mode 100644 index 0000000..3875ead --- /dev/null +++ b/application/admincpp/controller/Wechatset.php @@ -0,0 +1,182 @@ +send(); + exit; + }*/ + } + /** + * 小程序资讯信息页面 + */ + public function wechatRealTimeInfo() + { + return $this->view->fetch('realTimeInfo'); + } + /** + * 小程序添加资讯信息页面 + */ + public function wechatRealTimeInfoAdd() + { + return $this->view->fetch('realTimeInfoAdd'); + } + /** + * 小程序添加资讯信息页面 + */ + public function wechatRealTimeInfoUpdate(Request $request) + { + $id=$request->get('id'); + $this->assign('id',$id); + return $this->view->fetch('realTimeInfoUpdate'); + } + /** + * 查询小程序资讯信息 + * @author hjc + * @date 2024-05-14 + */ + public function getWechatRealTimeInfoList(Request $request){ + $post=$request->param(); + + $page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1;//页数 + $page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30;//每页条数 + //搜索 + $where=[]; + if(isset($post['title']) && !empty($post['title'])){ + $where['title_plain']=['like','%'.$post['title'].'%']; + } + //升序获取菜单列表 + $res = Db::name('wechat_real_time_info') + ->field('id,title_plain,thumbnail,excerpt_plain,url,create_time') + ->where($where) + ->order('create_time desc') + ->paginate($page_size,false,['page'=>$page]); + $lists=$res->items(); + $start=($page-1)*$page_size; + foreach($lists as $k=>$v){ + $start+=1; + $lists[$k]['no_id']=$start; + } + $result['lists'] =$lists; + $result['lastPage'] = $res->lastPage();//总页数 + $result['currentPage'] = $res->currentPage();//当前页 +// $result['total'] = $res->total();//数据总条数 + $result['erro'] = 0; + $result['msg'] = '查询成功'; + return json($result); + } + public function wechatRecordList() + { + return $this->view->fetch('wechatRecordList'); + } + /** + * 删除小程序资讯信息 + * @author hjc + * @date 2024-05-14 + */ + public function delWechatRealTimeInfo(Request $request){ + $post=$request->param(); + if(!isset($post['id']) || empty($post['id']) ){ + $result['erro'] = -1; + $result['msg'] = "请选择要删除的记录"; + return json($result); + } + $id=Db::name('wechat_real_time_info')->where('id',$post['id'])->value('id'); + if(empty($id)){ + $result['erro'] = -1; + $result['msg'] = "该记录异常,无法删除"; + return json($result); + } + $res=Db::name('wechat_real_time_info')->where('id',$id)->delete(); + if($res > 0){ + $result['erro'] = 0; + $result['msg'] = '删除成功'; + }else{ + $result['erro'] = -1; + $result['msg'] = '删除失败'; + } + return json($result); + } + /*** + *保存小程序资讯信息 + **/ + public function saveWechatRealTimeInfo(Request $request){ + $post=$request->param(); + + if(!isset($post['title_plain']) || empty($post['title_plain']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入标题"; + return json($result); + } + if(!isset($post['thumbnail']) || empty($post['thumbnail']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入图片"; + return json($result); + } + if(!isset($post['excerpt_plain']) || empty($post['excerpt_plain']) ){ + $result['erro'] = -1; + $result['msg'] = "未传入简介"; + return json($result); + } + if(!isset($post['url']) || empty($post['url'])){ + $result['erro'] = -1; + $result['msg'] = "未传入资讯跳转链接"; + return json($result); + } + //提交数据 + $data=[]; + $data['title_plain']=$post['title_plain'];//标题 + $data['thumbnail']=$post['thumbnail'];//图片 + $data['excerpt_plain']=$post['excerpt_plain'];//介绍 + $data['url']=$post['url'];//跳转连接 + if(isset($post['id']) && !empty($post['id'])){ + //修改数据 + $res=Db::name('wechat_real_time_info')->where('id',$post['id'])->update($data); + }else{ + //保存记录数据 + $data['id']=md5(time().rand(100000,999999)); + $data['create_time']=date('Y-m-d H:i:s'); + $res=Db::name('wechat_real_time_info')->insert($data); + } + if($res===false){ + $result['erro'] = -1; + $result['msg'] = "添加失败"; + return json($result); + }else{ + $result['erro'] = 0; + $result['msg'] = "添加成功"; + return json($result); + } + } + /** + *查询资讯信息详情 + */ + public function getRealTimeInfoDetail(Request $request){ + $post=$request->param(); + if(!isset($post['id']) || empty($post['id'])){ + $result['erro'] = -1; + $result['msg'] = "未传入资讯id"; + return json($result); + } + //修改数据 + $result['infro']=Db::name('wechat_real_time_info')->where('id',$post['id'])->find(); + $result['erro'] = 0; + $result['msg'] = "查询成功"; + return json($result); + } +} diff --git a/application/admincpp/model/Permission.php b/application/admincpp/model/Permission.php new file mode 100644 index 0000000..f4b96bf --- /dev/null +++ b/application/admincpp/model/Permission.php @@ -0,0 +1,11 @@ + + +
+ + + + +