介绍页
个人信息
👋 姓名: xss | 性别: 男 | 出生日期: 2001年07月29日 | 国籍: 中国
联系方式
📧 电子邮件: xud0687@gmail.com | 🌐 GitHub: github.com/xssctt | 💼 LinkedIn: linkedin.com/in/xssctt| 📱 iPhone: 13523773853
菜鸟的博客,你干嘛~
👋 姓名: xss | 性别: 男 | 出生日期: 2001年07月29日 | 国籍: 中国
📧 电子邮件: xud0687@gmail.com | 🌐 GitHub: github.com/xssctt | 💼 LinkedIn: linkedin.com/in/xssctt| 📱 iPhone: 13523773853
注意:这块会涉及到操作系统和计算机组成原理相关内容。
I/O简而言之,就是输入输出,那么为什么会有I/O呢?其实I/O无时无刻都在我们的身边,比如读取硬盘上的文件,网络文件传输,鼠标键盘输入,也可以是接受单片机发回的数据,而能够支持这些操作的设备就是I/O设备。
我们可以大致看一下整个计算机的总线结构:
more
注释之前的内容被视为文章摘要。
package com.javaclimb.xshopping.service;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.javaclimb.xshopping.common.Common;
import com.javaclimb.xshopping.common.ResultCode;
import com.javaclimb.xshopping.entity.GoodsInfo;
import com.javaclimb.xshopping.entity.OrderGoodsRel;
import com.javaclimb.xshopping.entity.OrderInfo;
import com.javaclimb.xshopping.entity.UserInfo;
import com.javaclimb.xshopping.exception.CustomException;
import com.javaclimb.xshopping.mapper.OrderGoodsRelMapper;
import com.javaclimb.xshopping.mapper.OrderInfoMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
public class OrderInfoService {
@Resource
private UserInfoService userInfoService;
@Resource
private OrderInfoMapper orderInfoMapper;
@Resource
private GoodsInfoService goodsInfoService;
@Resource
private CartInfoSevice cartInfoSevice;
@Resource
private OrderGoodsRelMapper orderGoodsRelMapper;
/**
* 下单
*
* 前端把订单商品列表返回后台orderInfo
* orderInfo 存在用户id 后台获取用户信息
* 修饰订单id 保存
*/
//spring管理sql事务 出错回滚数据
@Transactional
public OrderInfo add(OrderInfo orderInfo){
//1 生成订单信息 用户信息 放到orderOInfo
Long userId=orderInfo.getUserid();
//d订单id 用户id+当前时间+流水号
String orderId=userId+ DateUtil.format(new Date(),"yyyyMMddHHmm")+ RandomUtil.randomNumbers(4);
orderInfo.setOrderid(orderId);
//用户相关
// 用户查到的数据放到订单信息表
UserInfo userInfo=userInfoService.findById(userId);
//地址
orderInfo.setLinkaddress(userInfo.getAddress());
//昵称
orderInfo.setLinkman(userInfo.getNickname());
//电话
orderInfo.setLinkphone(userInfo.getPhone());
//2 保存订单表//订单创建时间
orderInfo.setCreatetime(DateUtil.formatDateTime(new Date()));
//保存
orderInfoMapper.insertSelective(orderInfo);
//
List<OrderInfo> orderInfoList=orderInfoMapper.findByOrderId(orderId);
/**
* //3 查询订单商品列表 便利
* goodsList
* 从orderInfo获取商品列表
* 获取各个商品id 在后台查询商品数量 商品库存 修改
* 查询销量 修改销量 sale+count
* 修改关联表
*/
List<GoodsInfo> goodsList=orderInfo.getGoodsList();
for (GoodsInfo orderGoodsVO : goodsList){
Long goodsId=orderGoodsVO.getId();
//goodsDetail goodsInfoService 数据库
GoodsInfo goodsDetail=goodsInfoService.findById(goodsId);
if (goodsDetail == null){
continue;
}
//order 购买
Integer orderCount=orderGoodsVO.getCount() == null ? 0 : orderGoodsVO.getCount();
// 库存
Integer goodsCount=goodsDetail.getCount() == null ? 0 :goodsDetail.getCount();
//4 修改库存
if (orderCount>goodsCount){
throw new CustomException(ResultCode.ORDER_PAY_ERROR);
}
goodsDetail.setCount(goodsCount - orderCount);
//5 增加销量
int sales=goodsDetail.getSales() == null ? 0 :goodsDetail.getSales();
goodsDetail.setSales(sales+orderCount);
goodsInfoService.update(goodsDetail);
//6 商品订单关联表 将增加关系
OrderGoodsRel orderGoodsRel=new OrderGoodsRel();
orderGoodsRel.setOrderid(orderInfoList.get(0).getId());
orderGoodsRel.setGoodsid(goodsId);
orderGoodsRel.setCount(orderCount);
orderGoodsRelMapper.insert(orderGoodsRel);
}
//7 清除购物车
cartInfoSevice.empty(userId);
return orderInfo;
}
/**
* 根据终端用户获取 订单 状态
*
*/
public PageInfo<OrderInfo> findFrontPages(Long userId,String state,Integer pageNum,Integer pageSize){
PageHelper.startPage(pageNum,pageSize);
List<OrderInfo> orderInfos;
//
if (userId ==null){
orderInfos=new ArrayList<>();
}else {
orderInfos=orderInfoMapper.findByEndUserId(userId,state);
}
for (OrderInfo orderInfo:orderInfos){
packOrder(orderInfo);
}
return PageInfo.of(orderInfos);
}
/**
*包装订单的用户和商品信息
* order
* userid --> userinfo
* id -----> order_goods_rel : orderid(order.id) goodsid count
* goodsid --> goodsinfo
* count
*
* 包装 把 用户信息user info 商品信息 goods info 查询到并放入orderinfo
*
*/
private void packOrder(OrderInfo orderInfo){
//用户信息 userinfo orderInfo.getUserid()不会空 在添加购物车已判断是否空
orderInfo.setUserInfo(userInfoService.findById(orderInfo.getUserid())) ;
//商品信息
Long orderId=orderInfo.getId();
//rel id goodsid count 用户买的什么商品id 买了多少件
List<OrderGoodsRel> rels= orderGoodsRelMapper.findByOrderid(orderId);
List<GoodsInfo> goodsInfoList=new ArrayList<>();
for (OrderGoodsRel rel: rels){
//获取 用户购买 商品的信息
GoodsInfo goodsInfo=goodsInfoService.findById(rel.getGoodsid());
if (goodsInfo != null){
//rel.getCount() 用户买的什么商品id 买了多少件
goodsInfo.setCount(rel.getCount());
goodsInfoList.add(goodsInfo);
}
}
orderInfo.setGoodsList(goodsInfoList);
//orderInfo userInfo + goodsList
}
/**
* 改变订单状态
* @param id
* @param state
*/
public void changeState(Long id,String state){
OrderInfo order=orderInfoMapper.finById(id);
Long userId=order.getUserid();
UserInfo user=userInfoService.findById(userId);
if (state.equals("待发货")){
//校验余额
Double account=user.getAccount();
Double totalPrice=order.getTotalprice();
if ((account < totalPrice)){
throw new CustomException("-1","账户余额不足");
}
user.setAccount(user.getAccount() - order.getTotalprice());
//修改用户余额
userInfoService.update(user);
}
if (state.equals("已退货")){
//校验余额
Double account=user.getAccount();
Double totalPrice=order.getTotalprice();
user.setAccount(user.getAccount() + order.getTotalprice());
//修改用户余额
userInfoService.update(user);
}
//更新订单的状态
orderInfoMapper.updateState(id,state);
}
/**
*后台 查看订单列表
* @param userId
* @param pageNum
* @param pageSize
* @param request
* @return
*/
public PageInfo<OrderInfo> findPage(Long userId, Integer pageNum, Integer pageSize, HttpServletRequest request){
//
UserInfo user=(UserInfo) request.getSession().getAttribute(Common.USER_INFO);
if (user == null){
throw new CustomException("1001","session已失效,请重新登录");
}
//
Integer level=user.getLevel();
PageHelper.startPage(pageNum,pageSize);
List<OrderInfo> orderInfos;
//
if (1 == level){
orderInfos=orderInfoMapper.selectAll();
}else if(userId!=null){
orderInfos=orderInfoMapper.findByEndUserId(userId,null);
}else {
orderInfos=new ArrayList<>();
}
for (OrderInfo orderInfo: orderInfos){
packOrder(orderInfo);
}
return PageInfo.of(orderInfos);
}
/**
* 删除订单
* @param id
* Transactional
*/
@Transactional
public void delete(Long id) {
orderInfoMapper.deleteById(id);
orderGoodsRelMapper.deleteByOrderId(id);
}
/**
* 根据id查询订单信息
*
*/
public OrderInfo findById(Long id) {
OrderInfo orderInfo= orderInfoMapper.selectByPrimaryKey(id);
packOrder(orderInfo);
return orderInfo;
}
/**
*总交易额
*/
public Double count(){
return orderInfoMapper.count();
}
/**
* 总销量
*/
public Integer totalShopping(){
return orderGoodsRelMapper.totalShopping();
}
/**
* 分类总销售
*/
public List<Map<String,Object>> getTypePrice(){
return orderInfoMapper.getTypePrice();
}
/**
* 分类总销售
*/
public List<Map<String,Object>> getTypeCount(){
return orderInfoMapper.getTypeCount();
}
}
通过了解其他的SpringBoot框架,我们就可以在我们自己的Web服务器上实现更多更高级的功能。
我们在注册很多的网站时,都会遇到邮件或是手机号验证,也就是通过你的邮箱或是手机短信去接受网站发给你的注册验证信息,填写验证码之后,就可以完成注册了,同时,网站也会绑定你的手机号或是邮箱。
那么,像这样的功能,我们如何实现呢?SpringBoot已经给我们提供了封装好的邮件模块使用:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/xssctt/--
git push -u origin main
已经进行了批改:
Linux系统的内核是() c
A. Windows B. Unix C. Linux D. MacOS
Linux系统的缺省Shell是()a
A. bash B. dash C. ksh D. tcsh
用来查看Linux系统版本的命令是()d
A. uname B. uname -a C. uname -r D. uname -v
用来查看Linux系统上运行的进程的命令是() a
A. ps B. top C. htop D. atop
用来查看Linux系统上安装的软件包信息的命令是()d A. rpm -qa B. dpkg -l C. yum list installed D. apt list --installed
用来搜索文件内容的命令是() D
A. find B. locate C. which D. grep
用来查看文件或目录权限的命令是()a
A. ls -l B. ls -a C. ls -al D. ls -la
用来切换用户的命令是() A
A. su B. sudo C. switch D. login
用来查看磁盘使用情况的命令是()a
A. df -h B. du -h C. free -h D. diskusage
用来查看内存使用情况的命令是()c
A. top B. htop C. free -m D. vmstat
用来查看网络接口信息的命令是()b
A. ip addr B. ifconfig C. ip link D. iwconfig
用来查看当前登录用户的命令是()b
A. id B. whoami C. users D. who
用来查看系统运行时间的命令是() a
A. uptime B. runtime C. sysinfo D. time
用来查看CPU信息的命令是() C
A. cpuinfo B. procinfo C. lscpu D. cpudetails
用来查看系统内核版本的命令是() b
A. kernel -v B. uname -r C. kernel -r D. lsb_release -a
用来重启系统的命令是()a
A. reboot B. restart C. reload D. shutdown -r now
用来关闭系统的命令是() b
A. poweroff B. shutdown C. halt D. turnoff
用来终止进程的命令是() a
A. kill B. end C. terminate D. stop
用来查看端口使用情况的命令是() B
A. ss -tplun B. netstat -plunt C. ports D. netstat -anp
用来设置系统时间的命令是() B
A. time B. date C. clock D. timestamp
查看网络连接状态的命令是() b
A. netstat B. ping C. traceroute D. dig
查看网络服务监听端口的命令是()b A. ss B. netstat C. lsof D. nmap
查看进程详细信息的命令是()a
A. ps B. pidof C. pstree D. pgrep
kill进程的语法是() c
A. kill -9 pid B. kill -15 pid C. kill pid D. pkill process_name
定义环境变量的命令是() a
A. export B. env C. set D. source
查看环境变量的命令是()A
A. env B. set C. export D. echo
查看系统引导日志的命令是()C
A. dmesg B. bootlog C. journalctl D. syslog
查看系统登录日志的命令是()
查看系统登录日志的命令是 journalctl 或 cat /var/log/secure。
查看磁盘分区信息的命令是()b
A. fdisk B. df C. du D. partprobe
统计文件行数的命令是()a A. wc -l B. count C. numlines D. rows
查找文件和目录的命令是()a
A. find B. which C. whereis D. locate
解压gzip文件的参数是() b
A. -z B. -x C. -d D. -u
创建软链接的命令是()A A. ln -s B. link C. symlink D. softlink
显示日历的命令是() c
A. calendar B. date C. cal D. time
创建用户的命令是() A
A. useradd B. adduser C. usercreate D. addnewuser
删除用户的命令是()A
A. userdel B. deluser C. rmuser D. userremove
显示登录用户的命令是()a
A. who B. users C. logins D. loggedin
查看文件内容的命令是()c
A. more B. less C. cat D. head
移动文件和目录的命令是()a A. mv B. move C. cut D. changes
删除文件和目录的命令是()a
A. rm B. del C. remove D. erase
用来查看文件或目录占用空间的命令是() A
A. du B. df C. ls D. dir
用来比较两个文件的不同的命令是()b
A. diff B. cmp C. comm D. patch
用来打包文件或目录的命令是()c
A. zip B. gzip C. tar D. compress
用来复制文件或目录的命令是()a A. cp B. copy C. replicate D. duplicate
用来删除文件或目录的命令是() a
A. rm B. del C. remove D. erase
用来终止进程的信号是() a
A. SIGTERM B. SIGKILL C. SIGSTOP D. SIGQUIT
用来查看进程信号的命令是() d
A. kill B. pkill C. pgrep D. ps
用来创建用户组的命令是() a
A. groupadd B. addgroup C. newgroup D. usergroup
用来查看系统运行级别的命令是()D A. runlevel B. init C. telinit D. systemctl get-default
用来挂载文件系统的命令是() a
A. mount B. mnt C. fstab D. mountdev
用来写入数据到文件末尾的命令是() a
A. echo >> B. append C. tail -f D. sync
用来查找命令的手册页的命令是() c
A. whatis B. help C. man D. info
用来显示文件最后几行的命令是()a A. tail B. head C. last D. final
用来展开缩写的命令是() b
A. expand B. unabbreviate C. echo D. print
用来打印文件的命令是()a
A. cat B. print C. echo D. less
用来对文件进行排序的命令是()a
A. sort B. order C. arrange D. sorted
用来展示文件内容的分页工具是() b
A. more B. less C. pager D. page
用来切换目录的命令是() a
A. cd B. chdir C. switchdir D. pushd
用来查看网卡的物理地址的命令是()a
A. ifconfig B. hwinfo --netcard C. lspci D. lshw -class network
用来修改文件权限的命令是()a A. chmod B. permission C. acl D. chown
用来查看网关地址的命令是() b
A. route -n B. ip route C. netstat -nr D. traceroute
用来查看进程启动时间的命令是()a
A. ps B. pstime C. psr D. top
用来远程登录的命令是()a A. ssh B. telnet C. rlogin D. remote
用来下载文件的命令是()b
A. curl B. wget C. fetch D. download
用来创建链接文件的命令是() a
A. ln B. link C. symlink D. hardlink
用来查看当前工作目录的命令是()a A. pwd B. cwd C. pwdd D. currentdir
用来查看存储设备的使用信息的是() c
A. lsblk B. fdisk C. df D. du
用来编辑文本文件的命令是()a
A. vim B. vi C. nano D. pico
用来解压文件的是()c A. unzip B. gunzip C. tar D. uncompress
用来显示当前日期和时间的命令是()a
A. date B. cal C. time D. clock
用来查看内存使用情况的命令是() a
A. free B. vmstat C. top D. /proc/meminfo
查看当前登录用户的UID是()b A. id -u B. whoami C. echo $UID D. uid
查看当前登录用户的组ID是()
A. id -g B. groups C. echo $GID D. gid
查看本机IP地址的命令是() A. ip addr B. ifconfig C. hostname -i D. dig +short myip.opendns.com @resolver1.opendns.com
查看网络连接状态的命令是()
A. ping B. netstat C. traceroute D. route
查看网络接口流量统计的命令是()
A. ifconfig B. netstat -i C. ip -s link D. iwconfig
给文件加密码的命令是()c A. passwd B. encrypt C. gpg D. chpasswd
查看代理设置的命令是()
A. env | grep -i proxy B. proxychains C. settings D. connections
查看端口使用的命令组合是()b
A. lsof -i B. netstat -an C. ss -tpl D. nmap -sT
优雅关闭系统的命令是()
A. shutdown -h now B. halt C. poweroff D. init 0
强制关闭系统的命令是()
A. poweroff -f B. reboot -f C. shutdown -h 0 D. init 6
临时禁用网络接口的命令是() A. ifdown B. ifconfig down C. ip link set down D. nmcli con down
查看防火墙规则的命令是()
A. iptables -L B. firewall-cmd --list-all C. ufw status D. pfctl -s rules
查看进程树的命令是()
A. pstree B. pgrep -a C. ps auxf D. top -H
解压zip文件的参数是()
A. -z B. -x C. -d D. -u
重复执行命令的参数是()
A. -r B. --repeat C. -n D. -l
查看文本文件的前几行的参数是()
A. head -n 10 B. tail -n 10 C. less -N 10 D. cat -n 10
创建隐藏文件的参数是()
A. --hide B. -a C. .filename D. filename.
递归创建目录的参数是() A. -r B. -p C. --recursive D. --parents
按大小排序的命令参数是()
A. sort -k B. sort -S C. sort -n D. sort -s
查找文件修改时间的命令参数是()
A. find -mmin B. find -mtime C. locate -t D. whereis -m
查找文件类型的参数是()
A. -type B. -name C. -exec D. -ok
统计字符数的参数是()
A. wc -m B. wc -l C. wc -c D. wc -w
搜索命令历史的参数是()
A. history | grep B. ctrl+r C. ~/.bash_history D. ~/.history
强制删除目录的参数是() A. rm -rf B. rmdir C. deltree D. rm -f
允许所有主机访问的防火墙规则是()
A. -A INPUT -s 0/0 -j ACCEPT B. -I INPUT -s 0/0 -j ACCEPT C. -A OUTPUT -d 0/0 -j ACCEPT D. -A FORWARD -d 0/0 -j ACCEPT
设置环境变量的命令是()
A. export B. setenv C. env D. ~/.bashrc
显示行号的命令参数是()
A. nl file B. cat -n file C. more -N file D. less -N file
比较目录的命令是() A. diff B. comm C. cmp D. vimdiff
统计网络连接的命令是()
A. netstat -an | wc -l B. ip s | wc -l C. ss -s | wc -l D. ifconfig -s | wc -l
查看内核日志的命令是()
A. cat /var/log/messages B. dmesg C. journalctl D. syslog
查找文件名的命令是()
A. locate B. find C. which D. whereis
显示10行的命令是()
A. head -n 10 B. head -10 C. top 10 D. top -n 10
显示文件类型的命令是() A. type B. file C. whatis D. info
监视日志文件的命令是() A. watch -d -n 0.5 tail /var/log/syslog B. tail -f /var/log/syslog C. more /var/log/syslog D. cat /var/log/syslog
归档日志文件的命令是() A. gzip /var/log/messages B. bzip2 /var/log/syslog C. xz /var/log/syslog D. tar -cvzf logs.tar.gz /var/log/*.log
查看网络统计的命令是() A. netstat -s B. ip -s link C. ifconfig -s D. iw dev
批量杀死进程的命令是() A. pkill process B. killall process C. kill -9 -1 D. xkill
查看文本文件的命令是() A. more B. less C. head D. cat
搜索文件内容的命令是() A. grep pattern files B. find . -name files C. locate files D. whereis files
查看配置文件的命令是() A. cat config B. more config C. head config D. less config
统计文件个数的命令是() A. ls /dir | wc -l B. find /dir -type f | wc -l C. count /dir/* D. du -a /dir | wc -l
下载文件的命令是() A. curl -O url B. wget url C. fetch url D. scp user@host:file .
复制文件或目录的命令是() A. cp B. copy C. duplicate D. clone
复制时保留属性的命令参数是()a A. -p B. -a C. -r D. -R
追加输出的命令是()a
A. >> B. tee C. append D. out -a
强制删除文件的参数是()a A. -f B. -r C. -d D. -q
安全删除文件的命令是() A. shred B. rm C. del D. wipe
package free300.demo.Stream;
import java.io.*;
public class FileStream {
public static void main(String[] args) throws IOException {
String PATH="src/main/java/free300/demo/Stream/";
System.out.println(new File(PATH).listRoots());
File file=new File(PATH+"demo.txt");
// file.renameTo(new File(PATH+"demo1.txt"));
if(file.exists()){
System.out.println("存在");
}
if(file.canRead()){
System.out.println("可读");
}
if(file.canWrite()){
System.out.println("可写");
}
// File file1=new File(PATH+"delete/deletedemo.txt");
//
// if(file1.delete()){
// System.out.println("删除成功");
// }else {
// System.out.println("删除失败");
// }
File file2=new File(PATH+"delete");
if(file2.isDirectory()){
System.out.println("文件夹");
}else {
System.out.println("不是文件夹");
}
File file3=new File(PATH);
System.out.println("长度"+file3.length());
System.out.println(file3.canExecute());
File[] files=file3.listFiles();
for (File f: files) {
System.out.println(f.getPath());
}
FileInputStream inputStream=new FileInputStream(file);
// int buffer;
//
// byte[] buff=new byte[2];
// Byte[] buff2=new Byte[1024];
//
//
// while ((buffer = inputStream.read()) != -1){
// System.out.println((char) buffer);
// }
InputStreamReader inputStreamReader=new InputStreamReader(inputStream);
// int bt;
// Byte[] bt1=new Byte[1024];
// byte[] bt2=new byte[2];
// char[] chars=new char[1024];
//
// System.out.println(inputStreamReader.read(chars, 0, 10));
//
// while ((bt = inputStreamReader.read(chars,0,100)) != -1){
// System.out.println(new String(chars,0,bt));
// }
BufferedReader bufferedReader=new BufferedReader(inputStreamReader);
System.out.println(bufferedReader.readLine());
if(bufferedReader != null){
bufferedReader.close();
}
if(inputStreamReader != null){
inputStreamReader.close();
}
//int read(byte[] b)
// 从此输入流中将最多 b.length 个字节的数据读入一个 byte 数组中。
// int read(byte[] b, int off, int len)
// 从此输入流中将最多 len 个字节的数据读入一个 byte 数组中。
// long skip(long n)
// 从输入流中跳过并丢弃 n 个字节的数据。
// while ((buffer = inputStream.read(buff)) != -1){
// System.out.println(new String(buff));
// }
//
// while ((buffer = inputStream.read(buff)) != -1){
// System.out.println(buff);
// }
//
// while ((buffer = inputStream.read(buff)) != -1){
// System.out.println(buffer);
// }
//
//
// while ((buffer = inputStream.read(buff)) != -1){
// System.out.println(new String(buff,0,buffer));
// }
if(inputStream != null){
inputStream.close();
}
//------------------------------------------------------------------------------------------------------------------------------------------------
FileOutputStream outputStream=new FileOutputStream(PATH+"dt.txt");
String demo="aweiyijingsiloigvb哦苹果v抵抗";
// byte[] bytes = demo.getBytes();
//
// outputStream.write(bytes);
OutputStreamWriter outputStreamWriter=new OutputStreamWriter(outputStream);
BufferedWriter bufferedWriter=new BufferedWriter(outputStreamWriter);
bufferedWriter.write(demo);
// outputStreamWriter.write(demo,0,demo.length());
if(bufferedWriter != null){
bufferedWriter.close();
}
if(outputStreamWriter != null){
outputStreamWriter.close();
}
if(outputStream != null){
outputStream.close();
}
}
}