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

SpringBoot | 构建客户树及其关联关系的设计思路和实践Demo

关注:CodingTechWork

引言

  在企业级应用中,客户关系管理(CRM)是核心功能之一。客户树是一种用于表示客户之间层级关系的结构,例如企业客户与子公司、经销商与下级经销商等。本文将详细介绍如何设计客户树及其关联关系,通过三张表来实现:客户表、客户树表和客户关联关系表。这种设计可以清晰地分离客户的基本信息、树的结构信息以及客户之间的层级关系。

一、客户树及其关联关系的定义

客户树是一种层级结构,用于表示客户之间的上下级关系。每个客户可以有多个子客户,而每个子客户又可以有自己的子客户,形成一个树状结构。客户树通常用于以下场景:

  • 企业与子公司:表示企业集团的层级结构。
  • 经销商与下级经销商:表示销售渠道的层级关系。
  • 客户与联系人:表示客户内部的组织架构。

客户树的特点包括:

  • 层级性:每个客户都有一个层级,顶级客户为第1层,其子客户为第2层,依此类推。
  • 递归性:客户树的结构是递归的,每个子客户可以有自己的子客户。
  • 关联性:客户之间通过父子关系关联。

二、设计方案

2.1 数据库设计

为了实现客户树及其关联关系,我们需要设计三张表:customer 表(客户表)、customer_tree 表(客户树表)和 customer_relationship 表(客户关联关系表)。

2.1.1 客户表(customer
字段名数据类型描述
idINT客户唯一标识(主键)
nameVARCHAR(100)客户名称
codeVARCHAR(50)客户编码
created_atDATETIME创建时间
updated_atDATETIME更新时间
2.1.2 客户树表(customer_tree
字段名数据类型描述
idINT树唯一标识(主键)
tree_nameVARCHAR(100)树名称
root_idINT根节点ID(外键,指向customer表)
max_levelINT树的最大层级
created_atDATETIME创建时间
updated_atDATETIME更新时间
2.1.3 客户关联关系表(customer_relationship
字段名数据类型描述
idINT关系唯一标识(主键)
tree_idINT所属树ID(外键,指向customer_tree表)
customer_idINT客户ID(外键,指向customer表)
parent_idINT父节点ID(外键,指向customer表)
levelINT当前层级
created_atDATETIME创建时间
updated_atDATETIME更新时间

2.2 功能设计

  1. 查询客户树:通过递归查询或存储过程,获取完整的客户树结构。
  2. 新增客户:支持添加顶级客户或子客户。
  3. 删除客户:删除客户时,需要考虑其子客户是否需要同时删除。
  4. 更新客户信息:更新客户的基本信息或层级关系。
  5. 查询客户层级:查询某个客户的层级关系。

三、SQL实现

3.1 创建表

创建客户表
CREATE TABLE `customer` (`id` INT AUTO_INCREMENT PRIMARY KEY,`name` VARCHAR(100) NOT NULL,`code` VARCHAR(50) NOT NULL,`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
创建客户树表
CREATE TABLE `customer_tree` (`id` INT AUTO_INCREMENT PRIMARY KEY,`tree_name` VARCHAR(100) NOT NULL,`root_id` INT,`max_level` INT DEFAULT 1,`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,FOREIGN KEY (`root_id`) REFERENCES `customer` (`id`)
);
创建客户关联关系表
CREATE TABLE `customer_relationship` (`id` INT AUTO_INCREMENT PRIMARY KEY,`tree_id` INT,`customer_id` INT,`parent_id` INT,`level` INT DEFAULT 1,`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,FOREIGN KEY (`tree_id`) REFERENCES `customer_tree` (`id`),FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`),FOREIGN KEY (`parent_id`) REFERENCES `customer` (`id`)
);

3.2 插入测试数据

插入客户数据
INSERT INTO `customer` (`name`, `code`) VALUES
('顶级客户A', 'A'),
('子客户A1', 'A1'),
('子客户A2', 'A2'),
('子客户A1-1', 'A1-1'),
('顶级客户B', 'B'),
('子客户B1', 'B1');
插入客户树数据
INSERT INTO `customer_tree` (`tree_name`, `root_id`, `max_level`) VALUES
('客户树A', 1, 3),
('客户树B', 5, 2);
插入客户关联关系数据
INSERT INTO `customer_relationship` (`tree_id`, `customer_id`, `parent_id`, `level`) VALUES
(1, 1, NULL, 1),  -- 顶级客户A
(1, 2, 1, 2),     -- 子客户A1
(1, 3, 1, 2),     -- 子客户A2
(1, 4, 2, 3),     -- 子客户A1-1
(2, 5, NULL, 1),  -- 顶级客户B
(2, 6, 5, 2);     -- 子客户B1

3.3 查询客户树

使用递归查询(MySQL 8.0+):

WITH RECURSIVE CustomerTree AS (SELECT cr.id, cr.customer_id, cr.parent_id, cr.levelFROM customer_relationship crWHERE cr.parent_id IS NULLUNION ALLSELECT cr.id, cr.customer_id, cr.parent_id, cr.levelFROM customer_relationship crJOIN CustomerTree cte ON cr.parent_id = cte.customer_id
)
SELECT * FROM CustomerTree ORDER BY level, id;

3.4 删除客户

删除客户及其所有子客户:

-- 删除客户及其所有子客户
WITH RECURSIVE CustomerTree AS (SELECT id FROM customer_relationship WHERE customer_id = ?UNION ALLSELECT cr.id FROM customer_relationship cr JOIN CustomerTree cte ON cr.parent_id = cte.customer_id
)
DELETE FROM customer_relationship WHERE id IN (SELECT id FROM CustomerTree);

四、Java代码实现

4.1 项目依赖

使用Spring Boot和MyBatis:

<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.1.4</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><scope>runtime</scope></dependency>
</dependencies>

4.2 实体类

客户实体类
package com.example.demo.model;import java.util.Date;public class Customer {private Integer id;private String name;private String code;private Date createdAt;private Date updatedAt;// Getters and Setterspublic Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getCode() {return code;}public void setCode(String code) {this.code = code;}public Date getCreatedAt() {return createdAt;}public void setCreatedAt(Date createdAt) {this.createdAt = createdAt;}public Date getUpdatedAt() {return updatedAt;}public void setUpdatedAt(Date updatedAt) {this.updatedAt = updatedAt;}
}
客户树实体类
package com.example.demo.model;import java.util.Date;public class CustomerTree {private Integer id;private String treeName;private Integer rootId;private Integer maxLevel;private Date createdAt;private Date updatedAt;// Getters and Setterspublic Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getTreeName() {return treeName;}public void setTreeName(String treeName) {this.treeName = treeName;}public Integer getRootId() {return rootId;}public void setRootId(Integer rootId) {this.rootId = rootId;}public Integer getMaxLevel() {return maxLevel;}public void setMaxLevel(Integer maxLevel) {this.maxLevel = maxLevel;}public Date getCreatedAt() {return createdAt;}public void setCreatedAt(Date createdAt) {this.createdAt = createdAt;}public Date getUpdatedAt() {return updatedAt;}public void setUpdatedAt(Date updatedAt) {this.updatedAt = updatedAt;}
}
客户关联关系实体类
package com.example.demo.model;import java.util.Date;public class CustomerRelationship {private Integer id;private Integer treeId;private Integer customerId;private Integer parentId;private Integer level;private Date createdAt;private Date updatedAt;// Getters and Setterspublic Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public Integer getTreeId() {return treeId;}public void setTreeId(Integer treeId) {this.treeId = treeId;}public Integer getCustomerId() {return customerId;}public void setCustomerId(Integer customerId) {this.customerId = customerId;}public Integer getParentId() {return parentId;}public void setParentId(Integer parentId) {this.parentId = parentId;}public Integer getLevel() {return level;}public void setLevel(Integer level) {this.level = level;}public Date getCreatedAt() {return createdAt;}public void setCreatedAt(Date createdAt) {this.createdAt = createdAt;}public Date getUpdatedAt() {return updatedAt;}public void setUpdatedAt(Date updatedAt) {this.updatedAt = updatedAt;}
}

4.3 Mapper接口

客户Mapper
package com.example.demo.mapper;import com.example.demo.model.Customer;
import org.apache.ibatis.annotations.*;import java.util.List;@Mapper
public interface CustomerMapper {@Select("SELECT * FROM customer")List<Customer> getAllCustomers();@Insert("INSERT INTO customer (name, code) VALUES (#{name}, #{code})")void insertCustomer(Customer customer);@Delete("DELETE FROM customer WHERE id = #{id}")void deleteCustomerById(Integer id);@Update("UPDATE customer SET name = #{name}, code = #{code} WHERE id = #{id}")void updateCustomer(Customer customer);
}
客户树Mapper
package com.example.demo.mapper;import com.example.demo.model.CustomerTree;
import org.apache.ibatis.annotations.*;import java.util.List;@Mapper
public interface CustomerTreeMapper {@Select("SELECT * FROM customer_tree")List<CustomerTree> getAllCustomerTrees();@Insert("INSERT INTO customer_tree (tree_name, root_id, max_level) VALUES (#{treeName}, #{rootId}, #{maxLevel})")void insertCustomerTree(CustomerTree customerTree);@Delete("DELETE FROM customer_tree WHERE id = #{id}")void deleteCustomerTreeById(Integer id);@Update("UPDATE customer_tree SET tree_name = #{treeName}, root_id = #{rootId}, max_level = #{maxLevel} WHERE id = #{id}")void updateCustomerTree(CustomerTree customerTree);
}
客户关联关系Mapper
package com.example.demo.mapper;import com.example.demo.model.CustomerRelationship;
import org.apache.ibatis.annotations.*;import java.util.List;@Mapper
public interface CustomerRelationshipMapper {@Select("SELECT * FROM customer_relationship")List<CustomerRelationship> getAllCustomerRelationships();@Insert("INSERT INTO customer_relationship (tree_id, customer_id, parent_id, level) VALUES (#{treeId}, #{customerId}, #{parentId}, #{level})")void insertCustomerRelationship(CustomerRelationship customerRelationship);@Delete("DELETE FROM customer_relationship WHERE id = #{id}")void deleteCustomerRelationshipById(Integer id);@Update("UPDATE customer_relationship SET tree_id = #{treeId}, customer_id = #{customerId}, parent_id = #{parentId}, level = #{level} WHERE id = #{id}")void updateCustomerRelationship(CustomerRelationship customerRelationship);
}

4.4 服务层

客户服务类
package com.example.demo.service;import com.example.demo.mapper.CustomerMapper;
import com.example.demo.model.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;@Service
public class CustomerService {@Autowiredprivate CustomerMapper customerMapper;public List<Customer> getAllCustomers() {return customerMapper.getAllCustomers();}public void addCustomer(Customer customer) {customerMapper.insertCustomer(customer);}public void deleteCustomer(Integer id) {customerMapper.deleteCustomerById(id);}public void updateCustomer(Customer customer) {customerMapper.updateCustomer(customer);}
}
客户树服务类
package com.example.demo.service;import com.example.demo.mapper.CustomerTreeMapper;
import com.example.demo.model.CustomerTree;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;@Service
public class CustomerTreeService {@Autowiredprivate CustomerTreeMapper customerTreeMapper;public List<CustomerTree> getAllCustomerTrees() {return customerTreeMapper.getAllCustomerTrees();}public void addCustomerTree(CustomerTree customerTree) {customerTreeMapper.insertCustomerTree(customerTree);}public void deleteCustomerTree(Integer id) {customerTreeMapper.deleteCustomerTreeById(id);}public void updateCustomerTree(CustomerTree customerTree) {customerTreeMapper.updateCustomerTree(customerTree);}
}
客户关联关系服务类
package com.example.demo.service;import com.example.demo.mapper.CustomerRelationshipMapper;
import com.example.demo.model.CustomerRelationship;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;@Service
public class CustomerRelationshipService {@Autowiredprivate CustomerRelationshipMapper customerRelationshipMapper;public List<CustomerRelationship> getAllCustomerRelationships() {return customerRelationshipMapper.getAllCustomerRelationships();}public void addCustomerRelationship(CustomerRelationship customerRelationship) {customerRelationshipMapper.insertCustomerRelationship(customerRelationship);}public void deleteCustomerRelationship(Integer id) {customerRelationshipMapper.deleteCustomerRelationshipById(id);}public void updateCustomerRelationship(CustomerRelationship customerRelationship) {customerRelationshipMapper.updateCustomerRelationship(customerRelationship);}
}

4.5 控制器

客户控制器
package com.example.demo.controller;import com.example.demo.model.Customer;
import com.example.demo.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;import java.util.List;@RestController
@RequestMapping("/customers")
public class CustomerController {@Autowiredprivate CustomerService customerService;@GetMappingpublic List<Customer> getAllCustomers() {return customerService.getAllCustomers();}@PostMappingpublic void addCustomer(@RequestBody Customer customer) {customerService.addCustomer(customer);}@DeleteMapping("/{id}")public void deleteCustomer(@PathVariable Integer id) {customerService.deleteCustomer(id);}@PutMappingpublic void updateCustomer(@RequestBody Customer customer) {customerService.updateCustomer(customer);}
}
客户树控制器
package com.example.demo.controller;import com.example.demo.model.CustomerTree;
import com.example.demo.service.CustomerTreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;import java.util.List;@RestController
@RequestMapping("/customer-trees")
public class CustomerTreeController {@Autowiredprivate CustomerTreeService customerTreeService;@GetMappingpublic List<CustomerTree> getAllCustomerTrees() {return customerTreeService.getAllCustomerTrees();}@PostMappingpublic void addCustomerTree(@RequestBody CustomerTree customerTree) {customerTreeService.addCustomerTree(customerTree);}@DeleteMapping("/{id}")public void deleteCustomerTree(@PathVariable Integer id) {customerTreeService.deleteCustomerTree(id);}@PutMappingpublic void updateCustomerTree(@RequestBody CustomerTree customerTree) {customerTreeService.updateCustomerTree(customerTree);}
}
客户关联关系控制器
package com.example.demo.controller;import com.example.demo.model.CustomerRelationship;
import com.example.demo.service.CustomerRelationshipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;import java.util.List;@RestController
@RequestMapping("/customer-relationships")
public class CustomerRelationshipController {@Autowiredprivate CustomerRelationshipService customerRelationshipService;@GetMappingpublic List<CustomerRelationship> getAllCustomerRelationships() {return customerRelationshipService.getAllCustomerRelationships();}@PostMappingpublic void addCustomerRelationship(@RequestBody CustomerRelationship customerRelationship) {customerRelationshipService.addCustomerRelationship(customerRelationship);}@DeleteMapping("/{id}")public void deleteCustomerRelationship(@PathVariable Integer id) {customerRelationshipService.deleteCustomerRelationship(id);}@PutMappingpublic void updateCustomerRelationship(@RequestBody CustomerRelationship customerRelationship) {customerRelationshipService.updateCustomerRelationship(customerRelationship);}
}

五、总结

  本文通过设计客户表、客户树表和客户关联关系表,展示了如何构建和管理客户树及其关联关系。这种设计可以满足企业级应用中对客户关系管理的需求,同时提供了灵活的查询和操作功能。希望本文能够为需要实现类似功能的开发者提供参考。如果对本文有任何疑问或建议,欢迎在评论区留言。

相关文章:

SpringBoot | 构建客户树及其关联关系的设计思路和实践Demo

关注&#xff1a;CodingTechWork 引言 在企业级应用中&#xff0c;客户关系管理&#xff08;CRM&#xff09;是核心功能之一。客户树是一种用于表示客户之间层级关系的结构&#xff0c;例如企业客户与子公司、经销商与下级经销商等。本文将详细介绍如何设计客户树及其关联关系…...

SpringCloud——负载均衡

一.负载均衡 1.问题提出 上一篇文章写了服务注册和服务发现的相关内容。这里再提出一个新问题&#xff0c;如果我给一个服务开了多个端口&#xff0c;这几个端口都可以访问服务。 例如&#xff0c;在上一篇文章的基础上&#xff0c;我又新开了9091和9092端口&#xff0c;现在…...

Springboot3+ JDK21 升级踩坑指南

目录 GetMapping和 RequestBody 一起使用时&#xff0c;会把请求方式由GET变为POST 变更默认的httpClient feign 超时配置失效 GetMapping和 RequestBody 一起使用时&#xff0c;会把请求方式由GET变为POST 变更默认的httpClient 添加依赖 <dependency><groupId&g…...

Qt UDP组播实现与调试指南

在Qt中使用UDP组播(Multicast)可以实现高效的一对多网络通信。以下是关键步骤和示例代码: 一、UDP组播核心机制 组播地址:使用D类地址(224.0.0.0 - 239.255.255.255)TTL设置:控制数据包传播范围(默认1,同一网段)网络接口:指定发送/接收的物理接口二、发送端实现 /…...

idea连接远程服务器kafka

一、idea插件安装 首先idea插件市场搜索“kafka”进行插件安装 二、kafka链接配置 1、检查服务器kafka配置 配置链接前需要保证远程服务器的kafka配置里边有配置好服务器IP&#xff0c;以及开放好kafka端口9092&#xff08;如果有修改 过端口的开放对应端口就好&#xff09; …...

第十节:性能优化高频题-虚拟DOM与Diff算法优化

优化策略&#xff1a;同层比较、静态节点标记、最长递增子序列算法 Key的作用&#xff1a;精确识别节点身份 虚拟DOM与Diff算法深度优化策略解析 一、核心优化策略 同层比较机制 Diff算法仅对比同一层级的虚拟节点&#xff0c;避免跨层级遍历带来的性能损耗。 • 实现原理&am…...

vmware workstation的下载地址页面

Fusion and Workstation | VMware...

kubernetes》》k8s》》Dashboard

安装Dashboard 因为我的Kubernetes 版本是 v1.28.2 对应的 Dashboard V2.7.0 wget -O https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml # 因为默认是集群内访问的&#xff0c;需要追加 NodePort访问类型 vim recommended.yaml …...

软考:数值转换知识点详解

文章目录 1. 进制转换1.1 二进制&#xff08;Binary&#xff09;、八进制&#xff08;Octal&#xff09;、十进制&#xff08;Decimal&#xff09;、十六进制&#xff08;Hexadecimal&#xff09;之间的转换1.2 手动转换和计算方法1.3 使用编程语言进行进制转换 2. 数据类型转换…...

第15章:MCP服务端项目开发实战:性能优化

第15章:MCP服务端项目开发实战:性能优化 在构建和部署 MCP(Memory, Context, Planning)驱动的 AI Agent 系统时,性能和可扩展性是关键的考量因素。随着用户量、数据量和交互复杂度的增加,系统需要能够高效地处理请求,并能够平滑地扩展以应对更高的负载。本章将探讨 MCP…...

Windows申请苹果开发者测试证书Uniapp使用

注意事项 苹果设备,最好是iPhone XS以上,要不然下载不了Apple DeveloperopenSSL 要是V1版本的来生成证书,要不然HBuilder报错按步骤来,生成证书,生成标识符,添加测试设备,生成描述性文件注册苹果开发者账号 (如果有苹果账号直接登录) 苹果开发者官网 开通付费 点击右上…...

服务器数据恢复—NAS存储中raid5上层lv分区数据恢复案例

NAS数据恢复环境&#xff1a; QNAP TS-532X NAS设备中有两块1T的SSD固态硬盘和3块5T的机械硬盘。三块机械硬盘组建了一组RAID5阵列&#xff0c;两块固态硬盘组建RAID1阵列。划分了一个存储池&#xff0c;并通过精简LVM划分了7个lv。 NAS故障&#xff1a; 硬盘故障导致无法正常…...

uniapp跨平台开发---switchTab:fail page `/undefined` is not found

问题描述 在项目中新增了一个底部tab导航栏,点击底部tabBar,跳转失败,控制台打印错误信息switchTab:fail page /undefined is not found 排查思路 错误信息提示,switchTab跳转的页面路径变成了/undefined,排查新增的pages.json文件,发现pages,以及tabBar中的list均已经加入该导…...

详细讲解 QMutex 线程锁和 QMutexLocker 自动锁的区别

详细讲解 QMutex 线程锁和 QMutexLocker 自动锁的区别 下面我们详细拆解 Qt 中用于线程同步的两个核心类&#xff1a;QMutex 和 QMutexLocker。 &#x1f9f1; 一、什么是 QMutex&#xff1f; QMutex 是 Qt 中的互斥锁&#xff08;mutex&#xff09;类&#xff0c;用于防止多个…...

如何获取静态IP地址?完整教程

静态IP地址&#xff0c;因其固定不变的特性&#xff0c;在远程访问、服务器搭建、电商多开、游戏搬砖等场景中显得尤为重要。以下是获取静态IP地址的完整教程&#xff0c;涵盖家庭网络、企业网络和公网静态IP的配置方法&#xff1a; 一、什么是静态IP&#xff1f; 内网IP&…...

JavaScript 里创建对象

咱们来用有趣的方式探索一下 JavaScript 里创建对象的各种“魔法咒语”&#xff01; 想象一下&#xff0c;你是一位魔法工匠&#xff0c;想要在你的代码世界里创造各种奇妙的“魔法物品”&#xff08;也就是对象&#xff09;。你有好几种不同的配方和工具&#xff1a; 1. 随手…...

【华为HCIP | 华为数通工程师】821—多选解析—第十五页

多选794、以下关于高可用性网络特点的描述,正确的是哪些项? A、不会出现故障 B、不能频出现故障 C、一旦出现故障只通过人工干预恢复业务 D出现故障后能很快恢复 解析:高可用性网络拥有良好的可靠性,不间断转发NSF…...

Kaamel视角下的MCP安全最佳实践

在以AI为核心驱动的现代产品体系中&#xff0c;大模型逐渐从实验室走向生产环境&#xff0c;如何确保其在推理阶段的信息安全和隐私保护&#xff0c;成为各方关注的重点。Model Context Protocol&#xff08;MCP&#xff09; 作为一个围绕模型调用上下文进行结构化描述的协议&a…...

Kafka 命令行操作与 Spark-Streaming 核心编程总结

一、Kafka 命令行操作详解 1.创建 Topic 命令格式&#xff1a; kafka-topics.sh --create --zookeeper <zk节点列表> --topic <主题名> --partitions <分区数> --replication-factor <副本数> 参数说明&#xff1a; 分区数&#xff08;partitions…...

【华为OD机试真题】428、连续字母长度 | 机试真题+思路参考+代码解析(E卷)(C++)

文章目录 一、题目题目描述输入输出样例1样例2 一、代码与思路&#x1f9e0;C语言思路✅C代码 一、题目 参考&#xff1a;https://sars2025.blog.csdn.net/article/details/139492358 题目描述 ◎ 给定一个字符串&#xff0c;只包含大写字母&#xff0c;求在包含同一字母的子串…...

nodejs获取请求体的中间件 body-parse

虽然 Express 4.16.0 之后已经内置了处理请求体的功能&#xff08;express.json() 和 express.urlencoded()&#xff09;&#xff0c;但你也可以单独使用老牌中间件 body-parser&#xff0c;它仍然很常用&#xff0c;尤其在某些旧项目中。 &#x1f4e6; 一、安装 body-parser …...

5.学习笔记-SpringMVC(P61-P70)

SpringMVC-SSM整合-接口测试 (1)业务层接口使用junit接口做测试 (2)表现层用postman做接口测试 (3)事务处理— 1&#xff09;在SpringConfig.java&#xff0c;开启注解&#xff0c;是事务驱动 2&#xff09;配置事务管理器&#xff08;因为事务管理器是要配置数据源对象&…...

腾讯云服务器安全——服务防火墙端口放行

点击服务进入安全策略 添加规则...

mfc学习(一)

mfc为微软创建的一个类qt框架的客户端程序&#xff0c;只不过因为微软目前有自己 的亲身儿子C#&#xff08;.net&#xff09;,所以到2010没有进行维护。然后一些的工业企业还在继续进行维护相关的内容。我目前就接手一个现在这样的项目&#xff0c;其实本质与qt的思路是差不多的…...

【MQ篇】初识RabbitMQ保证消息可靠性

&#x1f31f;我的其他文章也讲解的比较有趣&#x1f601;&#xff0c;如果喜欢博主的讲解方式&#xff0c;可以多多支持一下&#xff0c;感谢&#x1f917;&#xff01; &#x1f31f;了解 MQ 请看 &#xff1a; 【MQ篇】初识MQ&#xff01; 其他优质专栏&#xff1a; 【&…...

神经网络基础[ANN网络的搭建]

神经网络 人工神经网络&#xff08; Artificial Neural Network&#xff0c; 简写为ANN&#xff09;也简称为神经网络&#xff08;NN&#xff09;&#xff0c;是一种模仿生物神经网络结构和功能的计算模型。各个神经元传递复杂的电信号&#xff0c;树突接收到输入信号&#xf…...

【技术派后端篇】整合WebSocket长连接实现消息实时推送

在技术派平台中&#xff0c;实现了文章被点赞或评论后&#xff0c;在右上角实时弹出消息提醒的功能。相较于之前仅有的消息通知红色标识&#xff0c;这种实时通知在交互体验上有显著提升。本文将详细介绍如何借助WebSocket实现消息的实时通知。 1 基础知识点 1.1 相关概念 W…...

​Janus Pro

目录 一、模型概述与开源情况 二、模型能力与性能 三、竞品分析 四、部署成本与个人部署成本比较 五、其他维度比较 1. 模型架构与创新性 2. 社区支持与生态系统 3. 更新频率与维护 4. 适用场景与灵活性 5. 商业化潜力 六、总结 Janus Pro 是中国初创公司 DeepSeek …...

[密码学实战]在Linux中实现SDF密码设备接口

[密码学实战]在Linux中实现SDF密码设备接口 引言 在密码学应用开发中,SDF(Security Device Interface)作为中国国家密码管理局制定的密码设备接口标准,被广泛应用于金融、政务等领域的安全系统中。本文将以GmSSL国产密码库为基础,手把手指导在Linux系统中部署SoftSDF——…...

机器学习基础 - 分类模型之SVM

SVM:支持向量机 文章目录 SVM:支持向量机简介基础准备1. 线性可分2. 最大间隔超平面3. 什么是支持向量?4. SVM 能解决哪些问题?5. 支持向量机的分类硬间隔 SVM0. 几何间隔与函数间隔1. SVM 最优化问题2. 对偶问题1. 拉格朗日乘数法 - 等式约束优化问题2. 拉格朗日乘数法 - …...

PostgreSQL 中的权限视图

PostgreSQL 中的权限视图 PostgreSQL 提供了多个系统视图来查询权限信息&#xff0c;虽然不像 Oracle 的 DBA_SYS_PRIVS 那样集中在一个视图中&#xff0c;但可以通过组合以下视图获取完整的系统权限信息。 一 主要权限相关视图 Oracle 视图PostgreSQL 对应视图描述DBA_SYS_…...

pnpm install报错:此系统上禁止运行脚本

依赖安装 报错信息&#xff1a; pnpm : 无法加载文件 C:\Users\XXX\AppData\Roaming\npm\pnpm.ps1&#xff0c;因为在此系统上禁止运行脚本。有关详细信息&#xff0c;请参阅 https:/go.microsoft.com/fwlink/?LinkID135170 中的 about_Execution_Policies。 所在位置 行:1 …...

解决yarn install 报错 error \node_modules\electron: Command failed.

在电脑重装系统后,重新安装项目依赖,遇到这一报错 完整报错信息如下: error D:\xxxxx\xxxxxx\node_modules\electron: Command failed. Exit code: 1 Command: node install.js Arguments: Directory: D:\xxxxx\xxxxx\node_modules\electron Output: HTTPError: Response cod…...

深度学习3.7 softmax回归的简洁实现

import torch from torch import nn from d2l import torch as d2lbatch_size 256 train_iter, test_iter d2l.load_data_fashion_mnist(batch_size)3.7.1 初始化模型参数 net nn.Sequential(nn.Flatten(), nn.Linear(784, 10))def init_weights(m):if type(m) nn.Linear:…...

Linux424 chage密码信息 gpasswd 附属组

https://chat.deepseek.com/a/chat/s/e55a5e85-de97-450d-a19e-2c48f6669234...

Spring Boot单元测试实战指南:从零到高效测试

在Spring Boot开发中&#xff0c;单元测试是保障代码质量的核心环节。本文将基于实际开发场景&#xff0c;手把手教你如何快速实现分层测试、模拟依赖、编写高效断言&#xff0c;并分享最佳实践&#xff01; 一、5分钟环境搭建 添加依赖 在pom.xml中引入spring-boot-starter-te…...

Netty线上如何做性能调优?

大家好&#xff0c;我是锋哥。今天分享关于【Netty线上如何做性能调优&#xff1f;】面试题。希望对大家有帮助&#xff1b; Netty线上如何做性能调优&#xff1f; 1000道 互联网大厂Java工程师 精选面试题-Java资源分享网 在使用 Netty 进行线上服务时&#xff0c;性能调优是…...

总结-SQL注入分类手法注入漏洞总结性分化说明

目录 关键要点 按参数类型分类 按提交方式分类 按反馈结果分类 其他高级注入类型 最新漏洞动态 防御措施 调查笔记&#xff1a;SQL注入类型与详细分析 一、按参数类型分类 二、按提交方式分类 三、按反馈结果分类 四、其他高级注入类型 五、最新漏洞动态 六、防御…...

Linux:进程的创建进程的终止

进程的创建 fork fork是c语言中的一个函数&#xff0c;用于创建新的子进程&#xff0c;它存放在<unistd.h>的头文件中 当我们运行程序时&#xff0c;如果使用了fork函数那么就会为这个进程创建一个它的子进程&#xff0c;这个子进程会继承父进程的所有数据和代码&…...

[C#]反射的实战应用,实际数据模拟

long? value null; // 看它是不是 HEX_STRING var dtAttr prop.GetCustomAttribute<DataTypeAttribute>(); if (dtAttr ! null && dtAttr.DataType DataType.HEX_STRING) {// 去掉可能的 "0x" 前缀string txt attribute.Value.StartsWith("0…...

机器人灵巧手有刷与无刷空心杯电机解析

一、电机结构分析 (一)有刷空心杯电机结构 有刷空心杯电机主要由上壳、碳刷、连接板、换向器线圈、外壳、轴承、永磁体、下壳及轴承密封圈组成。碳刷与换向器直接接触,负责传导电流,使线圈在永磁体产生的磁场中受力转动。这种机械换向方式虽直接,但碳刷磨损会影响电机寿命…...

JetBrains GoLang IDE无限重置试用期,适用最新2025版

注意本文仅用于学习使用&#xff01;&#xff01;&#xff01; 本文在重置2024.3.5版本亲测有效&#xff0c;环境为window(mac下应该也一样奏效) 之前eval-reset插件只能在比较低的版本才能起作用。 总结起来就一句&#xff1a;卸载重装&#xff0c;额外要删掉旧安装文件和注册…...

【网络应用程序设计】实验四:物联网监控系统

个人博客&#xff1a;https://alive0103.github.io/ 代码在GitHub&#xff1a;https://github.com/Alive0103/XDU-CS-lab 能点个Star就更好了&#xff0c;欢迎来逛逛哇~❣ 主播写的刚够满足基本功能&#xff0c;多有不足&#xff0c;仅供参考&#xff0c;还请提PR指正&#xff…...

第六章:安全最佳实践

Chapter 6: 安全最佳实践 &#x1f31f; 从上一章到本章 在第五章&#xff1a;框架/工具抽象中&#xff0c;我们学会了如何用框架快速搭建MCP服务器。现在想象这样一个场景&#xff1a;你的文件服务器已经开发完成&#xff0c;但突然发现恶意用户能通过路径遍历攻击访问系统文…...

最高支持高速L3商用,华为发布ADS 4智驾系统

作者 |张马也 编辑 |德新 4月22日&#xff0c;华为在上海召开乾崑智能技术大会。 会上&#xff0c;华为正式推出乾崑智驾ADS 4、鸿蒙座舱HarmonySpace 5、乾崑车控XMC数字底盘引擎等一系列智能汽车解决方案。 其中最为重磅的是&#xff0c;华为正式发布高速L3商用解决方案&a…...

[创业之路-382]:企业法务 - 企业如何通过技术专利与技术秘密保护自己

企业通过技术专利与技术秘密保护自身创新成果是构建核心竞争力的关键策略。以下从技术专利和技术秘密两大维度&#xff0c;系统阐述其保护路径及实施要点&#xff1a; 一、技术专利保护策略 1. 专利布局规划 核心专利&#xff1a;针对核心技术进行专利申请&#xff0c;构建基…...

多路转接epoll原理详解

目录 从epoll接口入手 创建epoll模型 用户告诉内核关心的事件 内核告诉用户就绪的事件 epoll的原理 整体思路 如何判断事件是否就绪 事件就绪后如何实现将节点插入就绪队列 从epoll接口入手 本篇文章从epoll的三个接口入手介绍epoll的具体工作原理 创建epoll模型 #in…...

基于 MCP用 Python 搭建 “大模型网关”在 MCP 服务器端聚合多个大模型的 API,将其统一为 MCP 协议接口

下面给出基于 MCP(Model-Connection-Protocol)设计思想,用 Python 搭建 “大模型网关” 的典型开发流程。整体思路是:在 MCP 服务器端聚合多个大模型的 API,将其统一为 MCP 协议接口;在客户端按需调用这些统一后的接口。总结如下: 概要: 需求与架构定位:Clarify 要接入…...

Linux的时间函数

ucos中有systick这个系统时间滴答&#xff0c;那linux中有没有这种系统时间滴答呢&#xff1f;有&#xff0c;jiffies&#xff0c;但是用户空间不可以使用。那么在linux中除了使用timer定时器进行定时&#xff0c;可以通过时间滴答的方式来进行粗略的计时吗&#xff1f;下面介绍…...

JCE cannot authenticate the provider BC

本地使用了加密类、并且运行正常、 用hutool做RSA加密时候出现这个问题的! import cn.hutool.core.codec.Base64; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SmUtil; import…...