# pigmall **Repository Path**: eklinpig/pigmall ## Basic Information - **Project Name**: pigmall - **Description**: 猪猪商城 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2020-08-14 - **Last Updated**: 2021-03-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # pigmall #### 介绍 猪猪商城 #### 软件架构 软件架构说明 #### 安装教程 1. xxxx 2. xxxx 3. xxxx #### 使用说明 1. xxxx 2. xxxx 3. xxxx #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 码云特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo yum makecache ## 基础篇 docker update --restart=always xxx 1. redis docker pull redis mkdir -p /mydata/redis/conf touch /mydata/redis/conf/redis.conf docker run -p 6379:6379 --name redis \ -v /mydata/redis/data:/data \ -v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \ -d redis redis-server /etc/redis/redis.conf 2. mysql docker pull mysql:5.7 docker run -p 3306: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 \ -e MYSQL_ROOT_PASSWORD=root \ -d mysql:5.7 [client] default-character-set=utf8 [mysql] default-character-set=utf8 [mysqld] init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_unicode_ci skip-character-set-client-handshake skip-name-resolve 3. vscode全局模板 { "生成vue模板": { "prefix": "vue", "body": [ "", "", "", "", "", ], "description": "生成vue模板" }, "http-get请求": { "prefix": "httpget", "body": [ "this.\\$http({", "url: this.\\$http. adornUrl(''),", "method: 'get',", "params: this.\\$http.adornParams({})", "}).then(({ data })=>{", "})" ], "description": "httpGet请求" }, "http-post请求": { "prefix": "httppost", "body": [ "this.\\$http({", "url: this.\\$http.adornUrl(''),", "method: 'post',", "data: this.\\$http.adornData(data,false)", "}).then(({ data })=>{", "});" ], "description": "httpPOST请求" }, } ## 高级篇 1. ElasticSearch docker pull elasticsearch:7.4.2 mkdir -p /mydata/elasticsearch/config mkdir -p /mydata/elasticsearch/data echo "http.host: 0.0.0.0" >> /mydata/elasticsearch/config/elasticsearch.yml chmod -R 777 /mydata/elasticsearch/ docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \ -e "discovery.type=single-node" \ -e ES_JAVA_OPTS="-Xms64m -Xmx512m" \ -v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \ -v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \ -v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \ -d elasticsearch:7.4.2 2. kibana docker pull kibana:7.4.2 docker run --name kibana -e ELASTICSEARCH_HOSTS=http://192.168.56.10:9200 -p 5601:5601 \ -d kibana:7.4.2 3. nginx docker run -p 80:80 --name nginx -d nginx:1.10 docker container cp nginx:/etc/nginx /mydata/nginx/conf docker run -p 80:80 --name nginx \ -v /mydata/nginx/html:/usr/share/nginx/html \ -v /mydata/nginx/logs:/var/log/nginx \ -v /mydata/nginx/conf:/etc/nginx \ -d nginx:1.10 vi nginx.conf http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; upstream pigmall{ server 192.168.56.1:88; } include /etc/nginx/conf.d/*.conf; } vi pigmall.conf server { listen 80; server_name pigmall.com; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { proxy_set_header Host $host; proxy_pass http://pigmall; } } 4. ElasticSearch使用 #### 查看 _cat GET /_cat/nodes: 查看所有节点 GET /_cat/health: 查看 es 健康状况 GET /_cat/master: 查看主节点 GET /_cat/indices: 查看所有索引 show databases; #### 提交一个文档 直接更新数据 PUT /customer/external/1 { "name":"Pig" } POST /customer/external/1 { "name":"Pig" } #### 获取文档 GET /customer/external/1 #### 更新文档 _update POST /customer/external/1/_update { "doc": { name":"Cat" } } 对比原来数据,与原来一样就什么都不做(version, seq_no) #### 删除文档 DELETE /customer/external/1 #### 批量 _bulk POST /customer/external/_bulk {"index":{"_id":"1"}} {"name":"Pig"} {"index":{"_id":"2"}} {"name":"Cat"} POST /_bulk {"delete":{"_index":"website","_type":"blog","_id":"123"}} {"create":{"_index":"website","_type":"blog","_id":"123"}} {"title":"My first blog post"} {"index":{"_index":"website","_type":"blog"}} {"title":"My second blog post"} {"update":{"_index":"website","_type":"blog","_id":"123"}} {"doc":{"title":"My updated blog post"}} https://raw.githubusercontent.com/elastic/elasticsearch/master/docs/src/test/resources/accounts.json #### 查询 _search GET bank/_search { "query": { "match": { "address": "Mill Lane" } } } ## 全文检索按照评分进行排序,会对检索条件进行分词匹配 GET bank/_search { "query": { "match_phrase": { "address": "Mill Lane" } } } ## match_phrase短语匹配,不会进行分词 GET bank/_search { "query": { "multi_match": { "query": "mill movico", "fields": ["address", "city"] } } } ## 多字段匹配 GET bank/_search { "query": { "bool": { "must": [ {"match": { "gender": "M" }}, {"match": { "address": "Mill" }} ], "must_not": [ {"match": { "age": "18" }} ], "should": [ {"match": { "lastname": "Wallace" }} ] } } } ## 复合查询 #### 映射 _mapping ## 查询映射 GET bank/_mapping ## 新建 PUT /my_index { "mappings": { "properties": { "age": {"type": "integer"}, "email": {"type": "keyword"}, "name": {"type": "text"} } } } ## 添加 PUT /my_index/_mapping { "properties": { "employee-id": { "type": "keyword", "index": false } } } #### 数据迁移 _reindex POST _reindex { "source": { "index": "bank", "type": "account" }, "dest": { "index": "newbank" } } #### 分词器 _analyze POST _analyze { "analyzer": "standard", "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone." } http://github.com/medcl/elasticsearch-analysis-ik/releases POST _analyze { "analyzer": "ik_max_word", "text": "玉林师范学院" } 自定义分词 /mydata/elasticsearch/plugins/ik/config/IKAnalyzer.cfg.xml IK Analyzer 扩展配置 http://192.168.56.10/es/fenci.txt # 模糊匹配,过滤(属性,分类,品牌,价格区间,库存),排序,分页,高亮,聚合分析 # 如果是嵌入式的属性,查询,聚合,分析都应该用嵌入式的 PUT product { "mappings": { "properties": { "skuId": { "type": "long" }, "spuId": { "type": "keyword" }, "skuTitle": { "type": "text", "analyzer": "ik_smart" }, "skuPrice": { "type": "keyword" }, "skuImg": { "type": "keyword", "index": false, "doc_values": false }, "saleCount": { "type": "long" }, "hasStock": { "type": "boolean" }, "hotScore": { "type": "long" }, "brandId": { "type": "long" }, "catalogId": { "type": "long" }, "brandName": { "type": "keyword", "index": false, "doc_values": false }, "brandImg": { "type": "keyword", "index": false, "doc_values": false }, "catalogName": { "type": "keyword", "index": false, "doc_values": false }, "attrs": { "type": "nested", "properties": { "attrId": { "type": "long" }, "attrName": { "type": "keyword", "index": false, "doc_values": false }, "attrValue": { "type": "keyword" } } } } } } GET pigmall_product/_search { "query": { "bool": { "must": [ { "match": { "skuTitle": "华为" } } ], "filter": [ { "term": { "catalogId": "225" } }, { "terms": { "brandId": [ "8", "9", "15" ] } }, { "nested": { "path": "attrs", "query": { "bool": { "must": [ { "term": { "attrs.attrId": { "value": "8" } } }, { "terms": { "attrs.attrValue": [ "高通", "海思" ] } } ] } } } }, { "term": { "hasStock": "true" } }, { "range": { "skuPrice": { "gte": 0, "lte": 6000 } } } ] } }, "sort": [ { "skuPrice": { "order": "desc" } } ], "from": 0, "size": 5, "highlight": { "fields": { "skuTitle": {} }, "pre_tags": "", "post_tags": "" }, "aggs": { "brand_agg": { "terms": { "field": "brandId", "size": 10 }, "aggs": { "brand_name_agg": { "terms": { "field": "brandName", "size": 10 } }, "brand_img_agg": { "terms": { "field": "brandImg", "size": 10 } } } }, "catelog_agg": { "terms": { "field": "catalogId", "size": 100 }, "aggs": { "catalog_name_agg": { "terms": { "field": "catalogName", "size": 10 } } } }, "attr_agg": { "nested": { "path": "attrs" }, "aggs": { "attr_id_agg": { "terms": { "field": "attrs.attrId", "size": 10 }, "aggs": { "attr_name_agg": { "terms": { "field": "attrs.attrName", "size": 10 } }, "attr_value_agg": { "terms": { "field": "attrs.attrValue", "size": 10 } } } } } } } } 5. jvisualvm visualvm.github.io/pluginscenters.html 6. RabbitMQ docker run -d --name rabbitmq -p 5671:5671 -p 5672:5672 -p 4369:4369 -p 25672:25672 -p 15671:15671 -p 15672:15672 rabbitmq:management 4369,25672(Erlang发现&集群端口) 5672,5671(AMQP端口) 15672(web管理后台端口) 61613,61614(STOMP协议端口) 1883,8883(MQTT协议端口) https://www.rabbitmq.com/networking.html