123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- <?php
- /**
- * 易优CMS
- * ============================================================================
- * 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
- * 网站地址: http://www.eyoucms.com
- * ----------------------------------------------------------------------------
- * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
- * ============================================================================
- * Author: 小虎哥 <1105415366@qq.com>
- * Date: 2018-4-3
- */
-
- namespace app\api\controller;
-
- use \think\Db;
- use Overtrue\Pinyin\Pinyin;
- use app\api\logic\Sqldata;
-
- class Mapbuild extends Base
- {
- /*
- * 初始化操作
- */
-
- public function _initialize() {
- parent::_initialize();
- session('user'); // 哪里用到 session_id() , 哪个文件就加上这行代码
- }
-
-
- /*
- * 地图url分组
- * https://www.zc10000.com/api/mapbuild/catIndex
- */
- public function catIndex()
- {
-
- $data = [
- '主页',
- '申报资讯列表页',
- '申报资讯详情页',
- '评审政策列表页',
- '评审政策详情页',
- '评审政策 区域 列表页',
- '评审政策 区域 列表页 分页',
- '评审政策 区域 详情页',
- '业绩材料列表页',
- '业绩材料详情页',
- '标签页列表页',
- '标签页列表页分页'
- ];
- foreach ($data as $key => $row){
- $insert['gid'] = $key;
- $insert['name'] = $row;
- $one = Db::name('all_name')->where('gid','=',$key)->find();
- if(!empty($one)){
- Db::name('all_name')->where('gid','=',$key)->update($insert);
- }else{
- Db::name('all_name')->insert($insert);
- }
- }
- /*
- * 查询sql
- *
- */
- $sql = "select a.group_id,(SELECT b.name FROM ey_all_name b WHERE b.gid = a.group_id) AS group_name,a.url, date_format(a.update_time,'%Y-%m-%d %H:%i:%s') AS 更新时间, CASE
- WHEN a.is_del = 0 THEN ''
- ELSE '文档已删除'
- END AS 是否删除,CASE
- WHEN a.is_null = 0 THEN ''
- ELSE '列表数据为空'
- END AS 列表是否为空,CASE
- WHEN a.is_arcrank = 0 THEN ''
- ELSE '文档审核中'
- END AS 文档是否审核,CASE
- WHEN a.is_status = 0 THEN ''
- ELSE '屏蔽中'
- END AS 正常或者屏蔽 from ey_all_url a order by a.group_id asc";
-
- }
-
- /*
- * 生成百度地图
- * https://www.zc10000.com/api/mapbuild/index100?type=xml
- * https://www.zc10000.com/api/mapbuild/index100?type=txt
- * https://www.zc10000.com/api/mapbuild/index100?type=html
- *
- */
- public function index100(){
-
- $Sqldata = new Sqldata();
- //$aid = $Sqldata->index();
- //var_dump($aid);die;
-
- /*
- * 可对比系统的xml生成
- * 地图文档开头输出
- */
- $type = request()->get('type','xml');
- $data = '';
- switch ($type) {
- case 'xml':
- header('Content-type: text/xml');
- $data = new \XMLWriter();
- $data->openMemory();
- $data->startDocument('1.0', 'UTF-8');
- $data->startElement('urlset');
- $data->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
- $data->writeAttribute('xmlns:mobile', 'http://www.google.com/schemas/sitemap-mobile/1.0');
-
- break;
- case 'txt':
- $data = '';
- break;
- case 'html':
- //var_dump("444");
- $data = $Sqldata->gethtml();
- break;
- default:
- // 如果没有匹配的值
- }
-
- /*
- * 方法1 获取主页
- */
- $data = $Sqldata->add_1($type,$data);
-
-
- /*
- * 方法2 生成其他数据
- * 根据具体场景生成 组id
- */
-
- //申报资讯列表页
- $list = $Sqldata->get_url_list('zx',1231,12);
- $data = $Sqldata->add_2($type,$data,$list,1,0,'hourly','0.9',0);
-
- //申报资讯详情页
- $list = $Sqldata->get_url_detail('zx',1231,2);
- $data = $Sqldata->add_2($type,$data,$list,2,0,'hourly','0.8',0);
-
- //评审政策列表页
- $list = $Sqldata->get_url_list('zc',1232,12);
- $data = $Sqldata->add_2($type,$data,$list,3,0,'hourly','0.9',0);
-
-
-
-
- //评审政策详情页
- $list = $Sqldata->get_url_detail('zc/',1232,2);
- $data = $Sqldata->add_2($type,$data,$list,4,0,'hourly','0.8',0);
-
- //评审政策 区域 列表页
- $list = $Sqldata->get_cat_area_list('zc',1232,12);
- $data = $Sqldata->add_2($type,$data,$list,5,1,'hourly','0.9',1);
-
- //评审政策 区域 列表页 分页
- $list = $Sqldata->get_cat_area_list_page('zc',1232,12);
- $data = $Sqldata->add_2($type,$data,$list,6,0,'hourly','0.9',0);
-
- //评审政策 区域 详情页
- $list = $Sqldata->get_url_area_detail('zc',1232,2);
- $data = $Sqldata->add_2($type,$data,$list,7,0,'hourly','0.8',0);
-
-
- //业绩材料列表页
- $list = $Sqldata->get_url_list('cl',1233,12);
- $data = $Sqldata->add_2($type,$data,$list,8,0,'hourly','0.9',0);
-
- //业绩材料详情页
- $list = $Sqldata->get_url_detail('cl/',1233,2);
- $data = $Sqldata->add_2($type,$data,$list,9,0,'hourly','0.8',0);
-
-
- //标签页列表页 不需要标签页主页和分页
- $list = $Sqldata->get_tag_list();
- $data = $Sqldata->add_2($type,$data,$list,10,0,'hourly','0.9',0);
-
- //标签页列表页 分页
- $list = $Sqldata->get_tag_list_page('tag',12);
- $data = $Sqldata->add_2($type,$data,$list,11,0,'hourly','0.9',0);
-
-
- //地图文档结尾输出
- switch ($type) {
- case 'xml':
- // ... 添加其他页面的URL
- $data->endElement();
- $data->endDocument();
- //var_dump($xmlWriter->outputMemory(true));
- file_put_contents('./sitemap.xml', $data->outputMemory(true));
- break;
- case 'txt':
- file_put_contents('./sitemap.txt',$data);
- break;
- case 'html':
-
- $data .= $Sqldata->gethtmlend();
-
- //./sitemaps/sitemap.html
- file_put_contents('./sitemap.html',$data);
- break;
- default:
- // 如果没有匹配的值
- }
- return json([]);
- }
-
-
- /*
- * 以下都是获取链接的方法
- * 有共性 有差异
- */
-
- }
|