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

SpringBootWeb案例_01

Web后端开发_04

SpringBootWeb案例_01

原型展示

image-20231126101510691

成品展示

image-20231126101610266

准备工作

需求&环境搭建

需求说明:

完成tlias智能学习辅助系统的部门管理,员工管理

image-20231126101755949

环境搭建
  • 准备数据库表(dept、emp)
  • 创建springboot工程,引入对应的起步依赖(web、mybatis、mysql驱动、lombok)
  • 配置文件application.properties中引入mybatis的配置信息,准备对应的实体类
  • 准备对应的Mapper、Service(接口、实现类)、Controller基础结构

image-20231126102329624

示例工程文件

image-20231126104315440

数据准备

-- 部门管理
create table dept
(id          int unsigned primary key auto_increment comment '主键ID',name        varchar(10) not null unique comment '部门名称',create_time datetime    not null comment '创建时间',update_time datetime    not null comment '修改时间'
) comment '部门表';insert into dept (id, name, create_time, update_time)
values (1, '学工部', now(), now()),(2, '教研部', now(), now()),(3, '咨询部', now(), now()),(4, '就业部', now(), now()),(5, '人事部', now(), now());-- 员工管理(带约束)
create table emp
(id          int unsigned primary key auto_increment comment 'ID',username    varchar(20)      not null unique comment '用户名',password    varchar(32) default '123456' comment '密码',name        varchar(10)      not null comment '姓名',gender      tinyint unsigned not null comment '性别, 说明: 1 男, 2 女',image       varchar(300) comment '图像',job         tinyint unsigned comment '职位, 说明: 1 班主任,2 讲师, 3 学工主管, 4 教研主管, 5 咨询师',entrydate   date comment '入职时间',dept_id     int unsigned comment '部门ID',create_time datetime         not null comment '创建时间',update_time datetime         not null comment '修改时间'
) comment '员工表';INSERT INTO emp
(id, username, password, name, gender, image, job, entrydate, dept_id, create_time, update_time)
VALUES (1, 'jinyong', '123456', '金庸', 1, '1.jpg', 4, '2000-01-01', 2, now(), now()),(2, 'zhangwuji', '123456', '张无忌', 1, '2.jpg', 2, '2015-01-01', 2, now(), now()),(3, 'yangxiao', '123456', '杨逍', 1, '3.jpg', 2, '2008-05-01', 2, now(), now()),(4, 'weiyixiao', '123456', '韦一笑', 1, '4.jpg', 2, '2007-01-01', 2, now(), now()),(5, 'changyuchun', '123456', '常遇春', 1, '5.jpg', 2, '2012-12-05', 2, now(), now()),(6, 'xiaozhao', '123456', '小昭', 2, '6.jpg', 3, '2013-09-05', 1, now(), now()),(7, 'jixiaofu', '123456', '纪晓芙', 2, '7.jpg', 1, '2005-08-01', 1, now(), now()),(8, 'zhouzhiruo', '123456', '周芷若', 2, '8.jpg', 1, '2014-11-09', 1, now(), now()),(9, 'dingminjun', '123456', '丁敏君', 2, '9.jpg', 1, '2011-03-11', 1, now(), now()),(10, 'zhaomin', '123456', '赵敏', 2, '10.jpg', 1, '2013-09-05', 1, now(), now()),(11, 'luzhangke', '123456', '鹿杖客', 1, '11.jpg', 5, '2007-02-01', 3, now(), now()),(12, 'hebiweng', '123456', '鹤笔翁', 1, '12.jpg', 5, '2008-08-18', 3, now(), now()),(13, 'fangdongbai', '123456', '方东白', 1, '13.jpg', 5, '2012-11-01', 3, now(), now()),(14, 'zhangsanfeng', '123456', '张三丰', 1, '14.jpg', 2, '2002-08-01', 2, now(), now()),(15, 'yulianzhou', '123456', '俞莲舟', 1, '15.jpg', 2, '2011-05-01', 2, now(), now()),(16, 'songyuanqiao', '123456', '宋远桥', 1, '16.jpg', 2, '2007-01-01', 2, now(), now()),(17, 'chenyouliang', '123456', '陈友谅', 1, '17.jpg', NULL, '2015-03-21', NULL, now(), now());

创建工程

image-20231126111243772

添加依赖

image-20231126111348722

配置文件application.properties中引入mybatis的配置信息

#驱动类名称
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#数据库连接的url
spring.datasource.url=jdbc:mysql://localhost:3306/tlias
#连接数据库的用户名
spring.datasource.username=root
#连接数据库的密码
spring.datasource.password=123456
#配置mybatis的日志, 指定输出到控制台
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
#开启mybatis的驼峰命名自动映射开关 a_column ------> aCloumn
mybatis.configuration.map-underscore-to-camel-case=true

准备对应的Mapper、Service(接口、实现类)、Controller基础结构

image-20231126113932247

开发规范

案例基于当前最为主流的前后端分离模式进行开发

image-20231126114201493

开发规范-Restful

  • REST(REpresentational State Transfer),表述性状态转换,它是一种软件架构风格

image-20231126114802069

image-20231126114828145

注意事项

  • REST是风格,是约定方式,约定不是规矩,可以打破
  • 描述模块的功能通常使用复数,也就是加s的格式来描述,表示此类资源,而非单个资源。如:users、emps、books等
  • 前后端交互统一响应结果Result

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public class Result {private Integer code;//响应码,1 代表成功;0 代表失败private String msg;//响应信息 描述字符串private Object data;//返回的数据public static Result success() {//增删改 成功响应return new Result(1, "success", null);}public static Result success(Object data) {//增删改 成功响应return new Result(1, "success", data);}public static Result error(String msg) {//增删改 成功响应return new Result(0, msg, null);}}
    

开发流程

image-20231126121654739

部门管理

需求说明

部门管理页面 , 管理员可以对部门信息进行管理,包括新增、修改、删除部门信息等。

页面开发规则

  1. 部门查询

1.1 查询全部数据(由于部门数据比较少,不考虑分页)。

  1. 新增部门

1.1 点击新增部门,会打开新增部门的页面。

1.2 部门名称,必填,唯一,长度为2-10位。

  1. 删除部门

​ 弹出确认框 , 提示 “您确定要删除该部门的信息吗 ?” 如果选择确定 , 则删除该部门 , 删除成功后 , 重新刷新列表页面。 如果选择了 取消 , 则不执行任何操作。

查询部门

image-20231126123847051

思路

image-20231126122241806

DeptController.java

/*** @ClassName DeptController* @Description 部门管理的controller* @Author Bowen* @Date 2023/11/26 11:19* @Version 1.0**/
@Slf4j
@RestController
public class DeptController {@Autowiredprivate DeptService deptService;@GetMapping("/depts")public Result list() {log.info("查询全部部门数据");//调用service查询部门数据List<Dept> deptList = deptService.list();return Result.success(deptList);}
}

注解

@Slf4j日志管理的注解

log.info("查询全部部门数据");调用该方法,控制台输出日志

@GetMapping("/depts")GET请求方法的注解

DeptService.java接口

/*** 部门管理*/
public interface DeptService {/*** 查询全部数据* @return*/List<Dept> list();
}

DeptServiceImpl.java部门接口实现类

/*** @ClassName DeptServiceImpl* @Description 部门 接口的实现类* @Author Bowen* @Date 2023/11/26 11:25* @Version 1.0**/
@Service
public class DeptServiceImpl implements DeptService {@Autowiredprivate DeptMapper deptMapper;@Overridepublic List<Dept> list() {return deptMapper.list();}
}

DeptMapper.java接口

/*** 部门管理*/
@Mapper
public interface DeptMapper {/*** 查询全部部门* @return*/@Select("select * from dept")List<Dept> list();
}

API测试

image-20231126140412602

前后端联调

  • 将资料中提供的“前端工程”文件夹中的压缩包,拷贝到一个没有中文不带空格的目录下,解压。
  • 启动nginx,访问测试:http://localhost:90

image-20231126140552983

若使用自己下载的nginx,需要修改nginx安装目录的conf文件夹下的nginx.conf文件的配置内容(在我的电脑上启动nginx.exe都会闪退,是否运行成功,需要在任务管理器中查看)

#user  nobody;
worker_processes  1;#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '#                  '$status $body_bytes_sent "$http_referer" '#                  '"$http_user_agent" "$http_x_forwarded_for"';#access_log  logs/access.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#gzip  on;server {listen       90;server_name  localhost;location / {root   html;index  index.html index.htm;}location ^~ /api/ {rewrite ^/api/(.*)$ /$1 break;proxy_pass http://localhost:8080;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}}

然后再将前端项目打包后的文件(dist文件夹下的所有文件)拷贝到nginx安装目录的html文件夹下

联调成功

image-20231126154717422

删除部门

需求

image-20231126164009048

思路

image-20231126164440283

DeptController.java

/*** 删除部门数据* @return*/
@DeleteMapping("/depts/{id}")
public Result delete(@PathVariable Integer id){log.info("根据id删除部门:{}",id);//调用service删除部门deptService.delete(id);return Result.success();
}

DeptService.java接口

/*** 删除部门* @param id*/
void delete(Integer id);

DeptServiceImpl.java部门接口实现类

@Override
public void delete(Integer id) {deptMapper.deleteById(id);
}

DeptMapper.java接口

/*** 根据ID删除部门** @param id*/
@Delete("delete from dept where id = #{id}")
void deleteById(Integer id);

API测试

image-20231126171026504

新增部门

需求

image-20231126171138611

思路

image-20231126171553593

实现

image-20231127003632179

@RequestParam的属性defaultValue可以来设置参数的默认值

DeptController.java

/*** 新增部门*/
@PostMapping("/depts")
public Result add(@RequestBody Dept dept) {log.info("新增一个部门:{}", dept);deptService.add(dept);return Result.success();
}

DeptService.java接口

/*** 新增部门* @param dept*/
void add(Dept dept);

DeptServiceImpl.java部门接口实现类

@Override
public void add(Dept dept) {dept.setCreateTime(LocalDateTime.now());dept.setUpdateTime(LocalDateTime.now());deptMapper.insert(dept);
}

DeptMapper.java接口

/*** 插入一条部门信息* @param dept*/
@Insert("insert into dept(name, create_time, update_time) values (#{name}, #{createTime}, #{updateTime})")
void insert(Dept dept);

API测试

image-20231126174239203

@RequestMapping

image-20231126174459084

注意事项

  • 一个完整的请求路径,应该是类上的@RequestMapping的value属性+方法上的@RequestMapping的value属性。

修改部门

1、实现数据回显

根据ID查询

请求路径:/depts/{id}
请求方式:GET
接口描述:该接口用于根据ID查询部门数据

请求参数

参数格式:路径参数

参数说明:

image-20231126194305745

响应数据

参数格式:application/json

参数说明:

image-20231126194412240

响应数据样例:

{
"code": 1,
"msg": "success",
"data": {"id": 1,"name": "学工部","createTime": "2022-09-01T23:06:29","updateTime": "2022-09-01T23:06:29"
}
}

DeptController.java

/*** 根据ID查询部门数据*/
@GetMapping("/{id}")
public Result get(@PathVariable Integer id) {log.info("根据id查部门:{}", id);Dept dept = deptService.get(id);return Result.success(dept);
}

DeptService.java接口

/*** 查询id* @param id* @return*/
Dept get(Integer id);

DeptServiceImpl.java部门接口实现类

@Override
public Dept get(Integer id) {Dept dept = deptMapper.getById(id);return dept;
}

DeptMapper.java接口

/*** 查找id* @param id* @return*/
@Select("select * from dept where id = #{id}")
Dept getById(Integer id);

测试点击编辑出现部门名称

image-20231126194959456

2、修改部门

基本信息

请求路径:/depts
请求方式:PUT
接口描述:该接口用于修改部门数据

请求参数

格式:application/json

参数说明:

image-20231126195158426

请求参数样例:

{
"id": 1,
"name": "教研部"
}

响应数据

参数格式:application/json

参数说明:

image-20231126195333592

响应数据样例:

{
"code":1,
"msg":"success",
"data":null
}

DeptController.java

/*** 更新部门*/
@PutMapping
public Result update(@RequestBody Dept dept) {log.info("根据id修改部门:{}", dept.getId());deptService.update(dept);return Result.success();
}

DeptService.java接口

/*** 更新部门* @param dept*/
void update(Dept dept);

DeptServiceImpl.java部门接口实现类

@Override
public void update(Dept dept) {dept.setUpdateTime(LocalDateTime.now());deptMapper.update(dept);
}

DeptMapper.java接口

/*** 更新部门信息* @param dept*/
@Update("update dept set name = #{name}, update_time = #{updateTime} where id = #{id}")
void update(Dept dept);

测试-修改成功

image-20231126195701919

小结

部门管理

  • 查询部门 @GetMapping
  • 删除部门 @DeleteMapping
  • 新增部门 @PostMapping
  • 修改部门 @PostMapping-根据ID查询、PutMapping-修改部门

员工管理

分页查询

需求

image-20231126215439693

image-20231126215746489

思路

image-20231126220527203

pageBean.java分页查询结果封装类

@Data
@NoArgsConstructor
@AllArgsConstructor
public class PageBean {private Long total;//总记录数private List<Emp> rows;//数据列表
}

EmpController.java员工管理的controller

@Slf4j
@RestController
public class EmpController {@Autowiredprivate EmpService empService;@GetMapping("/emps")public Result page(@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "10") Integer pageSize) {log.info("分页查询,参数:{},{}", page, pageSize);//掉用service分页查询PageBean pageBean = empService.page(page, pageSize);return Result.success(pageBean);}
}

EmpService.java员工管理service层

public interface EmpService {/*** 分页查询* @param page* @param pageSize* @return*/PageBean page(Integer page, Integer pageSize);
}

EmpServiceImpl.java员工 接口实现类

@Service
public class EmpServiceImpl implements EmpService {@Autowiredprivate EmpMapper empMapper;@Overridepublic PageBean page(Integer page, Integer pageSize) {//1. 获取总记录数Long count = empMapper.count();//2. 获取分页查询结果列表Integer start = (page - 1) * pageSize;List<Emp> empList = empMapper.page(start, pageSize);//3. 封装PageBean对象PageBean pageBean = new PageBean(count, empList);return pageBean;}
}

EmpMapper.java员工管理mapper层,可能是mybatis版本不同,需要添加@Param("start")@Param("pageSize"),可参考MyBatis框架_01中的参数名说明(http://t.csdnimg.cn/1ovab)

@Mapper
public interface EmpMapper {//查询总记录数@Select("select count(*) from emp")public Long count();//分页查询获取列表数据的方法@Select("select * from emp limit #{start}, #{pageSize}")public List<Emp> page(@Param("start") Integer start, @Param("pageSize") Integer pageSize);
}

API测试(无参)localhost:8080/emps

image-20231127002823590

API测试(带参)localhost:8080/emps?page=3&pageSize=5

image-20231127003015694

前端进行联调

image-20231127003518462

小结

1、分页查询

  • 请求参数:页码、每页展示记录数
  • 响应结果:总记录数 、结果列表(PageBean)

2、注解

@RequestParam(defaultValue="1")//设置请求参数默认值
分页插件PageHelper

image-20231127112643682

image-20231127112732487

实现

pom.xml引入依赖

<!--PageHelper分页插件-->
<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><version>1.4.6</version>
</dependency>

EmpMapper.java 接口

@Select("select * from tlias.emp")
public List<Emp> list();

EmpServiceIml.java员工 接口的实现类

@Override
public PageBean page(Integer page, Integer pageSize) {//1. 设置分页参数PageHelper.startPage(page, pageSize);//2. 执行查询List<Emp> empList = empMapper.list();Page<Emp> p = (Page<Emp>) empList;//3. 封装PageBean对象PageBean pageBean = new PageBean(p.getTotal(), p.getResult());return pageBean;
}

API测试

image-20231127115226597

查看控制台,SELECT count(0) FROM tlias.empselect * from tlias.emp LIMIT ?都是分页插件PageHelper生成的,

image-20231127115437376

进行前后端联调

image-20231127120035377

小结

PageHelper分页插件

  • 引入依赖:pagehelper-spring-boot-starter

  • 使用:

    PageHelper.startPage(pageNum, pageSize);
    List<Emp> List = empMapper.list();
    Page<Emp> p = (Page<Emp>) List;
    

分页查询(带条件)

需求

image-20231127133944120

思路

image-20231127140208911

请求参数

参数格式:queryString

参数说明:

image-20231127140438551

EmpController.java员工管理的controller层

@Slf4j
@RestController
public class EmpController {@Autowiredprivate EmpService empService;@GetMapping("/emps")public Result page(@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "10") Integer pageSize,String name, Short gender,@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end) {log.info("分页查询,参数:{},{},{},{},{},{}", page, pageSize, name, gender, begin, end);//掉用service分页查询PageBean pageBean = empService.page(page, pageSize, name, gender, begin, end);return Result.success(pageBean);}
}

EmpService.java员工管理的service层

public interface EmpService {//分页查询PageBean page(Integer page, Integer pageSize, String name, Short gender, LocalDate begin, LocalDate end);
}

EmpServiceImpl.java员工 service接口的实现类

@Service
public class EmpServiceImpl implements EmpService {@Autowiredprivate EmpMapper empMapper;@Overridepublic PageBean page(Integer page, Integer pageSize, String name, Short gender, LocalDate begin, LocalDate end) {//1. 设置分页参数PageHelper.startPage(page, pageSize);//2. 执行查询List<Emp> empList = empMapper.list(name, gender, begin, end);Page<Emp> p = (Page<Emp>) empList;//3. 封装PageBean对象PageBean pageBean = new PageBean(p.getTotal(), p.getResult());return pageBean;}
}

EmpMapper.java员工Mapper层接口

@Mapper
public interface EmpMapper {//员工信息查询public List<Emp> list(@Param("name") String name, @Param("gender") Short gender,@Param("begin") LocalDate begin, @Param("end") LocalDate end);
}

resource/com/bowen/mapper/EmpMapper.xml使用动态SQL-XML映射文件

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bowen.mapper.EmpMapper"><!--  条件查询  --><select id="list" resultType="com.bowen.pojo.Emp">select *from tlias.emp<where><if test="name != null and name != ''">name like concat('%', #{name}, '%')</if><if test="gender != null">and gender = #{gender}</if><if test="begin != null and end != null">and entrydate between #{begin} and #{end}</if></where>order by update_time desc</select>
</mapper>

API测试,尽量测试的全面一些,以方便bug的修复

使用get请求

localhost:8080/emps?page=1&pageSize=5&name=张&gender=1&begin=2000-01-01&end=2010-01-01

localhost:8080/emps?page=1&pageSize=5&name=张&gender=1

localhost:8080/emps?page=1&pageSize=5&gender=1

localhost:8080/emps?name=张&gender=1

localhost:8080/emps?gender=1

image-20231127152129513

在前端进行联调

image-20231127152233670

删除员工

需求

image-20231127152524323

接口文档

基本信息

请求路径:/emps/{ids}

请求方式:DELETE

接口描述:该接口用于批量删除员工的数据信息

请求参数

参数格式:路径参数

参数说明:

image-20231127152749167

思路

image-20231127153253080

EmpController.java

@DeleteMapping("/{ids}")
public Result delete(@PathVariable List<Integer> ids) {log.info("批量删除操作,ids:{}", ids);empService.delete(ids);return Result.success();
}

EmpService.java员工service层接口

/*** 批量删除操作* @param ids*/
void delete(List<Integer> ids);

EmpServiceImpl.java员工 接口的实现类

@Override
public void delete(List<Integer> ids) {empMapper.delete(ids);
}

EmpMapper.java员工Mapper层接口

/*** 批量删除* @param ids*/
void delete(@Param("ids") List<Integer> ids);

resource/com/bowen/mapper/EmpMapper.xml使用动态SQL-XML映射文件

<!--批量删除(1, 2, 3)-->
<delete id="delete">deletefrom tlias.empwhere id in<foreach collection="ids" item="id" separator="," open="(" close=")">#{id}</foreach>
</delete>

API测试

image-20231127155528180

IDEA控制台中的日志,说明id=1,2,3的员工删除成功

image-20231127155720654

前端联调,删除 张三丰、方东白

image-20231127155952371

日志

image-20231127160153068

a`

@DeleteMapping("/{ids}")
public Result delete(@PathVariable List<Integer> ids) {log.info("批量删除操作,ids:{}", ids);empService.delete(ids);return Result.success();
}

EmpService.java员工service层接口

/*** 批量删除操作* @param ids*/
void delete(List<Integer> ids);

EmpServiceImpl.java员工 接口的实现类

@Override
public void delete(List<Integer> ids) {empMapper.delete(ids);
}

EmpMapper.java员工Mapper层接口

/*** 批量删除* @param ids*/
void delete(@Param("ids") List<Integer> ids);

resource/com/bowen/mapper/EmpMapper.xml使用动态SQL-XML映射文件

<!--批量删除(1, 2, 3)-->
<delete id="delete">deletefrom tlias.empwhere id in<foreach collection="ids" item="id" separator="," open="(" close=")">#{id}</foreach>
</delete>

API测试

在这里插入图片描述

IDEA控制台中的日志,说明id=15,16,17的员工删除成功

image-20231127155720654

前端联调,删除 张三丰、方东白

image-20231127155952371

日志

在这里插入图片描述

相关文章:

SpringBootWeb案例_01

Web后端开发_04 SpringBootWeb案例_01 原型展示 成品展示 准备工作 需求&环境搭建 需求说明&#xff1a; 完成tlias智能学习辅助系统的部门管理&#xff0c;员工管理 环境搭建 准备数据库表&#xff08;dept、emp&#xff09;创建springboot工程&#xff0c;引入对应…...

C语言数据结构-----栈和队列练习题(分析+代码)

前言 前面的博客写了如何实现栈和队列&#xff0c;下来我们来看一下队列和栈的相关习题。 链接: 栈和队列的实现 文章目录 前言1.用栈实现括号匹配2.用队列实现栈3.用栈实现队列4.设计循环队列 1.用栈实现括号匹配 此题最重要的就是数量匹配和顺序匹配。 用栈可以完美的做到…...

uniapp基础-教程之HBuilderX配置篇-01

uniapp教程之HBuilderX配置篇-01 为什么要做这个教程的梳理&#xff0c;主要用于自己学习和总结&#xff0c;利于增加自己的积累和记忆。首先下载HBuilderX&#xff0c;并保证你的软件在C盘进行运行&#xff0c;最好使用英文或者拼音&#xff0c;这个操作是为了保证软件的稳定…...

【备忘录】快速回忆ElasticSearch的CRUD

导引——第一条ElasticSearch语句 测试分词器 POST /_analyze {"text":"黑马程序员学习java太棒了","analyzer": "ik_smart" }概念 语法规则 HTTP_METHOD /index/_action/IDHTTP_METHOD 是 HTTP 请求的方法&#xff0c;常见的包括…...

影响PPC广告成本预算的因素,如何计算亚马逊PPC广告预算——站斧浏览器

亚马逊PPC&#xff0c;又称按点击付费(Pay Per Click)&#xff0c;是一种只有用户点击你的广告时才会向你收费的模式。那么影响PPC广告成本预算的因素,如何计算亚马逊PPC广告预算&#xff1f; 影响PPC广告成本预算的因素 1、产品类别&#xff1a;不同类别的产品竞争程度不同&…...

Qt 信号和槽

目录 概念 代码 mainwindow.h me.h xiaohuang.h main.cc mainwindow.cc me.cc xianghuang.cc mainwindow.ui 自定义信号的要求和注意事项: 自定义槽的要求和注意事项: 概念 信号槽是 Qt 框架引以为豪的机制之一。所谓信号槽&#xff0c;实际就是观察者模式(发布-订…...

Linux基本命令二

Linux基本命令二 1、head 命令 head ​ **作用&#xff1a;**用于查看文件的开头部分的内容&#xff0c;有一个常用的参数 -n 用于显示行数&#xff0c;默认为 10&#xff0c;即显示 10 行的内容 ​ **语法&#xff1a;**head [参数] [文件] ​ 命令参数&#xff1a; 参数…...

isbn api开放接口

接口地址&#xff1a;http://openapi.daohe168.com.cn/api/library/isbn/query?isbn9787115618085&appKeyd7c6c07a0a04ba4e65921e2f90726384 响应结果&#xff1a; { "success": true, "code": "200", "message": …...

助力企业实现更简单的数据库管理,ATOMDB 与 TDengine 完成兼容性互认

为加速数字化转型进程&#xff0c;当下越来越多的企业开始进行新一轮数据架构改造升级。在此过程中&#xff0c;全平台数据库管理客户端提供了一个集中管理和操作数据库的工具&#xff0c;提高了数据库管理的效率和便利性&#xff0c;减少了人工操作的复杂性和错误率&#xff0…...

如何通过低代码工具,提升运输行业的运营效率和服务质量

《中国数字货运发展报告》显示&#xff0c;2022年我国公路货运市场规模在5万亿元左右。其中&#xff0c;数字货运整体市场规模约为7000亿元&#xff0c;市场渗透率约为15%。而以小微企业为主的货运行业&#xff0c;却以小、散、乱的行业特征&#xff0c;承载着5万亿元左右的市场…...

Vue3中调用外部iframe链接方法

业务场景&#xff0c;点击某个按钮需要跳转到外部iframe的地址&#xff0c;但是需要在本项目内显示。以前项目中写过调用外部链接的功能&#xff0c;是有菜单的&#xff0c;但是这次是按钮&#xff0c;所以不能直接把地址配到菜单里。 实现方法&#xff1a;在本地路由文件里写个…...

Node——事件的监听与触发

Node.js是由事件驱动的&#xff0c;每个任务都可以当作一个事件来处理&#xff0c;本贴将对Node.js中的events模块及其中处理事件的类EventEmitter的使用进行详细讲解。 1、EventEmitter对象 在JavaScript中&#xff0c;通过事件可以处理许多用户的交互&#xff0c;比如鼠标…...

一个基于.NET Core开源、跨平台的仓储管理系统

前言 今天给大家推荐一个基于.NET Core开源、跨平台的仓储管理系统&#xff0c;数据库支持MSSQL/MySQL&#xff1a;ZEQP.WMS。 仓储管理系统介绍 仓储管理系统&#xff08;Warehouse Management System&#xff0c;WMS&#xff09;是一种用于管理和控制仓库操作的软件系统&…...

主机安全-WindowsLinux的SSH安全加固

信息安全相关 - 建设篇 第三章 主机安全-Linux的SSH安全加固 信息安全相关 - 建设篇系列文章回顾下章内容主机安全-Linux的SSH安全加固前言Windows openssh相关命令&#xff0c;安装openssh获取openssh命令Windows openssl相关命令&#xff0c;安装Git获取openssl命令修复 CVE-…...

pcie-2-rj45速度优化

背景: 目前用iperf3打流传输速率达不到要求,千兆实际要求跑到800M以上: 优化方案: 1.优化defconfig: 首先编译user版本验证看是否正常 debug版本关闭CONFIG_SLUB_DEBUG_ON宏控。 2.找FAE ,通过更换驱动,或者更新驱动来优化 3.绑定大核: 以8125网卡为例,udp…...

AWVS 使用方法归纳

1.首先确认扫描的网站&#xff0c;以本地的dvwa为例 2.在awvs中添加目标 输入的地址可以是域名也可以是ip&#xff0c;只要本机可以在浏览器访问的域名或ip即可 添加地址及描述之后&#xff0c;点击保存&#xff0c;就会展现出目标设置选项 business criticality译为业务关键…...

数据库基础入门 — SQL运算符

我是南城余&#xff01;阿里云开发者平台专家博士证书获得者&#xff01; 欢迎关注我的博客&#xff01;一同成长&#xff01; 一名从事运维开发的worker&#xff0c;记录分享学习。 专注于AI&#xff0c;运维开发&#xff0c;windows Linux 系统领域的分享&#xff01; 本…...

SELinux零知识学习二十九、SELinux策略语言之类型强制(14)

接前一篇文章:SELinux零知识学习二十八、SELinux策略语言之类型强制(13) 二、SELinux策略语言之类型强制 4. 类型规则 类型规则在创建客体或在运行过程中重新标记时指定其默认类型。在策略语言中定义了两个类型规则: type_transtition在域转换过程中标记行为发生时以及创…...

Git控制指令

git status查看当前本地分支的修改状态 git diff 文件路径 查看具体文件的修改内容 git log打印用户信息 git remote -v查看远程地址 git checkout -- *还原被删除的文件 git rm -r --force .删除本地所有文件 git commit -m "Remove all files from repositor…...

C#中警告CA1050、CA1821、CA1822、CA1859、CA2249及处理

目录 一、CA1050警告及处理 1.如何解决冲突&#xff1a; 2.何时禁止显示警告&#xff1a; 二、CA1821警告及处理 三、CA1822警告及处理 四、CA1859警告及处理 1.警告解决之前 2.警告解决之后 3.解决办法 1.警告解决之前 2.警告解决之后 3.解决办法 五、CA2249警告…...

浅谈 React Hooks

React Hooks 是 React 16.8 引入的一组 API&#xff0c;用于在函数组件中使用 state 和其他 React 特性&#xff08;例如生命周期方法、context 等&#xff09;。Hooks 通过简洁的函数接口&#xff0c;解决了状态与 UI 的高度解耦&#xff0c;通过函数式编程范式实现更灵活 Rea…...

7.4.分块查找

一.分块查找的算法思想&#xff1a; 1.实例&#xff1a; 以上述图片的顺序表为例&#xff0c; 该顺序表的数据元素从整体来看是乱序的&#xff0c;但如果把这些数据元素分成一块一块的小区间&#xff0c; 第一个区间[0,1]索引上的数据元素都是小于等于10的&#xff0c; 第二…...

前端倒计时误差!

提示:记录工作中遇到的需求及解决办法 文章目录 前言一、误差从何而来?二、五大解决方案1. 动态校准法(基础版)2. Web Worker 计时3. 服务器时间同步4. Performance API 高精度计时5. 页面可见性API优化三、生产环境最佳实践四、终极解决方案架构前言 前几天听说公司某个项…...

Nginx server_name 配置说明

Nginx 是一个高性能的反向代理和负载均衡服务器&#xff0c;其核心配置之一是 server 块中的 server_name 指令。server_name 决定了 Nginx 如何根据客户端请求的 Host 头匹配对应的虚拟主机&#xff08;Virtual Host&#xff09;。 1. 简介 Nginx 使用 server_name 指令来确定…...

【HTML-16】深入理解HTML中的块元素与行内元素

HTML元素根据其显示特性可以分为两大类&#xff1a;块元素(Block-level Elements)和行内元素(Inline Elements)。理解这两者的区别对于构建良好的网页布局至关重要。本文将全面解析这两种元素的特性、区别以及实际应用场景。 1. 块元素(Block-level Elements) 1.1 基本特性 …...

JUC笔记(上)-复习 涉及死锁 volatile synchronized CAS 原子操作

一、上下文切换 即使单核CPU也可以进行多线程执行代码&#xff0c;CPU会给每个线程分配CPU时间片来实现这个机制。时间片非常短&#xff0c;所以CPU会不断地切换线程执行&#xff0c;从而让我们感觉多个线程是同时执行的。时间片一般是十几毫秒(ms)。通过时间片分配算法执行。…...

视觉slam十四讲实践部分记录——ch2、ch3

ch2 一、使用g++编译.cpp为可执行文件并运行(P30) g++ helloSLAM.cpp ./a.out运行 二、使用cmake编译 mkdir build cd build cmake .. makeCMakeCache.txt 文件仍然指向旧的目录。这表明在源代码目录中可能还存在旧的 CMakeCache.txt 文件,或者在构建过程中仍然引用了旧的路…...

SQL慢可能是触发了ring buffer

简介 最近在进行 postgresql 性能排查的时候,发现 PG 在某一个时间并行执行的 SQL 变得特别慢。最后通过监控监观察到并行发起得时间 buffers_alloc 就急速上升,且低水位伴随在整个慢 SQL,一直是 buferIO 的等待事件,此时也没有其他会话的争抢。SQL 虽然不是高效 SQL ,但…...

MySQL 部分重点知识篇

一、数据库对象 1. 主键 定义 &#xff1a;主键是用于唯一标识表中每一行记录的字段或字段组合。它具有唯一性和非空性特点。 作用 &#xff1a;确保数据的完整性&#xff0c;便于数据的查询和管理。 示例 &#xff1a;在学生信息表中&#xff0c;学号可以作为主键&#xff…...

WebRTC从入门到实践 - 零基础教程

WebRTC从入门到实践 - 零基础教程 目录 WebRTC简介 基础概念 工作原理 开发环境搭建 基础实践 三个实战案例 常见问题解答 1. WebRTC简介 1.1 什么是WebRTC&#xff1f; WebRTC&#xff08;Web Real-Time Communication&#xff09;是一个支持网页浏览器进行实时语音…...