diff --git a/app/Http/Controllers/Api/ProjectController.php b/app/Http/Controllers/Api/ProjectController.php
index aff301c0..b810eded 100755
--- a/app/Http/Controllers/Api/ProjectController.php
+++ b/app/Http/Controllers/Api/ProjectController.php
@@ -18,6 +18,14 @@ use Request;
*/
class ProjectController extends AbstractController
{
+ private $projectSelect = [
+ '*',
+ 'projects.id AS id',
+ 'projects.userid AS userid',
+ 'projects.created_at AS created_at',
+ 'projects.updated_at AS updated_at',
+ ];
+
/**
* 项目列表
*
@@ -33,7 +41,8 @@ class ProjectController extends AbstractController
$user = User::IDE($user['data']);
}
//
- $list = Project::join('project_users', 'projects.id', '=', 'project_users.project_id')
+ $list = Project::select($this->projectSelect)
+ ->join('project_users', 'projects.id', '=', 'project_users.project_id')
->where('project_users.userid', $user->userid)
->orderByDesc('projects.id')
->paginate(Base::getPaginate(200, 100));
@@ -62,10 +71,15 @@ class ProjectController extends AbstractController
$taskQuery->where('parent_id', 0);
}]);
}, 'projectUser'])
+ ->select($this->projectSelect)
->join('project_users', 'projects.id', '=', 'project_users.project_id')
->where('projects.id', $project_id)
->where('project_users.userid', $user->userid)
->first();
+ if ($project) {
+ $owner_user = $project->projectUser->where('owner', 1)->first();
+ $project->owner_userid = $owner_user ? $owner_user->userid : 0;
+ }
//
return Base::retSuccess('success', $project);
}
diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php
index 465f8278..9f49914a 100755
--- a/app/Http/Controllers/Api/UsersController.php
+++ b/app/Http/Controllers/Api/UsersController.php
@@ -6,6 +6,7 @@ use App\Models\User;
use App\Module\Base;
use Cache;
use Captcha;
+use Carbon\Carbon;
use Request;
/**
@@ -87,11 +88,11 @@ class UsersController extends AbstractController
}
//
$array = [
- 'loginnum' => $user['loginnum'] + 1,
- 'lastip' => Base::getIp(),
- 'lastdate' => time(),
- 'lineip' => Base::getIp(),
- 'linedate' => time(),
+ 'login_num' => $user->login_num + 1,
+ 'last_ip' => Base::getIp(),
+ 'last_at' => Carbon::now(),
+ 'line_ip' => Base::getIp(),
+ 'line_at' => Carbon::now(),
];
foreach ($array as $key => $value) {
$user->$key = $value;
@@ -159,14 +160,13 @@ class UsersController extends AbstractController
"email": "admin@admin.com",
"nickname": "admin",
"userimg": "",
- "loginnum": 10,
+ "login_num": 10,
"changepass": 0,
- "lastip": "10.22.22.1",
- "lastdate": 1622468661,
- "lineip": "10.22.22.1",
- "linedate": 1622468661,
- "regip": "",
- "regdate": 0,
+ "last_ip": "10.22.22.1",
+ "last_at": "2021-06-01 12:00:00",
+ "line_ip": "10.22.22.1",
+ "line_at": "2021-06-01 12:00:00",
+ "created_ip": "",
}
*/
public function info()
diff --git a/app/Models/User.php b/app/Models/User.php
index 322c3f62..d35cbee6 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -5,6 +5,7 @@ namespace App\Models;
use App\Module\Base;
use Cache;
+use Carbon\Carbon;
/**
* Class User
@@ -18,14 +19,13 @@ use Cache;
* @property string|null $userimg 头像
* @property string|null $encrypt
* @property string|null $userpass 登录密码
- * @property int|null $loginnum 累计登录次数
+ * @property int|null $login_num 累计登录次数
* @property int|null $changepass 登录需要修改密码
- * @property string|null $lastip 最后登录IP
- * @property int|null $lastdate 最后登录时间
- * @property string|null $lineip 最后在线IP(接口)
- * @property int|null $linedate 最后在线时间(接口)
- * @property string|null $regip 注册IP
- * @property int|null $regdate 注册时间
+ * @property string|null $last_ip 最后登录IP
+ * @property \Illuminate\Support\Carbon|null $last_at 最后登录时间
+ * @property string|null $line_ip 最后在线IP(接口)
+ * @property \Illuminate\Support\Carbon|null $line_at 最后在线时间(接口)
+ * @property string|null $created_ip 注册IP
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read string $usering
@@ -38,14 +38,13 @@ use Cache;
* @method static \Illuminate\Database\Eloquent\Builder|User whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereEncrypt($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereIdentity($value)
- * @method static \Illuminate\Database\Eloquent\Builder|User whereLastdate($value)
- * @method static \Illuminate\Database\Eloquent\Builder|User whereLastip($value)
- * @method static \Illuminate\Database\Eloquent\Builder|User whereLinedate($value)
- * @method static \Illuminate\Database\Eloquent\Builder|User whereLineip($value)
- * @method static \Illuminate\Database\Eloquent\Builder|User whereLoginnum($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|User whereLastAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|User whereLastIp($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|User whereLineAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|User whereLineIp($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|User whereLoginNum($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereNickname($value)
- * @method static \Illuminate\Database\Eloquent\Builder|User whereRegdate($value)
- * @method static \Illuminate\Database\Eloquent\Builder|User whereRegip($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|User whereCreatedIp($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereUserid($value)
* @method static \Illuminate\Database\Eloquent\Builder|User whereUserimg($value)
@@ -59,7 +58,6 @@ class User extends AbstractModel
protected $hidden = [
'encrypt',
'userpass',
- 'created_at',
'updated_at',
];
@@ -80,7 +78,7 @@ class User extends AbstractModel
*/
public function getUserimgAttribute($value)
{
- return self::userimg($value);
+ return $value ? Base::fillUrl($value) : url('images/other/avatar.png');
}
/**
@@ -129,8 +127,7 @@ class User extends AbstractModel
'encrypt' => $encrypt,
'email' => $email,
'userpass' => Base::md52($userpass, $encrypt),
- 'regip' => Base::getIp(),
- 'regdate' => time()
+ 'created_ip' => Base::getIp(),
];
if ($other) {
$inArray = array_merge($inArray, $other);
@@ -228,11 +225,11 @@ class User extends AbstractModel
$row = self::whereUserid($authInfo['userid'])->whereEmail($authInfo['email'])->whereEncrypt($authInfo['encrypt'])->first();
if ($row) {
$upArray = [];
- if (Base::getIp() && $row->lineip != Base::getIp()) {
- $upArray['lineip'] = Base::getIp();
+ if (Base::getIp() && $row->line_ip != Base::getIp()) {
+ $upArray['line_ip'] = Base::getIp();
}
- if ($row->linedate + 30 < time()) {
- $upArray['linedate'] = time();
+ if (Carbon::parse($row->line_at)->addSeconds(30)->lt(Carbon::now())) {
+ $upArray['line_at'] = Carbon::now();
}
if ($upArray) {
$row->updateInstance($upArray);
@@ -333,50 +330,14 @@ class User extends AbstractModel
if (isset($_A["__static_userid2basic_" . $userid])) {
return $_A["__static_userid2basic_" . $userid];
}
- $fields = ['userid', 'email', 'nickname', 'userimg'];
+ $fields = ['userid', 'email', 'nickname', 'userimg', 'line_at'];
$userInfo = self::whereUserid($userid)->select($fields)->first();
+ if ($userInfo) {
+ $userInfo->line_at;
+ }
return $_A["__static_userid2basic_" . $userid] = ($userInfo ?: []);
}
- /**
- * email 获取 基本信息
- * @param string $email 邮箱地址
- * @return self
- */
- public static function email2basic(string $email)
- {
- global $_A;
- if (empty($email)) {
- return null;
- }
- if (isset($_A["__static_email2basic_" . $email])) {
- return $_A["__static_email2basic_" . $email];
- }
- $fields = ['userid', 'email', 'nickname', 'userimg'];
- $userInfo = self::whereEmail($email)->select($fields)->first();
- return $_A["__static_email2basic_" . $email] = ($userInfo ?: []);
- }
-
- /**
- * 用户头像,不存在时返回默认
- * @param string $var 头像地址 或 会员邮箱
- * @return string
- */
- public static function userimg(string $var)
- {
- if (!Base::strExists($var, '.')) {
- if (empty($var)) {
- $var = "";
- } else {
- $userInfo = self::email2basic($var);
- if ($userInfo) {
- $var = $userInfo->userimg;
- }
- }
- }
- return $var ? Base::fillUrl($var) : url('images/other/avatar.png');
- }
-
/**
* 更新首字母
* @param $userid
diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js
index 11dcb12c..9c95ad69 100644
--- a/resources/assets/js/app.js
+++ b/resources/assets/js/app.js
@@ -20,13 +20,14 @@ import Loading from './components/Loading.vue'
import AutoTip from './components/AutoTip.vue'
import TagInput from './components/TagInput.vue'
import TableAction from './components/TableAction.vue'
+import UserAvatar from './components/UserAvatar.vue'
Vue.component('PageTitle', PageTitle);
Vue.component('Loading', Loading);
Vue.component('AutoTip', AutoTip);
Vue.component('TagInput', TagInput)
Vue.component('TableAction', TableAction);
-
+Vue.component('UserAvatar', UserAvatar);
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
diff --git a/resources/assets/js/components/UserAvatar.vue b/resources/assets/js/components/UserAvatar.vue
new file mode 100755
index 00000000..452a5ad9
--- /dev/null
+++ b/resources/assets/js/components/UserAvatar.vue
@@ -0,0 +1,76 @@
+
+