dever hace 5 años
padre
commit
65ebcb02de
Se han modificado 2 ficheros con 195 adiciones y 0 borrados
  1. 167 0
      database/address.php
  2. 28 0
      src/Api.php

+ 167 - 0
database/address.php

@@ -0,0 +1,167 @@
+<?php
+
+$type = array
+(
+	1 => '普通地址',
+	2 => '默认地址',
+);
+return array
+(
+    # 表名
+    'name' => 'address',
+    # 显示给用户看的名称
+    'lang' => '用户地址库',
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户名',
+			'default' 	=> '0',
+			'desc' 		=> '请选择用户',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			//'search'	=> 'select',
+			'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+			'list'		=> '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
+		),
+
+		'type'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '类型',
+			'default' 	=> '1',
+			'desc' 		=> '类型',
+			'match' 	=> 'is_numeric',
+			'option' 	=> $type,
+			'update'	=> 'select',
+			//'list'		=> true,
+		),
+
+        'country'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '国家',
+			'default' 	=> '',
+			'desc' 		=> '国家',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+		),
+
+		'province'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '省份',
+			'default' 	=> '',
+			'desc' 		=> '省份',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+		),
+
+		'city'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '城市',
+			'default' 	=> '',
+			'desc' 		=> '城市',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+		),
+
+		'area'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> '地区',
+			'default' 	=> '',
+			'desc' 		=> '地区',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'area_id'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> '地区',
+			'default' 	=> '',
+			'desc' 		=> '地区',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'address'		=> array
+		(
+			'type' 		=> 'varchar-1000',
+			'name' 		=> '详细地址',
+			'default' 	=> '',
+			'desc' 		=> '详细地址',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '操作时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            //'insert'    => true,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        
+    ),
+
+    'request' => array
+    (
+		'getList' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'uid' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('type' => 'desc','id' => 'desc'),
+			'page' => array(10, 'list');
+			'col' => '*',
+		),
+    ),
+);

+ 28 - 0
src/Api.php

@@ -35,4 +35,32 @@ class Api
         $base = new Base;
         $base->combine(3, 321313);
     }
+
+    # 获取地址列表
+    public function getAddress($uid)
+    {
+        $where['uid'] = $uid;
+        $data = Dever::db('passport/address')->getList($where);
+
+        return $data;
+    }
+
+    # 添加或者更新地址
+    public function upAddress($id, $uid, $country, $province, $city, $area, $address)
+    {
+        $update['country'] = $country;
+        $update['province'] = $province;
+        $update['city'] = $city;
+        $update['area'] = $area;
+        $update['area'] = $address;
+        if ($id) {
+            $update['where_id'] = $id;
+            Dever::db('passport/address')->update($update);
+        } else {
+            $update['uid'] = $uid;
+            $id = Dever::db('passport/address')->insert($update);
+        }
+
+        return $id;
+    }
 }