A high performance online bookstore system.

HPOB 高性能网上书店

A high performance online bookstore system.

Introduction 介绍

一个基于Gin、gorm、viper、zap等库的web服务器,实现了网上书店相关接口。

Summary 概要

使用go语言编写的,基于gin、gorm、viper、zap等模块的在线书店商城服务。

Features 特性

路由高效,日志高性能,配置读取便捷,代码通俗易懂。

Requirements 必要条件

系统支持Go语言环境,已经安装mariadb或mysql数据库,其它模块依赖参考go.mod文件。

Configuration 配置

在conf/config.yaml文件中修改配置。

level: debug                 # 开发模式, debug, release, test
name: bookstore-server       # API服务的名字
addr: :8080                  # HTTP绑定端口
url: http://127.0.0.1:8080   # pingServer函数请求的API服务器的ip:port
max_ping_count: 10           # pingServer函数try的次数
jwt_secret: Rtg8BPKNEf2mB4mgvKONGPZZQSaJWNLijxR42qRgq0iBb5 #token密钥
tls:
  addr: :8081                # https地址
  cert: conf/server.crt      # 证书地址
  key: conf/server.key       # 私钥文件
log:
  log_level: DEBUG           # 日志级别,可选DEBUG, INFO, WARN, ERROR, DPANIC, PANIC, FATAL
  file_output: true          # 是否在文件中输出日志
  log_file: blog/server.log  # 输出日志文件路径
  max_backups: 5             # 日志文件最大保留数量
  max_size: 1                # 日志文件最大大小,单位 MB
  max_age: 30                # 日志文件最大存储时间,单位 天
  compress: false            # 是否启用日志压缩
db:
  name: bookstore_server     # 数据库名称
  addr: 127.0.0.1:3306       # 数据库所在IP及端口号
  username: root             # 数据库登陆用户
  password: aa11bb22cc33     # 数据库登陆密码
docker_db:
  name: bookstore_server
  addr: 127.0.0.1:3306
  username: root
  password: aa11bb22cc33

Installation 安装

#克隆存储库
git clone https://github.com/zouyonghe/High-Performance-Online-Bookstore.git

#进入项目目录
cd High-Performance-Online-Bookstore

#安装依赖库
go mod tidy

Usage 用法

#初始化数据库

cd database
mysql -uroot -pPASSWORD -e "
source bookstore.sql
quit
"
cd ..

#编译程序

go build

#启动服务

./server.sh start

#终止服务

./server.sh stop

#重启服务

./server.sh restart

#版本信息

./server.sh version

Struct 项目结构

main

程序入口。

conf

配置文件,yaml文档及TLS证书和私钥,基于角色的权限控制配置等。

config

服务配置获取。

database

数据库连接配置,初始化脚本。

log

日志配置获取。

router

路由与中间件。

  • router.go 路由函数及中间件注册
  • middleware 中间件

handler

路由处理函数,包括用户路由处理函数等。

  • handler.go 响应结构体,响应函数
  • state 状态查询响应
  • user 用户请求响应

model

服务主体对象类型及方法。

  • model.go 其他数据模型
  • user.go 用户模型和方法
  • book.go 图书模型和方法
  • cart.go 购物车模型和方法
  • order.go 订单模型和方法

service

复杂业务逻辑函数。

util

工具包。

pkg

其他功能包,认证、错误码、状态、token、版本等。

Development 开发文档

待补充。

FAQ - 常见问题

Support 支持

如果需要反馈问题,可以直接提交 Issues 或联系邮箱。

Dos 文档

Contact 联系

name: buding

email: [email protected]

Authors and acknowledgment 贡献者和感谢

The Go programming language

Gin is a HTTP web framework written in Golang.

Gorm is a fantastic ORM library for Golang, aims to be developer friendly.

Viper is a complete configuration solution for Go applications including 12-Factor apps.

Casbin is a powerful and efficient open-source access control library for Golang projects.

License 版权信息

本软件基于 GPLv3 协议开源,使用者可以自由的使用、修改、再分发此软件源代码,但须遵守许可证相关条例。

Similar Resources

Simple online syncing tool for Oracle Object Store

TrollBox ... use your storage with Oracle Object Store Quick Start Make sure you have the Object Storage, bucket and you know the compartment id where

Oct 25, 2021

Andrews-monitor - A Go program to monitor when times were available to order for Brown's Andrews dining hall. Used during the portion of the pandemic when the dining hall was only available for online order.

Andrews Dining Hall Monitor A Go program to monitor when times were available to order for Brown's Andrews dining hall. Used during the portion of the

Jan 1, 2022

GoScanPlayers - Hypixel online player tracker. Runs as an executable and can notify a Discord Webhook

GoScanPlayers - Hypixel online player tracker. Runs as an executable and can notify a Discord Webhook

GoScanPlayers Hypixel online player tracker. Runs as an executable and can notif

Oct 16, 2022

The server-side reproduction, similar the one of https://popcat.click, improve the performance and speed.

PopCat Echo The server-side reproduction, similar the one of https://popcat.click, improve the performance and speed. Docker Image The docker image is

Dec 15, 2022

Kubernetes Node Performance Validator

Kubernetes Node Performance Evaluator This repository contains a set of tools for testing the performance of all the nodes in a kubernetes cluster. Wh

Dec 24, 2021

This library provides a metrics package which can be used to instrument code, expose application metrics, and profile runtime performance in a flexible manner.

This library provides a metrics package which can be used to instrument code, expose application metrics, and profile runtime performance in a flexible manner.

Jan 18, 2022

False-sharing-demo - Demo for performance effects of CPU cache false-sharing

Example of CPU cache false-sharing in Go. A simple example where 2 integer varia

Aug 28, 2022

Grafana Tempo is a high volume, minimal dependency distributed tracing backend.

Grafana Tempo is a high volume, minimal dependency distributed tracing backend.

Grafana Tempo is an open source, easy-to-use and high-scale distributed tracing backend. Tempo is cost-efficient, requiring only object storage to ope

Jan 8, 2023

PolarDB Stack is a DBaaS implementation for PolarDB-for-Postgres, as an operator creates and manages PolarDB/PostgreSQL clusters running in Kubernetes. It provides re-construct, failover swtich-over, scale up/out, high-available capabilities for each clusters.

PolarDB Stack is a DBaaS implementation for PolarDB-for-Postgres, as an operator creates and manages PolarDB/PostgreSQL clusters running in Kubernetes. It provides re-construct, failover swtich-over, scale up/out, high-available capabilities for each clusters.

PolarDB Stack开源版生命周期 1 系统概述 PolarDB是阿里云自研的云原生关系型数据库,采用了基于Shared-Storage的存储计算分离架构。数据库由传统的Share-Nothing,转变成了Shared-Storage架构。由原来的N份计算+N份存储,转变成了N份计算+1份存储

Nov 8, 2022
A Golang based high performance, scalable and distributed workflow framework
A Golang based high performance, scalable and distributed workflow framework

Go-Flow A Golang based high performance, scalable and distributed workflow framework It allows to programmatically author distributed workflow as Dire

Jan 6, 2023
topolvm operator provide kubernetes local storage which is light weight and high performance

Topolvm-Operator Topolvm-Operator is an open source cloud-native local storage orchestrator for Kubernetes, which bases on topolvm. Supported environm

Nov 24, 2022
An high performance and ops-free local storage solution for Kubernetes.
An high performance and ops-free local storage solution for Kubernetes.

Carina carina 是一个CSI插件,在Kubernetes集群中提供本地存储持久卷 项目状态:开发测试中 CSI Version: 1.3.0 Carina architecture 支持的环境 Kubernetes:1.20 1.19 1.18 Node OS:Linux Filesys

May 18, 2022
A batch scheduler of kubernetes for high performance workload, e.g. AI/ML, BigData, HPC
A batch scheduler of kubernetes for high performance workload, e.g. AI/ML, BigData, HPC

kube-batch kube-batch is a batch scheduler for Kubernetes, providing mechanisms for applications which would like to run batch jobs leveraging Kuberne

Jan 6, 2023
Carina: an high performance and ops-free local storage for kubernetes
Carina: an high performance and ops-free local storage for kubernetes

Carina English | 中文 Background Storage systems are complex! There are more and more kubernetes native storage systems nowadays and stateful applicatio

Dec 30, 2022
A high-performance Directed-Acyclic-Graph JIT in Go
A high-performance Directed-Acyclic-Graph JIT in Go

GAG - A Directed-Acyclic-Graph JIT in Go GAG is a library I created while developing https://isobot.io to experiment with different ways of implementi

Mar 16, 2022
A golang CTF competition platform with high-performance, security and low hardware requirements.
A golang CTF competition platform with high-performance, security and low hardware requirements.

CTFgo - CTF Platform written in Golang A golang CTF competition platform with high-performance, security and low hardware requirements. Live Demo • Di

Oct 20, 2022
StoneWork is a high-performance, all-(CNFs)-in-one network solution.

StoneWork, high-performance dataplane, modular control-plane solution StoneWork is used by PANTHEON.tech to integrate its CNFs on top of a single shar

Dec 23, 2022
High-performance GitHub webhook events toolset for Go :rocket:
High-performance GitHub webhook events toolset for Go :rocket:

githubevents GitHub webhook events toolset for Go githubevents is a webhook events toolset for the Go programming language inspired by octokit/webhook

Dec 24, 2022
A simple tool who pulls data from Online.net API and parse them to a Prometheus format

Dedibox backup monitoring A simple tool who reads API from Online.net and parse them into a Prometheus-compatible format. Conceived to be lightweight,

Aug 16, 2022