年后好累啊

57 阅读1分钟

过年天天被鞭炮教育 , 累啊

最近好喜欢这么写代码

public function addFriend()
{
    $userId = Context::get('user_id');

    $friendId = $this->request->post('friend_id', 0);
    if (!$friendId) {
        $errParams = '熟人';
        goto  PARAM_ERR;
    }

    if (!is_array($friendId)) {
        $friendId = explode(',', $friendId);
    }

    $res = $this->userService->addFriend($userId, $friendId);
    if ($res) {
        return $this->successResponse(data: $res);
    } else {
        return $this->failResponse();
    }

    PARAM_ERR:
    return $this->failResponse(
        message: $errParams . config('statuscode.err_msg.params_not_complete'),
        code: config('statuscode.err_code.params_not_complete')
    );
}