diff --git a/server/app/adminapi/logic/article/ArticleCateLogic.php b/server/app/adminapi/logic/article/ArticleCateLogic.php index 1836fe6eb..9fcbd21ab 100644 --- a/server/app/adminapi/logic/article/ArticleCateLogic.php +++ b/server/app/adminapi/logic/article/ArticleCateLogic.php @@ -61,8 +61,7 @@ public static function edit(array $params) : bool ]); return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/adminapi/logic/article/ArticleLogic.php b/server/app/adminapi/logic/article/ArticleLogic.php index 641ab0404..ac91c03a4 100644 --- a/server/app/adminapi/logic/article/ArticleLogic.php +++ b/server/app/adminapi/logic/article/ArticleLogic.php @@ -74,8 +74,7 @@ public static function edit(array $params) : bool ]); return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/adminapi/logic/auth/AdminLogic.php b/server/app/adminapi/logic/auth/AdminLogic.php index dbaddd621..74f5fdba1 100644 --- a/server/app/adminapi/logic/auth/AdminLogic.php +++ b/server/app/adminapi/logic/auth/AdminLogic.php @@ -71,8 +71,7 @@ public static function add(array $params) return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } @@ -138,8 +137,7 @@ public static function edit(array $params): bool return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } @@ -177,8 +175,7 @@ public static function delete(array $params): bool return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/adminapi/logic/channel/OfficialAccountMenuLogic.php b/server/app/adminapi/logic/channel/OfficialAccountMenuLogic.php index 454526f5d..85cd5f823 100644 --- a/server/app/adminapi/logic/channel/OfficialAccountMenuLogic.php +++ b/server/app/adminapi/logic/channel/OfficialAccountMenuLogic.php @@ -40,8 +40,7 @@ public static function save($params) ConfigService::set('oa_setting', 'menu', $params); return true; } catch (\Exception $e) { - OfficialAccountMenuLogic::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } @@ -192,13 +191,11 @@ public static function saveAndPublish($params) return true; } - self::setError('保存发布菜单失败' . json_encode($result->getContent())); + return self::setError('保存发布菜单失败' . json_encode($result)); - return false; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/adminapi/logic/channel/OfficialAccountReplyLogic.php b/server/app/adminapi/logic/channel/OfficialAccountReplyLogic.php index 870602426..eaf423c91 100644 --- a/server/app/adminapi/logic/channel/OfficialAccountReplyLogic.php +++ b/server/app/adminapi/logic/channel/OfficialAccountReplyLogic.php @@ -51,8 +51,7 @@ public static function add($params) OfficialAccountReply::create($params); return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } @@ -93,8 +92,7 @@ public static function edit($params) OfficialAccountReply::update($params); return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/adminapi/logic/crontab/CrontabLogic.php b/server/app/adminapi/logic/crontab/CrontabLogic.php index 2786ae867..af67063d3 100644 --- a/server/app/adminapi/logic/crontab/CrontabLogic.php +++ b/server/app/adminapi/logic/crontab/CrontabLogic.php @@ -43,8 +43,7 @@ public static function add($params) return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } @@ -84,8 +83,7 @@ public static function edit($params) return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } @@ -104,8 +102,7 @@ public static function delete($params) return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } @@ -136,8 +133,7 @@ public static function operate($params) return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/adminapi/logic/dept/DeptLogic.php b/server/app/adminapi/logic/dept/DeptLogic.php index c39bd654a..10c76aa32 100644 --- a/server/app/adminapi/logic/dept/DeptLogic.php +++ b/server/app/adminapi/logic/dept/DeptLogic.php @@ -148,8 +148,7 @@ public static function edit(array $params): bool ]); return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/adminapi/logic/dept/JobsLogic.php b/server/app/adminapi/logic/dept/JobsLogic.php index 925ea55a0..f921b4c7d 100644 --- a/server/app/adminapi/logic/dept/JobsLogic.php +++ b/server/app/adminapi/logic/dept/JobsLogic.php @@ -68,8 +68,7 @@ public static function edit(array $params) : bool ]); return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/adminapi/logic/notice/NoticeLogic.php b/server/app/adminapi/logic/notice/NoticeLogic.php index 552999e0b..22bebaea4 100644 --- a/server/app/adminapi/logic/notice/NoticeLogic.php +++ b/server/app/adminapi/logic/notice/NoticeLogic.php @@ -109,8 +109,7 @@ public static function set($params) NoticeSetting::where('id', $params['id'])->update($updateData); return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/adminapi/logic/recharge/RechargeLogic.php b/server/app/adminapi/logic/recharge/RechargeLogic.php index 6ffa17519..b85022458 100644 --- a/server/app/adminapi/logic/recharge/RechargeLogic.php +++ b/server/app/adminapi/logic/recharge/RechargeLogic.php @@ -71,8 +71,7 @@ public static function setConfig($params) } return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/api/logic/LoginLogic.php b/server/app/api/logic/LoginLogic.php index 1a9263bf0..dbd54d837 100644 --- a/server/app/api/logic/LoginLogic.php +++ b/server/app/api/logic/LoginLogic.php @@ -63,8 +63,7 @@ public static function register(array $params) return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } @@ -111,8 +110,7 @@ public static function login($params) 'token' => $userInfo['token'], ]; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/api/logic/RechargeLogic.php b/server/app/api/logic/RechargeLogic.php index 3fe2e45e8..125806583 100644 --- a/server/app/api/logic/RechargeLogic.php +++ b/server/app/api/logic/RechargeLogic.php @@ -53,8 +53,7 @@ public static function recharge(array $params) 'from' => 'recharge' ]; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/api/logic/UserLogic.php b/server/app/api/logic/UserLogic.php index f48efe314..8e225d526 100644 --- a/server/app/api/logic/UserLogic.php +++ b/server/app/api/logic/UserLogic.php @@ -152,8 +152,7 @@ public static function resetPassword(array $params) return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } @@ -194,8 +193,7 @@ public static function changePassword(array $params, int $userId) return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } @@ -234,8 +232,7 @@ public static function getMobileByMnp(array $params) return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } @@ -283,8 +280,7 @@ public static function bindMobile(array $params) return true; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/api/logic/WechatLogic.php b/server/app/api/logic/WechatLogic.php index 6cda0b533..70daa7012 100644 --- a/server/app/api/logic/WechatLogic.php +++ b/server/app/api/logic/WechatLogic.php @@ -58,8 +58,7 @@ public static function jsConfig($params) 'scanQRCode' ]); } catch (Exception $e) { - self::setError('获取jssdk失败:' . $e->getMessage()); - return false; + return self::setError('获取jssdk失败:' . $e->getMessage()); } } } \ No newline at end of file diff --git a/server/app/common/logic/BaseLogic.php b/server/app/common/logic/BaseLogic.php index 0be59edaa..3352f2188 100644 --- a/server/app/common/logic/BaseLogic.php +++ b/server/app/common/logic/BaseLogic.php @@ -56,12 +56,13 @@ public static function getError() : string /** * @notes 设置错误信息 * @param $error - * @author 段誉 - * @date 2021/7/21 18:20 + * @author 段誉,muxi_k + * @date 2023/12/29 18:20 */ - public static function setError($error) : void + public static function setError($error) : bool { !empty($error) && self::$error = $error; + return false; } diff --git a/server/app/common/logic/NoticeLogic.php b/server/app/common/logic/NoticeLogic.php index 913aa0914..1e33823f7 100644 --- a/server/app/common/logic/NoticeLogic.php +++ b/server/app/common/logic/NoticeLogic.php @@ -56,8 +56,7 @@ public static function noticeByScene($params) return $res; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/common/logic/PayNotifyLogic.php b/server/app/common/logic/PayNotifyLogic.php index b3339b5d5..1dacbc4d6 100644 --- a/server/app/common/logic/PayNotifyLogic.php +++ b/server/app/common/logic/PayNotifyLogic.php @@ -45,8 +45,7 @@ public static function handle($action, $orderSn, $extra = []) $e->getLine(), $e->getMessage() ])); - self::setError($e->getMessage()); - return $e->getMessage(); + return self::setError($e->getMessage()); } } diff --git a/server/app/common/logic/PaymentLogic.php b/server/app/common/logic/PaymentLogic.php index 247d6a776..f03dd322a 100644 --- a/server/app/common/logic/PaymentLogic.php +++ b/server/app/common/logic/PaymentLogic.php @@ -85,8 +85,7 @@ public static function getPayWay($userId, $terminal, $params) ]; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } @@ -129,8 +128,7 @@ public static function getPayStatus($params) 'order' => $orderInfo ]; } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } diff --git a/server/app/common/service/generator/stub/php/logic.stub b/server/app/common/service/generator/stub/php/logic.stub index 4d4b7a6a3..20c16b318 100644 --- a/server/app/common/service/generator/stub/php/logic.stub +++ b/server/app/common/service/generator/stub/php/logic.stub @@ -48,8 +48,7 @@ class {UPPER_CAMEL_NAME}Logic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } } @@ -73,8 +72,7 @@ class {UPPER_CAMEL_NAME}Logic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - self::setError($e->getMessage()); - return false; + return self::setError($e->getMessage()); } }