Java面向对象(进阶)-- 拼电商客户管理系统(康师傅)
文章目录
- 一、目标
- 二、需求说明
- (1)主菜单
- (2)添加客户
- (3)修改客户
- (4)删除客户
- (5)客户列表
- 三、软件设计结构
- 四、类的设计
- (1)Customer类的设计
- (2)CustomerList类的设计
- (3)CustomerView类的设计
- (4)CMUtility工具类
- 五、结果展示
一、目标
项目学习巩固目标:
-
模拟实现一个基于文本界面的《拼电商客户管理系统》
-
进一步掌握编程技巧和调试技巧,熟悉面向对象编程
-
主要涉及以下知识点:
-
类结构的使用:属性、方法及构造器
-
对象的创建与使用
-
类的封装性
-
声明和使用数组
-
数组的插入、删除和替换
-
关键字的使用:this
-
二、需求说明
模拟实现基于文本界面的《拼电商客户管理系统》。
该软件能够实现对客户对象的插入、修改和删除(用数组实现),并能够打印客户明细表。
(1)主菜单
项目采用分级菜单方式。主菜单如下:
-----------------拼电商客户管理系统-----------------
1 添 加 客 户
2 修 改 客 户
3 删 除 客 户
4 客 户 列 表
5 退 出
请选择(1-5):_
•每个客户的信息被保存在Customer对象中。
•以一个Customer类型的数组来记录当前所有的客户。
•每次“添加客户”(菜单1)后,客户(Customer)对象被添加到数组中。
•每次“修改客户”(菜单2)后,修改后的客户(Customer)对象替换数组中原对象。
•每次“删除客户”(菜单3)后,客户(Customer)对象被从数组中清除。
•执行“客户列表 ”(菜单4)时,将列出数组中所有客户的信息。
(2)添加客户
“添加客户”的界面及操作过程如下所示:
……
请选择(1-5):1
---------------------添加客户---------------------
姓名:佟刚
性别:男
年龄:35
电话:010-56253825
邮箱:tongtong@atguigu.com
---------------------添加完成---------------------
(3)修改客户
“修改客户”的界面及操作过程如下所示:
……
请选择(1-5):2
---------------------修改客户---------------------
请选择待修改客户编号(-1退出):1
姓名(佟刚):<直接回车表示不修改>
性别(男):
年龄(35):
电话(010-56253825):
邮箱(tongtong@atguigu.com):tongg@atguigu.com
---------------------修改完成---------------------
(4)删除客户
“删除客户”的界面及操作过程如下所示:
……
请选择(1-5):3
---------------------删除客户---------------------
请选择待删除客户编号(-1退出):1
确认是否删除(Y/N):y
---------------------删除完成---------------------
(5)客户列表
“客户列表”的界面及操作过程如下所示:
……
请选择(1-5):4
---------------------------客户列表---------------------------
编号 姓名 性别 年龄 电话 邮箱
1 佟刚 男 45 010-56253825 tong@abc.com
2 封捷 女 36 010-56253825 fengjie@ibm.com
3 雷丰阳 男 32 010-56253825 leify@163.com
-------------------------客户列表完成-------------------------
三、软件设计结构
该软件由以下三个模块组成:

Ø CustomerView(视图)为主模块,负责菜单的显示和处理用户操作
Ø CustomerList为Customer对象的管理模块,内部用数组管理一组Customer对象,并提供相应的添加、修改、删除和遍历方法,供CustomerView调用(操作数组的行为都放在CustomerList里面)
Ø Customer为实体对象,用来封装客户信息(数组是Customer类类型的,也可以设计为JavaBean)
enterMainMenu()方法的活动图

四、类的设计
(1)Customer类的设计
Customer为实体类,用来封装客户信息
- 该类封装客户的以下信息:
String name:客户姓名char gender:性别int age:年龄String phone:电话号码String email:电子邮箱
- 提供各属性的get/set方法
- 提供所需的构造器(可自行确定)
🤺代码
【Customer.java】
package yuyi03;/*** ClassName: Customer* Package: yuyi03* Description:* 客户类* @Author 雨翼轻尘* @Create 2023/10/28 0028 18:30*/
public class Customer {//属性private String name; //客户姓名private char gender; //性别private int age; //年龄private String phone; //电话号码private String email; //电子邮箱//方法public void setName(String name){this.name=name;}public char getGender() {return gender;}public void setGender(char gender) {this.gender = gender;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}public String getPhone() {return phone;}public void setPhone(String phone) {this.phone = phone;}public String getEmail() {return email;}public void setEmail(String email) {this.email = email;}public String getName(){return name;}public String getDetails(){return name + "\t" +gender +"\t" +age+ "\t" +phone +"\t"+email;}//构造器public Customer() {}public Customer(String name, char gender, int age, String phone, String email) {this.name = name;this.gender = gender;this.age = age;this.phone = phone;this.email = email;}
}
(2)CustomerList类的设计
CustomerList为Customer对象的管理模块,内部使用数组管理一组Customer对象
- 本类封装以下信息:
Customer[] customers:用来保存客户对象的数组int total = 0:记录已保存客户对象的数量
- 该类至少提供以下构造器和方法:
- public CustomerList(int totalCustomer)
- public booleanaddCustomer(Customer customer)
- public booleanreplaceCustomer(int index, Customer cust)
- public booleandeleteCustomer(int index)
- public Customer[] getAllCustomers()
- public Customer getCustomer(int index)
- public int getTotal()
⚡各方法的作用与参数:
①public CustomerList(inttotalCustomer)
- 用途:构造器,用来初始化customers数组
- 参数:totalCustomer:指定customers数组的最大空间
②public booleanaddCustomer(Customer customer)
- 用途:将参数customer添加组中最后一个客户对象记录之后
- 参数:customer指定要添加的客户对象
- 返回:添加成功返回true;false表示数组已满,无法添加
③public booleanreplaceCustomer(int index, Customer cust)
-
用途:用参数customer替换数组中由index指定的对象
-
参数:customer指定替换的新客户对象
index指定所替换对象在数组中的位置,从0开始 -
返回:替换成功返回true;false表示索引无效,无法替换
/*** 用途:从数组中删除参数index指定索引位置的客户对象记录* @param index 参数: index指定所删除对象在数组中的索引位置,从0开始* @return 返回:删除成功返回true;false表示索引无效,无法删除*/
public boolean deleteCustomer(int index){//后边元素往前挪if(index>=0 && index<total){for (int i = index; i <total-1 ; i++) { //比如现在有3个元素,角标是0-2,index为1(第二个元素),角标为2的元素(第三个)往前移动,现在只有两个元素,角标不能超过1customers[i]=customers[i+1]; //i的最大值是tatal-2,则customers[i+1]最大值为customers[total-1]}//将有效数据最后一个位置置空customers[total-1]=null; total--; //总人数减一return true;}else{return false;}
}
还可以这样:
/*** 用途:从数组中删除参数index指定索引位置的客户对象记录* @param index 参数: index指定所删除对象在数组中的索引位置,从0开始* @return 返回:删除成功返回true;false表示索引无效,无法删除*/public boolean deleteCustomer(int index){if(index<0 || index>=total){return false;}for (int i = index; i < total-1; i++) {customers[i]=customers[i+1];}//将有效数据最后一个位置置空//customers[total-1]=null;//total--;//或customers[--total]=null;return true;}
④public booleandeleteCustomer(int index)
- 用途:从数组中删除参数index指定索引位置的客户对象记录
- 参数: index指定所删除对象在数组中的索引位置,从0开始
- 返回:删除成功返回true;false表示索引无效,无法删除
⑤public Customer[] getAllCustomers()
- 用途:返回数组中记录的所有客户对象
- 返回: Customer[] 数组中包含了当前所有客户对象,该数组长度与对象个数相同。
⑥public Customer getCustomer(int index)
- 用途:返回参数index指定索引位置的客户对象记录
- 参数: index指定所要获取的客户在数组中的索引位置,从0开始
- 返回:封装了客户信息的Customer对象

🤺代码
【CustomerList.java】
package yuyi03;/*** ClassName: CustomerList* Package: yuyi03* Description:* CustomerList为Customer对象的管理模块,内部使用数组管理一组Customer对象* @Author 雨翼轻尘* @Create 2023/10/28 0028 18:47*/
public class CustomerList {//属性private Customer[] customers; //用来保存客户对象的数组private int total; //记录已保存客户对象的数量//构造器/*** 用途:构造器,用来初始化customers数组* @param totalCustomer 指定customers数组的最大空间*/public CustomerList(int totalCustomer){customers=new Customer[totalCustomer];}//方法/*** 用途:将参数customer添加组中最后一个客户对象记录之后* @param customer 参数:customer指定要添加的客户对象* @return 返回:添加成功返回true;false表示数组已满,无法添加*/public boolean addCustomer(Customer customer){if(total<customers.length){ //若此时客户对象的数量(total)小于数组长度,说明数组没有满,可以添加客户进去customers[total]=customer;total++; //加完一个客户进数组,客户对象数量加一return true;}else{return false;}}/*** 用途:用参数cust替换数组中由index指定的对象* @param index index指定所替换对象在数组中的位置,从0开始* @param cust 参数:cust 指定替换的新客户对象* @return 返回:替换成功返回true;false表示索引无效,无法替换*/public boolean replaceCustomer(int index, Customer cust){if(index>=0 && index<total){customers[index]=cust;return true;}else{return false;}}/*** 用途:从数组中删除参数index指定索引位置的客户对象记录* @param index 参数: index指定所删除对象在数组中的索引位置,从0开始* @return 返回:删除成功返回true;false表示索引无效,无法删除*/public boolean deleteCustomer(int index){if(index<0 || index>=total){return false;}for (int i = index; i < total-1; i++) {customers[i]=customers[i+1];}//将有效数据最后一个位置置空//customers[total-1]=null;//total--;//或customers[--total]=null;return true;}/*** 用途:返回数组中记录的所有客户对象* @return 返回: Customer[] 数组中包含了当前所有客户对象,该数组长度与对象个数相同。*/public Customer[] getAllCustomers(){//错误的://return customers; 会将空的元素也一起返回,现在只需要有客户的对象元素//正确的:Customer[] cus=new Customer[total]; //要是一个也没有存,total是0,循环进不去,直接返回,相当于造了一个长度为0的数组for (int i = 0; i < total; i++) { //total也可以改为cus.lengthcus[i]=customers[i]; //没有将对象复制过来,只是将地址复制过来了,对象还是原来的那个}return cus;}/*** 用途:返回参数index指定索引位置的客户对象记录* @param index 参数: index指定所要获取的客户在数组中的索引位置,从0开始* @return 返回:封装了客户信息的Customer对象*/public Customer getCustomer(int index){if(index>0 || index<total){ //index有效范围return customers[index];}else{return null;}}/***获取客户列表中客户的数量* @return 客户数量total*/public int getTotal(){return total;}}
(3)CustomerView类的设计
CustomerView为主模块,负责菜单的显示和处理用户操作
- 本类封装以下信息:
- CustomerList customerList = new CustomerList(10);
- 创建最大包含10个客户对象的CustomerList对象,供以下各成员方法使用。
- 该类至少提供以下方法:
- public void enterMainMenu()
- private void addNewCustomer()
- private void modifyCustomer()
- private void deleteCustomer()
- private void listAllCustomers()
- public static void main(String[] args)
⚡各方法的作用与参数:
①public void enterMainMenu()
- 用途:显示主菜单,响应用户输入,根据用户操作分别调用其他相应的成员方法(如addNewCustomer),以完成客户信息处理。
②private void addNewCustomer()
private void modifyCustomer()
private void deleteCustomer()
private void listAllCustomers()
- 用途:这四个方法分别完成“添加客户”、“修改客户”、“删除客户”和“客户列表”等各菜单功能。
- 这四个方法仅供enterMainMenu()方法调用。
③public static void main(String[] args)
- 用途:创建CustomerView实例,并调用 enterMainMenu()方法以执行程序。
🤺代码
【CustomerView.java】
package yuyi03;/*** ClassName: CustomerView* Package: yuyi03* Description:* CustomerView为主模块,负责菜单的显示和处理用户操作* @Author 雨翼轻尘* @Create 2023/10/29 0029 10:16*/
public class CustomerView {//造CustoomerList的对象,作为当前类的属性出现CustomerList customerList = new CustomerList(10); //数组长度为10,最多添加10个客户//方法/*** 进入主界面的方法*/public void enterMainMenu(){boolean isFlag=true;while(isFlag){//显示界面System.out.println("\n-------------------拼电商客户管理系统-----------------\n");System.out.println(" 1 添 加 客 户");System.out.println(" 2 修 改 客 户");System.out.println(" 3 删 除 客 户");System.out.println(" 4 客 户 列 表");System.out.println(" 5 退 出\n");System.out.print(" 请选择(1-5):");char key = CMUtility.readMenuSelection(); //让用户从1-5做选择,不是这个范围就出不来switch(key){case '1'://添加客户addNewCustomer();break;case '2'://修改客户modifyCustomer();break;case '3'://删除客户deleteCustomer();break;case'4'://客户列表listAllCustomers();break;case '5':System.out.print("确认是否退出(Y/N):");char isExit=CMUtility.readConfirmSelection();if(isExit=='Y'){ //Y要大写,因为在CMUtility.readConfirmSelection()方法里面给它转成大写的了//获取用户选择为5的时候退出isFlag=false;}//若是N就不用管它了,继续循环即可break;}}}//添加客户private void addNewCustomer(){System.out.println("---------------------添加客户---------------------");System.out.print("姓名:");String name = CMUtility.readString(4);System.out.print("性别:");char gender = CMUtility.readChar();System.out.print("年龄:");int age = CMUtility.readInt();System.out.print("电话:");String phone = CMUtility.readString(15);System.out.print("邮箱:");String email = CMUtility.readString(15);Customer cust = new Customer(name, gender, age, phone, email);boolean flag = customerList.addCustomer(cust);if (flag) {System.out.println("---------------------添加完成---------------------");} else {System.out.println("----------------记录已满,无法添加-----------------");}}private void modifyCustomer() {System.out.println("---------------------修改客户---------------------");int index = 0;Customer cust = null;for (;;) {System.out.print("请选择待修改客户编号(-1退出):");index = CMUtility.readInt();if (index == -1) {return;}cust = customerList.getCustomer(index - 1);if (cust == null) {System.out.println("无法找到指定客户!");} elsebreak;}System.out.print("姓名(" + cust.getName() + "):");String name = CMUtility.readString(4, cust.getName());System.out.print("性别(" + cust.getGender() + "):");char gender = CMUtility.readChar(cust.getGender());System.out.print("年龄(" + cust.getAge() + "):");int age = CMUtility.readInt(cust.getAge());System.out.print("电话(" + cust.getPhone() + "):");String phone = CMUtility.readString(15, cust.getPhone());System.out.print("邮箱(" + cust.getEmail() + "):");String email = CMUtility.readString(15, cust.getEmail());cust = new Customer(name, gender, age, phone, email);boolean flag = customerList.replaceCustomer(index - 1, cust);if (flag) {System.out.println("---------------------修改完成---------------------");} else {System.out.println("----------无法找到指定客户,修改失败--------------");}}//删除客户private void deleteCustomer() {System.out.println("---------------------删除客户---------------------");int index = 0;Customer cust = null;for (;;) {System.out.print("请选择待删除客户编号(-1退出):");index = CMUtility.readInt();if (index == -1) {return;}cust = customerList.getCustomer(index - 1);if (cust == null) {System.out.println("无法找到指定客户!");} elsebreak;}System.out.print("确认是否删除(Y/N):");char yn = CMUtility.readConfirmSelection();if (yn == 'N')return;boolean flag = customerList.deleteCustomer(index - 1);if (flag) {System.out.println("---------------------删除完成---------------------");} else {System.out.println("----------无法找到指定客户,删除失败--------------");}}//客户列表private void listAllCustomers() {System.out.println("---------------------------客户列表---------------------------");Customer[] custs = customerList.getAllCustomers();if (custs.length == 0) {System.out.println("没有客户记录!");} else {System.out.println("编号\t姓名\t\t性别\t年龄\t电话\t\t\t邮箱");for (int i = 0; i < custs.length; i++) {// System.out.println(i + 1 + "\t" + custs[i].getName() + "\t" + custs[i].getGender() + "\t" + custs[i].getAge() + "\t\t" + custs[i].getPhone() + "\t" + custs[i].getEmail());System.out.println((i+1) + "\t" + custs[i].getDetails());}}System.out.println("-------------------------客户列表完成-------------------------");}public static void main(String[] args){//创建当前类的对象CustomerView view =new CustomerView();view.enterMainMenu();}}
(4)CMUtility工具类
项目中提供了CMUtility.java类,可用来方便地实现键盘访问。
该类提供了以下静态方法:
-
public static char readMenuSelection()
- 用途:该方法读取键盘,如果用户键入’1’-’5’中的任意字符,则方法返回。返回值为用户键入字符。
-
public static char readChar()和 public static char readChar(char defaultValue)
- 用途:这两个方法功能相同,均从键盘读取一个字符,并将其作为方法的返回值。
- 参数:defaultValue— 如果用户不输入字符而直接回车,方法将以defaultValue 作为返回值。(提示:此方法可在修改客户时调用)
-
public static int readInt() 和public static int readInt(int defaultValue)
- 用途:这两个方法功能相同,均从键盘读取一个长度不超过2位的 整数,并将其作为方法的返回值。
- 参数:defaultValue— 如果用户不输入字符而直接回车,方法将以defaultValue 作为返回值。
-
public static String readString(int limit) 和public static String readString(int limit, String defaultValue)
-
用途:这两个方法功能相同,均从键盘读取一个长度不超过limit的字符串,并将其作为方法的返回值。
-
参数:limit — 指定字符串的最大长度
defaultValue— 如果用户不输入字符而直接回车,方法将以defaultValue 作为返回值。
-
-
public static char readConfirmSelection()
- 用途:从键盘读取‘Y’或’N’,并将其作为方法的返回值。
【CMUtility.java】
package com.atguigu02.project;import java.util.Scanner;/**
* CMUtility工具类:
* 将不同的功能封装为方法,就是可以直接通过调用方法使用它的功能,而无需考虑具体的功能实现细节。
*
* @author 尚硅谷-宋红康
* @create 17:17
*/
public class CMUtility {private static Scanner scanner = new Scanner(System.in);/**用于界面菜单的选择。该方法读取键盘,如果用户键入’1’-’5’中的任意字符,则方法返回。返回值为用户键入字符。*/public static char readMenuSelection() {char c;for (; ; ) {String str = readKeyBoard(1, false);c = str.charAt(0);if (c != '1' && c != '2' && c != '3' && c != '4' && c != '5') {System.out.print("选择错误,请重新输入:");} else break;}return c;}/**从键盘读取一个字符,并将其作为方法的返回值。*/public static char readChar() {String str = readKeyBoard(1, false);return str.charAt(0);}/**从键盘读取一个字符,并将其作为方法的返回值。如果用户不输入字符而直接回车,方法将以defaultValue 作为返回值。*/public static char readChar(char defaultValue) {String str = readKeyBoard(1, true);return (str.length() == 0) ? defaultValue : str.charAt(0);}/**从键盘读取一个长度不超过2位的整数,并将其作为方法的返回值。*/public static int readInt() {int n;for (; ; ) {String str = readKeyBoard(2, false);try {n = Integer.parseInt(str);break;} catch (NumberFormatException e) {System.out.print("数字输入错误,请重新输入:");}}return n;}/**从键盘读取一个长度不超过2位的整数,并将其作为方法的返回值。如果用户不输入字符而直接回车,方法将以defaultValue 作为返回值。*/public static int readInt(int defaultValue) {int n;for (; ; ) {String str = readKeyBoard(2, true);if (str.equals("")) {return defaultValue;}try {n = Integer.parseInt(str);break;} catch (NumberFormatException e) {System.out.print("数字输入错误,请重新输入:");}}return n;}/**从键盘读取一个长度不超过limit的字符串,并将其作为方法的返回值。*/public static String readString(int limit) {return readKeyBoard(limit, false);}/**从键盘读取一个长度不超过limit的字符串,并将其作为方法的返回值。如果用户不输入字符而直接回车,方法将以defaultValue 作为返回值。*/public static String readString(int limit, String defaultValue) {String str = readKeyBoard(limit, true);return str.equals("")? defaultValue : str;}/**用于确认选择的输入。该方法从键盘读取‘Y’或’N’,并将其作为方法的返回值。*/public static char readConfirmSelection() {char c;for (; ; ) {String str = readKeyBoard(1, false).toUpperCase();c = str.charAt(0);if (c == 'Y' || c == 'N') {break;} else {System.out.print("选择错误,请重新输入:");}}return c;}private static String readKeyBoard(int limit, boolean blankReturn) {String line = "";while (scanner.hasNextLine()) {line = scanner.nextLine();if (line.length() == 0) {if (blankReturn) return line;else continue;}if (line.length() < 1 || line.length() > limit) {System.out.print("输入长度(不大于" + limit + ")错误,请重新输入:");continue;}break;}return line;}}
五、结果展示
项目简图

①主菜单

②添加客户(1)

③客户列表(4)

④修改客户(2)

⑤删除客户(3)

⑥退出(5)

相关文章:
Java面向对象(进阶)-- 拼电商客户管理系统(康师傅)
文章目录 一、目标二、需求说明(1)主菜单(2)添加客户(3)修改客户(4)删除客户(5)客户列表 三、软件设计结构四、类的设计(1)Customer类…...
Qt配置OpenCV教程,亲测已试过
详细版可参考:Qt配置OpenCV教程,亲测已试过(详细版)_qt opencv_-_Matrix_-的博客-CSDN博客 软件准备:QtOpenCVCMake (QtOpenCV安装不说了,CMake的安装,我用的是:可参考博客&#x…...
【实用网站分享】
1、PyDebloatX https://pydebloatx.com/pydebloatx 是一种用于 Windows 操作系统的 Python 脚本,用于卸载 Windows 10 系统中的预装应用和系统组件,以便提高系统性能和释放磁盘空间。它是 Debloat Windows 10 脚本的一个分支,但具有更友好和…...
问题 U: 折线分割平面(类比+规律)
规律类比: 1.一个折线的角,只会对应一个部分 2.若反向延长,角对应的部分被分为3部分 (即一条折现线改为两条直线) 3.所以n条折线分成的平面数,等于2n条直线减去2n 代码实现:...
npm 彻底卸载
问题: 执行 npm -v 指令出现如下报错: ERROR: npm v10.2.1 is known not to run on Node.js v12.10.0. This version of npm supports the following node versions: ^18.17.0 || >20.5.0. 分析: 由于编译环境问题,需要更新…...
云安全-云原生技术架构(Docker逃逸技术-特权与危险挂载)
0x00 云原生技术-docker docker容器和虚拟机的对比:前者是将运行环境打包,封装一个环境。后者是将整个系统打包,封装一个系统。在操作使用上来说各有利弊。 0x01 docker容器的三种逃逸类型 特权模式启动(不安全的启动方式&…...
【Python爬虫三天从0到1】Day1:爬虫核心
目录 1.HTTP协议与WEB开发 (1)简介 (2)请求协议和响应协议 2. requests&反爬破解 (1)UA反爬 (2)referer反爬 (3)cookie反爬 3.请求参数 &#x…...
2023-10 最新jsonwebtoken-jjwt 0.12.3 基本使用
导入依赖 <dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt</artifactId><version>0.12.3</version></dependency>包括了下面三个依赖, 所以导入上面一个就OK了 <dependency><groupId>io.jsonwe…...
云起无垠典型案例入选《2023软件供应链安全洞察》报告
近日,历时6个月,由ISC编制的《2023软件供应链安全洞察》报告(以下简称《报告》)正式对外发布。《报告》围绕软件供应链安全现状、技术内核、治理指南、落地实践展开,以期为行业从业者提供有价值的信息和洞见࿰…...
怎么从休学证明中取出休学原因(python自动化办公,涉及word和excel)
怎么从休学证明中取出休学原因(python自动化办公,涉及word和excel) 本代码偏向处理高校教务处的工作 休学或请假模板如下: 休学证明(此联存教务办)编号:休202323 计算机系23级计算机科学与技术…...
C语言 定义一个函数,并调用,该函数中打印显示直角三角形
#include<stdio.h> void chengfabiao() {for (int i 1; i < 5; i){for (int j 1; j < i; j){printf("*");} printf("\n");} } int main(int argc,const char *argv[]) {chengfabiao();return 0; }...
Doceker-compose——容器群集编排管理工具
目录 Docker-compose 1、Docker-compose 的三大概念 2、YAML文件格式及编写注意事项 1)使用 YAML 时需要注意下面事项 2)ymal文件格式 3)json格式 3、Docker Compose配置常用字段 4、Docker-compose的四种重启策略 5、Docker Compos…...
Redis 与 MySQL 一致性 实现方案
正常情况下的流程是:请求来了,先检查 Redis 有没有数据,有返回;没有便查询 MySQL 然后 放入 Redis。 此时,如果 MySQL 的数据发生了变化,所以需要同步到 Redis 中。 解决方法:MySQL 中的数据更新…...
运维 | 使用 Docker 安装 Jenkins | Jenkins
运维 | 使用 Docker 安装 Jenkins | Jenkins 前言 本期内容主要是为了学习如何通过 Docker 安装Jenkins,仅作为记录与参考,希望对大家有所帮助。 准备工作 系统:CentOS 7.9配置:4c8g 快速安装 下面以 Docker 方式安装 Jenkin…...
linux-磁盘应用
目录 一、磁盘内容简述 1、一些基本概念 2、分区简述 3、常见文件系统 4、linux硬盘文件 二、对linux系统进行分区 1、用fdisk进行分区 2、用parted进行分区 一、磁盘内容简述 1、一些基本概念 - 扇区大小:512Btyes,0.5KB - 磁盘最小存储单位&…...
java版直播商城平台规划及常见的营销模式 电商源码/小程序/三级分销+商城免费搭建
涉及平台 平台管理、商家端(PC端、手机端)、买家平台(H5/公众号、小程序、APP端(IOS/Android)、微服务平台(业务服务) 2. 核心架构 Spring Cloud、Spring Boot、Mybatis、Redis …...
软考高级之系统架构师之软件工程
软件工程 面向对象设计原则 单一职责:设计目的单一的类开闭原则;对扩展开放,对修改关闭里氏替换:子类可以替代父类依赖倒置:要依赖于抽象,而不是实现。要针对接口编程,不要针对实现编程接口隔…...
SpringBoot集成与应用Neo4j
文章目录 前言集成使用定义实体配置定义Repository查询方法方式一:Query方式二:Cypher语法构建器方式三:Example条件构建器方式四:DSL语法 自定义方法自定义接口继承自定义接口实现自定义接口neo4jTemplateNeo4jClient 自定义抽象…...
做人,不一定要风风光光,但一定要堂堂正正。处事,不一定要尽善尽美,但一定要问心无愧。
做人,不一定要风风光光,但一定要堂堂正正。处事,不一定要尽善尽美,但一定要问心无愧。以真诚的心,对待身边的每一个人。以感恩的心,感谢拥有的一切。 未来,不是穷人的天下,也不是富人…...
51单片机实验:数码管动态显示00-99
1、实验要求 利用STC89C52RC单片机开发板实现:使用2位数码管循环显示00-99,每次间隔1s,并且当计数到20时,则蜂鸣器鸣响1次。 2、实验分析 程序实现分析: 1、定义数码管位选引脚(P2.4、P2.5、P2.6、…...
IDEA运行Tomcat出现乱码问题解决汇总
最近正值期末周,有很多同学在写期末Java web作业时,运行tomcat出现乱码问题,经过多次解决与研究,我做了如下整理: 原因: IDEA本身编码与tomcat的编码与Windows编码不同导致,Windows 系统控制台…...
《从零掌握MIPI CSI-2: 协议精解与FPGA摄像头开发实战》-- CSI-2 协议详细解析 (一)
CSI-2 协议详细解析 (一) 1. CSI-2层定义(CSI-2 Layer Definitions) 分层结构 :CSI-2协议分为6层: 物理层(PHY Layer) : 定义电气特性、时钟机制和传输介质(导线&#…...
基础测试工具使用经验
背景 vtune,perf, nsight system等基础测试工具,都是用过的,但是没有记录,都逐渐忘了。所以写这篇博客总结记录一下,只要以后发现新的用法,就记得来编辑补充一下 perf 比较基础的用法: 先改这…...
高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数
高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数 在软件开发中,单例模式(Singleton Pattern)是一种常见的设计模式,确保一个类仅有一个实例,并提供一个全局访问点。在多线程环境下,实现单例模式时需要注意线程安全问题,以防止多个线程同时创建实例,导致…...
FFmpeg:Windows系统小白安装及其使用
一、安装 1.访问官网 Download FFmpeg 2.点击版本目录 3.选择版本点击安装 注意这里选择的是【release buids】,注意左上角标题 例如我安装在目录 F:\FFmpeg 4.解压 5.添加环境变量 把你解压后的bin目录(即exe所在文件夹)加入系统变量…...
群晖NAS如何在虚拟机创建飞牛NAS
套件中心下载安装Virtual Machine Manager 创建虚拟机 配置虚拟机 飞牛官网下载 https://iso.liveupdate.fnnas.com/x86_64/trim/fnos-0.9.2-863.iso 群晖NAS如何在虚拟机创建飞牛NAS - 个人信息分享...
【多线程初阶】单例模式 指令重排序问题
文章目录 1.单例模式1)饿汉模式2)懒汉模式①.单线程版本②.多线程版本 2.分析单例模式里的线程安全问题1)饿汉模式2)懒汉模式懒汉模式是如何出现线程安全问题的 3.解决问题进一步优化加锁导致的执行效率优化预防内存可见性问题 4.解决指令重排序问题 1.单例模式 单例模式确保某…...
使用ch340继电器完成随机断电测试
前言 如图所示是市面上常见的OTA压测继电器,通过ch340串口模块完成对继电器的分路控制,这里我编写了一个脚本方便对4路继电器的控制,可以设置开启时间,关闭时间,复位等功能 软件界面 在设备管理器查看串口号后&…...
安全领域新突破:可视化让隐患无处遁形
在安全领域,隐患就像暗处的 “幽灵”,随时可能引发严重事故。传统安全排查手段,常常难以将它们一网打尽。你是否好奇,究竟是什么神奇力量,能让这些潜藏的隐患无所遁形?没错,就是可视化技术。它如…...
盲盒一番赏小程序:引领盲盒新潮流
在盲盒市场日益火爆的今天,如何才能在众多盲盒产品中脱颖而出?盲盒一番赏小程序给出了答案,它以创新的玩法和优质的服务,引领着盲盒新潮流。 一番赏小程序的最大特色在于其独特的赏品分级制度。赏品分为多个等级,从普…...
