From ab083686a812f0b3fdc215e24206e450dac58416 Mon Sep 17 00:00:00 2001 From: Karson Date: Tue, 6 Apr 2021 12:03:25 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=A7=AF=E5=88=86?= =?UTF-8?q?=E5=92=8C=E4=BD=99=E9=A2=9D=E5=B9=B6=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/model/User.php | 61 +++++++++++++++++++------------ 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/application/common/model/User.php b/application/common/model/User.php index c32598c92..097ed4aed 100644 --- a/application/common/model/User.php +++ b/application/common/model/User.php @@ -2,6 +2,7 @@ namespace app\common\model; +use think\Db; use think\Model; /** @@ -22,8 +23,8 @@ class User extends Model /** * 获取个人URL - * @param string $value - * @param array $data + * @param string $value + * @param array $data * @return string */ public function getUrlAttr($value, $data) @@ -33,8 +34,8 @@ class User extends Model /** * 获取头像 - * @param string $value - * @param array $data + * @param string $value + * @param array $data * @return string */ public function getAvatarAttr($value, $data) @@ -57,8 +58,8 @@ class User extends Model /** * 获取验证字段数组值 - * @param string $value - * @param array $data + * @param string $value + * @param array $data * @return object */ public function getVerificationAttr($value, $data) @@ -87,15 +88,21 @@ class User extends Model */ public static function money($money, $user_id, $memo) { - $user = self::get($user_id); - if ($user && $money != 0) { - $before = $user->money; - //$after = $user->money + $money; - $after = function_exists('bcadd') ? bcadd($user->money, $money, 2) : $user->money + $money; - //更新会员信息 - $user->save(['money' => $after]); - //写入日志 - MoneyLog::create(['user_id' => $user_id, 'money' => $money, 'before' => $before, 'after' => $after, 'memo' => $memo]); + Db::startTrans(); + try { + $user = self::lock(true)->find($user_id); + if ($user && $money != 0) { + $before = $user->money; + //$after = $user->money + $money; + $after = function_exists('bcadd') ? bcadd($user->money, $money, 2) : $user->money + $money; + //更新会员信息 + $user->save(['money' => $after]); + //写入日志 + MoneyLog::create(['user_id' => $user_id, 'money' => $money, 'before' => $before, 'after' => $after, 'memo' => $memo]); + } + Db::commit(); + } catch (\Exception $e) { + Db::rollback(); } } @@ -107,15 +114,21 @@ class User extends Model */ public static function score($score, $user_id, $memo) { - $user = self::get($user_id); - if ($user && $score != 0) { - $before = $user->score; - $after = $user->score + $score; - $level = self::nextlevel($after); - //更新会员信息 - $user->save(['score' => $after, 'level' => $level]); - //写入日志 - ScoreLog::create(['user_id' => $user_id, 'score' => $score, 'before' => $before, 'after' => $after, 'memo' => $memo]); + Db::startTrans(); + try { + $user = self::lock(true)->find($user_id); + if ($user && $score != 0) { + $before = $user->score; + $after = $user->score + $score; + $level = self::nextlevel($after); + //更新会员信息 + $user->save(['score' => $after, 'level' => $level]); + //写入日志 + ScoreLog::create(['user_id' => $user_id, 'score' => $score, 'before' => $before, 'after' => $after, 'memo' => $memo]); + } + Db::commit(); + } catch (\Exception $e) { + Db::rollback(); } } -- Gitee From 1c62049989f8ec5aeeb91e2eb1673513fde4f2ad Mon Sep 17 00:00:00 2001 From: YouKnow <2900928498@qq.com> Date: Fri, 9 Apr 2021 15:56:03 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E4=BC=98=E5=8C=96user=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/validate/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/admin/validate/User.php b/application/admin/validate/User.php index ab0622055..252f4cf5c 100644 --- a/application/admin/validate/User.php +++ b/application/admin/validate/User.php @@ -32,7 +32,7 @@ class User extends Validate */ protected $scene = [ 'add' => [], - 'edit' => ['username', 'email', 'nickname', 'password', 'email', 'mobile'], + 'edit' => ['username', 'nickname', 'password', 'email', 'mobile'], ]; public function __construct(array $rules = [], $message = [], $field = []) -- Gitee From 6b9e5ba379b682ea7069217e797bb69f35e3ec48 Mon Sep 17 00:00:00 2001 From: T2cc <5152438+gtguizhou@user.noreply.gitee.com> Date: Sun, 11 Apr 2021 22:36:53 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=9F=E6=88=90=20ap?= =?UTF-8?q?i=20=E6=96=87=E6=A1=A3=E6=8A=A5=E9=94=99=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Api/library/Extractor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/admin/command/Api/library/Extractor.php b/application/admin/command/Api/library/Extractor.php index 401153657..fdd52de18 100644 --- a/application/admin/command/Api/library/Extractor.php +++ b/application/admin/command/Api/library/Extractor.php @@ -297,7 +297,7 @@ class Extractor } } $methodAnnotations['ApiPermissionLogin'] = [!in_array('*', $noNeedLogin) && !in_array($methodName, $noNeedLogin)]; - $methodAnnotations['ApiPermissionRight'] = !$methodAnnotations['ApiPermissionLogin'][0] ? false : [!in_array('*', $noNeedRight) && !in_array($methodName, $noNeedRight)]; + $methodAnnotations['ApiPermissionRight'] = !$methodAnnotations['ApiPermissionLogin'][0] ? [false] : [!in_array('*', $noNeedRight) && !in_array($methodName, $noNeedRight)]; return $methodAnnotations; } -- Gitee From d59ff78fd89ecda4db2fd41a3fbbc62d566414af Mon Sep 17 00:00:00 2001 From: F4NNIU Date: Thu, 13 May 2021 22:31:12 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20framework=20type=20?= =?UTF-8?q?=E4=B8=BA=20git?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e20ce7460..90e0ea86d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -FastAdmin是一款基于ThinkPHP5+Bootstrap的极速后台开发框架。 +FastAdmin是一款基于ThinkPHP+Bootstrap的极速后台开发框架。 ## 主要特性 diff --git a/composer.json b/composer.json index b3b118b4d..b059b41ab 100755 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ }, "repositories": [ { - "type": "vcs", + "type": "git", "url": "https://gitee.com/karson/framework" } ] -- Gitee From cdebb284c33b8a9eee54745b4934a83fd3849355 Mon Sep 17 00:00:00 2001 From: Karson Date: Wed, 19 May 2021 17:52:34 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E8=A7=84=E5=88=99=E4=B8=AD=E7=9A=84=E6=9D=A1=E4=BB=B6=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/fast/Auth.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/extend/fast/Auth.php b/extend/fast/Auth.php index 396c4cfc9..81429ef30 100644 --- a/extend/fast/Auth.php +++ b/extend/fast/Auth.php @@ -140,7 +140,7 @@ class Auth /** * 根据用户id获取用户组,返回值为数组 - * @param int $uid 用户id + * @param int $uid 用户id * @return array 用户所属的用户组 array( * array('uid'=>'用户id','group_id'=>'用户组id','name'=>'用户组名称','rules'=>'用户组拥有的规则id,多个,号隔开'), * ...) @@ -205,9 +205,17 @@ class Auth if (!empty($rule['condition']) && !in_array('*', $ids)) { //根据condition进行验证 $user = $this->getUserInfo($uid); //获取用户信息,一维数组 - $command = preg_replace('/\{(\w*?)\}/', '$user[\'\\1\']', $rule['condition']); - @(eval('$condition=(' . $command . ');')); - if ($condition) { + $nums = 0; + $condition = str_replace(['&&', '||'], "\r\n", $rule['condition']); + $condition = preg_replace('/\{(\w*?)\}/', '\\1', $condition); + $conditionArr = explode("\r\n", $condition); + foreach ($conditionArr as $index => $item) { + preg_match("/^(\w+)\s?([\>\<\=]+)\s?(.*)$/", trim($item), $matches); + if ($matches && isset($user[$matches[1]]) && version_compare($user[$matches[1]], $matches[3], $matches[2])) { + $nums++; + } + } + if ($conditionArr && ((stripos($rule['condition'], "||") !== false && $nums > 0) || count($conditionArr) == $nums)) { $rulelist[$rule['id']] = strtolower($rule['name']); } } else { @@ -254,4 +262,4 @@ class Auth return $user_info[$uid]; } -} \ No newline at end of file +} -- Gitee From bf720c176ebe8ec3d2ffb011a4b68f8e18d07979 Mon Sep 17 00:00:00 2001 From: Karson Date: Fri, 4 Jun 2021 14:33:44 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=8A=9F=E8=83=BD=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=8E=A5=E5=8F=A3=E8=AE=BE=E5=AE=9A=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E5=8A=9F=E8=83=BD=20=E4=BC=98=E5=8C=96=E5=88=86?= =?UTF-8?q?=E7=89=87=E4=B8=8A=E4=BC=A0=E8=BF=9B=E8=A1=8C=E7=99=BE=E5=88=86?= =?UTF-8?q?=E6=AF=94=E8=AE=A1=E7=AE=97=20=E4=BC=98=E5=8C=96=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E9=85=8D=E7=BD=AE=E5=AD=97=E5=85=B8=E6=96=87=E5=AD=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/command/Install/fastadmin.sql | 4 +- .../admin/controller/general/Attachment.php | 39 ++++++++++++++++-- .../admin/controller/general/Config.php | 8 ++++ .../admin/lang/zh-cn/general/attachment.php | 8 ++++ .../admin/lang/zh-cn/general/config.php | 3 ++ .../admin/view/general/attachment/edit.html | 13 ++++++ .../admin/view/general/attachment/index.html | 18 +++++++- .../admin/view/general/attachment/select.html | 6 +-- application/common/library/Upload.php | 3 ++ application/common/model/Attachment.php | 24 +++++++++++ application/extra/site.php | 5 +++ .../assets/js/backend/general/attachment.js | 41 +++++++++++++++---- public/assets/js/require-upload.js | 14 +++++-- 13 files changed, 163 insertions(+), 23 deletions(-) diff --git a/application/admin/command/Install/fastadmin.sql b/application/admin/command/Install/fastadmin.sql index 8df72f5f3..9fa3529ed 100755 --- a/application/admin/command/Install/fastadmin.sql +++ b/application/admin/command/Install/fastadmin.sql @@ -80,6 +80,7 @@ CREATE TABLE `fa_area` ( DROP TABLE IF EXISTS `fa_attachment`; CREATE TABLE `fa_attachment` ( `id` int(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', + `category` varchar(50) DEFAULT '' COMMENT '类别', `admin_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '管理员ID', `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '会员ID', `url` varchar(255) DEFAULT '' COMMENT '物理路径', @@ -103,7 +104,7 @@ CREATE TABLE `fa_attachment` ( -- Records of fa_attachment -- ---------------------------- BEGIN; -INSERT INTO `fa_attachment` VALUES (1, 1, 0, '/assets/img/qrcode.png', '150', '150', 'png', 0, 'qrcode.png', 21859, 'image/png', '', 1491635035, 1491635035, 1491635035, 'local', '17163603d0263e4838b9387ff2cd4877e8b018f6'); +INSERT INTO `fa_attachment` VALUES (1, '', 1, 0, '/assets/img/qrcode.png', '150', '150', 'png', 0, 'qrcode.png', 21859, 'image/png', '', 1491635035, 1491635035, 1491635035, 'local', '17163603d0263e4838b9387ff2cd4877e8b018f6'); COMMIT; -- ---------------------------- @@ -350,6 +351,7 @@ INSERT INTO `fa_config` VALUES (14, 'mail_smtp_user', 'email', 'Mail smtp user', INSERT INTO `fa_config` VALUES (15, 'mail_smtp_pass', 'email', 'Mail smtp password', '(填写您的密码或授权码)', 'string', 'password', '', '', '', ''); INSERT INTO `fa_config` VALUES (16, 'mail_verify_type', 'email', 'Mail vertify type', '(SMTP验证方式[推荐SSL])', 'select', '2', '[\"无\",\"TLS\",\"SSL\"]', '', '', ''); INSERT INTO `fa_config` VALUES (17, 'mail_from', 'email', 'Mail from', '', 'string', '10000@qq.com', '', '', '', ''); +INSERT INTO `fa_config` VALUES (18, 'attachmentcategory', 'dictionary', 'Attachment category', '', 'array', '{\"category1\":\"Category1\",\"category2\":\"Category2\",\"custom\":\"Custom\"}', '', '', '', ''); COMMIT; -- ---------------------------- diff --git a/application/admin/controller/general/Attachment.php b/application/admin/controller/general/Attachment.php index d73c25cef..57296f2f9 100644 --- a/application/admin/controller/general/Attachment.php +++ b/application/admin/controller/general/Attachment.php @@ -8,7 +8,7 @@ use app\common\controller\Backend; * 附件管理 * * @icon fa fa-circle-o - * @remark 主要用于管理上传到又拍云的数据或上传至本服务的上传数据 + * @remark 主要用于管理上传到服务器或第三方存储的数据 */ class Attachment extends Backend { @@ -18,11 +18,15 @@ class Attachment extends Backend */ protected $model = null; + protected $searchFields = 'id,filename,url'; + public function _initialize() { parent::_initialize(); $this->model = model('Attachment'); $this->view->assign("mimetypeList", \app\common\model\Attachment::getMimetypeList()); + $this->view->assign("categoryList", \app\common\model\Attachment::getCategoryList()); + $this->assignconfig("categoryList", \app\common\model\Attachment::getCategoryList()); } /** @@ -36,10 +40,15 @@ class Attachment extends Backend $mimetypeQuery = []; $filter = $this->request->request('filter'); $filterArr = (array)json_decode($filter, true); + if (isset($filterArr['category']) && $filterArr['category'] == 'unclassed') { + $filterArr['category'] = ''; + $this->request->get(['filter' => json_encode(array_diff_key($filterArr, ['category' => '']))]); + } if (isset($filterArr['mimetype']) && preg_match("/[]\,|\*]/", $filterArr['mimetype'])) { - $this->request->get(['filter' => json_encode(array_diff_key($filterArr, ['mimetype' => '']))]); - $mimetypeQuery = function ($query) use ($filterArr) { - $mimetypeArr = explode(',', $filterArr['mimetype']); + $mimetype = $filterArr['mimetype']; + $filterArr = array_diff_key($filterArr, ['mimetype' => '']); + $mimetypeQuery = function ($query) use ($mimetype) { + $mimetypeArr = explode(',', $mimetype); foreach ($mimetypeArr as $index => $item) { if (stripos($item, "/*") !== false) { $query->whereOr('mimetype', 'like', str_replace("/*", "/", $item) . '%'); @@ -49,6 +58,7 @@ class Attachment extends Backend } }; } + $this->request->get(['filter' => json_encode($filterArr)]); list($where, $sort, $order, $offset, $limit) = $this->buildparams(); @@ -121,4 +131,25 @@ class Attachment extends Backend $this->error(__('Parameter %s can not be empty', 'ids')); } + /** + * 移动 + */ + public function move($ids = "") + { + if (!$this->request->isPost()) { + $this->error(__("Invalid parameters")); + } + $category = $this->request->post('category', ''); + $ids = $this->request->post('ids'); + if (!$ids) { + $this->error(__('Parameter %s can not be empty', 'ids')); + } + $categoryList = \app\common\model\Attachment::getCategoryList(); + if ($category && !isset($categoryList[$category])) { + $this->error(__('Category not found')); + } + \app\common\model\Attachment::where('id', 'in', $ids)->update(['category' => $category]); + $this->success(); + } + } diff --git a/application/admin/controller/general/Config.php b/application/admin/controller/general/Config.php index f4b93e2a1..bab69e841 100644 --- a/application/admin/controller/general/Config.php +++ b/application/admin/controller/general/Config.php @@ -60,6 +60,14 @@ class Config extends Backend $value['value'] = explode(',', $value['value']); } $value['content'] = json_decode($value['content'], true); + if (in_array($value['name'], ['categorytype', 'configgroup', 'attachmentcategory'])) { + $dictValue = (array)json_decode($value['value'], true); + foreach ($dictValue as $index => &$item) { + $item = __($item); + } + unset($item); + $value['value'] = json_encode($dictValue, JSON_UNESCAPED_UNICODE); + } $value['tip'] = htmlspecialchars($value['tip']); $siteList[$v['group']]['list'][] = $value; } diff --git a/application/admin/lang/zh-cn/general/attachment.php b/application/admin/lang/zh-cn/general/attachment.php index 90fe66d72..86690e2a2 100644 --- a/application/admin/lang/zh-cn/general/attachment.php +++ b/application/admin/lang/zh-cn/general/attachment.php @@ -23,9 +23,17 @@ return [ 'Createtime' => '创建日期', 'Uploadtime' => '上传时间', 'Storage' => '存储引擎', + 'Category1' => '分类一', + 'Category2' => '分类二', + 'Custom' => '自定义', + 'Unclassed' => '未归类', + 'Category' => '类别', 'Upload to third' => '上传到第三方', 'Upload to local' => '上传到本地', 'Upload to third by chunk' => '上传到第三方(分片模式)', 'Upload to local by chunk' => '上传到本地(分片模式)', + 'Please enter a new name' => '请输入新的类别名称', + 'Please select category' => '请选择一个类别', + 'Category not found' => '指定的类别未找到', 'Upload from editor' => '从编辑器上传' ]; diff --git a/application/admin/lang/zh-cn/general/config.php b/application/admin/lang/zh-cn/general/config.php index 021384f3b..6a2b95d6a 100644 --- a/application/admin/lang/zh-cn/general/config.php +++ b/application/admin/lang/zh-cn/general/config.php @@ -57,6 +57,9 @@ return [ 'Fixed page' => '后台固定页', 'Category type' => '分类类型', 'Config group' => '配置分组', + 'Attachment category' => '附件类别', + 'Category1' => '分类一', + 'Category2' => '分类二', 'Rule tips' => '校验规则使用请参考Nice-validator文档', 'Extend tips' => '扩展属性支持{id}、{name}、{group}、{title}、{value}、{content}、{rule}替换', 'Mail type' => '邮件发送方式', diff --git a/application/admin/view/general/attachment/edit.html b/application/admin/view/general/attachment/edit.html index 8caa393ec..85898b573 100644 --- a/application/admin/view/general/attachment/edit.html +++ b/application/admin/view/general/attachment/edit.html @@ -1,5 +1,18 @@ + +
+
+ +
+ +
+
diff --git a/application/admin/view/general/attachment/index.html b/application/admin/view/general/attachment/index.html index 53cb2b8f5..8aaf0435b 100644 --- a/application/admin/view/general/attachment/index.html +++ b/application/admin/view/general/attachment/index.html @@ -2,9 +2,9 @@
{:build_heading(null,FALSE)} -