【类 型】:factor
【原 因】:优化了数据库 地图表的结构 删除多余字段 【过 程】:后端接口字段对应修改 【影 响】:
This commit is contained in:
parent
1a0127ca90
commit
48c825951c
@ -1103,7 +1103,7 @@ class PlaneController extends PublicController
|
||||
{
|
||||
$where['is_active'] = 1;
|
||||
$mapStyleDb = D('map_styles');
|
||||
$field = array('id', 'name', 'sprite', 'glyphs', 'version', 'source_name', 'source_type', 'tile_size', 'tiles', 'attribution', 'layer_id', 'layer_type', 'layer_source', 'sort_order');
|
||||
$field = array('id', 'name', 'sprite', 'glyphs', 'tiles', 'sort_order');
|
||||
|
||||
$list = $mapStyleDb->where($where)->field($field)->order('sort_order ASC')->select();
|
||||
if ($list) {
|
||||
@ -1151,9 +1151,8 @@ class PlaneController extends PublicController
|
||||
*/
|
||||
public function addMapStyle()
|
||||
{
|
||||
|
||||
// 必填字段校验
|
||||
$required = ['name', 'version', 'source_name', 'source_type', 'tile_size', 'tiles', 'layer_id', 'layer_type', 'layer_source'];
|
||||
$required = ['name', 'tiles'];
|
||||
foreach ($required as $key) {
|
||||
if (!isset($_REQUEST[$key]) || $_REQUEST[$key] === '') {
|
||||
echo json_encode(['status' => 0, 'msg' => '参数缺失: ' . $key]);
|
||||
@ -1161,22 +1160,14 @@ class PlaneController extends PublicController
|
||||
}
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['name'] = $_REQUEST['name'];
|
||||
$data['sprite'] = isset($_REQUEST['sprite']) ? $_REQUEST['sprite'] : '';
|
||||
$data['glyphs'] = isset($_REQUEST['glyphs']) ? $_REQUEST['glyphs'] : '';
|
||||
$data['version'] = intval($_REQUEST['version']);
|
||||
$data['source_name'] = $_REQUEST['source_name'];
|
||||
$data['source_type'] = $_REQUEST['source_type'];
|
||||
$data['tile_size'] = intval($_REQUEST['tile_size']);
|
||||
// tiles 直接保存为字符串(JSON),getMapStyleList 时再 decode
|
||||
$data['tiles'] = $_REQUEST['tiles'];
|
||||
$data['attribution'] = isset($_REQUEST['attribution']) ? $_REQUEST['attribution'] : '';
|
||||
$data['layer_id'] = $_REQUEST['layer_id'];
|
||||
$data['layer_type'] = $_REQUEST['layer_type'];
|
||||
$data['layer_source'] = $_REQUEST['layer_source'];
|
||||
$data['is_active'] = isset($_REQUEST['is_active']) ? intval($_REQUEST['is_active']) : 1;
|
||||
$data['sort_order'] = isset($_REQUEST['sort_order']) ? intval($_REQUEST['sort_order']) : 0;
|
||||
$data = [
|
||||
'name' => $_REQUEST['name'],
|
||||
'sprite' => $_REQUEST['sprite'] ?? '',
|
||||
'glyphs' => $_REQUEST['glyphs'] ?? 'mapbox://fonts/mapbox/{fontstack}/{range}.pbf',
|
||||
'tiles' => is_array($_REQUEST['tiles']) ? json_encode($_REQUEST['tiles']) : $_REQUEST['tiles'],
|
||||
'is_active' => isset($_REQUEST['is_active']) ? intval($_REQUEST['is_active']) : 1,
|
||||
'sort_order' => isset($_REQUEST['sort_order']) ? intval($_REQUEST['sort_order']) : 0
|
||||
];
|
||||
|
||||
$db = D('map_styles');
|
||||
if ($db->data($data)->add()) {
|
||||
@ -1191,7 +1182,6 @@ class PlaneController extends PublicController
|
||||
*/
|
||||
public function saveMapStyle()
|
||||
{
|
||||
|
||||
if (!isset($_REQUEST['id']) || $_REQUEST['id'] === '') {
|
||||
echo json_encode(['status' => 0, 'msg' => '参数缺失: id']);
|
||||
return;
|
||||
@ -1203,15 +1193,9 @@ class PlaneController extends PublicController
|
||||
if (isset($_REQUEST['name'])) $data['name'] = $_REQUEST['name'];
|
||||
if (isset($_REQUEST['sprite'])) $data['sprite'] = $_REQUEST['sprite'];
|
||||
if (isset($_REQUEST['glyphs'])) $data['glyphs'] = $_REQUEST['glyphs'];
|
||||
if (isset($_REQUEST['version'])) $data['version'] = intval($_REQUEST['version']);
|
||||
if (isset($_REQUEST['source_name'])) $data['source_name'] = $_REQUEST['source_name'];
|
||||
if (isset($_REQUEST['source_type'])) $data['source_type'] = $_REQUEST['source_type'];
|
||||
if (isset($_REQUEST['tile_size'])) $data['tile_size'] = intval($_REQUEST['tile_size']);
|
||||
if (isset($_REQUEST['tiles'])) $data['tiles'] = $_REQUEST['tiles'];
|
||||
if (isset($_REQUEST['attribution'])) $data['attribution'] = $_REQUEST['attribution'];
|
||||
if (isset($_REQUEST['layer_id'])) $data['layer_id'] = $_REQUEST['layer_id'];
|
||||
if (isset($_REQUEST['layer_type'])) $data['layer_type'] = $_REQUEST['layer_type'];
|
||||
if (isset($_REQUEST['layer_source'])) $data['layer_source'] = $_REQUEST['layer_source'];
|
||||
if (isset($_REQUEST['tiles'])) {
|
||||
$data['tiles'] = is_array($_REQUEST['tiles']) ? json_encode($_REQUEST['tiles']) : $_REQUEST['tiles'];
|
||||
}
|
||||
if (isset($_REQUEST['is_active'])) $data['is_active'] = intval($_REQUEST['is_active']);
|
||||
if (isset($_REQUEST['sort_order'])) $data['sort_order'] = intval($_REQUEST['sort_order']);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user