当前位置: 首页 > news >正文

Spring之Aop切面---日志收集(环绕处理、前置处理方式)--使用/教程/实例

Spring之Aop切面---日志收集(环绕处理、前置处理方式)--使用/教程/实例

    • 简介
      • 系统登录日志类LoginLogEntity .java
    • 一、环绕处理方式
      • 1、自定义注解类LoginLogAop.class
      • 2、切面处理类LogoutLogAspect.java
    • 二、前置处理方式:
      • 1、自定义注解类LogoutLogAop.class
      • 2、切面处理类LogoutLogAspect.java
    • 三、Proceedingjoinpoint简述

简介

本文章介绍采用两种不同方式处理----系统登录、系统退出登录两种场景日志。

  • 环绕处理系统登录日志
  • 前置处理系统退出登录日志

系统登录日志类LoginLogEntity .java

package com.fy.test.entity;import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;import java.io.Serializable;
import java.time.LocalDateTime;import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;/*** @ClassName: LoginLogEntity * @Description: * @Author fy* @Date 2023/07/10 9:00*/
@Data
@Accessors(chain = true)
@TableName("t_login_log")
public class LoginLogEntity implements Serializable {private static final long serialVersionUID = 1L;/*** 主键*/@TableId(value = "id", type = IdType.ASSIGN_ID)private String id;/*** 操作系统*/private String opOs;/*** 浏览器类型*/private String opBrowser;/*** 登录IP地址*/private String opIp;/*** 登录时间*/private LocalDateTime opDate;/*** 登录用户ID*/private String userId;/*** 登录用户名称*/private String userName;/*** 错误类型*/private String exCode;/*** 错误信息*/private String exMsg;/*** 登录状态*/private boolean status;/*** 描述*/private String desc;
}

一、环绕处理方式

1、自定义注解类LoginLogAop.class

package com.fy.test.log.annotation;import java.lang.annotation.*;/*** @ClassName: LoginLogAop* @Description: * @Author fy* @Date 2023/07/10 9:05*/
@Target({ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface LoginLogAop {/*** 描述*/String desc() default "";}

2、切面处理类LogoutLogAspect.java

package com.fy.test.log.aspect;import cn.hutool.extra.servlet.ServletUtil;
import cn.hutool.http.useragent.UserAgent;
import cn.hutool.http.useragent.UserAgentUtil;
import com.fy.test.log.annotation.LoginLogAop;
import com.fy.test.utils.RequestHolder;
import com.fy.test.utils.SecurityUtil;
import com.fy.test.service.dto.LoginLogDto;
import com.fy.test.service.feign.LogServiceFeign;
import com.fy.test.service.vo.UserVo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;/*** @ClassName: LoginLogAspect* @Description:* @Author fy* @Date 2023/07/10 9:05*/
@Slf4j
@Aspect
public class LoginLogAspect {@Autowiredprivate LogServiceFeign logServiceFeign;/*** 配置织入点*/@Pointcut("@annotation(com.fy.test.common.log.annotation.LoginLogAop)")public void logPointCut() {}/*** 通知方法会将目标方法封装起来* 注意:环绕方式选择ProceedingJoinPoint* Proceedingjoinpoint 继承了JoinPoint,在JoinPoint的基础上暴露出 proceed(), 这个方法是AOP代理链执行的方法。* JoinPoint仅能获取相关参数,无法执行连接点。* 暴露出proceed()这个方法,就能支持 aop:around 这种切面(而其他的几种切面只需要用到JoinPoint,这跟切面类型有关),* 就能控制走代理链还是走自己拦截的其他逻辑。  * * @param joinPoint 切点*/@Around(value = "logPointCut()")public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {Object result = joinPoint.proceed();LoginLogDto logDto = getLog();logDto.setStatus(true);handleLog(joinPoint, logDto);return result;}/*** 通知方法会在目标方法抛出异常后执行** @param joinPoint* @param e*/@AfterThrowing(value = "logPointCut()", throwing = "e")public void doAfterThrowing(JoinPoint joinPoint, Exception e) {LoginLogDto logDto = getLog();logDto.setExCode(e.getClass().getSimpleName()).setExMsg(e.getMessage());logDto.setStatus(false);handleLog(joinPoint, logDto);}private LoginLogDto getLog() {HttpServletRequest request = RequestHolder.getHttpServletRequest();UserAgent userAgent = UserAgentUtil.parse(request.getHeader("User-Agent"));LoginLogDto loginLog = new LoginLogDto();loginLog.setOpIp(ServletUtil.getClientIP(request)).setOpOs(userAgent.getOs().getName()).setOpBrowser(userAgent.getBrowser().getName()).setUserId(SecurityUtil.getUserId()).setUserName(SecurityUtil.getUserName()).setOpDate(LocalDateTime.now());return loginLog;}protected void handleLog(final JoinPoint joinPoint, LoginLogDto loginLogDto) {// 获得注解LoginLogAop logAop = getAnnotationLog(joinPoint);if (null == logAop) {return;}loginLogDto.setDescription(logAop.description());Map<String, Object> requestParams = getRequestParams(joinPoint);if (requestParams.containsKey("userVo")) {UserVo userVo = JSONObject.parseObject(JSON.toJSONString(requestParams.get("userVo")), UserVo.class);if (null != userVo && StringUtils.isBlank(loginLogDto.getUserName())) {loginLogDto.setUserName(userVo.getUsername());}}// 保存数据库logServiceFeign.saveLoginLog(loginLogDto);}/*** 是否存在注解,如果存在就获取*/private LoginLogAop getAnnotationLog(JoinPoint joinPoint) {Signature signature = joinPoint.getSignature();MethodSignature methodSignature = (MethodSignature) signature;Method method = methodSignature.getMethod();if (method != null) {return method.getAnnotation(LoginLogAop.class);}return null;}/*** 获取入参*/private Map<String, Object> getRequestParams(JoinPoint joinPoint) {Map<String, Object> requestParams = new HashMap<>();// 参数名String[] paramNames = ((MethodSignature) joinPoint.getSignature()).getParameterNames();// 参数值Object[] paramValues = joinPoint.getArgs();for (int i = 0; i < paramNames.length; i++) {Object value = paramValues[i];// 如果是文件对象if (value instanceof MultipartFile) {MultipartFile file = (MultipartFile) value;// 获取文件名value = file.getOriginalFilename();}requestParams.put(paramNames[i], value);}return requestParams;}
}

二、前置处理方式:

1、自定义注解类LogoutLogAop.class

package com.fy.test.log.annotation;import java.lang.annotation.*;/*** @ClassName: LogoutLogAop* @Description: * @Author fy* @Date 2023/07/10 9:10*/
@Target({ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface LogoutLogAop {/*** 描述*/String desc() default "";}

2、切面处理类LogoutLogAspect.java

package com.fy.test.log.aspect;import cn.hutool.extra.servlet.ServletUtil;
import cn.hutool.http.useragent.UserAgent;
import cn.hutool.http.useragent.UserAgentUtil;
import com.fy.test.log.annotation.LoginLogAop;
import com.fy.test.log.annotation.LogoutLogAop;
import com.fy.test.utils.RequestHolder;
import com.fy.test.utils.SecurityUtil;
import com.fy.test.service.dto.LoginLogDto;
import com.fy.test.service.feign.LogServiceFeign;
import com.fy.test.service.vo.UserVo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;/*** @ClassName: LogoutLogAspect* @Description:* @Author fy* @Date 2023/07/10 9:10*/
@Slf4j
@Aspect
public class LogoutLogAspect {@Autowiredprivate LogServiceFeign logServiceFeign;/*** 配置织入点*/@Pointcut("@annotation(com.fy.test.log.annotation.LogoutLogAop)")public void logPointCut() {}/*** 通知方法会将目标方法封装起来** @param joinPoint 切点*/@Before("logPointCut()")public void doBefore(JoinPoint joinPoint) throws Throwable {try {System.out.println("==============前置处理开始==============");LoginLogDto logDto = getLog();logDto.setStatus(true);handleLog(joinPoint, logDto);} catch (Exception e) {//记录本地异常日志log.error("==前置通知异常==");log.error("异常信息:{}", e.getMessage());}}/*** 通知方法会在目标方法抛出异常后执行** @param joinPoint* @param e*/@AfterThrowing(value = "logPointCut()", throwing = "e")public void doAfterThrowing(JoinPoint joinPoint, Exception e) {LoginLogDto logDto = getLog();logDto.setExCode(e.getClass().getSimpleName()).setExMsg(e.getMessage());logDto.setStatus(false);handleLog(joinPoint, logDto);}private LoginLogDto getLog() {HttpServletRequest request = RequestHolder.getHttpServletRequest();UserAgent userAgent = UserAgentUtil.parse(request.getHeader("User-Agent"));LoginLogDto loginLogDto = new LoginLogDto();loginLogDto.setOpIp(ServletUtil.getClientIP(request)).setOpOs(userAgent.getOs().getName()).setOpBrowser(userAgent.getBrowser().getName()).setUserId(SecurityUtil.getUserId()).setUserName(SecurityUtil.getUserName()).setOpDate(LocalDateTime.now());return loginLogDto;}protected void handleLog(final JoinPoint joinPoint, LoginLogDto loginLogDto) {// 获得注解LogoutLogAop logAop = getAnnotationLog(joinPoint);if (null == logAop) {return;}loginLogDto.setDesc(logAop.desc());// 保存数据库logServiceFeign.saveLoginLog(loginLogDto);}/*** 是否存在注解,如果存在就获取*/private LogoutLogAop getAnnotationLog(JoinPoint joinPoint) {Signature signature = joinPoint.getSignature();MethodSignature methodSignature = (MethodSignature) signature;Method method = methodSignature.getMethod();if (method != null) {return method.getAnnotation(LogoutLogAop.class);}return null;}/*** 获取入参*/private Map<String, Object> getRequestParams(JoinPoint joinPoint) {Map<String, Object> requestParams = new HashMap<>();// 参数名String[] paramNames = ((MethodSignature) joinPoint.getSignature()).getParameterNames();// 参数值Object[] paramValues = joinPoint.getArgs();for (int i = 0; i < paramNames.length; i++) {Object value = paramValues[i];// 如果是文件对象if (value instanceof MultipartFile) {MultipartFile file = (MultipartFile) value;// 获取文件名value = file.getOriginalFilename();}requestParams.put(paramNames[i], value);}return requestParams;}
}

三、Proceedingjoinpoint简述

Proceedingjoinpoint 继承了JoinPoint,在JoinPoint的基础上暴露出 proceed(), 这个方法是AOP代理链执行的方法。

JoinPoint仅能获取相关参数,无法执行连接点。暴露出proceed()这个方法,就能支持 aop:around 这种切面(而其他的几种切面只需要用到JoinPoint,这跟切面类型有关),就能控制走代理链还是走自己拦截的其他逻辑。

import org.aspectj.lang.reflect.SourceLocation;  
public interface JoinPoint {  String toString();         //连接点所在位置的相关信息  String toShortString();    //连接点所在位置的简短相关信息  String toLongString();     //连接点所在位置的全部相关信息  Object getThis();          //返回AOP代理对象,也就是com.sun.proxy.$Proxy18Object getTarget();        //返回目标对象,一般我们都需要它或者(也就是定义方法的接口或类,为什么会是接口呢?//这主要是在目标对象本身是动态代理的情况下,例如Mapper。所以返回的是定义方法的对象如//aoptest.daoimpl.GoodDaoImpl或com.b.base.BaseMapper<T, E, PK>)Object[] getArgs();        //返回被通知方法参数列表  Signature getSignature();  //返回当前连接点签名。其getName()方法返回方法的FQN,如void aoptest.dao.GoodDao.delete()//或com.b.base.BaseMapper.insert(T)(需要注意的是,很多时候我们定义了子类继承父类的时候,//我们希望拿到基于子类的FQN,无法直接拿到,要依赖于//AopUtils.getTargetClass(point.getTarget())获取原始代理对象,下面会详细讲解)SourceLocation getSourceLocation();//返回连接点方法所在类文件中的位置  String getKind();           //连接点类型  StaticPart getStaticPart(); //返回连接点静态部分  }  public interface ProceedingJoinPoint extends JoinPoint {  public Object proceed() throws Throwable;  public Object proceed(Object[] args) throws Throwable;  }

JoinPoint.StaticPart:提供访问连接点的静态部分,如被通知方法签名、连接点类型等等。

public interface StaticPart {  Signature getSignature();    //返回当前连接点签名  String getKind();            //连接点类型  int getId();                 //唯一标识  String toString();           //连接点所在位置的相关信息  String toShortString();      //连接点所在位置的简短相关信息  String toLongString();       //连接点所在位置的全部相关信息  
}

相关文章:

Spring之Aop切面---日志收集(环绕处理、前置处理方式)--使用/教程/实例

Spring之Aop切面---日志收集&#xff08;环绕处理、前置处理方式&#xff09;--使用/教程/实例 简介系统登录日志类LoginLogEntity .java 一、环绕处理方式1、自定义注解类LoginLogAop.class2、切面处理类LogoutLogAspect.java 二、前置处理方式&#xff1a;1、自定义注解类Log…...

UE4/UE5 照明构建失败 “Lightmass crashed”解决“数组索引越界”

在构建全局光照时,经常会出现“Lightmass crashed”的错误,导致光照构建失败。本文将分析这一问题的原因,并给出解决建议。 UE4 版本4.26 报错如下&#xff1a; <None> Lightmass crashed: Assertion failed: (Index > 0) & (Index < ArrayNum) [File:d:\bu…...

并发编程系列-Semaphore

Semaphore&#xff0c;如今通常被翻译为"信号量"&#xff0c;过去也曾被翻译为"信号灯"&#xff0c;因为类似于现实生活中的红绿灯&#xff0c;车辆是否能通行取决于是否是绿灯。同样&#xff0c;在编程世界中&#xff0c;线程是否能执行取决于信号量是否允…...

3年 Android 开发的面试心经(后悔当初没有拿 N+1)

作者&#xff1a;勇闯天涯 当某人顺利通过大厂面试时&#xff0c;总会有人认为这是运气比较好罢了&#xff0c;但他们不曾得知对方之前受过多少苦和委屈&#xff0c;又付出了多少努力一步步去突破这些困境。正是因为他们的努力付出&#xff0c;在合适的时间与地点&#xff0c;用…...

【c语言】 -- 指针进阶

&#x1f4d5;博主介绍&#xff1a;目前大一正在学习c语言&#xff0c;数据结构&#xff0c;计算机网络。 c语言学习&#xff0c;是为了更好的学习其他的编程语言&#xff0c;C语言是母体语言&#xff0c;是人机交互接近底层的桥梁。 本章来学习指针进阶。 让我们开启c语言学习…...

软件压力测试对软件产品起到什么作用?

一、软件压力测试是什么? 软件压力测试是一种通过模拟正常使用环境中可能出现的大量用户和大数据量的情况&#xff0c;来评估软件系统在压力下的稳定性和性能表现的测试方法。在软件开发过程中&#xff0c;经常会遇到一些性能瓶颈和稳定性问题&#xff0c;而软件压力测试的作…...

Stephen Wolfram:那么…ChatGPT 在做什么,为什么它有效呢?

So … What Is ChatGPT Doing, and Why Does It Work? 那么…ChatGPT在做什么&#xff0c;为什么它有效呢&#xff1f; The basic concept of ChatGPT is at some level rather simple. Start from a huge sample of human-created text from the web, books, etc. Then train…...

机器学习基础(五)

决策树 决策树是一种预测模型,它代表着对象属属性与对象值之间的一种映射关系。树中的每个节点代表一个对象,分叉路径(或者叫树枝)则代表一个属性值。 决策树常用方法: 分类树分析,是一种监督学习,用于预计结果可能为离散类型。 回归树分析,用于预计结果为实数。 CART,…...

阿里云服务器安装WordPress网站教程基于CentOS系统

阿里云百科分享使用阿里云服务器安装WordPress博客网站教程&#xff0c;WordPress是使用PHP语言开发的博客平台&#xff0c;在支持PHP和MySQL数据库的服务器上&#xff0c;您可以用WordPress架设自己的网站&#xff0c;也可以用作内容管理系统&#xff08;CMS&#xff09;。本教…...

【100天精通python】Day37:GUI界面编程_PyQT从入门到实战(上)

目录 专栏导读 1 PyQt6 简介&#xff1a; 1.1 安装 PyQt6 和相关工具&#xff1a; 1.2 PyQt6 基础知识&#xff1a; 1.2.1 Qt 的基本概念和组件&#xff1a; 1.2.2 创建和使用 Qt 窗口、标签、按钮等基本组件 1.2.3 布局管理器&#xff1a;垂直布局、水平布局、网格布局…...

数据结构—散列表的查找

7.4散列表的查找 7.4.1散列表的基本概念 基本思想&#xff1a;记录的存储位置域关键字之间存在对应关系 ​ 对应关系——hash函数 ​ Loc&#xff08;i&#xff09; H&#xff08;keyi&#xff09; 如何查找&#xff1a; 根据散列函数 H(key) k 查找key9&#xff0c;则访…...

Expo项目 使用Native base UI库

装包&#xff1a; yarn add native-base expo install react-native-svg12.1.1 Index.js: import React from react import { View, Text } from react-native import useList from ./useList import { NativeBaseProvider, Button, Box } from native-base import styles f…...

74、75、76——tomcat项目实战

tomcat项目实战 tomcat 依赖 java运行环境,必须要有jre , 选择 jdk1.8 JvmPertest 千万不能用 kyj易捷支付 项目机器 选择 一台机器 ,安装jdk1.8的机器下载tomcat的包 上传到机器,解压tomcattomcat文件 bin文件夹: 启动文件 堆栈配置文件 catalina.sh JAVA_OPTS="-Xm…...

jmeter errstr :“unsupported field type for multipart.FileHeader“

在使用jmeter测试接口的时候&#xff0c;提示errstr :"unsupported field type for multipart.FileHeader"如图所示 这是因为我们 在HTTP信息头管理加content-type参数有问题 直接在HTTP请求中&#xff0c;勾选&#xff1a; use multipart/form-data for POST【中文…...

C#调用C++ DLL传参byte[]数组字节值大于127时会变为0x3f的问题解决

最近做了一个网络编程的DLL给C#调用&#xff0c;DLL中封装了一个TCP Client的函数接口&#xff0c;如下所示 //C TCP报文发送接口 int TcpClient_send(unsigned char* buffSend, unsigned int nLen) {unsigned char buff[1024];int len StringToHex(buffSend, buff);int nRet…...

【vue3+xlxs+xlsx-style-vite】vue3项目中使用xlsx插件实现Excel表格的导出和解析,已实现

在vue3项目中使用xlsx插件实现Excel表格的导出和解析 1、xlsx插件包官方 xlsx插件包官方 2、FileReader官方文档&#xff1a;FileReader官方文档 安装xlsx和xlsx-style-vite、file-saver npm install xlsx npm install xlsx-style-vite npm install file-saverpackage.json中查…...

Doris2.0时代的一些机遇和挑战!

300万字&#xff01;全网最全大数据学习面试社区等你来&#xff01; 上个周五的时候&#xff0c;Doris官宣了2.0版本&#xff0c;除了在性能上的大幅提升&#xff0c;还有一些特性需要大家特别关注。 根据官网的描述&#xff0c;Doris在下面领域都有了长足进步&#xff1a; 日志…...

Leetcode-每日一题【剑指 Offer 32 - I. 从上到下打印二叉树】

题目 从上到下打印出二叉树的每个节点&#xff0c;同一层的节点按照从左到右的顺序打印。 例如: 给定二叉树: [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回&#xff1a; [3,9,20,15,7] 提示&#xff1a; 节点总数 < 1000 解题思路 1.题目要求我们从…...

网神 SecGate 3600 防火墙任意文件上传漏洞复现

0x01 产品简介 网神SecGate3600下一代极速防火墙&#xff08;NSG系列&#xff09;是基于完全自主研发、经受市场检验的成熟稳定网神第三代SecOS操作系统 并且在专业防火墙、VPN、IPS的多年产品经验积累基础上精心研发的高性能下一代防火墙 专门为运营商、政府、军队、教育、大型…...

把独显塞回CPU,新核显能够媲美RTX 30、40系显卡了

上个月&#xff0c;AMD 发布了 Zen4 架构 R5 7600X 的无核显版 - 7500F 。 各种数据评测和玩家实际体验大家也已经看过了&#xff0c;说是变相降价一点不错。 原因也很简单&#xff0c;感谢 Intel 。 Jon Peddie Research 刚出炉报告显示&#xff0c;2023 第二季度 AMD 客户端…...

树莓派超全系列教程文档--(61)树莓派摄像头高级使用方法

树莓派摄像头高级使用方法 配置通过调谐文件来调整相机行为 使用多个摄像头安装 libcam 和 rpicam-apps依赖关系开发包 文章来源&#xff1a; http://raspberry.dns8844.cn/documentation 原文网址 配置 大多数用例自动工作&#xff0c;无需更改相机配置。但是&#xff0c;一…...

Git常用命令完全指南:从入门到精通

Git常用命令完全指南&#xff1a;从入门到精通 一、基础配置命令 1. 用户信息配置 # 设置全局用户名 git config --global user.name "你的名字"# 设置全局邮箱 git config --global user.email "你的邮箱example.com"# 查看所有配置 git config --list…...

在鸿蒙HarmonyOS 5中使用DevEco Studio实现企业微信功能

1. 开发环境准备 ​​安装DevEco Studio 3.1​​&#xff1a; 从华为开发者官网下载最新版DevEco Studio安装HarmonyOS 5.0 SDK ​​项目配置​​&#xff1a; // module.json5 {"module": {"requestPermissions": [{"name": "ohos.permis…...

学习一下用鸿蒙​​DevEco Studio HarmonyOS5实现百度地图

在鸿蒙&#xff08;HarmonyOS5&#xff09;中集成百度地图&#xff0c;可以通过以下步骤和技术方案实现。结合鸿蒙的分布式能力和百度地图的API&#xff0c;可以构建跨设备的定位、导航和地图展示功能。 ​​1. 鸿蒙环境准备​​ ​​开发工具​​&#xff1a;下载安装 ​​De…...

LLaMA-Factory 微调 Qwen2-VL 进行人脸情感识别(二)

在上一篇文章中,我们详细介绍了如何使用LLaMA-Factory框架对Qwen2-VL大模型进行微调,以实现人脸情感识别的功能。本篇文章将聚焦于微调完成后,如何调用这个模型进行人脸情感识别的具体代码实现,包括详细的步骤和注释。 模型调用步骤 环境准备:确保安装了必要的Python库。…...

数据分析六部曲?

引言 上一章我们说到了数据分析六部曲&#xff0c;何谓六部曲呢&#xff1f; 其实啊&#xff0c;数据分析没那么难&#xff0c;只要掌握了下面这六个步骤&#xff0c;也就是数据分析六部曲&#xff0c;就算你是个啥都不懂的小白&#xff0c;也能慢慢上手做数据分析啦。 第一…...

AI书签管理工具开发全记录(十八):书签导入导出

文章目录 AI书签管理工具开发全记录&#xff08;十八&#xff09;&#xff1a;书签导入导出1.前言 &#x1f4dd;2.书签结构分析 &#x1f4d6;3.书签示例 &#x1f4d1;4.书签文件结构定义描述 &#x1f523;4.1. ​整体文档结构​​4.2. ​核心元素类型​​4.3. ​层级关系4.…...

八、【ESP32开发全栈指南:UDP客户端】

1. 环境准备 安装ESP-IDF v4.4 (官方指南)确保Python 3.7 和Git已安装 2. 创建项目 idf.py create-project udp_client cd udp_client3. 完整优化代码 (main/main.c) #include <string.h> #include "freertos/FreeRTOS.h" #include "freertos/task.h&…...

动态生成element-plus的scss变量;SCSS中实现动态颜色变体生成

文章目录 一、动态css变量1.生成内容2.动态生成css变量2.1新增_color-utils.scss&#xff08;不推荐&#xff09;2.2新增_color-utils.scss&#xff08;推荐&#xff09;2.3theme.scss引入使用 一、动态css变量 1.生成内容 在我们修改element-plus主题色时候&#xff0c;会自…...

STM32+MPU6050传感器

#创作灵感## 在嵌入式系统开发中&#xff0c;STM32F103C8T6单片机与MPU6050传感器的组合因其高性能、低功耗以及丰富的功能而备受青睐。本文将简单介绍如何在Keil 5开发环境中实现STM32F103C8T6与MPU6050的连接和基本数据采集&#xff0c;带你快速入门智能硬件开发。 一、硬件…...