提交 f2eb15ce 编写于 作者: 彭世瑜's avatar 彭世瑜

fix

上级 5ccb0a46
...@@ -34,4 +34,5 @@ ...@@ -34,4 +34,5 @@
- 其他 - 其他
- [其他](doc/index.md) - [其他](doc/index.md)
- [chrome](doc/chrome.md) - [chrome](doc/chrome.md)
\ No newline at end of file - [微信支付](blog/pay/weixin-pay.md)
\ No newline at end of file
...@@ -40,3 +40,8 @@ Elastic Stack ...@@ -40,3 +40,8 @@ Elastic Stack
[聚合查询 aggregation](blog/elasticsearch/aggregation.md) [聚合查询 aggregation](blog/elasticsearch/aggregation.md)
[核心概念]
[搜索和查询]
https://www.bilibili.com/video/BV1LY4y167n5?p=20&vd_source=efbb4dc944fa761b6e016ce2ca5933da
\ No newline at end of file
...@@ -313,6 +313,24 @@ http.cors.allow-origin: "*" ...@@ -313,6 +313,24 @@ http.cors.allow-origin: "*"
备用地址:[https://github.com/mouday/ElasticSearch-Head.crx](https://github.com/mouday/ElasticSearch-Head.crx) 备用地址:[https://github.com/mouday/ElasticSearch-Head.crx](https://github.com/mouday/ElasticSearch-Head.crx)
## 集群健康检查
- green 集群健康
- yellow 至少一个数据可用
- red 数据不完整,集群不可用
查看健康值
```bash
# 返回简要
GET _cat/health
# 返回带有标题的数据
GET _cat/health?v
# 返回json数据
GET _cluster/health
```
## 5、不同编程语言的客户端 ## 5、不同编程语言的客户端
https://www.elastic.co/guide/en/elasticsearch/client/index.html https://www.elastic.co/guide/en/elasticsearch/client/index.html
...@@ -364,5 +382,4 @@ server { ...@@ -364,5 +382,4 @@ server {
} }
} }
``` ```
https://www.bilibili.com/video/BV1LY4y167n5?p=5&spm_id_from=pageDriver&vd_source=efbb4dc944fa761b6e016ce2ca5933da https://www.bilibili.com/video/BV1LY4y167n5?p=5&spm_id_from=pageDriver&vd_source=efbb4dc944fa761b6e016ce2ca5933da
\ No newline at end of file
# 创建项目
- SpringBoot java SpringMVC RESTful json
- Swagger 接口文档和测试页面生成工具
- 定义统一的结果 让前后端数据通信更规范
- MySQL
- MyBatis-Plus
- Vue.js
## 创建项目
阿里云脚手架:https://start.aliyun.com/
版本:SpringBoot 2.3.7
依赖
```xml
<!-- pom.xml -->
<!-- 使用web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<!--<artifactId>spring-boot-starter</artifactId>-->
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
```
配置文件
application.properties 重命名为 application.yml
```yaml
# application.yml
server:
port: 8090
sprint:
applicaiotn:
# 应用名称
name: payment-demo
```
定义测试接口
```java
package com.mouday.paymentdemo.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/product")
public class ProductController {
@GetMapping("/test")
public String test(){
return "Hello";
}
}
```
访问测试
http://localhost:8090/api/product/test
## 引入 swagger
```xml
<!-- Swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<!-- Swagger ui-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
```
配置文件
```java
package com.mouday.paymentdemo.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class Swagger2Config {
@Bean
public Docket docket() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(new ApiInfoBuilder().title("微信支付文档").build());
}
}
```
完善接口配置
```java
package com.mouday.paymentdemo.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "商品管理")
@RestController
@RequestMapping("/api/product")
public class ProductController {
@ApiOperation("测试接口")
@GetMapping("/test")
public String test(){
return "Hello";
}
}
```
查看地址:http://localhost:8090/swagger-ui.html
## 引入lombok
```xml
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
```
## 定义统一的返回格式
```java
package com.mouday.paymentdemo.vo;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
@Data
public class Result {
// 响应码
private Integer code;
//响应消息
private String message;
//响应数据
private Map<String, Object> data = new HashMap<>();
public static Result success() {
Result result = new Result();
result.setCode(0);
result.setMessage("成功");
return result;
}
public static Result error() {
Result result = new Result();
result.setCode(-1);
result.setMessage("失败");
return result;
}
public Result data(String key, Object value) {
this.data.put(key, value);
return this;
}
}
```
使用
```java
package com.mouday.paymentdemo.controller;
import com.mouday.paymentdemo.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
@Api(tags = "商品管理")
@RestController
@RequestMapping("/api/product")
public class ProductController {
@ApiOperation("测试接口")
@GetMapping("/test")
public Result test(){
return Result.success().data("now", new Date());
}
}
```
返回结果
```json
{
"code": 0,
"message": "成功",
"data": {
"now": "2022-06-12T02:59:15.447+00:00"
}
}
```
## 引入数据库依赖
```xml
<!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
<!-- mybatis-plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.2</version>
</dependency>
```
创建数据库
```bash
mysql -uroot -p
create database db_payment_demo;
```
数据库信息配置
```yaml
# application.yml
sprint:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
# 设置连接的时区和字符编码
url: jdbc:mysql://localhost:3306/db_payment_demo?serverTimezone=Asia/Shanghai&characterEncoding=utf-8
username: root
password: 123456
```
实现以下类
```bash
entity
BaseEntity.java
mapper
/xml
service
/impl
```
扫描mapper类
```java
package com.mouday.paymentdemo.config;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@MapperScan("com.mouday.paymentdemo.mapper")
// 启用事务管理
@EnableTransactionManagement
public class MyBatisPlusConfig {
}
```
打包xml文件
```xml
<build>
<!-- 项目打包时,将xml文件也打包,默认只打包java文件 -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
```
```yaml
# 配置 mybatis-plus
mybatis-plus:
configuratin:
# sql日志
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath:com/mouday/paymentdemo/mapper/xml/*.xml
```
## 前端项目
安装Node.js
```
node -v
14.18.0
```
编辑工具:vscode
插件: Volar vue-helper
vue.js: https://cn.vuejs.org/index.html
```bash
# 设置淘宝镜像
npm config set registry https://registry.npm.taobao.org
# 全局安装vue-cli
npm install @vue/cli -g
# 创建vue2项目
vue create vue-demo
# 运行项目
npm run serve -- --port 8001
# 清屏
ctrl + l
```
浏览器开发工具:vue.js devtools
数据绑定
```vue
<tempalte>
<!-- 数据绑定 -->
<div>{{name}}</div>
<!-- 双向数据绑定 -->
<input v-model="name" type="text"/>
<!-- 事件绑定 -->
<button @click="handleClick">支付</button>
</tempalte>
<script>
export default {
// 数据
data(){
return {
name: 'Tom'
}
},
// 方法
methods: {
handleClick(){
}
}
}
</script>
```
内容
1. 引入支付参数
2. 加载商户私钥
3. 获取平台证书和验证签名
4. 获取HttpClient对象
5. API字典和接口规则
6. 内网穿透
7. API v3
```xml
<!-- 生成自定义配置的元数据信息 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
```
```xml
<!-- json处理器 -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
```
# 加密
术语:
```
明文 plain text
密文 cipher text
秘钥 key
加密 encrypt
解密 decrtpt
加密算法
```
## 对称加密
加密解密的秘钥是同一个
```
明文 秘钥加密 密文 秘钥解密 明文
```
eg: AES
## 非对称加密
加密解密的秘钥不是同一个
```
明文 公钥加密 密文 私钥解密 明文
```
eg: RSA
|加密分类 | 优点 | 缺点
|- | - | -
|对称加密 | 速度快 | 消息容易被破解
|非对称加密 | 速度慢 | 消息不容易被破解
## 身份认证
- 加密信息:公钥加密 -> 私钥解密
- 身份认证:私钥加密 -> 公钥解密
## 摘要算法
摘要算法(Digest Algorithm)即:散列函数、哈希函数(Hash Function)
作用:保证数据完整性
```
固定长度字符串 = Hash(任意长度字符串)
```
好的摘要算法:
- 不可逆
- 难题友好性
- 发散性
- 抗碰撞性
常见算法:MD5、SHA1、SHA2(SHA224、SHA256、SHA384)
## 数字签名
```
发送方:
原文 -> hash -> 签名 -> private key -> 密文
接收方:
密文 -> public key -> 明文 -> hash -> 签名
```
## 数字证书
- 公钥
- 所有者
- 颁发者
使用场景:https
# 接入指引
1. 申请APPID
- 公众号: https://mp.weixin.qq.com/
- 小程序:https://mp.weixin.qq.com/
- APP 开放平台:https://open.weixin.qq.com/
2. 申请mchid(商户号)
- 微信商户平台:https://pay.weixin.qq.com/
3. API v3密钥
- 微信商户平台:https://pay.weixin.qq.com/
4. 商户证书
- 微信商户平台:https://pay.weixin.qq.com/
5. 微信平台证书
- Java命令行下载工具: https://github.com/wechatpay-apiv3/CertificateDownloader
- php命令行下载工具:[https://github.com/wechatpay-apiv3/wechatpay-php/blob/main/bin/README.md](https://github.com/wechatpay-apiv3/wechatpay-php/blob/main/bin/README.md)
> 商户和微信平台进行通信,所以双方都需要有一套证书
## SDK
Java: https://github.com/wechatpay-apiv3/wechatpay-apache-httpclient
```xml
<dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-apache-httpclient</artifactId>
<version>0.4.7</version>
</dependency>
```
PHP:https://github.com/wechatpay-apiv3/wechatpay-php
- Guzzle 7.0,PHP >= 7.2.5
- Guzzle 6.5,PHP >= 7.1.2
```bash
composer require wechatpay/wechatpay
```
\ No newline at end of file
【尚硅谷】微信支付&支付宝支付,一套搞定Java在线支付开发教程
https://www.bilibili.com/video/BV1US4y1D77m
## 微信支付
https://pay.weixin.qq.com
[接入指引](blog/pay/start.md)
[支付安全](blog/pay/security.md)
[创建项目](blog/pay/create-project.md)
https://www.bilibili.com/video/BV1US4y1D77m?p=51
\ No newline at end of file
...@@ -54,9 +54,9 @@ ...@@ -54,9 +54,9 @@
26. [视图 view](blog/php-mysql/sql-view.md) 26. [视图 view](blog/php-mysql/sql-view.md)
[事务安全 transaction](blog/php-mysql/sql-transaction.md) 27. [事务安全 transaction](blog/php-mysql/sql-transaction.md)
[变量 variables](blog/php-mysql/sql-variables.md) 28. [变量 variables](blog/php-mysql/sql-variables.md)
[流程结构 if while](blog/php-mysql/sql-if-while.md) [流程结构 if while](blog/php-mysql/sql-if-while.md)
......
# 变量 # 变量 variables
MySQL本质是一种编程语言 MySQL本质是一种编程语言
......
...@@ -75,6 +75,8 @@ Logo:https://www.logoly.pro/ ...@@ -75,6 +75,8 @@ Logo:https://www.logoly.pro/
[Snipaste](https://zh.snipaste.com/index.html) 截图 + 贴图,提高您的工作效率 [Snipaste](https://zh.snipaste.com/index.html) 截图 + 贴图,提高您的工作效率
[ngrok](https://ngrok.com/) 内网穿透工具
## 学习资料: ## 学习资料:
2022 黑马程序员 Java 学习路线图 2022 黑马程序员 Java 学习路线图
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
## 第三方库 ## 第三方库
[vue.js](https://cn.vuejs.org/v2/guide/) vue.js: 渐进式 JavaScript 框架
- [vue2.js](https://cn.vuejs.org/v2/guide/): https://cn.vuejs.org/
- [vue3.js](https://staging-cn.vuejs.org/guide/introduction.html): https://staging-cn.vuejs.org/
- [element-ui](https://element.eleme.cn/#/zh-CN/component/installation): 一套为开发者、设计师和产品经理准备的基于 Vue 2.0 的桌面端组件库 - [element-ui](https://element.eleme.cn/#/zh-CN/component/installation): 一套为开发者、设计师和产品经理准备的基于 Vue 2.0 的桌面端组件库
- [vColorPicker](http://vue-color-picker.rxshc.com/): 基于 Vue 的颜色选择器插件 - [vColorPicker](http://vue-color-picker.rxshc.com/): 基于 Vue 的颜色选择器插件
...@@ -68,6 +71,15 @@ ...@@ -68,6 +71,15 @@
[preactjs](https://preactjs.com/)Fast 3kB alternative to React with the same modern API. [preactjs](https://preactjs.com/)Fast 3kB alternative to React with the same modern API.
[node-qrcode](https://github.com/soldair/node-qrcode) QR code/2d barcode generator.
[QRCode.js](https://github.com/davidshimjs/qrcodejs): Cross-browser QRCode generator for javascript
[vue-qriously](https://github.com/theomessin/vue-qriously):A Vue.js 2 component to draw QR codes on an HTML Canvas using qrious.
[qrious](https://github.com/neocotic/qrious): Pure JavaScript library for QR code generation using canvas
## CDN ## CDN
[BootCDN](https://www.bootcdn.cn/): 稳定、快速、免费的前端开源项目 CDN 加速服务 [BootCDN](https://www.bootcdn.cn/): 稳定、快速、免费的前端开源项目 CDN 加速服务
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册