diff --git a/app/Http/Controllers/Api/SystemController.php b/app/Http/Controllers/Api/SystemController.php
new file mode 100755
index 000000000..88206ec0c
--- /dev/null
+++ b/app/Http/Controllers/Api/SystemController.php
@@ -0,0 +1,347 @@
+isAdmin()) {
+ return Base::retError('权限不足!');
+ }
+ $all = Request::input();
+ foreach ($all AS $key => $value) {
+ if (!in_array($key, ['reg', 'login_code'])) {
+ unset($all[$key]);
+ }
+ }
+ $setting = Base::setting('system', Base::newTrim($all));
+ } else {
+ $setting = Base::setting('system');
+ }
+ //
+ $setting['reg'] = $setting['reg'] ?: 'open';
+ $setting['login_code'] = $setting['login_code'] ?: 'auto';
+ //
+ return Base::retSuccess('success', $setting ?: json_decode('{}'));
+ }
+
+ /**
+ * @api {get} api/system/get/info 02. 获取终端详细信息
+ *
+ * @apiVersion 1.0.0
+ * @apiGroup system
+ * @apiName get__info
+ *
+ * @apiParam {String} key key值
+ *
+ * @apiSuccess {Number} ret 返回状态码(1正确、0错误)
+ * @apiSuccess {String} msg 返回信息(错误描述)
+ * @apiSuccess {Object} data 返回数据
+ */
+ public function get__info()
+ {
+ if (Request::input("key") !== env('APP_KEY')) {
+ return [];
+ }
+ return Base::retSuccess('success', [
+ 'ip' => Base::getIp(),
+ 'ip-info' => Base::getIpInfo(Base::getIp()),
+ 'ip-gcj02' => Base::getIpGcj02(Base::getIp()),
+ 'ip-iscn' => Base::isCnIp(Base::getIp()),
+ 'header' => Request::header(),
+ 'token' => Base::getToken(),
+ 'url' => url('') . Base::getUrl(),
+ ]);
+ }
+
+ /**
+ * @api {get} api/system/get/ip 03. 获取IP地址
+ *
+ * @apiVersion 1.0.0
+ * @apiGroup system
+ * @apiName get__ip
+ *
+ * @apiSuccess {Number} ret 返回状态码(1正确、0错误)
+ * @apiSuccess {String} msg 返回信息(错误描述)
+ * @apiSuccess {Object} data 返回数据
+ */
+ public function get__ip() {
+ return Base::getIp();
+ }
+
+ /**
+ * @api {get} api/system/get/cnip 04. 是否中国IP地址
+ *
+ * @apiVersion 1.0.0
+ * @apiGroup system
+ * @apiName get__cnip
+ *
+ * @apiParam {String} ip IP值
+ *
+ * @apiSuccess {Number} ret 返回状态码(1正确、0错误)
+ * @apiSuccess {String} msg 返回信息(错误描述)
+ * @apiSuccess {Object} data 返回数据
+ */
+ public function get__cnip() {
+ return Base::isCnIp(Request::input('ip'));
+ }
+
+ /**
+ * @api {get} api/system/get/ipgcj02 05. 获取IP地址经纬度
+ *
+ * @apiVersion 1.0.0
+ * @apiGroup system
+ * @apiName get__ipgcj02
+ *
+ * @apiParam {String} ip IP值
+ *
+ * @apiSuccess {Number} ret 返回状态码(1正确、0错误)
+ * @apiSuccess {String} msg 返回信息(错误描述)
+ * @apiSuccess {Object} data 返回数据
+ */
+ public function get__ipgcj02() {
+ return Base::getIpGcj02(Request::input("ip"));
+ }
+
+ /**
+ * @api {get} api/system/get/ipinfo 06. 获取IP地址详细信息
+ *
+ * @apiVersion 1.0.0
+ * @apiGroup system
+ * @apiName get__ipinfo
+ *
+ * @apiParam {String} ip IP值
+ *
+ * @apiSuccess {Number} ret 返回状态码(1正确、0错误)
+ * @apiSuccess {String} msg 返回信息(错误描述)
+ * @apiSuccess {Object} data 返回数据
+ */
+ public function get__ipinfo() {
+ return Base::getIpInfo(Request::input("ip"));
+ }
+
+ /**
+ * @api {post} api/system/imgupload 10. 上传图片
+ *
+ * @apiDescription 需要token身份
+ * @apiVersion 1.0.0
+ * @apiGroup system
+ * @apiName imgupload
+ *
+ * @apiParam {String} image64 图片base64
+ * @apiParam {String} filename 文件名
+ *
+ * @apiSuccess {Number} ret 返回状态码(1正确、0错误)
+ * @apiSuccess {String} msg 返回信息(错误描述)
+ * @apiSuccess {Object} data 返回数据
+ */
+ public function imgupload()
+ {
+ if (User::token2userid() === 0) {
+ return Base::retError('身份失效,等重新登录!');
+ }
+ $scale = [intval(Request::input('width')), intval(Request::input('height'))];
+ if (!$scale[0] && !$scale[1]) {
+ $scale = [2160, 4160, -1];
+ }
+ $path = "uploads/picture/" . User::token2userid() . "/" . date("Ym") . "/";
+ $image64 = trim(Base::getPostValue('image64'));
+ $fileName = trim(Base::getPostValue('filename'));
+ if ($image64) {
+ $data = Base::image64save([
+ "image64" => $image64,
+ "path" => $path,
+ "fileName" => $fileName,
+ "scale" => $scale
+ ]);
+ } else {
+ $data = Base::upload([
+ "file" => Request::file('image'),
+ "type" => 'image',
+ "path" => $path,
+ "fileName" => $fileName,
+ "scale" => $scale
+ ]);
+ }
+ if (Base::isError($data)) {
+ return Base::retError($data['msg']);
+ } else {
+ return Base::retSuccess('success', $data['data']);
+ }
+ }
+
+ /**
+ * @api {get} api/system/get/imgview 11. 浏览图片空间
+ *
+ * @apiDescription 需要token身份
+ * @apiVersion 1.0.0
+ * @apiGroup system
+ * @apiName imgview
+ *
+ * @apiParam {String} path 路径
+ *
+ * @apiSuccess {Number} ret 返回状态码(1正确、0错误)
+ * @apiSuccess {String} msg 返回信息(错误描述)
+ * @apiSuccess {Object} data 返回数据
+ */
+ public function imgview()
+ {
+ if (User::token2userid() === 0) {
+ return Base::retError('身份失效,等重新登录!');
+ }
+ $publicPath = "uploads/picture/" . User::token2userid() . "/";
+ $dirPath = public_path($publicPath);
+ $dirs = $files = [];
+ //
+ $path = Request::input('path');
+ if ($path && is_string($path)) {
+ $path = str_replace(array('||', '|'), '/', $path);
+ $path = trim($path, '/');
+ $path = str_replace('..', '', $path);
+ $path = Base::leftDelete($path, $publicPath);
+ if ($path) {
+ $path = $path . '/';
+ $dirPath .= $path;
+ //
+ $dirs[] = [
+ 'type' => 'dir',
+ 'title' => '...',
+ 'path' => substr(substr($path, 0, -1), 0, strripos(substr($path, 0, -1), '/')),
+ 'url' => '',
+ 'thumb' => Base::fillUrl('images/other/dir.png'),
+ 'inode' => 0,
+ ];
+ }
+ } else {
+ $path = '';
+ }
+ $list = glob($dirPath . '*', GLOB_BRACE);
+ foreach ($list as $v) {
+ $filename = basename($v);
+ $pathTemp = $publicPath . $path . $filename;
+ if (is_dir($v)) {
+ $dirs[] = [
+ 'type' => 'dir',
+ 'title' => $filename,
+ 'path' => $pathTemp,
+ 'url' => Base::fillUrl($pathTemp),
+ 'thumb' => Base::fillUrl('images/other/dir.png'),
+ 'inode' => fileatime($v),
+ ];
+ } elseif (substr($filename, -10) != "_thumb.jpg") {
+ $array = [
+ 'type' => 'file',
+ 'title' => $filename,
+ 'path' => $pathTemp,
+ 'url' => Base::fillUrl($pathTemp),
+ 'thumb' => $pathTemp,
+ 'inode' => fileatime($v),
+ ];
+ //
+ $extension = pathinfo($dirPath . $filename, PATHINFO_EXTENSION);
+ if (in_array($extension, array('gif', 'jpg', 'jpeg', 'png', 'bmp'))) {
+ if (file_exists($dirPath . $filename . '_thumb.jpg')) {
+ $array['thumb'] .= '_thumb.jpg';
+ }
+ $array['thumb'] = Base::fillUrl($array['thumb']);
+ $files[] = $array;
+ }
+ }
+ }
+ if ($dirs) {
+ $inOrder = [];
+ foreach ($dirs as $key => $item) {
+ $inOrder[$key] = $item['title'];
+ }
+ array_multisort($inOrder, SORT_DESC, $dirs);
+ }
+ if ($files) {
+ $inOrder = [];
+ foreach ($files as $key => $item) {
+ $inOrder[$key] = $item['inode'];
+ }
+ array_multisort($inOrder, SORT_DESC, $files);
+ }
+ //
+ return Base::retSuccess('success', ['dirs' => $dirs, 'files' => $files]);
+ }
+
+ /**
+ * @api {post} api/system/fileupload 12. 上传文件
+ *
+ * @apiDescription 需要token身份
+ * @apiVersion 1.0.0
+ * @apiGroup system
+ * @apiName fileupload
+ *
+ * @apiParam {String} [image64] 图片base64
+ * @apiParam {String} filename 文件名
+ * @apiParam {String} [files] 文件名
+ *
+ * @apiSuccess {Number} ret 返回状态码(1正确、0错误)
+ * @apiSuccess {String} msg 返回信息(错误描述)
+ * @apiSuccess {Object} data 返回数据
+ */
+ public function fileupload()
+ {
+ if (User::token2userid() === 0) {
+ return Base::retError('身份失效,等重新登录!');
+ }
+ $path = "uploads/files/" . User::token2userid() . "/" . date("Ym") . "/";
+ $image64 = trim(Base::getPostValue('image64'));
+ $fileName = trim(Base::getPostValue('filename'));
+ if ($image64) {
+ $data = Base::image64save([
+ "image64" => $image64,
+ "path" => $path,
+ "fileName" => $fileName,
+ ]);
+ } else {
+ $data = Base::upload([
+ "file" => Request::file('files'),
+ "type" => 'file',
+ "path" => $path,
+ "fileName" => $fileName,
+ ]);
+ }
+ //
+ return $data;
+ }
+}
diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php
index b1ea14cc3..d0a7b8fd6 100755
--- a/app/Http/Controllers/Api/UsersController.php
+++ b/app/Http/Controllers/Api/UsersController.php
@@ -28,7 +28,7 @@ class UsersController extends AbstractController
* - login:登录(默认)
* - reg:注册
* @apiParam {String} email 邮箱
- * @apiParam {String} userpass 密码
+ * @apiParam {String} password 密码
* @apiParam {String} [code] 登录验证码
* @apiParam {String} [key] 登陆验证码key
*
@@ -40,13 +40,13 @@ class UsersController extends AbstractController
{
$type = trim(Request::input('type'));
$email = trim(Request::input('email'));
- $userpass = trim(Request::input('userpass'));
+ $password = trim(Request::input('password'));
if ($type == 'reg') {
$setting = Base::setting('system');
if ($setting['reg'] == 'close') {
return Base::retError('未开放注册!');
}
- $user = User::reg($email, $userpass);
+ $user = User::reg($email, $password);
if (Base::isError($user)) {
return $user;
} else {
@@ -81,7 +81,7 @@ class UsersController extends AbstractController
if (empty($user)) {
return $retError('账号或密码错误!');
}
- if ($user->userpass != Base::md52($userpass, $user->encrypt)) {
+ if ($user->password != Base::md52($password, $user->encrypt)) {
return $retError('账号或密码错误!');
}
Cache::forget("code::" . $email);
@@ -96,8 +96,7 @@ class UsersController extends AbstractController
];
$user->updateInstance($array);
$user->save();
- //
- $user->token = User::token($user);
+ User::token($user);
return Base::retSuccess($type == 'reg' ? "注册成功" : "登录成功", $user);
}
@@ -181,6 +180,8 @@ class UsersController extends AbstractController
$user = User::IDE($user['data']);
}
//
+ User::token($user);
+ //
if (strlen($callback) > 3) {
return $callback . '(' . json_encode(Base::retSuccess('success', $user)) . ')';
}
@@ -197,6 +198,7 @@ class UsersController extends AbstractController
*
* @apiParam {Object} [userimg] 会员头像(地址)
* @apiParam {String} [nickname] 昵称
+ * @apiParam {String} [profession] 职位/职称
*
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
* @apiSuccess {String} msg 返回信息(错误描述)
@@ -222,14 +224,26 @@ class UsersController extends AbstractController
if ($nickname) {
if (mb_strlen($nickname) < 2) {
return Base::retError('昵称不可以少于2个字!');
- } elseif (mb_strlen($nickname) > 8) {
- return Base::retError('昵称最多只能设置8个字!');
+ } elseif (mb_strlen($nickname) > 20) {
+ return Base::retError('昵称最多只能设置20个字!');
} else {
$user->nickname = $nickname;
}
}
+ //职位/职称
+ $profession = trim(Request::input('profession'));
+ if ($profession) {
+ if (mb_strlen($profession) < 2) {
+ return Base::retError('职位/职称不可以少于2个字!');
+ } elseif (mb_strlen($profession) > 20) {
+ return Base::retError('职位/职称最多只能设置20个字!');
+ } else {
+ $user->profession = $profession;
+ }
+ }
//
$user->save();
+ User::token($user);
return Base::retSuccess('修改成功!', $user);
}
@@ -277,15 +291,16 @@ class UsersController extends AbstractController
return Base::retError('当前环境禁止修改密码!');
}
//
- $verify = User::whereUserid($user->userid)->whereUserpass(Base::md52($oldpass, User::token2encrypt()))->count();
+ $verify = User::whereUserid($user->userid)->wherePassword(Base::md52($oldpass, User::token2encrypt()))->count();
if (empty($verify)) {
return Base::retError('请填写正确的旧密码!');
}
//
$user->encrypt = Base::generatePassword(6);
- $user->userpass = Base::md52($newpass, $user->encrypt);
+ $user->password = Base::md52($newpass, $user->encrypt);
$user->changepass = 0;
$user->save();
+ User::token($user);
return Base::retSuccess('修改成功!', $user);
}
diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php
index 8ff89d06c..52064db32 100644
--- a/app/Http/Middleware/VerifyCsrfToken.php
+++ b/app/Http/Middleware/VerifyCsrfToken.php
@@ -12,6 +12,12 @@ class VerifyCsrfToken extends Middleware
* @var array
*/
protected $except = [
+ //上传图片
+ 'api/system/imgupload/',
+
+ //上传文件
+ 'api/system/fileupload/',
+
// 添加任务
'api/project/task/add/',
];
diff --git a/app/Models/ProjectTask.php b/app/Models/ProjectTask.php
index 8008751da..1c7a750b3 100644
--- a/app/Models/ProjectTask.php
+++ b/app/Models/ProjectTask.php
@@ -49,6 +49,8 @@ use Carbon\Carbon;
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereUserid($value)
* @mixin \Eloquent
+ * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProjectTaskTag[] $taskTag
+ * @property-read int|null $task_tag_count
*/
class ProjectTask extends AbstractModel
{
diff --git a/app/Models/User.php b/app/Models/User.php
index f3453eeac..245577efd 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -16,9 +16,10 @@ use Carbon\Carbon;
* @property string|null $az A-Z
* @property string|null $email 邮箱
* @property string $nickname 昵称
+ * @property string|null $profession 职位/职称
* @property string $userimg 头像
* @property string|null $encrypt
- * @property string|null $userpass 登录密码
+ * @property string|null $password 登录密码
* @property int|null $changepass 登录需要修改密码
* @property int|null $login_num 累计登录次数
* @property string|null $last_ip 最后登录IP
@@ -44,10 +45,11 @@ use Carbon\Carbon;
* @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 whereProfession($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)
- * @method static \Illuminate\Database\Eloquent\Builder|User whereUserpass($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|User wherePassword($value)
* @mixin \Eloquent
*/
class User extends AbstractModel
@@ -55,8 +57,6 @@ class User extends AbstractModel
protected $primaryKey = 'userid';
protected $hidden = [
- 'encrypt',
- 'userpass',
'updated_at',
];
@@ -119,6 +119,15 @@ class User extends AbstractModel
return WebSocket::whereUserid($this->userid)->exists();
}
+ /**
+ * 判断是否管理员
+ * @return bool
+ */
+ public function isAdmin()
+ {
+ return in_array('admin', $this->identity);
+ }
+
/** ***************************************************************************************** */
/** ***************************************************************************************** */
@@ -127,11 +136,11 @@ class User extends AbstractModel
/**
* 注册会员
* @param $email
- * @param $userpass
+ * @param $password
* @param array $other
* @return array
*/
- public static function reg($email, $userpass, $other = [])
+ public static function reg($email, $password, $other = [])
{
//邮箱
if (!Base::isMail($email)) {
@@ -141,9 +150,9 @@ class User extends AbstractModel
return Base::retError('邮箱地址已存在!');
}
//密码
- if (strlen($userpass) < 6) {
+ if (strlen($password) < 6) {
return Base::retError(['密码设置不能小于%位数!', 6]);
- } elseif (strlen($userpass) > 32) {
+ } elseif (strlen($password) > 32) {
return Base::retError(['密码最多只能设置%位数!', 32]);
}
//开始注册
@@ -151,7 +160,7 @@ class User extends AbstractModel
$inArray = [
'encrypt' => $encrypt,
'email' => $email,
- 'userpass' => Base::md52($userpass, $encrypt),
+ 'password' => Base::md52($password, $encrypt),
'created_ip' => Base::getIp(),
];
if ($other) {
@@ -293,7 +302,10 @@ class User extends AbstractModel
*/
public static function token($userinfo)
{
- return base64_encode($userinfo->userid . '#$' . $userinfo->email . '#$' . $userinfo->encrypt . '#$' . time() . '#$' . Base::generatePassword(6));
+ $userinfo->token = base64_encode($userinfo->userid . '#$' . $userinfo->email . '#$' . $userinfo->encrypt . '#$' . time() . '#$' . Base::generatePassword(6));
+ unset($userinfo->encrypt);
+ unset($userinfo->password);
+ return $userinfo->token;
}
/**
@@ -355,7 +367,7 @@ class User extends AbstractModel
if (isset($_A["__static_userid2basic_" . $userid])) {
return $_A["__static_userid2basic_" . $userid];
}
- $fields = ['userid', 'email', 'nickname', 'userimg'];
+ $fields = ['userid', 'email', 'nickname', 'profession', 'userimg'];
$userInfo = self::whereUserid($userid)->select($fields)->first();
if ($userInfo) {
$userInfo->online = $userInfo->getOnlineStatus();
@@ -383,8 +395,8 @@ class User extends AbstractModel
*/
public static function needCode($email)
{
- $loginCode = Base::settingFind('system', 'loginCode');
- switch ($loginCode) {
+ $login_code = Base::settingFind('system', 'login_code');
+ switch ($login_code) {
case 'open':
return Base::retSuccess('need');
diff --git a/app/Module/Base.php b/app/Module/Base.php
index 6b46be91c..bed515690 100755
--- a/app/Module/Base.php
+++ b/app/Module/Base.php
@@ -1149,6 +1149,7 @@ class Base
if ($array !== false) {
$setting = $array;
$row->updateInstance(['setting' => $array]);
+ $row->save();
}
$_A["__static_setting_" . $setname] = $setting;
return $setting;
diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue
index 1b3b04f56..4342f7246 100644
--- a/resources/assets/js/pages/manage.vue
+++ b/resources/assets/js/pages/manage.vue
@@ -10,7 +10,7 @@