Java 小项目开发日记 03(文章分类接口的开发)

Java 小项目开发日记 03(文章分类接口的开发)

项目目录

在这里插入图片描述

配置文件(pom.xml)

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><!--继承父工程--><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.1.6</version></parent><groupId>com.zhong</groupId><artifactId>big-event</artifactId><version>1.0-SNAPSHOT</version><packaging>jar</packaging><name>big-event</name><url>http://maven.apache.org</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><!--web 依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!--MyBatis 依赖--><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>3.0.0</version></dependency><!--MySQL 依赖--><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.29</version></dependency><!--lombok 依赖--><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></dependency><!--参数校验依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-validation</artifactId></dependency><!--jwt 令牌验证--><dependency><groupId>com.auth0</groupId><artifactId>java-jwt</artifactId><version>4.4.0</version></dependency><!--单元测试依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId></dependency></dependencies>
</project>

resources 配置

  • resources
    • application.yml
spring:datasource:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/big_eventusername: rootpassword: 123456
mybatis:configuration:map-underscore-to-camel-case: true    # 开启下划线映射

config

  • WebConfig
package com.zhong.config;import com.zhong.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;/*** @ClassName : WebConfig* @Description : Web 配置* @Author : zhx* @Date: 2024-02-28 19:30*/
@Configuration
public class WebConfig implements WebMvcConfigurer {@Autowiredprivate LoginInterceptor loginInterceptor;@Overridepublic void addInterceptors(InterceptorRegistry registry) {registry.addInterceptor(loginInterceptor).excludePathPatterns("/user/login", "/user/register");}
}

controller

  • CategoryController
package com.zhong.controller;import com.zhong.pojo.Category;
import com.zhong.pojo.Result;
import com.zhong.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;import java.util.List;/*** @ClassName : CategoryController* @Description : 文章操作* @Author : zhx* @Date: 2024-02-29 19:46*/
@RestController
@RequestMapping("/category")
public class CategoryController {@Autowiredprivate CategoryService categoryService;@PostMappingpublic Result add(@RequestBody @Validated(Category.Add.class) Category category) {categoryService.add(category);return Result.success();}@GetMappingpublic Result<List<Category>> findAll() {List<Category> category = categoryService.findAll();return Result.success(category);}@GetMapping("/detail")public Result<Category> findCategoryById(@RequestHeader @Validated(Category.Update.class) Integer id) {return Result.success(categoryService.findCategoryById(id));}@PutMappingpublic Result updateCategory(@RequestBody @Validated(Category.Update.class) Category category) {categoryService.updateCategory(category);return Result.success();}@DeleteMappingpublic Result deleteCategory(@RequestHeader @Validated(Category.Update.class) Integer id){categoryService.deleteCategory(id);return Result.success();}
}
  • UserController
package com.zhong.controller;import com.zhong.pojo.Result;
import com.zhong.pojo.User;
import com.zhong.service.UserService;
import com.zhong.utils.JwtUtil;
import com.zhong.utils.Md5Util;
import com.zhong.utils.ThreadLocalUtil;
import jakarta.validation.constraints.Pattern;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;import java.util.HashMap;
import java.util.Map;/*** @ClassName : UserController* @Description : 用户操作* @Author : zhx* @Date: 2024-02-27 20:40*/
@RestController
@RequestMapping("/user")
@Validated
public class UserController {@Autowiredprivate UserService userService;@PostMapping("/register")public Result register(@Pattern(regexp = "^\\S{6,16}$") String username, @Pattern(regexp = "^\\S{6,16}$") String password) {// 查询用户User user = userService.findByUserName(username);if (user == null) {// 没有被占用// 注册userService.registerUser(username, password);return Result.success();} else {// 被占用return Result.error("用户名已被占用......");}}@PostMapping("/login")public Result<String> login(@Pattern(regexp = "^\\S{2,10}$") String username, @Pattern(regexp = "^\\S{6,16}$") String password) {User user = userService.findByUserName(username);// 密码正确 登录if (user == null) {return Result.error("用户不存在......");}if (Md5Util.checkPassword(password, user.getPassword())) {  // 验证用户密码HashMap<String, Object> claims = new HashMap<>();   // 创建校验mapclaims.put("id", user.getId()); // 添加用户 IDclaims.put("username", user.getUsername()); // 添加用户名return Result.success(JwtUtil.genToken(claims));    // 返回获取到的 token}return Result.error("密码错误......");}@GetMapping("/userinfo")public Result<User> getUserInfo() {// 获取线程中的 user 对象Map<String, Object> user = ThreadLocalUtil.get();User userInfo = userService.getUserInfo((Integer) user.get("id"));return Result.success(userInfo);}@PutMapping("/update")public Result update(@RequestBody @Validated User user) {if (!userService.update(user)) {return Result.error("修改失败......");}return Result.success("修改成功!");}@PatchMapping("/updatepwd")public Result updatePassWord(@RequestBody Map<String, String> params) {String oldPwd = params.get("old_pwd");String newPwd = params.get("new_pwd");String rePwd = params.get("re_pwd");if (oldPwd.equals(newPwd) || oldPwd.equals(rePwd)) {return Result.error("修改密码与原密码相同......");}if (!StringUtils.hasLength(oldPwd) || !StringUtils.hasLength(newPwd) || !StringUtils.hasLength(rePwd)){return Result.error("密码不能为空......");}if (!newPwd.equals(rePwd)) {return Result.error("新密码不一致......");}if (!userService.updatePassWord(oldPwd, newPwd)){return Result.error("原密码不匹配......");}return Result.success("修改密码成功!");}
}

exception

  • GlobalExceptionHandler
package com.zhong.exception;import com.zhong.pojo.Result;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;/*** @ClassName : GlobalExceptionHandler* @Description : 全局异常处理* @Author : zhx* @Date: 2024-02-27 21:37*/
@RestControllerAdvice
public class GlobalExceptionHandler {@ExceptionHandler(Exception.class)public Result handlerException(Exception e) {e.printStackTrace();return Result.error(StringUtils.hasLength(e.getMessage()) ? e.getMessage() : "操作失败");}
}

interceptors

  • LoginInterceptor
package com.zhong.interceptors;import com.zhong.utils.JwtUtil;
import com.zhong.utils.ThreadLocalUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;import java.util.Map;/*** @ClassName : LoginInterceptor* @Description : 登录拦截器* @Author : zhx* @Date: 2024-02-28 19:25*/
@Component
public class LoginInterceptor implements HandlerInterceptor {@Overridepublic boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {// 获取浏览器中的 tokenString token = request.getHeader("Authorization");// 解析 tokentry {Map<String, Object> claims = JwtUtil.parseToken(token);// 把得到的数据存入 ThreadLocalThreadLocalUtil.set(claims);// 放行return true;} catch (Exception e) {response.setStatus(401);// 拦截return false;}}@Overridepublic void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {// 清空 ThreadLocal 中的数据  防止内存泄漏ThreadLocalUtil.remove();}
}

mapper

  • CategoryMapper
package com.zhong.mapper;import com.zhong.pojo.Category;
import org.apache.ibatis.annotations.*;import java.util.List;/*** @ClassName : CategoryMapper* @Description : 文章SQL* @Author : zhx* @Date: 2024-02-29 19:50*/
@Mapper
public interface CategoryMapper {@Insert("insert into category(category_name, category_alias, create_user, create_time, update_time) values (#{categoryName}, #{categoryAlias}, #{createUser} , now(), now())")void add(Category category);@Select("select * from category where create_user = #{userId}")List<Category> findAll(Integer userId);@Select("select * from category where id = #{id}")Category findCategoryById(Integer id);@Update("update category set category_name = #{categoryName}, category_alias = #{categoryAlias}, update_time = now() where id = #{id}")void updateCategory(Category category);@Delete("delete from category where id = #{id}")void deleteCategory(Integer id);
}
  • UserMapper
package com.zhong.mapper;import com.zhong.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;/*** @ClassName : UserMapper* @Description : 用户业务逻辑* @Author : zhx* @Date: 2024-02-27 20:42*/
@Mapper
public interface UserMapper {// 根据用户名查询用户@Select("select * from user where username = #{username}")User findByUserName(String username);// 添加用户@Insert("insert into user(username, password, create_time, update_time) values (#{username}, #{password}, now(), now()) ")void registerUser(String username, String password);@Select("select * from user where id = #{id}")User getUserInfo(Integer id);@Update("update user set username = #{user.username}, nickname = #{user.nickname}, email = #{user.email}, user_pic=#{user.userPic}, update_time = now() where id = #{myId};")Boolean update(User user,Integer myId);@Update("update user set password = #{newP}, update_time = now() where id= #{id} AND password = #{oldP}")boolean updatePassWord(Integer id, String oldP, String newP);
}

pojo

  • Category
package com.zhong.pojo;import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.groups.Default;
import lombok.Builder;
import lombok.Data;
import java.time.LocalDateTime;@Data
public class Category {@NotNull(groups = Update.class)private Integer id;//主键ID@NotEmptyprivate String categoryName;//分类名称@NotEmptyprivate String categoryAlias;//分类别名@JsonIgnore // 转换成 json 的时候忽略该字段private Integer createUser;//创建人ID@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")private LocalDateTime createTime;//创建时间@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")private LocalDateTime updateTime;//更新时间// Default 继承默认分组 不添加分组信息则是默认分组public interface Add extends Default {}public interface Update extends Default{}
}
  • Result
package com.zhong.pojo;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;//统一响应结果
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Result<T> {private Integer code;//业务状态码  0-成功  1-失败private String message;//提示信息private T data;//响应数据//快速返回操作成功响应结果(带响应数据)public static <E> Result<E> success(E data) {return new Result<>(0, "操作成功", data);}//快速返回操作成功响应结果public static Result success() {return new Result(0, "操作成功", null);}public static Result error(String message) {return new Result(1, message, null);}
}
  • User
package com.zhong.pojo;import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import org.hibernate.validator.constraints.URL;import java.time.LocalDateTime;
@Data
@NoArgsConstructor
public class User {@NonNullprivate Integer id;//主键ID@NotEmpty@Pattern(regexp = "^\\S{2,10}$")private String username;//用户名@JsonIgnore // 转换成 json 的时候忽略该字段private String password;//密码@NotEmpty@Pattern(regexp = "\\S{1,12}$")private String nickname;//昵称@NotEmpty@Emailprivate String email;//邮箱@URLprivate String userPic;//用户头像地址@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")private LocalDateTime createTime;//创建时间@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")private LocalDateTime updateTime;//更新时间
}

service

  • impl
    • CategoryServiceImpl
package com.zhong.service.impl;import com.zhong.mapper.CategoryMapper;
import com.zhong.pojo.Category;
import com.zhong.service.CategoryService;
import com.zhong.utils.GetNowLoginIdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;/*** @ClassName : CategoryServiceImpl* @Description : 文章接口实现类* @Author : zhx* @Date: 2024-02-29 19:48*/
@Service
public class CategoryServiceImpl implements CategoryService {@Autowiredprivate CategoryMapper categoryMapper;@Overridepublic void add(Category category) {Integer id = GetNowLoginIdUtil.getID();category.setCreateUser(id);categoryMapper.add(category);}@Overridepublic List<Category> findAll() {Integer id = GetNowLoginIdUtil.getID();return categoryMapper.findAll(id);}@Overridepublic Category findCategoryById(Integer id) {return categoryMapper.findCategoryById(id);}@Overridepublic void updateCategory(Category category) {categoryMapper.updateCategory(category);}@Overridepublic void deleteCategory(Integer id) {categoryMapper.deleteCategory(id);}
}
  • impl
    • UserServiceImpl
package com.zhong.service.impl;import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.zhong.mapper.UserMapper;
import com.zhong.pojo.User;
import com.zhong.service.UserService;
import com.zhong.utils.JwtUtil;
import com.zhong.utils.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.Map;/*** @ClassName : UserServiceImpl* @Description : 用户接口实现类* @Author : zhx* @Date: 2024-02-27 20:41*/
@Service
public class UserServiceImpl implements UserService {@Autowiredprivate UserMapper userMapper;@Overridepublic User findByUserName(String username) {return userMapper.findByUserName(username);}@Overridepublic void registerUser(String username, String password) {// 加密String md5String = Md5Util.getMD5String(password);// 添加userMapper.registerUser(username, md5String);}@Overridepublic User getUserInfo(Integer id) {return userMapper.getUserInfo(id);}@Overridepublic Boolean update(User user) {return userMapper.update(user);}}
  • CategoryService
package com.zhong.service;import com.zhong.pojo.Category;import java.util.List;/*** @ClassName : CategoryService* @Description : 文章接口* @Author : zhx* @Date: 2024-02-29 19:47*/
public interface CategoryService {// 添加分类void add(Category category);List<Category> findAll();Category findCategoryById(Integer id);void updateCategory(Category category);void deleteCategory(Integer id);
}
  • UserService
package com.zhong.service;import com.zhong.pojo.User;/*** @ClassName : UserService* @Description : 用户接口* @Author : zhx* @Date: 2024-02-27 20:40*/
public interface UserService {// 根据用户名查询用户User findByUserName(String username);// 注册用户void registerUser(String username, String password);User getUserInfo(Integer id);Boolean update(User user);
}

utils

  • GetNowLoginIdUtil
package com.zhong.utils;import java.util.Map;/*** @ClassName : GetNowLoginId* @Description : 获取当前用户登录的 id* @Author : zhx* @Date: 2024-02-29 20:32*/
public class GetNowLoginIdUtil {public static Integer getID(){Map<String, Object> claims = ThreadLocalUtil.get();return (Integer) claims.get("id");}
}
  • JwtUtil
package com.zhong.utils;import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;import java.util.Date;
import java.util.Map;public class JwtUtil {private static final String KEY = "zhong";//接收业务数据,生成token并返回public static String genToken(Map<String, Object> claims) {return JWT.create().withClaim("claims", claims).withExpiresAt(new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 12)).sign(Algorithm.HMAC256(KEY));}//接收token,验证token,并返回业务数据public static Map<String, Object> parseToken(String token) {return JWT.require(Algorithm.HMAC256(KEY)).build().verify(token).getClaim("claims").asMap();}}
  • Md5Util
package com.zhong.utils;import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;public class Md5Util {/*** 默认的密码字符串组合,用来将字节转换成 16 进制表示的字符,apache校验下载的文件的正确性用的就是默认的这个组合*/protected static char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};protected static MessageDigest messagedigest = null;static {try {messagedigest = MessageDigest.getInstance("MD5");} catch (NoSuchAlgorithmException nsaex) {System.err.println(Md5Util.class.getName() + "初始化失败,MessageDigest不支持MD5Util。");nsaex.printStackTrace();}}/*** 生成字符串的md5校验值** @param s* @return*/public static String getMD5String(String s) {return getMD5String(s.getBytes());}/*** 判断字符串的md5校验码是否与一个已知的md5码相匹配** @param password  要校验的字符串* @param md5PwdStr 已知的md5校验码* @return*/public static boolean checkPassword(String password, String md5PwdStr) {String s = getMD5String(password);return s.equals(md5PwdStr);}public static String getMD5String(byte[] bytes) {messagedigest.update(bytes);return bufferToHex(messagedigest.digest());}private static String bufferToHex(byte bytes[]) {return bufferToHex(bytes, 0, bytes.length);}private static String bufferToHex(byte bytes[], int m, int n) {StringBuffer stringbuffer = new StringBuffer(2 * n);int k = m + n;for (int l = m; l < k; l++) {appendHexPair(bytes[l], stringbuffer);}return stringbuffer.toString();}private static void appendHexPair(byte bt, StringBuffer stringbuffer) {char c0 = hexDigits[(bt & 0xf0) >> 4];// 取字节中高 4 位的数字转换, >>>// 为逻辑右移,将符号位一起右移,此处未发现两种符号有何不同char c1 = hexDigits[bt & 0xf];// 取字节中低 4 位的数字转换stringbuffer.append(c0);stringbuffer.append(c1);}
}
  • ThreadLocalUtil
package com.zhong.utils;/*** ThreadLocal 工具类*/
@SuppressWarnings("all")
public class ThreadLocalUtil {//提供ThreadLocal对象,private static final ThreadLocal THREAD_LOCAL = new ThreadLocal();//根据键获取值public static <T> T get(){return (T) THREAD_LOCAL.get();}//存储键值对public static void set(Object value){THREAD_LOCAL.set(value);}//清除ThreadLocal 防止内存泄漏public static void remove(){THREAD_LOCAL.remove();}
}

BigEventApplication

package com.zhong;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
public class BigEventApplication {public static void main(String[] args) {SpringApplication.run(BigEventApplication.class, args);}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/710120.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

计算机网络:数据链路层知识点汇总

文章目录 一、数据链路层功能概述二、封装成帧和透明传输三、差错控制&#xff08;检错编码&#xff09;四、差错控制&#xff08;纠错编码&#xff09;五、流量控制与可靠传输机制六、停止-等待协议七、后退N帧协议&#xff08;GBN&#xff09;八、选择重传协议&#xff08;SR…

用户增长6步法

什么是用户增长&#xff1f; 通过痛点、产品、渠道、内容、技术、数据等要素实现用户的获取、激活、留存、变现、推荐&#xff0c;用户增长包含了产品出现前的用户增长、产品生产周期内的用户增长、产品生命周期外的用户增长三个阶段。 用户增长6步法&#xff1a;方法、模型和…

YOLOv8-TensorRT on Jetson

YOLOv8-TensorRT Jetson 项目地址&#xff1a;https://github.com/triple-Mu/YOLOv8-TensorRT/blob/main/docs/Jetson.md 文档地址&#xff1a;https://github.com/triple-Mu/YOLOv8-TensorRT/blob/main/docs/Jetson.md 注意 engine 文件不跨平台&#xff0c;只能在对应的平台…

docker mysql主从复制

新建主服务器容器实例3301 mysql 主 3301 docker run -p 3301:3306 --name mysql-master \ -v /mydata/mysql-master/log:/var/log/mysql \ -v /mydata/mysql-master/data:/var/lib/mysql \ -v /mydata/mysql-master/conf:/etc/mysql \ -v /home/mysql/mysql-files:/var/lib/…

MATLAB环境下使用相关图可视化相关矩阵

为了处理各行各业中出现的高维数据&#xff0c;迫切需要寻找适用的统计学方法。大维随机矩阵理论是处理高维数据的理论工具之一&#xff0c;在高维统计分析中&#xff0c;表现出良好的性能并有着广泛的应用。 二十世纪四十年代和五十年代初期&#xff0c;大维随机矩阵理论起源…

AI大模型 拍照搜题

最近&#xff0c;发现一款小程序【问智通】&#xff0c;实现了拍照搜题结合AI大模型&#xff0c;省去了打字和敲数学公式向AI提问&#xff0c;完美的补充了其它拍照搜题平台拍不到&#xff0c;没解析等不足&#xff01;&#xff01;&#xff01; 小程序码&#xff1a; APP下载…

【多模态】28、LLaVA 第一版 | Visual Instruction Tuning 多模态模型的指令微调

论文&#xff1a;Visual Instruction Tuning 代码&#xff1a;https://llava-vl.github.io/ 出处&#xff1a;NeurIPS 2023 Oral 系列工作&#xff1a;LLaVA-1.5、LLaVA-PLUS、LLaVA-Interactive、Video-LLaVA、LLaVA-Med 等&#xff0c;LLaVA 也是首次将指令学习引入多模态…

西门子WinCC冗余项目使用

1 如果需要使用WinCC冗余系统时&#xff0c;请仔细阅读下面的文档&#xff0c;它将解决以下几个问题&#xff1a; &#xff08;1&#xff09;WinCC冗余有什么样的功能&#xff1f; &#xff08;2&#xff09;需要购买什么样的授权&#xff1f; &#xff08;3&#xff09;应…

TypeScript 中命名空间与模块的区别

&#x1f469; 个人主页&#xff1a;不爱吃糖的程序媛 &#x1f64b;‍♂️ 作者简介&#xff1a;前端领域新星创作者、CSDN内容合伙人&#xff0c;专注于前端各领域技术&#xff0c;成长的路上共同学习共同进步&#xff0c;一起加油呀&#xff01; ✨系列专栏&#xff1a;前端…

H3C OSPF 外部路由引入实验

H3C OSPF 外部路由引入实验 实验拓扑 实验需求 按照图示配置 IP 地址R1&#xff0c;R2&#xff0c;R3 运行 OSPF 使内网互通&#xff0c;所有接口&#xff08;公网接口除外&#xff09;全部宣告进 Area 0&#xff1b;要求使用环回口作为 Router-id业务网段不允许出现协议报文…

请立刻停止编写 Dockerfiles 并使用 docker init

您是那种觉得编写 Dockerfile 和 docker-compose.yml 文件很痛苦的人之一吗&#xff1f; 我承认&#xff0c;我就是其中之一。 我总是想知道我是否遵循了 Dockerfile、 docker-compose 文件的最佳编写实践&#xff0c;我害怕在不知不觉中引入了安全漏洞。 但是现在&#xff0c…

【数据结构和算法初阶(C语言)】时间复杂度(衡量算法快慢的高端玩家,搭配例题详细剖析)

目录 1.算法效率 1.1如何衡量一个算法的好坏 1.2 算法的复杂度 2.主菜-时间复杂度 2.1 时间复杂度的概念 2.2 大O的渐进表示法 2.2.1算法的最好&#xff0c;最坏和平均的情况 3.经典时间复杂度计算举例 3.1计算冒泡排序的时间复杂度 3.2计算折半查找的时间复杂度 3.…

Vue3 学习笔记(Day5)

「写在前面」 本文为尚硅谷禹神 Vue3 教程的学习笔记。本着自己学习、分享他人的态度&#xff0c;分享学习笔记&#xff0c;希望能对大家有所帮助。推荐先按顺序阅读往期内容&#xff1a; 1. Vue3 学习笔记&#xff08;Day1&#xff09; 2. Vue3 学习笔记&#xff08;Day2&…

提升培训考试效率的系统设计策略

随着培训的重要性日益凸显&#xff0c;如何提升培训考试系统的效率成为了许多组织和机构关注的焦点。 一、设计自适应的考试界面 培训考试系统的界面应该能够自适应不同的屏幕尺寸和设备类型&#xff0c;如电脑、平板电脑和手机。采用响应式设计技术&#xff0c;确保考生在不同…

Leetcode115. 不同的子序列 -代码随想录

题目&#xff1a; 代码(首刷看解析 2024年2月29日&#xff09;&#xff1a; 不晓得这种超过int和long的测试案例是用来恶心谁的&#xff0c;用DP都没机会取模 class Solution { public:// 动态规划const int MOD 1000000007;int numDistinct(string s, string t) {long n s.…

市场复盘总结 20240229

仅用于记录当天的市场情况&#xff0c;用于统计交易策略的适用情况&#xff0c;以便程序回测 短线核心&#xff1a;不参与任何级别的调整&#xff0c;采用龙空龙模式 一支股票 10%的时候可以操作&#xff0c; 90%的时间适合空仓等待 二进三&#xff1a; 进级率中 60% 最常用…

06|Mysql内部组件结构

1. 连接器 客户端要向mysql发起通信都必须先跟Server端建立通信连接&#xff0c;而建立连接的工作就是由连接器完成的 mysql -h host[数据库地址] -u root[用户] -p root[密码] -P 3306连接步骤: 1、如果用户名或密码不对&#xff0c;你就会收到一个"Access denied for us…

【转载】Windows 11 任务栏位置调整

更改注册表&#xff08;部分win11版本有效&#xff09; Win R快捷键打开「运行」——执行regedit命令打开「注册表编辑器」进入路径&#xff1a; 计算机\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3 修改Settings这个二进制的第 2 行…

前端同时传递文件数据+非文件数据,前后端解决方案

之前录制视频《文件上传组件》的时候有位观众提了个问题&#xff0c;如果我没有理解错的话&#xff0c;应该就是前后同时传递文件数据 非文件数据&#xff0c;前后端数据该如何接收&#xff0c;这里我给出我自己的解决方案 tip:下文在编写前端代码的时候&#xff0c;用到了这篇…

MYSQL安装及卸载

目录 一、下载 二、解压 三、配置 1. 添加环境变量 2. 初始化MySQL 3. 注册MySQL服务 4. 启动MySQL服务 5. 修改默认账户密码 四、登录MySQL 五、卸载MySQL 一、下载 点开下面的链接&#xff1a;MySQL :: Download MySQL Community Server 点击Download 就可以下载对…