Springboot集成支付宝沙箱支付(退款功能)

包括:
支付宝沙箱 支付 + 异步通知 + 退款功能

正式版本的sdk

通用版本SDK文档:https://opendocs.alipay.com/open/02np94

<dependency><groupId>com.alipay.sdk</groupId><artifactId>alipay-sdk-java</artifactId><version>4.22.110.ALL</version></dependency>

AlipayConfig.java 只需要获取配置alipay的参数即可

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;@Data
@Component
@ConfigurationProperties(prefix = "alipay")
public class AliPayConfig {private String appId;private String appPrivateKey;private String alipayPublicKey;private String notifyUrl;}

参数更新:

import lombok.Data;@Data
public class AliPay {private String traceNo;private double totalAmount;private String subject;private String alipayTraceNo;
}

完整的支付宝通用版本支付代码:

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.internal.util.AlipaySignature;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.alipay.api.request.AlipayTradeRefundRequest;
import com.alipay.api.response.AlipayTradeRefundResponse;
import com.example.springboot.common.Result;
import com.example.springboot.config.AliPayConfig;
import com.example.springboot.controller.dto.AliPay;
import com.example.springboot.entity.Orders;
import com.example.springboot.mapper.OrdersMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;// xjlugv6874@sandbox.com
// 9428521.24 - 30 = 9428491.24 + 30 = 9428521.24
@RestController
@RequestMapping("/alipay")
public class AliPayController {private static final String GATEWAY_URL = "https://openapi.alipaydev.com/gateway.do";private static final String FORMAT = "JSON";private static final String CHARSET = "UTF-8";//签名方式private static final String SIGN_TYPE = "RSA2";@Resourceprivate AliPayConfig aliPayConfig;@Resourceprivate OrdersMapper ordersMapper;@GetMapping("/pay") // &subject=xxx&traceNo=xxx&totalAmount=xxxpublic void pay(AliPay aliPay, HttpServletResponse httpResponse) throws Exception {// 1. 创建Client,通用SDK提供的Client,负责调用支付宝的APIAlipayClient alipayClient = new DefaultAlipayClient(GATEWAY_URL, aliPayConfig.getAppId(),aliPayConfig.getAppPrivateKey(), FORMAT, CHARSET, aliPayConfig.getAlipayPublicKey(), SIGN_TYPE);// 2. 创建 Request并设置Request参数AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();  // 发送请求的 Request类request.setNotifyUrl(aliPayConfig.getNotifyUrl());JSONObject bizContent = new JSONObject();bizContent.set("out_trade_no", aliPay.getTraceNo());  // 我们自己生成的订单编号bizContent.set("total_amount", aliPay.getTotalAmount()); // 订单的总金额bizContent.set("subject", aliPay.getSubject());   // 支付的名称bizContent.set("product_code", "FAST_INSTANT_TRADE_PAY");  // 固定配置request.setBizContent(bizContent.toString());// 执行请求,拿到响应的结果,返回给浏览器String form = "";try {form = alipayClient.pageExecute(request).getBody(); // 调用SDK生成表单} catch (AlipayApiException e) {e.printStackTrace();}httpResponse.setContentType("text/html;charset=" + CHARSET);httpResponse.getWriter().write(form);// 直接将完整的表单html输出到页面httpResponse.getWriter().flush();httpResponse.getWriter().close();}@PostMapping("/notify")  // 注意这里必须是POST接口public String payNotify(HttpServletRequest request) throws Exception {if (request.getParameter("trade_status").equals("TRADE_SUCCESS")) {System.out.println("=========支付宝异步回调========");Map<String, String> params = new HashMap<>();Map<String, String[]> requestParams = request.getParameterMap();for (String name : requestParams.keySet()) {params.put(name, request.getParameter(name));// System.out.println(name + " = " + request.getParameter(name));}String tradeNo = params.get("out_trade_no");String gmtPayment = params.get("gmt_payment");String alipayTradeNo = params.get("trade_no");String sign = params.get("sign");String content = AlipaySignature.getSignCheckContentV1(params);boolean checkSignature = AlipaySignature.rsa256CheckContent(content, sign, aliPayConfig.getAlipayPublicKey(), "UTF-8"); // 验证签名// 支付宝验签if (checkSignature) {// 验签通过System.out.println("交易名称: " + params.get("subject"));System.out.println("交易状态: " + params.get("trade_status"));System.out.println("支付宝交易凭证号: " + params.get("trade_no"));System.out.println("商户订单号: " + params.get("out_trade_no"));System.out.println("交易金额: " + params.get("total_amount"));System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));System.out.println("买家付款时间: " + params.get("gmt_payment"));System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));// 更新订单未已支付ordersMapper.updateState(tradeNo, "已支付", gmtPayment, alipayTradeNo);}}return "success";}@GetMapping("/return")public Result returnPay(AliPay aliPay) throws AlipayApiException {// 7天无理由退款String now = DateUtil.now();Orders orders = ordersMapper.getByNo(aliPay.getTraceNo());if (orders != null) {// hutool工具类,判断时间间隔long between = DateUtil.between(DateUtil.parseDateTime(orders.getPaymentTime()), DateUtil.parseDateTime(now), DateUnit.DAY);if (between > 7) {return Result.error("-1", "该订单已超过7天,不支持退款");}}// 1. 创建Client,通用SDK提供的Client,负责调用支付宝的APIAlipayClient alipayClient = new DefaultAlipayClient(GATEWAY_URL,aliPayConfig.getAppId(), aliPayConfig.getAppPrivateKey(), FORMAT, CHARSET,aliPayConfig.getAlipayPublicKey(), SIGN_TYPE);// 2. 创建 Request,设置参数AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();JSONObject bizContent = new JSONObject();bizContent.set("trade_no", aliPay.getAlipayTraceNo());  // 支付宝回调的订单流水号bizContent.set("refund_amount", aliPay.getTotalAmount());  // 订单的总金额bizContent.set("out_request_no", aliPay.getTraceNo());   //  我的订单编号// 返回参数选项,按需传入//JSONArray queryOptions = new JSONArray();//queryOptions.add("refund_detail_item_list");//bizContent.put("query_options", queryOptions);request.setBizContent(bizContent.toString());// 3. 执行请求AlipayTradeRefundResponse response = alipayClient.execute(request);if (response.isSuccess()) {  // 退款成功,isSuccess 为trueSystem.out.println("调用成功");// 4. 更新数据库状态ordersMapper.updatePayState(aliPay.getTraceNo(), "已退款", now);return Result.success();} else {   // 退款失败,isSuccess 为falseSystem.out.println(response.getBody());return Result.error(response.getCode(), response.getBody());}}}

至此,后端集成完毕。

注意事项

img
如果你在支付的过程中出现了这样的一个界面,不用慌,直接使用 隐私窗口打开即可。
img

参考SQL

商品表:

CREATE TABLE `goods` (`id` int(11) NOT NULL AUTO_INCREMENT,`name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名称',`price` decimal(10,2) DEFAULT NULL COMMENT '单价',`store` int(10) DEFAULT NULL COMMENT '库存',`unit` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '单位',`img` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '封面',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

订单表

CREATE TABLE `orders` (`id` int(11) NOT NULL AUTO_INCREMENT,`no` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '订单编号',`name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名称',`time` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '订单时间',`state` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '待支付' COMMENT '支付状态',`total` decimal(10,2) DEFAULT NULL COMMENT '订单总价',`user_id` int(11) DEFAULT NULL COMMENT '用户id',`payment_time` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '支付时间',`alipay_no` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '支付宝交易号',`return_time` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '退款时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

购买下订单的模拟接口:

@PostMapping("/{goodsId}/{num}")public Result createOrder(@PathVariable Integer goodsId, @PathVariable Integer num) {Goods goods = goodsService.getById(goodsId);if (goods == null) {throw new ServiceException("-1", "未找到商品");}User currentUser = TokenUtils.getCurrentUser();Integer userId = currentUser.getId();Orders orders = new Orders();orders.setName(goods.getName());orders.setNo(DateUtil.format(new Date(), "yyyyMMdd") + System.currentTimeMillis());orders.setTime(DateUtil.now());orders.setUserId(userId);orders.setTotal(goods.getPrice().multiply(BigDecimal.valueOf(num)));ordersService.save(orders);return Result.success();}

附赠前端调用代码:
Goods.vue

<template><div><div style="margin: 10px 0"><el-input style="width: 200px" placeholder="请输入名称" suffix-icon="el-icon-search" v-model="name"></el-input>
<!--      <el-input style="width: 200px" placeholder="请输入" suffix-icon="el-icon-message" class="ml-5" v-model="email"></el-input>-->
<!--      <el-input style="width: 200px" placeholder="请输入" suffix-icon="el-icon-position" class="ml-5" v-model="address"></el-input>--><el-button class="ml-5" type="primary" @click="load">搜索</el-button><el-button type="warning" @click="reset">重置</el-button></div><div style="margin: 10px 0"><el-button type="primary" @click="handleAdd">新增 <i class="el-icon-circle-plus-outline"></i></el-button><el-popconfirmclass="ml-5"confirm-button-text='确定'cancel-button-text='我再想想'icon="el-icon-info"icon-color="red"title="您确定批量删除这些数据吗?"@confirm="delBatch"><el-button type="danger" slot="reference">批量删除 <i class="el-icon-remove-outline"></i></el-button></el-popconfirm><!-- <el-upload action="http://localhost:9090/goods/import" :show-file-list="false" accept="xlsx" :on-success="handleExcelImportSuccess" style="display: inline-block"><el-button type="primary" class="ml-5">导入 <i class="el-icon-bottom"></i></el-button></el-upload><el-button type="primary" @click="exp" class="ml-5">导出 <i class="el-icon-top"></i></el-button> --></div><el-table :data="tableData" border stripe :header-cell-class-name="'headerBg'"  @selection-change="handleSelectionChange"><el-table-column type="selection" width="55"></el-table-column><el-table-column prop="id" label="ID" width="80" sortable></el-table-column><el-table-column prop="name" label="名称"></el-table-column><el-table-column prop="price" label="单价"></el-table-column><el-table-column prop="store" label="库存"></el-table-column><el-table-column prop="unit" label="单位"></el-table-column><el-table-column label="图片"><template slot-scope="scope"><el-image style="width: 100px; height: 100px" :src="scope.row.img" :preview-src-list="[scope.row.img]"></el-image></template></el-table-column><el-table-column label="购买"  width="180" align="center"><template v-slot="scope"><el-button type="primary" @click="buy(scope.row.id)">购 买</el-button></template></el-table-column><el-table-column label="操作"  width="180" align="center"><template slot-scope="scope"><el-button type="success" @click="handleEdit(scope.row)">编辑 <i class="el-icon-edit"></i></el-button><el-popconfirmclass="ml-5"confirm-button-text='确定'cancel-button-text='我再想想'icon="el-icon-info"icon-color="red"title="您确定删除吗?"@confirm="del(scope.row.id)"><el-button type="danger" slot="reference">删除 <i class="el-icon-remove-outline"></i></el-button></el-popconfirm></template></el-table-column></el-table><div style="padding: 10px 0"><el-pagination@size-change="handleSizeChange"@current-change="handleCurrentChange":current-page="pageNum":page-sizes="[2, 5, 10, 20]":page-size="pageSize"layout="total, sizes, prev, pager, next, jumper":total="total"></el-pagination></div><el-dialog title="信息" :visible.sync="dialogFormVisible" width="30%" :close-on-click-modal="false"><el-form label-width="100px" size="small" style="width: 90%"><el-form-item label="名称"><el-input v-model="form.name" autocomplete="off"></el-input></el-form-item><el-form-item label="单价"><el-input v-model="form.price" autocomplete="off"></el-input></el-form-item><el-form-item label="库存"><el-input v-model="form.store" autocomplete="off"></el-input></el-form-item><el-form-item label="单位"><el-input v-model="form.unit" autocomplete="off"></el-input></el-form-item><el-form-item label="封面"><el-upload action="http://localhost:9090/file/upload" ref="img" :on-success="handleImgUploadSuccess"><el-button size="small" type="primary">点击上传</el-button></el-upload></el-form-item></el-form><div slot="footer" class="dialog-footer"><el-button @click="dialogFormVisible = false">取 消</el-button><el-button type="primary" @click="save">确 定</el-button></div></el-dialog></div>
</template><script>
export default {name: "Goods",data() {return {tableData: [],total: 0,pageNum: 1,pageSize: 10,name: "",form: {},dialogFormVisible: false,multipleSelection: [],user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {}}},created() {this.load()},methods: {buy(goodsId) {this.request.post("/orders/" +  goodsId + "/" + 1).then(res => {if (res.code === '200') {this.$message.success("购买成功,请前往订单页面支付")} else {this.$message.error(res.msg)}})},load() {this.request.get("/goods/page", {params: {pageNum: this.pageNum,pageSize: this.pageSize,name: this.name,}}).then(res => {this.tableData = res.data.recordsthis.total = res.data.total})},save() {this.request.post("/goods", this.form).then(res => {if (res.code === '200') {this.$message.success("保存成功")this.dialogFormVisible = falsethis.load()} else {this.$message.error("保存失败")}})},handleAdd() {this.dialogFormVisible = truethis.form = {}this.$nextTick(() => {if(this.$refs.img) {this.$refs.img.clearFiles();}if(this.$refs.file) {this.$refs.file.clearFiles();}})},handleEdit(row) {this.form = JSON.parse(JSON.stringify(row))this.dialogFormVisible = truethis.$nextTick(() => {if(this.$refs.img) {this.$refs.img.clearFiles();}if(this.$refs.file) {this.$refs.file.clearFiles();}})},del(id) {this.request.delete("/goods/" + id).then(res => {if (res.code === '200') {this.$message.success("删除成功")this.load()} else {this.$message.error("删除失败")}})},handleSelectionChange(val) {console.log(val)this.multipleSelection = val},delBatch() {if (!this.multipleSelection.length) {this.$message.error("请选择需要删除的数据")return}let ids = this.multipleSelection.map(v => v.id)  // [{}, {}, {}] => [1,2,3]this.request.post("/goods/del/batch", ids).then(res => {if (res.code === '200') {this.$message.success("批量删除成功")this.load()} else {this.$message.error("批量删除失败")}})},reset() {this.name = ""this.load()},handleSizeChange(pageSize) {console.log(pageSize)this.pageSize = pageSizethis.load()},handleCurrentChange(pageNum) {console.log(pageNum)this.pageNum = pageNumthis.load()},handleFileUploadSuccess(res) {this.form.file = res},handleImgUploadSuccess(res) {this.form.img = res},download(url) {window.open(url)},exp() {window.open("http://localhost:9090/goods/export")},handleExcelImportSuccess() {this.$message.success("导入成功")this.load()}}
}
</script><style>
.headerBg {background: #eee!important;
}
</style>

Orders.vue

<template><div><div style="margin: 10px 0"><el-input style="width: 200px" placeholder="请输入名称" suffix-icon="el-icon-search" v-model="name"></el-input>
<!--      <el-input style="width: 200px" placeholder="请输入" suffix-icon="el-icon-message" class="ml-5" v-model="email"></el-input>-->
<!--      <el-input style="width: 200px" placeholder="请输入" suffix-icon="el-icon-position" class="ml-5" v-model="address"></el-input>--><el-button class="ml-5" type="primary" @click="load">搜索</el-button><el-button type="warning" @click="reset">重置</el-button></div><div style="margin: 10px 0"><el-button type="primary" @click="handleAdd">新增 <i class="el-icon-circle-plus-outline"></i></el-button><el-popconfirmclass="ml-5"confirm-button-text='确定'cancel-button-text='我再想想'icon="el-icon-info"icon-color="red"title="您确定批量删除这些数据吗?"@confirm="delBatch"><el-button type="danger" slot="reference">批量删除 <i class="el-icon-remove-outline"></i></el-button></el-popconfirm><!-- <el-upload action="http://localhost:9090/orders/import" :show-file-list="false" accept="xlsx" :on-success="handleExcelImportSuccess" style="display: inline-block"><el-button type="primary" class="ml-5">导入 <i class="el-icon-bottom"></i></el-button></el-upload><el-button type="primary" @click="exp" class="ml-5">导出 <i class="el-icon-top"></i></el-button> --></div><el-table :data="tableData" border stripe :header-cell-class-name="'headerBg'"  @selection-change="handleSelectionChange"><el-table-column type="selection" width="55"></el-table-column><el-table-column prop="id" label="ID" width="80" sortable></el-table-column><el-table-column prop="no" label="订单编号"></el-table-column><el-table-column prop="name" label="名称"></el-table-column><el-table-column prop="time" label="订单时间"></el-table-column><el-table-column prop="state" label="支付状态"></el-table-column><el-table-column prop="total" label="订单总价"></el-table-column><el-table-column prop="paymentTime" label="支付时间"></el-table-column><el-table-column prop="alipayNo" label="支付宝宝流水号"></el-table-column><el-table-column prop="returnTime" label="退款时间"></el-table-column><el-table-column label="支付"  width="180" align="center"><template v-slot="scope"><el-button type="primary" @click="pay(scope.row)" :disabled="scope.row.state !== '待支付'">支 付</el-button><el-button type="danger" @click="returnPay(scope.row)" :disabled="scope.row.state !== '已支付'">退款</el-button></template></el-table-column><el-table-column label="操作"  width="180" align="center"><template slot-scope="scope"><el-button type="success" @click="handleEdit(scope.row)">编辑 <i class="el-icon-edit"></i></el-button><el-popconfirmclass="ml-5"confirm-button-text='确定'cancel-button-text='我再想想'icon="el-icon-info"icon-color="red"title="您确定删除吗?"@confirm="del(scope.row.id)"><el-button type="danger" slot="reference">删除 <i class="el-icon-remove-outline"></i></el-button></el-popconfirm></template></el-table-column></el-table><div style="padding: 10px 0"><el-pagination@size-change="handleSizeChange"@current-change="handleCurrentChange":current-page="pageNum":page-sizes="[2, 5, 10, 20]":page-size="pageSize"layout="total, sizes, prev, pager, next, jumper":total="total"></el-pagination></div><el-dialog title="信息" :visible.sync="dialogFormVisible" width="30%" :close-on-click-modal="false"><el-form label-width="100px" size="small" style="width: 90%"><el-form-item label="订单编号"><el-input v-model="form.no" autocomplete="off"></el-input></el-form-item><el-form-item label="名称"><el-input v-model="form.name" autocomplete="off"></el-input></el-form-item><el-form-item label="订单时间"><el-date-picker v-model="form.time" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期时间"></el-date-picker></el-form-item><el-form-item label="支付状态"><el-input v-model="form.state" autocomplete="off"></el-input></el-form-item><el-form-item label="订单总价"><el-input v-model="form.total" autocomplete="off"></el-input></el-form-item></el-form><div slot="footer" class="dialog-footer"><el-button @click="dialogFormVisible = false">取 消</el-button><el-button type="primary" @click="save">确 定</el-button></div></el-dialog></div>
</template><script>
export default {name: "Orders",data() {return {tableData: [],total: 0,pageNum: 1,pageSize: 10,name: "",form: {},dialogFormVisible: false,multipleSelection: [],user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {}}},created() {this.load()},methods: {pay(row) {const url = `http://localhost:9090/alipay/pay?subject=${row.name}&traceNo=${row.no}&totalAmount=${row.total}`window.open(url);  //  得到一个url,这个url就是支付宝支付的界面url, 新窗口打开这个url就可以了},returnPay(row) {const url = `http://localhost:9090/alipay/return?totalAmount=${row.total}&alipayTraceNo=${row.alipayNo}&traceNo=${row.no}`this.request.get(url).then(res => {if(res.code === '200') {this.$message.success("退款成功")}  else {this.$message.error("退款失败")}this.load()})},load() {this.request.get("/orders/page", {params: {pageNum: this.pageNum,pageSize: this.pageSize,name: this.name,}}).then(res => {this.tableData = res.data.recordsthis.total = res.data.total})},save() {this.request.post("/orders", this.form).then(res => {if (res.code === '200') {this.$message.success("保存成功")this.dialogFormVisible = falsethis.load()} else {this.$message.error("保存失败")}})},handleAdd() {this.dialogFormVisible = truethis.form = {}this.$nextTick(() => {if(this.$refs.img) {this.$refs.img.clearFiles();}if(this.$refs.file) {this.$refs.file.clearFiles();}})},handleEdit(row) {this.form = JSON.parse(JSON.stringify(row))this.dialogFormVisible = truethis.$nextTick(() => {if(this.$refs.img) {this.$refs.img.clearFiles();}if(this.$refs.file) {this.$refs.file.clearFiles();}})},del(id) {this.request.delete("/orders/" + id).then(res => {if (res.code === '200') {this.$message.success("删除成功")this.load()} else {this.$message.error("删除失败")}})},handleSelectionChange(val) {console.log(val)this.multipleSelection = val},delBatch() {if (!this.multipleSelection.length) {this.$message.error("请选择需要删除的数据")return}let ids = this.multipleSelection.map(v => v.id)  // [{}, {}, {}] => [1,2,3]this.request.post("/orders/del/batch", ids).then(res => {if (res.code === '200') {this.$message.success("批量删除成功")this.load()} else {this.$message.error("批量删除失败")}})},reset() {this.name = ""this.load()},handleSizeChange(pageSize) {console.log(pageSize)this.pageSize = pageSizethis.load()},handleCurrentChange(pageNum) {console.log(pageNum)this.pageNum = pageNumthis.load()},handleFileUploadSuccess(res) {this.form.file = res},handleImgUploadSuccess(res) {this.form.img = res},download(url) {window.open(url)},exp() {window.open("http://localhost:9090/orders/export")},handleExcelImportSuccess() {this.$message.success("导入成功")this.load()}}
}
</script><style>
.headerBg {background: #eee!important;
}
</style>

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

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

相关文章

Java递归生成树

1.建菜单表 CREATE TABLE t_menu (id int(11) NOT NULL AUTO_INCREMENT,pid int(11) NOT NULL,name varchar(255) DEFAULT NULL,PRIMARY KEY (id) ) ENGINEInnoDB AUTO_INCREMENT11 DEFAULT CHARSETutf8mb4;2.造一些数据 注意&#xff1a;根节点的pid0&#xff0c;其他节点的p…

Springboot获取公网IP和当前所在城市(非常简单)

最近我们发现各大社交平台都出现了一个新的功能&#xff1a;IP属地。 比如某乎&#xff1a; 这个IP属地是怎么做到的呢&#xff1f;今天我来教教你&#xff0c;保证你看完直呼Easy~ 百度搜索 打开百度&#xff0c;搜索IP&#xff0c;你就能看到你当前的IP地址&#xff0c;类…

线程死锁——死锁产生的条件

什么是线程死锁 线程死锁是指由于两个或者多个线程互相持有对方所需要的资源&#xff0c;导致这些线程处于相互等待状态&#xff0c;若无外力作用&#xff0c;它们将无法继续执行下去。 造成死锁的原因可以概括成三句话&#xff1a; 当前线程拥有其他线程需要的资源当前线程…

TortoiseGit的使用详解

Git是什么&#xff0c;相信大家都很清楚。Git不就是分布式版本控制系统嘛&#xff1f;那你知道TortoiseGit是什么吗&#xff1f;下面我们就介绍一下TortoiseGit它是什么&#xff1f;如何使用&#xff1f;   TortoiseGit其实是一款开源的git的版本控制系统&#xff0c;也叫海龟…

将项目上传到Gitee上(命令方式使用TortoiseGit方式)

如何将项目上传到Gitee上&#xff08;命令方式&#xff09; 目录 将项目上传到Gitee是我们经常需要使用到的操作&#xff0c;因此我们要熟悉这些步骤 一、首先保证本机已经安装了Git git官网安装完成之后&#xff0c;鼠标右键会出现Git GUI Here和Git Bash Here 二、上传代…

BufferedImage类、Image类、Graphics类

BufferedImage Image是一个抽象类&#xff0c;BufferedImage是其实现类&#xff0c;是一个带缓冲区图像类&#xff0c;主要作用是将一幅图片加载到内存中&#xff08;BufferedImage生成的图片在内存里有一个图像缓冲区&#xff0c;利用这个缓冲区我们可以很方便地操作这个图片&…

Vue this.$refs的作用

案例一、ref 写在标签上时 <!-- ref 写在标签上时&#xff1a;this.$refs.名字 获取的是标签对应的dom元素ref 写在组件上时&#xff1a;这时候获取到的是 子组件&#xff08;比如counter&#xff09;的引用--><div id"root"><!-- ref hello&#…

linux电脑合盖后卡住了,解决ubuntu合盖后无法唤醒

解决办法&#xff1a;安装laptop-mode-tools工具包。1.检查是否安装了grep laptop-mode-tools 工具包$ dpkg -l | grep laptop-mode-tools如果执行命令无结果输出&#xff0c;表示未安装(如果已安装&#xff0c;忽略第2步)2.安装laptop-mode执行命令&#xff1a;$ sudo apt-get…

三列布局 css

实现如下图的三列布局&#xff1a; .box {width:1400px;margin:0 auto;padding-bottom:40px;> .left {float:left;width:180px;margin-top:100px;text-align:center;}> .center {float:left;margin-top:100px;margin-left:130px;item-box {float:left;text-align:left;…

axios和ajax的区别是什么

axios和ajax的区别&#xff1a; 1、axios是一个基于Promise的HTTP库&#xff0c;而ajax是对原生XHR的封装&#xff1b; 2、ajax技术实现了局部数据的刷新&#xff0c;而axios实现了对ajax的封装。 axios和ajax的区别是什么? axios和ajax的区别及优缺点: ajax&#xff1a; 1…

VUE学习笔记详细

VUE学习笔记 本文章以vue3来记录的&#xff0c;但并非记录vue3所有变化&#xff01; 1、ES6语法 1.1、let变量声明 let用于声明变量有局部作用域let声明的变量不会提升&#xff08;只能先定义后使用&#xff09; 1.2、const变量声明 const用于声明常量const声明的常量也不会…

Centos7配置gitlab服务器

Centos7配置gitlab服务器 1、安装SSH yum install -y curl policycoreutils-pythonopenssh-server设置开机自启 sudo systemctl enable sshd启动服务 sudo systemctl start sshd2、安装postfix 邮件服务 sudo yum install postfix设置开机自启 sudo systemctl enable po…

Jenkins学习笔记详细

最近接触了jenkins这个东西&#xff0c;所以花点时间了解了下。它可以在代码上传仓库&#xff08;如github,gitee&#xff0c;gitlab&#xff09;后&#xff0c;在jenkins&#xff08;一个网站界面&#xff09;中通过获取代码仓库中最新代码&#xff0c;进行自动化部署&#xf…

Form Data与Request Payload,你真的了解吗?

前言 做过前后端联调的小伙伴&#xff0c;可能有时会遇到一些问题。例如&#xff0c;我明明传递数据给后端了&#xff0c;后端为什么说没收到呢&#xff1f;这时候可能就会就会有小伙伴陷入迷茫&#xff0c;本文从chrome-dev-tools&#xff08;F12调试器&#xff09;中看到的F…

计算机网络知识点复习

基础 1.说下计算机网络体系结构 计算机网络体系结构&#xff0c;一般有三种&#xff1a;OSI 七层模型、TCP/IP 四层模型、五层结构。 简单说&#xff0c;OSI是一个理论上的网络通信模型&#xff0c;TCP/IP是实际上的网络通信模型&#xff0c;五层结构就是为了介绍网络原理而折…

n个1组成的整数能被2013整除c语言,求大神解算法,“编写程序,求n至少为多大时,n个1组成的整数能被2013 整除。”...

编写程序&#xff0c;求n至少为多大时&#xff0c;n个1组成的整数能被2013 整除。使用python黑科技:i 1while int(1 * i) % 2013:i 1print(i)不使用黑科技:i s t 1while s % 2013:i 1t t * 10 % 2013s (s t) % 2013print(i)而事实上可以从数论的角度看。20133*11*61&a…

Java基础知识点复习

转载&#xff1a;https://mp.weixin.qq.com/s/M-6RSRcRd3X93cR7VXpanw Java概述 1.什么是Java&#xff1f; Java是一门面向对象的编程语言&#xff0c;不仅吸收了C语言的各种优点&#xff0c;还摒弃了C里难以理解的多继承、指针等概念&#xff0c;因此Java语言具有功能强大和…

为什么都说Dubbo不适合传输大文件?Dubbo支持的协议

背景 之前公司有一个 Dubbo 服务&#xff0c;内部封装了腾讯云的对象存储服务 SDK&#xff0c;是为了统一管理这种三方服务的SDK&#xff0c;其他系统直接调用这个对象存储的 Dubbo 服务。用来避免因平台 SDK 出现不兼容的大版本更新&#xff0c;导致公司所有系统修改跟着升级…

c语言编写劫持dll,c语言-----劫持自己02

在上一节 c语言-----劫持原理01 已经叙述了劫持原理&#xff0c;下边正式进入劫持实战1. 需要实现的功能在c语言中system("notepad") 可以打开一个记事本system("mspaint") 可以打开画图工具所以这次我们需要把 可以打开一个记事本 这个功能更改为 在控制…

Java中Runtime类

一、概述 Runtime类封装了运行时的环境。每个 Java 应用程序都有一个 Runtime 类实例&#xff0c;使应用程序能够与其运行的环境相连接。 一般不能实例化一个Runtime对象&#xff0c;应用程序也不能创建自己的 Runtime 类实例&#xff0c;但可以通过 getRuntime 方法获取当前R…