hyperf 十九 数据库 二 模型
教程:Hyperf
一、命令行
symfony/console-CSDN博客
hypery 十一、命令行-CSDN博客
hyperf console 执行-CSDN博客
根据之前应该能了解到命令行的基本实现,和hyperf中命令行的定义。
1.1 命令初始化
hyperf.php中系统初始化中通过ApplicationFactory::__invoke(),将配置文件中的commands对应内容,通过Application::add($container->get($command)),设置为Application::command参数的值,类型为数组。
以ModelCommand::configure()为例,通过Hyperf\Config\ProviderConfig::load()进行配置加载,其作用就是将ModelCommand之类的命令类实例化,并设置为ProviderConfig::providerConfigs的值。
实例化的过程中,调用顺序为:
1、Hyperf\Database\Commands\ModelCommand::__construct()
2、Hyperf\Command\Command::__construct()
3、Symfony\Component\Console\Command::__construct()
4、$this->configure();
1.2 调用命令
执行命令通过Symfony\Component\Console\Application::run(),其中总过Application::get()获取Application::command中对应命令的尸体类。
Application::run()会调用Application::doRunCommand(),doRunCommand()中执行对应命令的run()方法。
实际运行以ModelCommand::handle()为例,调用顺序为:
1、Hyperf\Database\Commands\ModelCommand::run()
2、Hyperf\Command\Command::run()
3、Symfony\Component\Console\Command\Command::run()
4、Hyperf\Command\Command::execute()
5、Hyperf\Database\Commands\ModelCommand::handle()
1.3 ModelCommand执行
命令执行的入口为ModelCommand::handle(),通过设置参数,获取可处理数据。
若设置table则执行createModel(),否者执行createModels()。createModels()通过循环调用createModel()。
参数中ignore-tables,可设置需要忽略的表,在createModels()中起作用。
参数pool、inheritance、uses,替换对应/stubs/Model.stub文件中的内容。
参数path、prefix、table-mapping,则影响model文件生成。
和文档中不同的参数包括:with-ide、visitors
with-ide:是否生成对应mode的ide文件
visitors:设置ModelUpdateVisitor、ModelRewriteConnectionVisitor之类,用于处理数据的类。可用文件在vendor\hyperf\database\src\Commands\Ast中。可参考:创建脚本 - Hyperf 帮助文档 v2.0 - 开发文档 - 文江博客
二、参数设置
命令行
php bin/hyperf.php gen:model table_name
参数
参数 | 类型 | 默认值 | 备注 |
---|---|---|---|
--pool | string | default | 连接池,脚本会根据当前连接池配置创建 |
--path | string | app/Model | 模型路径 |
--force-casts | bool | false | 是否强制重置 casts 参数 |
--prefix | string | 空字符串 | 表前缀 |
--inheritance | string | Model | 父类 |
--uses | string | Hyperf\DbConnection\Model\Model | 配合 inheritance 使用 |
--refresh-fillable | bool | false | 是否刷新 fillable 参数 |
--table-mapping | array | [] | 为表名 -> 模型增加映射关系 比如 ['users:Account'] |
--ignore-tables | array | [] | 不需要生成模型的表名 比如 ['users'] |
--with-comments | bool | false | 是否增加字段注释 |
--property-case | int | 0 | 字段类型 0 蛇形 1 驼峰 |
可以通过命令行设置参数,可也在设置中写入参数。
设置中参数设置:
#config\autoload\databases.php
use Hyperf\Database\Commands\ModelOption;return ['default' => [// 忽略其他配置'commands' => ['gen:model' => ['path' => 'app/Model','force_casts' => true,'inheritance' => 'Model','uses' => '','refresh_fillable' => true,'table_mapping' => [],'with_comments' => true,'property_case' => ModelOption::PROPERTY_SNAKE_CASE,],],],
];
命令中设置参数的时候,通过ModelCommand::getOption(),会将命令行ArgvInput()::getOption(),通过判断是否使用配置中的参数
根据代码,参数中force-casts、refresh-fillable、with-comments、with-ide,若命令行中未传且配置中已设置,则会使用配置中的值。参数中table-mapping、ignore-tables、visitors都为数组,若命令行中未传且配置中已设置,则会使用配置中的值。即配置参数以命令行中参数优先使用。
三、测试
3.1 配置
hyperf.php配置
'commands' => ['gen:model' => ['path' => 'app1/Model','force_casts' => true,'inheritance' => 'Model',],
],
mysql:
CREATE TABLE `userinfo` (`id` int(11) NOT NULL AUTO_INCREMENT,`name` varchar(255) DEFAULT NULL,`age` tinyint(2) DEFAULT '0',PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=22 DEFAULT CHARSET=utf8;
composer.json
"autoload": {"psr-4": {"App\\": "app/","App1\\":"app1/"},"files": []},
3.2 创建
php bin/hyperf.php gen:model --table-mapping='userinfo:User' --prefix=app1 userinfo
执行挺简单一句, 没想到坑还挺多。
首先因为使用的是app1,而非app,所以在composer.json中增加psr-4,因为框架会循环psr-4中的值,根据逻辑判断返回对应的$path,没有匹配的数据则抛出throw。
composer.json修改之后需要composer update。否则对于以上情况,第一次生成model之后,再次处理对应model会报model找不到。
最后发现的一个坑,是文档上写明table-mapping应该是数组,写法应该是["userinfo:User"]。但是特别奇葩的是,创建过程中,将值格式化为["[userinfo"=>"User]"]……后来发现,table-mapping获取的值都是字符串和输入的格式无关,但是之后getTableMapping()没有对字符串进行处理,仅是分割字符串。可能和版本有关,或者因为我输入的格式有误。
还有一个可能是编译器导致的错误,创建的时候有个框架里的文件报错,里面的使用的部分类找不到。原因是没有设置对应的use,但是框架里对应文件存在,补充use语句之后bug解决。
3.3 插入
#model
class User extends Model
{public $timestamps = false;
}#测试
class TestController extends AbstractController
{public function testmodel(){$name = $this->request->input('name');$m_u = new User();$m_u->name = (string) $name;$result = $m_u->save();var_dump($result);}
}#执行结果
true
数据库配置文件在config/autoload/databases.php,但是里面设置的默认值只有在.env中对应值未设置的时候才生效。所以已有.env时,应该再检查下该文件数据库配置是否有误。
默认使用created_at,updated_at字段,设置$timestamps = false后关闭。
3.4 查询
$user = User::query()->where('id', 1)->first();
var_dump($user->name, $user->age);#运行结果
string(3) "123"
int(22)
3.5 软删除
#model
use Hyperf\DbConnection\Model\Model;
use Hyperf\Database\Model\SoftDeletes;
/***/
class User extends Model
{use SoftDeletes;
}#测试代码
$result = User::query()->where(['id' => 23])->delete();
var_dump($result);#测试结果
int(1)
软删除必须在数据中设置deleted_at字段。
四、源码
4.1 ModelCommand执行
namespace Hyperf\Database\Commands;
class ModelCommand extends Command
{public function handle(){$table = $this->input->getArgument('table');$pool = $this->input->getOption('pool');$option = new ModelOption();$option->setPool($pool)->setPath($this->getOption('path', 'commands.gen:model.path', $pool, 'app/Model'))->setPrefix($this->getOption('prefix', 'prefix', $pool, ''))->setInheritance($this->getOption('inheritance', 'commands.gen:model.inheritance', $pool, 'Model'))->setUses($this->getOption('uses', 'commands.gen:model.uses', $pool, 'Hyperf\DbConnection\Model\Model'))->setForceCasts($this->getOption('force-casts', 'commands.gen:model.force_casts', $pool, false))->setRefreshFillable($this->getOption('refresh-fillable', 'commands.gen:model.refresh_fillable', $pool, false))->setTableMapping($this->getOption('table-mapping', 'commands.gen:model.table_mapping', $pool, []))->setIgnoreTables($this->getOption('ignore-tables', 'commands.gen:model.ignore_tables', $pool, []))->setWithComments($this->getOption('with-comments', 'commands.gen:model.with_comments', $pool, false))->setWithIde($this->getOption('with-ide', 'commands.gen:model.with_ide', $pool, false))->setVisitors($this->getOption('visitors', 'commands.gen:model.visitors', $pool, []))->setPropertyCase($this->getOption('property-case', 'commands.gen:model.property_case', $pool));if ($table) {$this->createModel($table, $option);} else {$this->createModels($option);}}protected function createModel(string $table, ModelOption $option){$builder = $this->getSchemaBuilder($option->getPool());$table = Str::replaceFirst($option->getPrefix(), '', $table);$columns = $this->formatColumns($builder->getColumnTypeListing($table));$project = new Project();$class = $option->getTableMapping()[$table] ?? Str::studly(Str::singular($table));$class = $project->namespace($option->getPath()) . $class;$path = BASE_PATH . '/' . $project->path($class);if (!file_exists($path)) {$this->mkdir($path);file_put_contents($path, $this->buildClass($table, $class, $option));}$columns = $this->getColumns($class, $columns, $option->isForceCasts());$stms = $this->astParser->parse(file_get_contents($path));$traverser = new NodeTraverser();$traverser->addVisitor(make(ModelUpdateVisitor::class, ['class' => $class,'columns' => $columns,'option' => $option,]));$traverser->addVisitor(make(ModelRewriteConnectionVisitor::class, [$class, $option->getPool()]));$data = make(ModelData::class)->setClass($class)->setColumns($columns);foreach ($option->getVisitors() as $visitorClass) {$traverser->addVisitor(make($visitorClass, [$option, $data]));}$stms = $traverser->traverse($stms);$code = $this->printer->prettyPrintFile($stms);file_put_contents($path, $code);$this->output->writeln(sprintf('<info>Model %s was created.</info>', $class));if ($option->isWithIde()) {$this->generateIDE($code, $option, $data);}}
protected function createModels(ModelOption $option){$builder = $this->getSchemaBuilder($option->getPool());$tables = [];foreach ($builder->getAllTables() as $row) {$row = (array) $row;$table = reset($row);if (!$this->isIgnoreTable($table, $option)) {$tables[] = $table;}}foreach ($tables as $table) {$this->createModel($table, $option);}}protected function isIgnoreTable(string $table, ModelOption $option): bool{if (in_array($table, $option->getIgnoreTables())) {return true;}return $table === $this->config->get('databases.migrations', 'migrations');}
}
namespace Hyperf\Utils\CodeGen;
class Project
{public function namespace(string $path): string{$ext = pathinfo($path, PATHINFO_EXTENSION);if ($ext !== '') {$path = substr($path, 0, -(strlen($ext) + 1));} else {$path = trim($path, '/') . '/';}foreach ($this->getAutoloadRules() as $prefix => $prefixPath) {if ($this->isRootNamespace($prefix) || strpos($path, $prefixPath) === 0) {return $prefix . str_replace('/', '\\', substr($path, strlen($prefixPath)));}}throw new \RuntimeException("Invalid project path: {$path}");}protected function getAutoloadRules(): array{return data_get(Composer::getJsonContent(), 'autoload.psr-4', []);}
}
namespace Hyperf\Database\Commands;
class ModelOption
{public function setTableMapping(array $tableMapping): self{foreach ($tableMapping as $item) {[$key, $name] = explode(':', $item);$this->tableMapping[$key] = $name;}return $this;}
}
4.2 $timestamps使用
namespace Hyperf\Database\Model;
abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializable, CompressInterface
{use Concerns\HasTimestamps;public function save(array $options = []): bool{$this->mergeAttributesFromClassCasts();$query = $this->newModelQuery();// If the "saving" event returns false we'll bail out of the save and return// false, indicating that the save failed. This provides a chance for any// listeners to cancel save operations if validations fail or whatever.if ($saving = $this->fireModelEvent('saving')) {if ($saving instanceof StoppableEventInterface && $saving->isPropagationStopped()) {return false;}}// If the model already exists in the database we can just update our record// that is already in this database using the current IDs in this "where"// clause to only update this model. Otherwise, we'll just insert them.if ($this->exists) {$saved = $this->isDirty() ? $this->performUpdate($query) : true;} else {// If the model is brand new, we'll insert it into our database and set the// ID attribute on the model to the value of the newly inserted row's ID// which is typically an auto-increment value managed by the database.$saved = $this->performInsert($query);if (! $this->getConnectionName() && $connection = $query->getConnection()) {$this->setConnection($connection->getName());}}// If the model is successfully saved, we need to do a few more things once// that is done. We will call the "saved" method here to run any actions// we need to happen after a model gets successfully saved right here.if ($saved) {$this->finishSave($options);}return $saved;}protected function performUpdate(Builder $query){// If the updating event returns false, we will cancel the update operation so// developers can hook Validation systems into their models and cancel this// operation if the model does not pass validation. Otherwise, we update.if ($event = $this->fireModelEvent('updating')) {if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) {return false;}}// First we need to create a fresh query instance and touch the creation and// update timestamp on the model which are maintained by us for developer// convenience. Then we will just continue saving the model instances.if ($this->usesTimestamps()) {$this->updateTimestamps();}// Once we have run the update operation, we will fire the "updated" event for// this model instance. This will allow developers to hook into these after// models are updated, giving them a chance to do any special processing.$dirty = $this->getDirty();if (count($dirty) > 0) {$this->setKeysForSaveQuery($query)->update($dirty);$this->syncChanges();$this->fireModelEvent('updated');}return true;}
}
4.4 SoftDeletes使用
namespace Hyperf\Database\Model;
abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializable, CompressInterface
{public function delete(){$this->mergeAttributesFromClassCasts();if (is_null($this->getKeyName())) {throw new Exception('No primary key defined on model.');}// If the model doesn't exist, there is nothing to delete so we'll just return// immediately and not do anything else. Otherwise, we will continue with a// deletion process on the model, firing the proper events, and so forth.if (! $this->exists) {return;}if ($event = $this->fireModelEvent('deleting')) {if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) {return false;}}// Here, we'll touch the owning models, verifying these timestamps get updated// for the models. This will allow any caching to get broken on the parents// by the timestamp. Then we will go ahead and delete the model instance.$this->touchOwners();$this->performDeleteOnModel();// Once the model has been deleted, we will fire off the deleted event so that// the developers may hook into post-delete operations. We will then return// a boolean true as the delete is presumably successful on the database.$this->fireModelEvent('deleted');return true;}
}
namespace App1\Model;use Hyperf\Database\Model\SoftDeletes;
/***/
class User extends Model
{use SoftDeletes;
}
namespace Hyperf\Database\Model;
trait SoftDeletes
{protected function performDeleteOnModel(){if ($this->forceDeleting) {$this->exists = false;return $this->newModelQuery()->where($this->getKeyName(), $this->getKey())->forceDelete();}return $this->runSoftDelete();}protected function runSoftDelete(){$query = $this->newModelQuery()->where($this->getKeyName(), $this->getKey());$time = $this->freshTimestamp();$columns = [$this->getDeletedAtColumn() => $this->fromDateTime($time)];$this->{$this->getDeletedAtColumn()} = $time;if ($this->timestamps && ! is_null($this->getUpdatedAtColumn())) {$this->{$this->getUpdatedAtColumn()} = $time;$columns[$this->getUpdatedAtColumn()] = $this->fromDateTime($time);}$query->update($columns);}public function getDeletedAtColumn(){return defined('static::DELETED_AT') ? static::DELETED_AT : 'deleted_at';}
}
相关文章:
hyperf 十九 数据库 二 模型
教程:Hyperf 一、命令行 symfony/console-CSDN博客 hypery 十一、命令行-CSDN博客 hyperf console 执行-CSDN博客 根据之前应该能了解到命令行的基本实现,和hyperf中命令行的定义。 1.1 命令初始化 hyperf.php中系统初始化中通过ApplicationFacto…...

使用python快速开发与PDF文档对话的Gemini聊天机器人
检索增强生成(Retrieval-augmented generation,RAG)使得我们可以让大型语言模型(LLMs)访问外部知识库数据(如pdf,word、text等),从而让人们可以更加方便的通过LLM来学习外部数据的知识。今天我们将利用之前学习到的RAG方法,谷歌Gemini模型和l…...

Spring Cloud Gateway集成Knife4j
1、前提 网关路由能够正常工作。 案例 基于 Spring Cloud Gateway Nacos 实现动态路由拓展的参考地址:Spring Cloud Gateway Nacos 实现动态路由 详细官网案例:https://doc.xiaominfo.com/docs/middleware-sources/spring-cloud-gateway/spring-gatewa…...

Hive10_窗口函数
窗口函数(开窗函数) 1 相关函数说明 普通的聚合函数聚合的行集是组,开窗函数聚合的行集是窗口。因此,普通的聚合函数每组(Group by)只返回一个值,而开窗函数则可为窗口中的每行都返回一个值。简单理解,就是对查询的结果多出一列…...
ipvsadm命令详解
ipvsadm命令详解 大家好,我是免费搭建查券返利机器人赚佣金就用微赚淘客系统3.0的小编,也是冬天不穿秋裤,天冷也要风度的程序猿!今天我们将深入探讨一个在Linux系统网络管理中极具威力的命令——ipvsadm,通过详细解析…...

zabbix通过自动发现-配置监控项、触发器(小白教程)
自动发现配置参考链接(不小白,不友好) zabbix-get介绍 1配置 zabbix server:版本7(不影响),IP地址:192.168.0.60zabbix agent:版本agent1(不影响)ÿ…...
Dockerfile文件介绍
0 Preface/Foreword 0.1 Docker docker用来自制镜像。 1 Introduction 1.1 Dockerfile Dockerfile是用于定义Docker镜像的构建过程,它包含一系列的指令用于安装 软件包、配置环境等操作。 Dockerfile文件的格式如下: FROM base_image RUN apt-get up…...
【PHP】函数array_reduce()使用场景
目录 1.计算数组中所有元素的和 2.计算数组中所有元素的乘积 3.将多个字符串连接在一起 4.对数组中的元素进行逻辑计算 5.取出第一个满足条件的数组,筛选有用数组 6.array_reduce()函数的基本语法: array_reduce 函数通常用于对数组中的元素进行累…...

软件测试基础理论学习-软件测试方法论
软件测试方法论 软件测试的方法应该建立在不同的软件测试类型上,不同的测试类型会存在不同的方法。本文以软件测试中常见的黑盒测试为例,简述常见软件测试方法。 黑盒测试用例设计方法包括等价类划分法、边界值分析法、因果图法、判定表驱动法、正交试…...
Unity 关于点击不同物品移动并触发不同事件
关于点击不同物品触发不同事件 可以实现在界面中点击不同的物体,移动到物品附近位置,然后触发对应的事件。 首先建立一个公共管理的类: public class InteractionObject : MonoBehaviour {private NavMeshAgent PlayerAgent;private bool …...
c++IO库详细介绍
文章目录 前言c IO 类简介1. iostream库iostream 类标准IO对象 2. fstream库fstream 类 3. stringstream库stringstream 类 格式化和控制错误处理 IO对象无拷贝或赋值IO条件状态主要的状态标志检查流状态控制流状态示例 管理输出缓冲主要操作示例 文件输入输出使用文件流对象示…...

海外静态IP和动态IP有什么区别?推荐哪种?
什么是静态ip、动态ip,二者有什么区别?哪种好?关于这个问题,不难发现,在知道、知乎上面的解释有很多,但据小编的发现,这些回答都是关于静态ip和动态ip的专业术语解释,普通非专业人事…...

OpenHarmony从入门到放弃(一)
OpenHarmony从入门到放弃(二) 一、OpenHarmony的基本概念和特性 OpenHarmony是由开放原子开源基金会孵化及运营的开源项目,其目标是构建一个面向全场景、全连接、全智能的时代的智能终端设备操作系统。 分布式架构 OpenHarmony采用分布式…...

Unity3D UGUI图集打包与动态使用(TexturePacker)
制作图集的好处: 众所周知CPU是用来处理游戏的逻辑运算的,而GPU是用来处理游戏中图像的。在GPU中,我们要绘制一个图像需要提交图片(纹理)到显存,然后再进行绘制(在这个过程中会产生一次DrawCall…...

java maven项目添加oracle jdbc的依赖
一般添加依赖是直接在pom.xml中添加配置即可,Maven会自动获取对应的jar包,但是oracle驱动依赖添加后会显示红色,代表找不到依赖项,是因为Oracle授权问题,Maven3不提供Oracle JDBC driver,为了在Maven项目中…...

【UEFI基础】EDK网络框架(环境配置)
环境配置 为了能够让使用测试BIOS的QEMU与主机(就是指普通的Windows系统,我们使用它来编译BIOS和启动QEMU虚拟机)通过网络连接,需要额外的配置。 首先是下载和安装OpenVPN(这里安装的是OpenVPN-2.5.5-I601-amd64.msi…...
K8S学习指南(60)-K8S源代码走读之API-Server
文章目录 API Server 的代码结构API Server 的核心逻辑1. 请求处理流程1.1 HTTP 请求处理1.2 认证和授权1.3 API 版本处理1.4 资源路由1.5 资源处理1.6 响应生成 2. 存储层2.1 存储接口定义2.2 存储实现 二次开发扩展点1. 插件机制1.1 插件注册1.2 插件实现 2. 自定义资源定义&…...

基于深度学习的交通标志图像分类识别系统
温馨提示:文末有 CSDN 平台官方提供的学长 QQ 名片 :) 1. 项目简介 本文详细探讨了一基于深度学习的交通标志图像识别系统。采用TensorFlow和Keras框架,利用卷积神经网络(CNN)进行模型训练和预测,并引入VGG16迁移学习…...

使用uni-app editor富文本组件设置富文本内容及解决@Ready先于onload执行,无法获取后端接口数据的问题
开始使用富文本组件editor时,不知如何调用相关API设置富文本内容和获取内容,本文将举例详解 目录 一.了解editor组件的常用属性及相关API 1.属性常用说明 2.富文本相关API说明 1)editorContext 2) editorContext.setContents…...

Spring高手之路-Spring事务的传播机制(行为、特性)
目录 含义 七种事务传播机制 1.REQUIRED(默认) 2.REQUIRES_NEW 3.SUPPORTS 4.NOT_SUPPORTED 5.MANDATORY 6.NEVER 7.NESTED 含义 Spring事务的传播机制是指在多个事务方法相互调用时,如何处理这些事务的传播行为。对应七种事务传播行为…...
[2025CVPR]DeepVideo-R1:基于难度感知回归GRPO的视频强化微调框架详解
突破视频大语言模型推理瓶颈,在多个视频基准上实现SOTA性能 一、核心问题与创新亮点 1.1 GRPO在视频任务中的两大挑战 安全措施依赖问题 GRPO使用min和clip函数限制策略更新幅度,导致: 梯度抑制:当新旧策略差异过大时梯度消失收敛困难:策略无法充分优化# 传统GRPO的梯…...
逻辑回归:给不确定性划界的分类大师
想象你是一名医生。面对患者的检查报告(肿瘤大小、血液指标),你需要做出一个**决定性判断**:恶性还是良性?这种“非黑即白”的抉择,正是**逻辑回归(Logistic Regression)** 的战场&a…...

dedecms 织梦自定义表单留言增加ajax验证码功能
增加ajax功能模块,用户不点击提交按钮,只要输入框失去焦点,就会提前提示验证码是否正确。 一,模板上增加验证码 <input name"vdcode"id"vdcode" placeholder"请输入验证码" type"text&quo…...

【快手拥抱开源】通过快手团队开源的 KwaiCoder-AutoThink-preview 解锁大语言模型的潜力
引言: 在人工智能快速发展的浪潮中,快手Kwaipilot团队推出的 KwaiCoder-AutoThink-preview 具有里程碑意义——这是首个公开的AutoThink大语言模型(LLM)。该模型代表着该领域的重大突破,通过独特方式融合思考与非思考…...

DBAPI如何优雅的获取单条数据
API如何优雅的获取单条数据 案例一 对于查询类API,查询的是单条数据,比如根据主键ID查询用户信息,sql如下: select id, name, age from user where id #{id}API默认返回的数据格式是多条的,如下: {&qu…...

【Zephyr 系列 10】实战项目:打造一个蓝牙传感器终端 + 网关系统(完整架构与全栈实现)
🧠关键词:Zephyr、BLE、终端、网关、广播、连接、传感器、数据采集、低功耗、系统集成 📌目标读者:希望基于 Zephyr 构建 BLE 系统架构、实现终端与网关协作、具备产品交付能力的开发者 📊篇幅字数:约 5200 字 ✨ 项目总览 在物联网实际项目中,**“终端 + 网关”**是…...

DingDing机器人群消息推送
文章目录 1 新建机器人2 API文档说明3 代码编写 1 新建机器人 点击群设置 下滑到群管理的机器人,点击进入 添加机器人 选择自定义Webhook服务 点击添加 设置安全设置,详见说明文档 成功后,记录Webhook 2 API文档说明 点击设置说明 查看自…...
安卓基础(Java 和 Gradle 版本)
1. 设置项目的 JDK 版本 方法1:通过 Project Structure File → Project Structure... (或按 CtrlAltShiftS) 左侧选择 SDK Location 在 Gradle Settings 部分,设置 Gradle JDK 方法2:通过 Settings File → Settings... (或 CtrlAltS)…...
在树莓派上添加音频输入设备的几种方法
在树莓派上添加音频输入设备可以通过以下步骤完成,具体方法取决于设备类型(如USB麦克风、3.5mm接口麦克风或HDMI音频输入)。以下是详细指南: 1. 连接音频输入设备 USB麦克风/声卡:直接插入树莓派的USB接口。3.5mm麦克…...
Python竞赛环境搭建全攻略
Python环境搭建竞赛技术文章大纲 竞赛背景与意义 竞赛的目的与价值Python在竞赛中的应用场景环境搭建对竞赛效率的影响 竞赛环境需求分析 常见竞赛类型(算法、数据分析、机器学习等)不同竞赛对Python版本及库的要求硬件与操作系统的兼容性问题 Pyth…...