dever vor 3 Jahren
Ursprung
Commit
559a38ff1f
6 geänderte Dateien mit 116 neuen und 122 gelöschten Zeilen
  1. 0 114
      database/manage_group.php
  2. 4 4
      database/user.php
  3. 76 0
      database/user_system.php
  4. 30 0
      lib/Base.php
  5. 5 1
      src/App.php
  6. 1 3
      src/Applet.php

+ 0 - 114
database/manage_group.php

@@ -1,114 +0,0 @@
-<?php
-
-return array
-(
-    # 表名
-    'name' => 'manage_group',
-    # 显示给用户看的名称
-    'lang' => '管理分组',
-    # 后台菜单排序
-    'order' => 1,
-    # 数据结构
-    'struct' => array
-    (
-        'id'        => array
-        (
-            'type'      => 'int-11',
-            'name'      => 'ID',
-            'default'   => '',
-            'desc'      => '',
-            'match'     => 'is_numeric',
-            'search'    => 'order',
-            'list'      => true,
-            'order'     => 'desc',
-        ),
-        
-        'name'      => array
-        (
-            'type'      => 'varchar-32',
-            'name'      => '分组名称',
-            'default'   => '',
-            'desc'      => '分组名称',
-            'match'     => 'is_string',
-            'update'    => 'text',
-            'search'    => 'fulltext',
-            'list'      => true,
-        ),
-        
-        'reorder'       => array
-        (
-            'type'      => 'int-11',
-            'name'      => '排序(数值越大越靠前)',
-            'default'   => '1',
-            'desc'      => '请输入排序',
-            'match'     => 'option',
-            'update'    => 'text',
-            'search'    => 'order',
-            'list'      => true,
-            'order'     => 'desc',
-            'edit'      => 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,
-            'list'      => 'date("Y-m-d H:i:s", {cdate})',
-        ),
-    ),
-
-    # 默认值
-    'default' => array
-    (
-        'col' => 'name,state,cdate',
-        'value' => array
-        (
-            '"默认分组",1,' . time(),
-        ),
-    ),
-
-    'manage' => array
-    (
-        'insert' => false,
-        'edit' => false,
-
-        # 自定义快捷新增和编辑
-        'button' => array
-        (
-            '新增' => array('fast'),
-        ),
-        # 快捷更新
-        'list_button' => array
-        (
-            'edit' => array('编辑'),
-        ),
-    ),
-
-    'request' => array
-    (
-        'getAll' => array
-        (
-            # 匹配的正则或函数 选填项
-            'option' => array
-            (
-                'state' => 1,
-            ),
-            'type' => 'all',
-            'order' => array('reorder' => 'desc','id' => 'desc'),
-            'col' => '*',
-        ),
-    ),
-);

+ 4 - 4
database/user.php

@@ -154,8 +154,8 @@ return array
 			'match' 	=> 'option',
 			'update'	=> 'text',
 			'search'	=> 'fulltext',
-			'list'		=> '"{truename}" ? "{truename}" : "点此编辑"',
-			'edit'		=> true,
+			//'list'		=> '"{truename}" ? "{truename}" : "点此编辑"',
+			//'edit'		=> true,
 		),
 
 		'title'		=> array
@@ -490,8 +490,8 @@ return array
 			'default' 	=> '1',
 			'desc' 		=> '请选择状态',
 			'match' 	=> 'is_numeric',
-			'option' 	=> $option,
-			'update'	=> 'radio',
+			//'option' 	=> $option,
+			//'update'	=> 'radio',
 		),
 		
 		'cdate'		=> array

+ 76 - 0
database/user_system.php

@@ -0,0 +1,76 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'user_system',
+	# 显示给用户看的名称
+	'lang' => '用户与项目关联表',
+	'order' => 10,
+	'menu'	=> false,
+	# 数据结构
+	'struct' => array
+	(
+	
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order,fulltext',
+			'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}) : "匿名用户"',
+		),
+
+		'system_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '所属项目',
+			'default' 	=> '1',
+			'desc' 		=> '所属项目',
+			'match' 	=> 'is_numeric',
+			'option' 	=> $system,
+			//'update'	=> 'select',
+			//'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,
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+);

+ 30 - 0
lib/Base.php

@@ -72,6 +72,10 @@ class Base
 
         $uid = Dever::db('passport/user')->insert($user);
 
+        if ($user['system_id']) {
+            $this->setSystem($uid, $user['system_id']);
+        }
+
         $this->invite($uid);
 
         $this->createUsername($uid, $user['username'], true);
@@ -251,6 +255,10 @@ class Base
 
         $user = Dever::load('passport/user-one', $uid);
 
+        if ($system) {
+            $this->setSystem($uid, $system);
+        }
+
         $this->save($user);
 
         $user['uid'] = $user['id'];
@@ -259,6 +267,28 @@ class Base
         return $user;
     }
 
+    public function setSystem($uid, $system)
+    {
+        $where['uid'] = $uid;
+        $where['system_id'] = $system;
+        $one = Dever::db('passport/user_system')->find($where);
+
+        if (!$one) {
+            Dever::db('passport/user_system')->insert($where);
+        }
+    }
+
+    public function setProfession($uid, $profession)
+    {
+        $where['uid'] = $uid;
+        $where['profession'] = $system;
+        $one = Dever::db('passport/user_profession')->find($where);
+
+        if (!$one) {
+            Dever::db('passport/user_profession')->insert($where);
+        }
+    }
+
     /**
      * 更新用户信息 绑定用户手机号
      *

+ 5 - 1
src/App.php

@@ -124,6 +124,8 @@ class App extends Base
                 $appData['system_id'] = $system;
                 Dever::db('passport/app')->insert($appData);
             }
+
+            $this->setSystem($result['uid'], $system);
         }
 
         return $result;
@@ -183,6 +185,8 @@ class App extends Base
         	Dever::db('passport/app')->insert($appData);
         }
 
+        $this->setSystem($uid, $system);
+
         $result = Dever::db('passport/user')->one($uid);
         $result['uid'] = $uid;
         $result['signature'] = Dever::login($uid);
@@ -222,7 +226,7 @@ class App extends Base
         } else {
             $uid = $app['uid'];
         }
-
+        $this->setSystem($uid, $system);
         $result = Dever::db('passport/user')->one($uid);
         $result['uid'] = $uid;
         $result['signature'] = Dever::login($uid);

+ 1 - 3
src/Applet.php

@@ -236,9 +236,7 @@ class Applet extends Base
             $key = $this->cache . $id;
             $cache = Dever::cache($key, $data['session_key']);
 
-            if (!$cache) {
-                $wechat['session_key'] = $data['session_key'];
-            }
+            $wechat['session_key'] = $data['session_key'];
 
             if ($wechat) {
                 $wechat['where_id'] = $id;