feature(1.2.8): 使用 embed 打包静态资源

- go version 升级为 1.16
- 使用 embed 特性,将静态资源打包进二进制文件
- 优化代码
This commit is contained in:
新亮
2021-11-20 15:01:50 +08:00
parent 9aa0067e07
commit 8ed27cdce1
244 changed files with 2292 additions and 3193 deletions

View File

@@ -13,8 +13,7 @@
1. 支持 [Swagger](https://github.com/swaggo/gin-swagger) 接口文档生成
1. 支持 [GraphQL](https://github.com/99designs/gqlgen) 查询语言
1. 支持 trace 项目内部链路追踪
1. 支持 [pprof](https://github.com/gin-contrib/pprof) 性能剖析
1. 支持 [jwt](https://github.com/dgrijalva/jwt-go) 接口鉴权
1. 支持 [pprof](https://github.com/gin-contrib/pprof) 性能剖析
1. 支持 errno 统一定义错误码
1. 支持 [zap](https://go.uber.org/zap) 日志收集
1. 支持 [viper](https://github.com/spf13/viper) 配置文件解析
@@ -34,7 +33,9 @@
## 其他
查看 Jaeger 链路追踪代码,请查看 [v1.0版](https://github.com/xinliangnote/go-gin-api/releases/tag/v1.0),文档点这里 [jaeger.md](https://github.com/xinliangnote/go-gin-api/blob/master/docs/jaeger.md) 。
查看 Jaeger 链路追踪 Demo 代码,请查看 [v1.0 ](https://github.com/xinliangnote/go-gin-api/releases/tag/v1.0) ,链接地址:http://127.0.0.1:9999/jaeger_test
调用的其他服务端 Demo 代码为 [https://github.com/xinliangnote/go-jaeger-demo](https://github.com/xinliangnote/go-jaeger-demo)
## 联系作者

11
assets/assets.go Normal file
View File

@@ -0,0 +1,11 @@
package assets
import "embed"
var (
//go:embed bootstrap
Bootstrap embed.FS
//go:embed templates
Templates embed.FS
)

View File

@@ -1,4 +1,4 @@
document.write('<script type="text/javascript" src="../../bootstrap/js/bootstrap-notify/bootstrap-notify.min.js"></script>');
document.write('<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-notify/bootstrap-notify.min.js"></script>');
function SuccessNotify(content) {
$.notify({

View File

@@ -1,8 +1,8 @@
document.write('<script type="text/javascript" src="../../bootstrap/js/authorization/ksort.js"></script>');
document.write('<script type="text/javascript" src="../../bootstrap/js/authorization/crypto-js.min.js"></script>');
document.write('<script type="text/javascript" src="../../bootstrap/js/authorization/hmac-sha256.js"></script>');
document.write('<script type="text/javascript" src="../../bootstrap/js/authorization/enc-base64.min.js"></script>');
document.write('<script type="text/javascript" src="../../bootstrap/js/jquery.cookie.min.js"></script>');
document.write('<script type="text/javascript" src="/assets/bootstrap/js/authorization/ksort.js"></script>');
document.write('<script type="text/javascript" src="/assets/bootstrap/js/authorization/crypto-js.min.js"></script>');
document.write('<script type="text/javascript" src="/assets/bootstrap/js/authorization/hmac-sha256.js"></script>');
document.write('<script type="text/javascript" src="/assets/bootstrap/js/authorization/enc-base64.min.js"></script>');
document.write('<script type="text/javascript" src="/assets/bootstrap/js/jquery.cookie.min.js"></script>');
document.write('<div style="display:none"><script type="text/javascript">document.write(unescape("%3Cspan id=\'cnzz_stat_icon_1279911342\'%3E%3C/span%3E%3Cscript src=\'https://v1.cnzz.com/z_stat.php%3Fid%3D1279911342%26\' type=\'text/javascript\'%3E%3C/script%3E"));</script></div>');
function GenerateAuthorization(path, method, params) {

View File

@@ -3,11 +3,11 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -51,13 +51,13 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="../../bootstrap/js/authorization/md5.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/authorization/md5.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {

View File

@@ -3,10 +3,10 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -53,11 +53,11 @@
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery.pagination.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.pagination.js"></script>
<script type="text/javascript">
$(document).ready(function () {
// 加载列表页数据

View File

@@ -5,14 +5,14 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<title>登录页面</title>
<link rel="shortcut icon" type="image/x-icon" href="bootstrap/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="/assets/bootstrap/favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<link rel="stylesheet" type="text/css" href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css">
<link rel="stylesheet" type="text/css" href="../../bootstrap/css/materialdesignicons.min.css">
<link rel="stylesheet" type="text/css" href="../../bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../../bootstrap/css/style.min.css">
<link rel="stylesheet" type="text/css" href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css">
<link rel="stylesheet" type="text/css" href="/assets/bootstrap/css/materialdesignicons.min.css">
<link rel="stylesheet" type="text/css" href="/assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/assets/bootstrap/css/style.min.css">
<style>
.login-form .has-feedback {
@@ -47,7 +47,7 @@
<body class="center-vh">
<div class="card card-shadowed p-5 w-420 mb-0 mr-2 ml-2">
<div class="text-center mb-3">
<img src="../../bootstrap/images/logo-sidebar.png">
<img src="/assets/bootstrap/images/logo-sidebar.png">
</div>
<form class="login-form">
<div class="form-group has-feedback">
@@ -71,10 +71,10 @@
</form>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="../../bootstrap/js/authorization/md5.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/authorization/md5.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {

View File

@@ -3,11 +3,11 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -53,12 +53,12 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript">
$(document).ready(function () {
const hash_id = {{ .HashID }}

View File

@@ -3,11 +3,11 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -44,12 +44,12 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript">
$(document).ready(function () {

View File

@@ -3,11 +3,11 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -46,13 +46,13 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="../../bootstrap/js/authorization/md5.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/authorization/md5.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {

View File

@@ -3,11 +3,11 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -46,12 +46,12 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript">
$(document).ready(function () {

View File

@@ -3,11 +3,11 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -67,13 +67,13 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript">
$(document).ready(function () {

View File

@@ -3,9 +3,9 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -206,10 +206,10 @@ console.log({authorization: key + " " + digest, date: datetime});
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/main.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/main.min.js"></script>
<script type="text/javascript">document.write(unescape("%3Cspan id='cnzz_stat_icon_1279911342'%3E%3C/span%3E%3Cscript src='https://v1.cnzz.com/z_stat.php%3Fid%3D1279911342%26' type='text/javascript'%3E%3C/script%3E"));</script>
</body>
</html>

View File

@@ -3,10 +3,10 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -51,11 +51,11 @@
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery.pagination.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.pagination.js"></script>
<script type="text/javascript">
$(document).ready(function () {
// 加载列表页数据

View File

@@ -3,8 +3,8 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>

View File

@@ -3,9 +3,9 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -56,10 +56,10 @@
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript">
$(document).ready(function () {

View File

@@ -3,11 +3,11 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -138,12 +138,12 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript">
$(document).ready(function () {

View File

@@ -3,11 +3,11 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -137,12 +137,12 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript">
$(document).ready(function () {

View File

@@ -3,10 +3,10 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -57,12 +57,12 @@
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery.pagination.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.pagination.js"></script>
<script type="text/javascript">
$(document).ready(function () {

View File

@@ -3,8 +3,8 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -18,7 +18,12 @@
<div class="card-title">项目信息 <span class="badge badge-pill badge-warning">{{ .ProjectVersion }}</span> </div>
</header>
<div class="card-body">
<p>操作系统:{{ .GoOS }} <span class="badge badge-brown"> {{ .GoArch }} </span> <span class="badge badge-info"> {{ .GoVersion }} </span></p>
<p>操作系统:{{ .GoOS }}
<span class="badge badge-brown"> {{ .GoArch }} </span>
<span class="badge badge-info"> {{ .GoVersion }} </span>
<span class="badge badge-danger"> mysql{{ .MySQLVersion }} </span>
<span class="badge badge-danger"> redis{{ .RedisVersion }} </span>
</p>
<p>项目地址:{{ .ProjectPath }}</p>
<p>项目域名:{{ .Host }} <span class="badge badge-secondary"> {{ .Env }} </span></p>
</div>
@@ -82,7 +87,7 @@
<div class="card-title">开源信息</div>
</header>
<div class="card-body">
<p>GitHub 地址:<a target="_blank" href="https://github.com/xinliangnote/go-gin-api">xinliangnote/go-gin-api</a></p>
<p>GitHub 地址:<a target="_blank" href="https://github.com/xinliangnote/go-gin-api">[go-gin-api 源码地址]</a> <a target="_blank" href="https://www.yuque.com/xinliangnote/go-gin-api/ngc3x5">[中文文档]</a></p>
<p>GitHub Stars<a href="https://github.com/xinliangnote/go-gin-api/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/xinliangnote/go-gin-api?style=flat-square"></a></p>
<p>GitHub Forks<a href="https://github.com/xinliangnote/go-gin-api/network"><img alt="GitHub forks" src="https://img.shields.io/github/forks/xinliangnote/go-gin-api?style=flat-square"></a></p>
</div>
@@ -96,7 +101,7 @@
</header>
<div class="card-body text-center">
<p style="height: 105px;">
<img style="height: 100px;" src="../../bootstrap/images/qr-code.png"/>
<img style="height: 100px;" src="/assets/bootstrap/images/qr-code.png"/>
</p>
</div>
</div>

View File

@@ -3,9 +3,9 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -48,9 +48,9 @@
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#btnOk").click(function(){

View File

@@ -3,9 +3,9 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -44,9 +44,9 @@
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#btnOk").click(function(){

View File

@@ -5,16 +5,16 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<title>管理面板</title>
<link rel="shortcut icon" type="image/x-icon" href="bootstrap/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="/assets/bootstrap/favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<link rel="stylesheet" type="text/css" href="bootstrap/js/jquery-confirm/jquery-confirm.min.css">
<link rel="stylesheet" type="text/css" href="bootstrap/css/materialdesignicons.min.css">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="bootstrap/js/bootstrap-multitabs/multitabs.min.css">
<link rel="stylesheet" type="text/css" href="bootstrap/css/animate.min.css">
<link rel="stylesheet" type="text/css" href="bootstrap/css/style.min.css">
<link rel="stylesheet" type="text/css" href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css">
<link rel="stylesheet" type="text/css" href="/assets/bootstrap/css/materialdesignicons.min.css">
<link rel="stylesheet" type="text/css" href="/assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.css">
<link rel="stylesheet" type="text/css" href="/assets/bootstrap/css/animate.min.css">
<link rel="stylesheet" type="text/css" href="/assets/bootstrap/css/style.min.css">
</head>
<body>
@@ -26,7 +26,7 @@
<!-- logo -->
<div id="logo" class="sidebar-header">
<a href="/">
<img src="bootstrap/images/logo-sidebar.png"/>
<img src="/assets/bootstrap/images/logo-sidebar.png"/>
</a>
</div>
<div class="lyear-layout-sidebar-info lyear-scroll">
@@ -170,7 +170,7 @@
<li class="dropdown dropdown-profile">
<a href="javascript:void(0)" data-toggle="dropdown" class="dropdown-toggle">
<img class="img-avatar img-avatar-48 m-r-10" src="bootstrap/images/users/avatar.png">
<img class="img-avatar img-avatar-48 m-r-10" src="/assets/bootstrap/images/users/avatar.png">
<span id="nickname"></span>
</a>
<ul class="dropdown-menu dropdown-menu-right">
@@ -210,15 +210,15 @@
</div>
</div>
<script type="text/javascript" src="bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="bootstrap/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="bootstrap/js/jquery.cookie.min.js"></script>
<script type="text/javascript" src="bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="bootstrap/js/index.min.js"></script>
<script type="text/javascript" src="bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.cookie.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/index.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript">
$(document).ready(function () {
AjaxForm(

View File

@@ -5,15 +5,15 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<title>项目初始化</title>
<link rel="shortcut icon" type="image/x-icon" href="../../bootstrap/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="/assets/bootstrap/favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/js/bootstrap-select/bootstrap-select.css" rel="stylesheet">
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/bootstrap-select/bootstrap-select.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -27,7 +27,7 @@
<div class="card-body">
<h5 class="card-title"><span class="badge badge-info">检测 · 环境</span></h5>
<div class="input-group mb-3">
<p class="text-left">所需版本:<code>go1.15+</code> (<small>当前版本 </small><code>{{.GoVersion}}</code>)</p>
<p class="text-left">所需版本:<code>go{{.MinGoVersion}}+</code> (<small>当前版本 </small><code>{{.GoVersion}}</code>)</p>
</div>
<h5 class="card-title"><span class="badge badge-info">配置 · 语言</span></h5>
@@ -103,19 +103,6 @@
</div>
</div>
<div class="input-group mb-3">
<small>
<i class="mdi mdi-checkbox-marked-circle"></i>
初始化 MySQL 数据表:<code>authorized</code>
<code>authorized_api</code>
<code>admin</code>
<code>menu</code>
<code>menu_action</code>
<code>admin_menu</code>
<code>cron_task</code>
</small>
</div>
<button type="button" id="btnOk" class="btn btn-primary">初始化项目</button>
<button type="button" id="btnLoading" class="btn btn-primary" disabled style="display: none">
<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
@@ -138,13 +125,13 @@
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-select/bootstrap-select.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-select/i18n/defaults-zh_CN.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-select/bootstrap-select.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-select/i18n/defaults-zh_CN.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.select-picker').selectpicker();

View File

@@ -5,14 +5,14 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<title>服务升级</title>
<link rel="shortcut icon" type="image/x-icon" href="../../bootstrap/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="/assets/bootstrap/favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -115,10 +115,10 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(document).on('click', '.upgrade', function () {

View File

@@ -3,11 +3,11 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.css" rel="stylesheet" type="text/css">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -69,13 +69,13 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-multitabs/multitabs.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript">
$(document).ready(function () {

View File

@@ -3,13 +3,13 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/js/jquery-treegrid/jquery.treegrid.min.css" rel="stylesheet">
<link href="../../bootstrap/js/bootstrap-select/bootstrap-select.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-treegrid/jquery.treegrid.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/bootstrap-select/bootstrap-select.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -76,18 +76,18 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-table/bootstrap-table.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-treegrid/jquery.treegrid.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-table/bootstrap-table.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-treegrid/jquery.treegrid.min.js"></script>
<script type="text/javascript"
src="../../bootstrap/js/bootstrap-table/extensions/treegrid/bootstrap-table-treegrid.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-select/bootstrap-select.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-select/i18n/defaults-zh_CN.min.js"></script>
src="/assets/bootstrap/js/bootstrap-table/extensions/treegrid/bootstrap-table-treegrid.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-select/bootstrap-select.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-select/i18n/defaults-zh_CN.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.select-picker').selectpicker();

View File

@@ -3,10 +3,10 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -61,11 +61,11 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript">
$(document).ready(function () {

View File

@@ -3,11 +3,11 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/js/bootstrap-select/bootstrap-select.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/bootstrap-select/bootstrap-select.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -96,15 +96,15 @@
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/vkbeautify.js"></script>
<script type="text/javascript" src="../../bootstrap/js/main.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-select/bootstrap-select.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-select/i18n/defaults-zh_CN.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/vkbeautify.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/main.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-select/bootstrap-select.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-select/i18n/defaults-zh_CN.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.select-picker').selectpicker();

View File

@@ -3,10 +3,10 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -75,12 +75,12 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-maxlength/bootstrap-maxlength.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript">
$(document).ready(function () {

View File

@@ -3,9 +3,9 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -97,9 +97,9 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<div style="display:none">
<script type="text/javascript">document.write(unescape("%3Cspan id='cnzz_stat_icon_1279911342'%3E%3C/span%3E%3Cscript src='https://v1.cnzz.com/z_stat.php%3Fid%3D1279911342%26' type='text/javascript'%3E%3C/script%3E"));</script>
</div>

View File

@@ -3,11 +3,11 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="../../bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="../../bootstrap/css/animate.min.css" rel="stylesheet">
<link href="../../bootstrap/css/style.min.css" rel="stylesheet">
<link href="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/animate.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/style.min.css" rel="stylesheet">
</head>
<body>
@@ -74,12 +74,12 @@
</div>
</div>
</div>
<script type="text/javascript" src="../../bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../../bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="../../bootstrap/js/bootstrap-notify/notify.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/popper.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/httpclient/httpclient.js"></script>
<script type="text/javascript" src="/assets/bootstrap/js/bootstrap-notify/notify.js"></script>
<script type="text/javascript">
$(document).ready(function () {
const ws = new WebSocket("ws://127.0.0.1:9999/socket/system/message");

View File

@@ -1,9 +1,15 @@
package configs
import (
"bytes"
_ "embed"
"io"
"os"
"path/filepath"
"time"
"github.com/xinliangnote/go-gin-api/pkg/env"
"github.com/xinliangnote/go-gin-api/pkg/file"
"github.com/fsnotify/fsnotify"
"github.com/spf13/viper"
@@ -49,16 +55,6 @@ type Config struct {
To string `toml:"to"`
} `toml:"mail"`
JWT struct {
Secret string `toml:"secret"`
ExpireDuration time.Duration `toml:"expireDuration"`
} `toml:"jwt"`
URLToken struct {
Secret string `toml:"secret"`
ExpireDuration time.Duration `toml:"expireDuration"`
} `toml:"urlToken"`
HashIds struct {
Secret string `toml:"secret"`
Length int `toml:"length"`
@@ -69,12 +65,39 @@ type Config struct {
} `toml:"language"`
}
func init() {
viper.SetConfigName(env.Active().Value() + "_configs")
viper.SetConfigType("toml")
viper.AddConfigPath("./configs")
var (
//go:embed dev_configs.toml
devConfigs []byte
if err := viper.ReadInConfig(); err != nil {
//go:embed fat_configs.toml
fatConfigs []byte
//go:embed uat_configs.toml
uatConfigs []byte
//go:embed pro_configs.toml
proConfigs []byte
)
func init() {
var r io.Reader
switch env.Active().Value() {
case "dev":
r = bytes.NewReader(devConfigs)
case "fat":
r = bytes.NewReader(fatConfigs)
case "uat":
r = bytes.NewReader(uatConfigs)
case "pro":
r = bytes.NewReader(proConfigs)
default:
r = bytes.NewReader(fatConfigs)
}
viper.SetConfigType("toml")
if err := viper.ReadConfig(r); err != nil {
panic(err)
}
@@ -82,6 +105,27 @@ func init() {
panic(err)
}
viper.SetConfigName(env.Active().Value() + "_configs")
viper.AddConfigPath("./configs")
configFile := "./configs/" + env.Active().Value() + "_configs.toml"
_, ok := file.IsExists(configFile)
if !ok {
if err := os.MkdirAll(filepath.Dir(configFile), 0766); err != nil {
panic(err)
}
f, err := os.Create(configFile)
if err != nil {
panic(err)
}
defer f.Close()
if err := viper.WriteConfig(); err != nil {
panic(err)
}
}
viper.WatchConfig()
viper.OnConfigChange(func(e fsnotify.Event) {
if err := viper.Unmarshal(config); err != nil {

View File

@@ -1,6 +1,9 @@
package configs
const (
// MinGoVersion 最小 Go 版本
MinGoVersion = 1.16
// ProjectVersion 项目版本
ProjectVersion = "v1.2.8"
@@ -31,9 +34,6 @@ const (
// HeaderSignTokenDate 签名验证 DateHeader 中传递的参数
HeaderSignTokenDate = "Authorization-Date"
// RedisKeyPrefixRequestID Redis Key 前缀 - 防止重复提交
RedisKeyPrefixRequestID = ProjectName + ":request-id:"
// RedisKeyPrefixLoginUser Redis Key 前缀 - 登录用户信息
RedisKeyPrefixLoginUser = ProjectName + ":login-user:"
@@ -45,4 +45,7 @@ const (
// EnUS 英文 - 美国
EnUS = "en-us"
// MaxRequestsPerSecond 每秒最大请求量
MaxRequestsPerSecond = 10000
)

View File

@@ -3,10 +3,6 @@
length = 12
secret = "6ab6122836cfef95f8db"
[jwt]
expireduration = 24
secret = "i1ydX9RtHyuJTrw7frcu"
[language]
local = "zh-cn"
@@ -43,7 +39,3 @@
minidleconns = 5
pass = ""
poolsize = 10
[urltoken]
expireduration = 10
secret = "i1ydX9RtHyuJTrw7frcu"

View File

@@ -1,14 +1,13 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag
package docs
import (
"bytes"
"encoding/json"
"strings"
"text/template"
"github.com/alecthomas/template"
"github.com/swaggo/swag"
)
@@ -16,7 +15,7 @@ var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{.Description}}",
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"license": {
@@ -220,6 +219,35 @@ var doc = `{
}
}
},
"/api/admin/logout": {
"post": {
"description": "管理员登出",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"API.admin"
],
"summary": "管理员登出",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/admin_handler.logoutResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/code.Failure"
}
}
}
}
},
"/api/admin/menu": {
"post": {
"description": "提交菜单授权",
@@ -348,6 +376,51 @@ var doc = `{
}
}
},
"/api/admin/modify_personal_info": {
"patch": {
"description": "修改个人信息",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"tags": [
"API.admin"
],
"summary": "修改个人信息",
"parameters": [
{
"type": "string",
"description": "昵称",
"name": "nickname",
"in": "formData",
"required": true
},
{
"type": "string",
"description": "手机号",
"name": "mobile",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/admin_handler.modifyPersonalInfoResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/code.Failure"
}
}
}
}
},
"/api/admin/offline": {
"patch": {
"description": "下线管理员",
@@ -1689,6 +1762,126 @@ var doc = `{
}
}
},
"/api/order/cancel": {
"post": {
"description": "取消订单",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"API.order"
],
"summary": "取消订单",
"parameters": [
{
"description": "请求信息",
"name": "Request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/order_handler.cancelRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/order_handler.cancelResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/code.Failure"
}
}
}
}
},
"/api/order/create": {
"post": {
"description": "创建订单",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"API.order"
],
"summary": "创建订单",
"parameters": [
{
"description": "请求信息",
"name": "Request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/order_handler.createRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/order_handler.createResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/code.Failure"
}
}
}
}
},
"/api/order/{id}": {
"get": {
"description": "取消订单",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"API.order"
],
"summary": "取消订单",
"parameters": [
{
"description": "请求信息",
"name": "Request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/order_handler.detailRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/order_handler.detailResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/code.Failure"
}
}
}
}
},
"/api/tool/cache/clear": {
"patch": {
"description": "清空缓存",
@@ -2000,6 +2193,52 @@ var doc = `{
}
},
"definitions": {
"admin.ListMenuData": {
"type": "object",
"properties": {
"id": {
"description": "ID",
"type": "integer"
},
"is_have": {
"description": "是否已拥有权限",
"type": "integer"
},
"name": {
"description": "菜单名称",
"type": "string"
},
"pid": {
"description": "父类ID",
"type": "integer"
}
}
},
"admin.ListMyMenuData": {
"type": "object",
"properties": {
"icon": {
"description": "图标",
"type": "string"
},
"id": {
"description": "ID",
"type": "integer"
},
"link": {
"description": "链接地址",
"type": "string"
},
"name": {
"description": "菜单名称",
"type": "string"
},
"pid": {
"description": "父类ID",
"type": "integer"
}
}
},
"admin_handler.createResponse": {
"type": "object",
"properties": {
@@ -2025,7 +2264,7 @@ var doc = `{
"description": "菜单栏",
"type": "array",
"items": {
"$ref": "#/definitions/admin_service.ListMyMenuData"
"$ref": "#/definitions/admin.ListMyMenuData"
}
},
"mobile": {
@@ -2048,7 +2287,7 @@ var doc = `{
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/admin_service.ListMenuData"
"$ref": "#/definitions/admin.ListMenuData"
}
},
"username": {
@@ -2193,52 +2432,6 @@ var doc = `{
}
}
},
"admin_service.ListMenuData": {
"type": "object",
"properties": {
"id": {
"description": "ID",
"type": "integer"
},
"is_have": {
"description": "是否已拥有权限",
"type": "integer"
},
"name": {
"description": "菜单名称",
"type": "string"
},
"pid": {
"description": "父类ID",
"type": "integer"
}
}
},
"admin_service.ListMyMenuData": {
"type": "object",
"properties": {
"icon": {
"description": "图标",
"type": "string"
},
"id": {
"description": "ID",
"type": "integer"
},
"link": {
"description": "链接地址",
"type": "string"
},
"name": {
"description": "菜单名称",
"type": "string"
},
"pid": {
"description": "父类ID",
"type": "integer"
}
}
},
"authorized_handler.createAPIResponse": {
"type": "object",
"properties": {
@@ -2805,6 +2998,24 @@ var doc = `{
}
}
},
"order_handler.cancelRequest": {
"type": "object"
},
"order_handler.cancelResponse": {
"type": "object"
},
"order_handler.createRequest": {
"type": "object"
},
"order_handler.createResponse": {
"type": "object"
},
"order_handler.detailRequest": {
"type": "object"
},
"order_handler.detailResponse": {
"type": "object"
},
"tool_handler.dbData": {
"type": "object",
"properties": {
@@ -2964,6 +3175,13 @@ func (s *s) ReadDoc() string {
a, _ := json.Marshal(v)
return string(a)
},
"escape": func(v interface{}) string {
// escape tabs
str := strings.Replace(v.(string), "\t", "\\t", -1)
// replace " with \", and if that results in \\", replace that with \\\"
str = strings.Replace(str, "\"", "\\\"", -1)
return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1)
},
}).Parse(doc)
if err != nil {
return doc
@@ -2978,5 +3196,5 @@ func (s *s) ReadDoc() string {
}
func init() {
swag.Register(swag.Name, &s{})
swag.Register("swagger", &s{})
}

View File

@@ -1,20 +0,0 @@
## Jaeger Demo 代码
- 代码在 [v1.0](https://github.com/xinliangnote/go-gin-api/releases/tag/v1.0) 版本。
#### Jaeger Demo 文档
访问:
```
http://127.0.0.1:9999/jaeger_test
```
服务端测试代码:
- [https://github.com/xinliangnote/go-jaeger-demo](https://github.com/xinliangnote/go-jaeger-demo)
![](https://github.com/xinliangnote/Go/blob/master/03-go-gin-api%20%5B文档%5D/images/jaeger_demo_2.png)
![](https://github.com/xinliangnote/Go/blob/master/03-go-gin-api%20%5B文档%5D/images/jaeger_demo_3.png)

View File

@@ -203,6 +203,35 @@
}
}
},
"/api/admin/logout": {
"post": {
"description": "管理员登出",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"API.admin"
],
"summary": "管理员登出",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/admin_handler.logoutResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/code.Failure"
}
}
}
}
},
"/api/admin/menu": {
"post": {
"description": "提交菜单授权",
@@ -331,6 +360,51 @@
}
}
},
"/api/admin/modify_personal_info": {
"patch": {
"description": "修改个人信息",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"tags": [
"API.admin"
],
"summary": "修改个人信息",
"parameters": [
{
"type": "string",
"description": "昵称",
"name": "nickname",
"in": "formData",
"required": true
},
{
"type": "string",
"description": "手机号",
"name": "mobile",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/admin_handler.modifyPersonalInfoResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/code.Failure"
}
}
}
}
},
"/api/admin/offline": {
"patch": {
"description": "下线管理员",
@@ -1672,6 +1746,126 @@
}
}
},
"/api/order/cancel": {
"post": {
"description": "取消订单",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"API.order"
],
"summary": "取消订单",
"parameters": [
{
"description": "请求信息",
"name": "Request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/order_handler.cancelRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/order_handler.cancelResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/code.Failure"
}
}
}
}
},
"/api/order/create": {
"post": {
"description": "创建订单",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"API.order"
],
"summary": "创建订单",
"parameters": [
{
"description": "请求信息",
"name": "Request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/order_handler.createRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/order_handler.createResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/code.Failure"
}
}
}
}
},
"/api/order/{id}": {
"get": {
"description": "取消订单",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"API.order"
],
"summary": "取消订单",
"parameters": [
{
"description": "请求信息",
"name": "Request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/order_handler.detailRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/order_handler.detailResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/code.Failure"
}
}
}
}
},
"/api/tool/cache/clear": {
"patch": {
"description": "清空缓存",
@@ -1983,6 +2177,52 @@
}
},
"definitions": {
"admin.ListMenuData": {
"type": "object",
"properties": {
"id": {
"description": "ID",
"type": "integer"
},
"is_have": {
"description": "是否已拥有权限",
"type": "integer"
},
"name": {
"description": "菜单名称",
"type": "string"
},
"pid": {
"description": "父类ID",
"type": "integer"
}
}
},
"admin.ListMyMenuData": {
"type": "object",
"properties": {
"icon": {
"description": "图标",
"type": "string"
},
"id": {
"description": "ID",
"type": "integer"
},
"link": {
"description": "链接地址",
"type": "string"
},
"name": {
"description": "菜单名称",
"type": "string"
},
"pid": {
"description": "父类ID",
"type": "integer"
}
}
},
"admin_handler.createResponse": {
"type": "object",
"properties": {
@@ -2008,7 +2248,7 @@
"description": "菜单栏",
"type": "array",
"items": {
"$ref": "#/definitions/admin_service.ListMyMenuData"
"$ref": "#/definitions/admin.ListMyMenuData"
}
},
"mobile": {
@@ -2031,7 +2271,7 @@
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/admin_service.ListMenuData"
"$ref": "#/definitions/admin.ListMenuData"
}
},
"username": {
@@ -2176,52 +2416,6 @@
}
}
},
"admin_service.ListMenuData": {
"type": "object",
"properties": {
"id": {
"description": "ID",
"type": "integer"
},
"is_have": {
"description": "是否已拥有权限",
"type": "integer"
},
"name": {
"description": "菜单名称",
"type": "string"
},
"pid": {
"description": "父类ID",
"type": "integer"
}
}
},
"admin_service.ListMyMenuData": {
"type": "object",
"properties": {
"icon": {
"description": "图标",
"type": "string"
},
"id": {
"description": "ID",
"type": "integer"
},
"link": {
"description": "链接地址",
"type": "string"
},
"name": {
"description": "菜单名称",
"type": "string"
},
"pid": {
"description": "父类ID",
"type": "integer"
}
}
},
"authorized_handler.createAPIResponse": {
"type": "object",
"properties": {
@@ -2788,6 +2982,24 @@
}
}
},
"order_handler.cancelRequest": {
"type": "object"
},
"order_handler.cancelResponse": {
"type": "object"
},
"order_handler.createRequest": {
"type": "object"
},
"order_handler.createResponse": {
"type": "object"
},
"order_handler.detailRequest": {
"type": "object"
},
"order_handler.detailResponse": {
"type": "object"
},
"tool_handler.dbData": {
"type": "object",
"properties": {

View File

@@ -1,4 +1,37 @@
definitions:
admin.ListMenuData:
properties:
id:
description: ID
type: integer
is_have:
description: 是否已拥有权限
type: integer
name:
description: 菜单名称
type: string
pid:
description: 父类ID
type: integer
type: object
admin.ListMyMenuData:
properties:
icon:
description: 图标
type: string
id:
description: ID
type: integer
link:
description: 链接地址
type: string
name:
description: 菜单名称
type: string
pid:
description: 父类ID
type: integer
type: object
admin_handler.createResponse:
properties:
id:
@@ -16,7 +49,7 @@ definitions:
menu:
description: 菜单栏
items:
$ref: '#/definitions/admin_service.ListMyMenuData'
$ref: '#/definitions/admin.ListMyMenuData'
type: array
mobile:
description: 手机号
@@ -32,7 +65,7 @@ definitions:
properties:
list:
items:
$ref: '#/definitions/admin_service.ListMenuData'
$ref: '#/definitions/admin.ListMenuData'
type: array
username:
type: string
@@ -131,39 +164,6 @@ definitions:
description: 主键ID
type: integer
type: object
admin_service.ListMenuData:
properties:
id:
description: ID
type: integer
is_have:
description: 是否已拥有权限
type: integer
name:
description: 菜单名称
type: string
pid:
description: 父类ID
type: integer
type: object
admin_service.ListMyMenuData:
properties:
icon:
description: 图标
type: string
id:
description: ID
type: integer
link:
description: 链接地址
type: string
name:
description: 菜单名称
type: string
pid:
description: 父类ID
type: integer
type: object
authorized_handler.createAPIResponse:
properties:
id:
@@ -561,6 +561,18 @@ definitions:
description: 主键ID
type: integer
type: object
order_handler.cancelRequest:
type: object
order_handler.cancelResponse:
type: object
order_handler.createRequest:
type: object
order_handler.createResponse:
type: object
order_handler.detailRequest:
type: object
order_handler.detailResponse:
type: object
tool_handler.dbData:
properties:
db_name:
@@ -809,6 +821,25 @@ paths:
summary: 管理员登录
tags:
- API.admin
/api/admin/logout:
post:
consumes:
- application/json
description: 管理员登出
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/admin_handler.logoutResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/code.Failure'
summary: 管理员登出
tags:
- API.admin
/api/admin/menu:
post:
consumes:
@@ -894,6 +925,36 @@ paths:
summary: 修改密码
tags:
- API.admin
/api/admin/modify_personal_info:
patch:
consumes:
- multipart/form-data
description: 修改个人信息
parameters:
- description: 昵称
in: formData
name: nickname
required: true
type: string
- description: 手机号
in: formData
name: mobile
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/admin_handler.modifyPersonalInfoResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/code.Failure'
summary: 修改个人信息
tags:
- API.admin
/api/admin/offline:
patch:
consumes:
@@ -1766,6 +1827,84 @@ paths:
summary: 删除功能权限
tags:
- API.menu
/api/order/{id}:
get:
consumes:
- application/json
description: 取消订单
parameters:
- description: 请求信息
in: body
name: Request
required: true
schema:
$ref: '#/definitions/order_handler.detailRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/order_handler.detailResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/code.Failure'
summary: 取消订单
tags:
- API.order
/api/order/cancel:
post:
consumes:
- application/json
description: 取消订单
parameters:
- description: 请求信息
in: body
name: Request
required: true
schema:
$ref: '#/definitions/order_handler.cancelRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/order_handler.cancelResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/code.Failure'
summary: 取消订单
tags:
- API.order
/api/order/create:
post:
consumes:
- application/json
description: 创建订单
parameters:
- description: 请求信息
in: body
name: Request
required: true
schema:
$ref: '#/definitions/order_handler.createRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/order_handler.createResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/code.Failure'
summary: 创建订单
tags:
- API.order
/api/tool/cache/clear:
patch:
consumes:

5
en.md
View File

@@ -13,7 +13,6 @@ Features:
1. GraphQL supported by [GraphQL](https://github.com/99designs/gqlgen)
1. Trace project internal invoking
1. Visualized performance analysis supported by [pprof](https://github.com/gin-contrib/pprof)
1. Industry standard RFC 7519 method for authentication supported by [jwt](https://github.com/dgrijalva/jwt-go)
1. Uniformly defined error codes supported by errno
1. Blazing fast, structured, leveled logging system by [zap](https://go.uber.org/zap)
1. Complete configuration solution supported by [viper](https://github.com/spf13/viper)
@@ -29,10 +28,6 @@ Features:
**Detailed documentation[https://www.yuque.com/xinliangnote/go-gin-api/ngc3x5](https://www.yuque.com/xinliangnote/go-gin-api/ngc3x5)**
## Others
To check Jaeger code [v1.0](https://github.com/xinliangnote/go-gin-api/releases/tag/v1.0)documentation:[jaeger.md](https://github.com/xinliangnote/go-gin-api/blob/master/docs/jaeger.md) 。
## Contributing
Help us with translating `go-gin-api` to your native language.

61
go.mod
View File

@@ -1,50 +1,39 @@
module github.com/xinliangnote/go-gin-api
go 1.15
go 1.16
require (
github.com/99designs/gqlgen v0.13.0
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/99designs/gqlgen v0.14.0
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/dave/dst v0.26.2
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fsnotify/fsnotify v1.4.9
github.com/fsnotify/fsnotify v1.5.1
github.com/gin-contrib/pprof v1.3.0
github.com/gin-gonic/gin v1.7.0
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/go-openapi/spec v0.20.0 // indirect
github.com/go-playground/locales v0.13.0
github.com/go-playground/universal-translator v0.17.0
github.com/go-playground/validator/v10 v10.4.1
github.com/go-redis/redis/v7 v7.4.0
github.com/golang/protobuf v1.5.2
github.com/gin-gonic/gin v1.7.4
github.com/go-playground/locales v0.14.0
github.com/go-playground/universal-translator v0.18.0
github.com/go-playground/validator/v10 v10.9.0
github.com/go-redis/redis/v7 v7.4.1
github.com/gorilla/websocket v1.4.2
github.com/jakecoffman/cron v0.0.0-20190106200828-7e2009c226a5
github.com/jinzhu/gorm v1.9.16
github.com/onsi/ginkgo v1.14.2 // indirect
github.com/onsi/gomega v1.10.4 // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.10.0
github.com/rs/cors v1.7.0
github.com/shirou/gopsutil v3.21.2+incompatible
github.com/speps/go-hashids v2.0.0+incompatible
github.com/spf13/cast v1.3.1
github.com/spf13/viper v1.8.0
github.com/swaggo/gin-swagger v1.3.0
github.com/swaggo/swag v1.7.0
github.com/tklauser/go-sysconf v0.3.4 // indirect
github.com/vektah/gqlparser/v2 v2.1.0
go.uber.org/multierr v1.6.0
go.uber.org/zap v1.17.0
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
golang.org/x/tools v0.1.4
google.golang.org/grpc v1.38.0
github.com/prometheus/client_golang v1.11.0
github.com/rs/cors v1.8.0
github.com/shirou/gopsutil v3.21.10+incompatible
github.com/speps/go-hashids v1.0.0
github.com/spf13/cast v1.4.1
github.com/spf13/viper v1.9.0
github.com/swaggo/gin-swagger v1.3.3
github.com/swaggo/swag v1.7.4
github.com/tklauser/go-sysconf v0.3.9 // indirect
github.com/vektah/gqlparser/v2 v2.2.0
go.uber.org/multierr v1.7.0
go.uber.org/zap v1.19.1
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11
golang.org/x/tools v0.1.7
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gorm.io/driver/mysql v1.0.3
gorm.io/gorm v1.20.9
gorm.io/driver/mysql v1.2.0
gorm.io/gorm v1.22.3
)

506
go.sum

File diff suppressed because it is too large Load Diff

View File

@@ -3,10 +3,10 @@ package admin_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/admin_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/validation"
admin2 "github.com/xinliangnote/go-gin-api/internal/services/admin"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)
@@ -47,7 +47,7 @@ func (h *handler) Create() core.HandlerFunc {
return
}
createData := new(admin_service.CreateAdminData)
createData := new(admin2.CreateAdminData)
createData.Nickname = req.Nickname
createData.Username = req.Username
createData.Mobile = req.Mobile

View File

@@ -3,9 +3,9 @@ package admin_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/admin_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
admin2 "github.com/xinliangnote/go-gin-api/internal/services/admin"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)
@@ -52,7 +52,7 @@ func (h *handler) CreateAdminMenu() core.HandlerFunc {
return
}
createData := new(admin_service.CreateMenuData)
createData := new(admin2.CreateMenuData)
createData.AdminId = int32(ids[0])
createData.Actions = req.Actions

View File

@@ -3,7 +3,7 @@ package admin_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)

View File

@@ -5,21 +5,21 @@ import (
"net/http"
"github.com/xinliangnote/go-gin-api/configs"
"github.com/xinliangnote/go-gin-api/internal/api/service/admin_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/cache"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/api/repository/redis"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/password"
admin2 "github.com/xinliangnote/go-gin-api/internal/services/admin"
"github.com/xinliangnote/go-gin-api/pkg/errno"
"github.com/spf13/cast"
)
type detailResponse struct {
Username string `json:"username"` // 用户名
Nickname string `json:"nickname"` // 昵称
Mobile string `json:"mobile"` // 手机号
Menu []admin_service.ListMyMenuData `json:"menu"` // 菜单栏
Username string `json:"username"` // 用户名
Nickname string `json:"nickname"` // 昵称
Mobile string `json:"mobile"` // 手机号
Menu []admin2.ListMyMenuData `json:"menu"` // 菜单栏
}
// Detail 管理员详情
@@ -35,7 +35,7 @@ func (h *handler) Detail() core.HandlerFunc {
return func(c core.Context) {
res := new(detailResponse)
searchOneData := new(admin_service.SearchOneData)
searchOneData := new(admin2.SearchOneData)
searchOneData.Id = cast.ToInt32(c.UserID())
searchOneData.IsUsed = 1
@@ -49,7 +49,7 @@ func (h *handler) Detail() core.HandlerFunc {
return
}
menuCacheData, err := h.cache.Get(configs.RedisKeyPrefixLoginUser+password.GenerateLoginToken(searchOneData.Id)+":menu", cache.WithTrace(c.Trace()))
menuCacheData, err := h.cache.Get(configs.RedisKeyPrefixLoginUser+password.GenerateLoginToken(searchOneData.Id)+":menu", redis.WithTrace(c.Trace()))
if err != nil {
c.AbortWithError(errno.NewError(
http.StatusBadRequest,
@@ -59,7 +59,7 @@ func (h *handler) Detail() core.HandlerFunc {
return
}
var menuData []admin_service.ListMyMenuData
var menuData []admin2.ListMyMenuData
err = json.Unmarshal([]byte(menuCacheData), &menuData)
if err != nil {
c.AbortWithError(errno.NewError(

View File

@@ -4,12 +4,12 @@ import (
"net/http"
"github.com/xinliangnote/go-gin-api/configs"
"github.com/xinliangnote/go-gin-api/internal/api/service/admin_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/password"
admin2 "github.com/xinliangnote/go-gin-api/internal/services/admin"
"github.com/xinliangnote/go-gin-api/pkg/errno"
"github.com/xinliangnote/go-gin-api/pkg/time_parse"
"github.com/xinliangnote/go-gin-api/pkg/timeutil"
"github.com/spf13/cast"
)
@@ -82,7 +82,7 @@ func (h *handler) List() core.HandlerFunc {
pageSize = 10
}
searchData := new(admin_service.SearchData)
searchData := new(admin2.SearchData)
searchData.Page = page
searchData.PageSize = pageSize
searchData.Username = req.Username
@@ -137,9 +137,9 @@ func (h *handler) List() core.HandlerFunc {
Mobile: v.Mobile,
IsUsed: cast.ToInt(v.IsUsed),
IsOnline: isOnline,
CreatedAt: v.CreatedAt.Format(time_parse.CSTLayout),
CreatedAt: v.CreatedAt.Format(timeutil.CSTLayout),
CreatedUser: v.CreatedUser,
UpdatedAt: v.UpdatedAt.Format(time_parse.CSTLayout),
UpdatedAt: v.UpdatedAt.Format(timeutil.CSTLayout),
UpdatedUser: v.UpdatedUser,
}

View File

@@ -3,9 +3,9 @@ package admin_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/admin_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
admin2 "github.com/xinliangnote/go-gin-api/internal/services/admin"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)
@@ -14,8 +14,8 @@ type listAdminMenuRequest struct {
}
type listAdminMenuResponse struct {
List []admin_service.ListMenuData `json:"list"`
UserName string `json:"username"`
List []admin2.ListMenuData `json:"list"`
UserName string `json:"username"`
}
// ListAdminMenu 菜单授权列表
@@ -51,7 +51,7 @@ func (h *handler) ListAdminMenu() core.HandlerFunc {
return
}
searchOneData := new(admin_service.SearchOneData)
searchOneData := new(admin2.SearchOneData)
searchOneData.Id = int32(ids[0])
searchOneData.IsUsed = 1
@@ -67,7 +67,7 @@ func (h *handler) ListAdminMenu() core.HandlerFunc {
res.UserName = info.Username
searchData := new(admin_service.SearchListMenuData)
searchData := new(admin2.SearchListMenuData)
searchData.AdminId = int32(ids[0])
listData, err := h.adminService.ListMenu(c, searchData)

View File

@@ -6,11 +6,11 @@ import (
"time"
"github.com/xinliangnote/go-gin-api/configs"
"github.com/xinliangnote/go-gin-api/internal/api/service/admin_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/cache"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/api/repository/redis"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/password"
admin2 "github.com/xinliangnote/go-gin-api/internal/services/admin"
"github.com/xinliangnote/go-gin-api/pkg/errno"
"github.com/xinliangnote/go-gin-api/pkg/errors"
)
@@ -48,7 +48,7 @@ func (h *handler) Login() core.HandlerFunc {
return
}
searchOneData := new(admin_service.SearchOneData)
searchOneData := new(admin2.SearchOneData)
searchOneData.Username = req.Username
searchOneData.Password = password.GeneratePassword(req.Password)
searchOneData.IsUsed = 1
@@ -90,7 +90,7 @@ func (h *handler) Login() core.HandlerFunc {
adminJsonInfo, _ := json.Marshal(adminCacheData)
// 将用户信息记录到 Redis 中
err = h.cache.Set(configs.RedisKeyPrefixLoginUser+token, string(adminJsonInfo), time.Hour*24, cache.WithTrace(c.Trace()))
err = h.cache.Set(configs.RedisKeyPrefixLoginUser+token, string(adminJsonInfo), time.Hour*24, redis.WithTrace(c.Trace()))
if err != nil {
c.AbortWithError(errno.NewError(
http.StatusBadRequest,
@@ -100,7 +100,7 @@ func (h *handler) Login() core.HandlerFunc {
return
}
searchMenuData := new(admin_service.SearchMyMenuData)
searchMenuData := new(admin2.SearchMyMenuData)
searchMenuData.AdminId = info.Id
menu, err := h.adminService.MyMenu(c, searchMenuData)
if err != nil {
@@ -116,7 +116,7 @@ func (h *handler) Login() core.HandlerFunc {
menuJsonInfo, _ := json.Marshal(menu)
// 将菜单栏信息记录到 Redis 中
err = h.cache.Set(configs.RedisKeyPrefixLoginUser+token+":menu", string(menuJsonInfo), time.Hour*24, cache.WithTrace(c.Trace()))
err = h.cache.Set(configs.RedisKeyPrefixLoginUser+token+":menu", string(menuJsonInfo), time.Hour*24, redis.WithTrace(c.Trace()))
if err != nil {
c.AbortWithError(errno.NewError(
http.StatusBadRequest,
@@ -126,7 +126,7 @@ func (h *handler) Login() core.HandlerFunc {
return
}
searchActionData := new(admin_service.SearchMyActionData)
searchActionData := new(admin2.SearchMyActionData)
searchActionData.AdminId = info.Id
action, err := h.adminService.MyAction(c, searchActionData)
if err != nil {
@@ -142,7 +142,7 @@ func (h *handler) Login() core.HandlerFunc {
actionJsonInfo, _ := json.Marshal(action)
// 将可访问接口信息记录到 Redis 中
err = h.cache.Set(configs.RedisKeyPrefixLoginUser+token+":action", string(actionJsonInfo), time.Hour*24, cache.WithTrace(c.Trace()))
err = h.cache.Set(configs.RedisKeyPrefixLoginUser+token+":action", string(actionJsonInfo), time.Hour*24, redis.WithTrace(c.Trace()))
if err != nil {
c.AbortWithError(errno.NewError(
http.StatusBadRequest,

View File

@@ -4,8 +4,8 @@ import (
"net/http"
"github.com/xinliangnote/go-gin-api/configs"
"github.com/xinliangnote/go-gin-api/internal/pkg/cache"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/api/repository/redis"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
"github.com/xinliangnote/go-gin-api/pkg/errors"
@@ -23,13 +23,13 @@ type logoutResponse struct {
// @Produce json
// @Success 200 {object} logoutResponse
// @Failure 400 {object} code.Failure
// @Router /api/admin/login [post]
// @Router /api/admin/logout [post]
func (h *handler) Logout() core.HandlerFunc {
return func(c core.Context) {
res := new(logoutResponse)
res.Username = c.UserName()
if !h.cache.Del(configs.RedisKeyPrefixLoginUser+c.GetHeader(configs.HeaderLoginToken), cache.WithTrace(c.Trace())) {
if !h.cache.Del(configs.RedisKeyPrefixLoginUser+c.GetHeader(configs.HeaderLoginToken), redis.WithTrace(c.Trace())) {
c.AbortWithError(errno.NewError(
http.StatusBadRequest,
code.AdminLogOutError,

View File

@@ -3,10 +3,10 @@ package admin_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/admin_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/password"
admin2 "github.com/xinliangnote/go-gin-api/internal/services/admin"
"github.com/xinliangnote/go-gin-api/pkg/errno"
"github.com/spf13/cast"
@@ -47,7 +47,7 @@ func (h *handler) ModifyPassword() core.HandlerFunc {
userId := cast.ToInt32(c.UserID())
searchOneData := new(admin_service.SearchOneData)
searchOneData := new(admin2.SearchOneData)
searchOneData.Id = userId
searchOneData.Password = password.GeneratePassword(req.OldPassword)
searchOneData.IsUsed = 1

View File

@@ -3,9 +3,9 @@ package admin_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/admin_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
admin2 "github.com/xinliangnote/go-gin-api/internal/services/admin"
"github.com/xinliangnote/go-gin-api/pkg/errno"
"github.com/spf13/cast"
@@ -30,7 +30,7 @@ type modifyPersonalInfoResponse struct {
// @Param mobile formData string true "手机号"
// @Success 200 {object} modifyPersonalInfoResponse
// @Failure 400 {object} code.Failure
// @Router /api/admin/modify_password [patch]
// @Router /api/admin/modify_personal_info [patch]
func (h *handler) ModifyPersonalInfo() core.HandlerFunc {
return func(c core.Context) {
req := new(modifyPersonalInfoRequest)
@@ -46,7 +46,7 @@ func (h *handler) ModifyPersonalInfo() core.HandlerFunc {
userId := cast.ToInt32(c.UserID())
modifyData := new(admin_service.ModifyData)
modifyData := new(admin2.ModifyData)
modifyData.Nickname = req.Nickname
modifyData.Mobile = req.Mobile

View File

@@ -4,8 +4,8 @@ import (
"net/http"
"github.com/xinliangnote/go-gin-api/configs"
"github.com/xinliangnote/go-gin-api/internal/pkg/cache"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/api/repository/redis"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/password"
"github.com/xinliangnote/go-gin-api/pkg/errno"
@@ -54,7 +54,7 @@ func (h *handler) Offline() core.HandlerFunc {
id := int32(ids[0])
b := h.cache.Del(configs.RedisKeyPrefixLoginUser+password.GenerateLoginToken(id), cache.WithTrace(c.Trace()))
b := h.cache.Del(configs.RedisKeyPrefixLoginUser+password.GenerateLoginToken(id), redis.WithTrace(c.Trace()))
if !b {
c.AbortWithError(errno.NewError(
http.StatusBadRequest,

View File

@@ -3,7 +3,7 @@ package admin_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)

View File

@@ -3,7 +3,7 @@ package admin_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)

View File

@@ -2,10 +2,10 @@ package admin_handler
import (
"github.com/xinliangnote/go-gin-api/configs"
"github.com/xinliangnote/go-gin-api/internal/api/service/admin_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/cache"
"github.com/xinliangnote/go-gin-api/internal/api/repository/redis"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/db"
admin2 "github.com/xinliangnote/go-gin-api/internal/services/admin"
"github.com/xinliangnote/go-gin-api/pkg/hash"
"go.uber.org/zap"
@@ -84,17 +84,17 @@ type Handler interface {
type handler struct {
logger *zap.Logger
cache cache.Repo
cache redis.Repo
hashids hash.Hash
adminService admin_service.Service
adminService admin2.Service
}
func New(logger *zap.Logger, db db.Repo, cache cache.Repo) Handler {
func New(logger *zap.Logger, db db.Repo, cache redis.Repo) Handler {
return &handler{
logger: logger,
cache: cache,
hashids: hash.New(configs.Get().HashIds.Secret, configs.Get().HashIds.Length),
adminService: admin_service.New(db, cache),
adminService: admin2.New(db, cache),
}
}

View File

@@ -3,9 +3,9 @@ package authorized_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/authorized_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
authorized2 "github.com/xinliangnote/go-gin-api/internal/services/authorized"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)
@@ -44,7 +44,7 @@ func (h *handler) Create() core.HandlerFunc {
return
}
createData := new(authorized_service.CreateAuthorizedData)
createData := new(authorized2.CreateAuthorizedData)
createData.BusinessKey = req.BusinessKey
createData.BusinessDeveloper = req.BusinessDeveloper
createData.Remark = req.Remark

View File

@@ -3,9 +3,9 @@ package authorized_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/authorized_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
authorized2 "github.com/xinliangnote/go-gin-api/internal/services/authorized"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)
@@ -67,7 +67,7 @@ func (h *handler) CreateAPI() core.HandlerFunc {
return
}
createAPIData := new(authorized_service.CreateAuthorizedAPIData)
createAPIData := new(authorized2.CreateAuthorizedAPIData)
createAPIData.BusinessKey = authorizedInfo.BusinessKey
createAPIData.Method = req.Method
createAPIData.API = req.API

View File

@@ -3,7 +3,7 @@ package authorized_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)

View File

@@ -3,7 +3,7 @@ package authorized_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)

View File

@@ -3,11 +3,11 @@ package authorized_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/authorized_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
authorized2 "github.com/xinliangnote/go-gin-api/internal/services/authorized"
"github.com/xinliangnote/go-gin-api/pkg/errno"
"github.com/xinliangnote/go-gin-api/pkg/time_parse"
"github.com/xinliangnote/go-gin-api/pkg/timeutil"
"github.com/spf13/cast"
)
@@ -82,7 +82,7 @@ func (h *handler) List() core.HandlerFunc {
pageSize = 10
}
searchData := new(authorized_service.SearchData)
searchData := new(authorized2.SearchData)
searchData.Page = page
searchData.PageSize = pageSize
searchData.BusinessKey = req.BusinessKey
@@ -132,9 +132,9 @@ func (h *handler) List() core.HandlerFunc {
BusinessDeveloper: v.BusinessDeveloper,
Remark: v.Remark,
IsUsed: cast.ToInt(v.IsUsed),
CreatedAt: v.CreatedAt.Format(time_parse.CSTLayout),
CreatedAt: v.CreatedAt.Format(timeutil.CSTLayout),
CreatedUser: v.CreatedUser,
UpdatedAt: v.UpdatedAt.Format(time_parse.CSTLayout),
UpdatedAt: v.UpdatedAt.Format(timeutil.CSTLayout),
UpdatedUser: v.UpdatedUser,
}

View File

@@ -3,9 +3,9 @@ package authorized_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/authorized_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
authorized2 "github.com/xinliangnote/go-gin-api/internal/services/authorized"
"github.com/xinliangnote/go-gin-api/pkg/errno"
"github.com/spf13/cast"
@@ -75,7 +75,7 @@ func (h *handler) ListAPI() core.HandlerFunc {
res.BusinessKey = authorizedInfo.BusinessKey
searchAPIData := new(authorized_service.SearchAPIData)
searchAPIData := new(authorized2.SearchAPIData)
searchAPIData.BusinessKey = authorizedInfo.BusinessKey
resListData, err := h.authorizedService.ListAPI(c, searchAPIData)

View File

@@ -3,7 +3,7 @@ package authorized_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)

View File

@@ -2,10 +2,10 @@ package authorized_handler
import (
"github.com/xinliangnote/go-gin-api/configs"
"github.com/xinliangnote/go-gin-api/internal/api/service/authorized_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/cache"
"github.com/xinliangnote/go-gin-api/internal/api/repository/redis"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/db"
authorized2 "github.com/xinliangnote/go-gin-api/internal/services/authorized"
"github.com/xinliangnote/go-gin-api/pkg/hash"
"go.uber.org/zap"
@@ -54,16 +54,16 @@ type Handler interface {
type handler struct {
logger *zap.Logger
cache cache.Repo
authorizedService authorized_service.Service
cache redis.Repo
authorizedService authorized2.Service
hashids hash.Hash
}
func New(logger *zap.Logger, db db.Repo, cache cache.Repo) Handler {
func New(logger *zap.Logger, db db.Repo, cache redis.Repo) Handler {
return &handler{
logger: logger,
cache: cache,
authorizedService: authorized_service.New(db, cache),
authorizedService: authorized2.New(db, cache),
hashids: hash.New(configs.Get().HashIds.Secret, configs.Get().HashIds.Length),
}
}

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"github.com/xinliangnote/go-gin-api/configs"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/env"
"github.com/xinliangnote/go-gin-api/pkg/errno"
@@ -72,10 +72,6 @@ func (h *handler) Email() core.HandlerFunc {
return
}
viper.SetConfigName(env.Active().Value() + "_configs")
viper.SetConfigType("toml")
viper.AddConfigPath("./configs")
viper.Set("mail.host", req.Host)
viper.Set("mail.port", cast.ToInt(req.Port))
viper.Set("mail.user", req.User)

View File

@@ -1,7 +1,7 @@
package config_handler
import (
"github.com/xinliangnote/go-gin-api/internal/pkg/cache"
"github.com/xinliangnote/go-gin-api/internal/api/repository/redis"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/db"
@@ -21,10 +21,10 @@ type Handler interface {
type handler struct {
logger *zap.Logger
cache cache.Repo
cache redis.Repo
}
func New(logger *zap.Logger, db db.Repo, cache cache.Repo) Handler {
func New(logger *zap.Logger, db db.Repo, cache redis.Repo) Handler {
return &handler{
logger: logger,
cache: cache,

View File

@@ -3,10 +3,10 @@ package cron_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/cron_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/validation"
cron2 "github.com/xinliangnote/go-gin-api/internal/services/cron"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)
@@ -67,7 +67,7 @@ func (h *handler) Create() core.HandlerFunc {
return
}
createData := new(cron_service.CreateCronTaskData)
createData := new(cron2.CreateCronTaskData)
createData.Name = req.Name
createData.Spec = req.Spec
createData.Command = req.Command

View File

@@ -3,10 +3,10 @@ package cron_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/cron_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/validation"
cron2 "github.com/xinliangnote/go-gin-api/internal/services/cron"
"github.com/xinliangnote/go-gin-api/pkg/errno"
"github.com/spf13/cast"
@@ -66,7 +66,7 @@ func (h *handler) Detail() core.HandlerFunc {
return
}
searchOneData := new(cron_service.SearchOneData)
searchOneData := new(cron2.SearchOneData)
searchOneData.Id = cast.ToInt32(ids[0])
info, err := h.cronService.Detail(ctx, searchOneData)

View File

@@ -3,7 +3,7 @@ package cron_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/validation"
"github.com/xinliangnote/go-gin-api/pkg/errno"

View File

@@ -4,12 +4,12 @@ import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/repository/db_repo/cron_task_repo"
"github.com/xinliangnote/go-gin-api/internal/api/service/cron_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/validation"
cron2 "github.com/xinliangnote/go-gin-api/internal/services/cron"
"github.com/xinliangnote/go-gin-api/pkg/errno"
"github.com/xinliangnote/go-gin-api/pkg/time_parse"
"github.com/xinliangnote/go-gin-api/pkg/timeutil"
"github.com/spf13/cast"
)
@@ -91,7 +91,7 @@ func (h *handler) List() core.HandlerFunc {
pageSize = 10
}
searchData := new(cron_service.SearchData)
searchData := new(cron2.SearchData)
searchData.Page = req.Page
searchData.PageSize = req.PageSize
searchData.Name = req.Name
@@ -151,9 +151,9 @@ func (h *handler) List() core.HandlerFunc {
NotifyStatusText: cron_task_repo.NotifyStatusText[v.NotifyStatus],
IsUsed: cast.ToInt(v.IsUsed),
IsUsedText: cron_task_repo.IsUsedText[v.IsUsed],
CreatedAt: v.CreatedAt.Format(time_parse.CSTLayout),
CreatedAt: v.CreatedAt.Format(timeutil.CSTLayout),
CreatedUser: v.CreatedUser,
UpdatedAt: v.UpdatedAt.Format(time_parse.CSTLayout),
UpdatedAt: v.UpdatedAt.Format(timeutil.CSTLayout),
UpdatedUser: v.UpdatedUser,
}

View File

@@ -3,10 +3,10 @@ package cron_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/cron_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/validation"
cron2 "github.com/xinliangnote/go-gin-api/internal/services/cron"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)
@@ -81,7 +81,7 @@ func (h *handler) Modify() core.HandlerFunc {
id := int32(ids[0])
modifyData := new(cron_service.ModifyCronTaskData)
modifyData := new(cron2.ModifyCronTaskData)
modifyData.Name = req.Name
modifyData.Spec = req.Spec
modifyData.Command = req.Command

View File

@@ -3,7 +3,7 @@ package cron_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/validation"
"github.com/xinliangnote/go-gin-api/pkg/errno"

View File

@@ -2,11 +2,11 @@ package cron_handler
import (
"github.com/xinliangnote/go-gin-api/configs"
"github.com/xinliangnote/go-gin-api/internal/api/service/cron_service"
"github.com/xinliangnote/go-gin-api/internal/api/repository/redis"
"github.com/xinliangnote/go-gin-api/internal/cron/cron_server"
"github.com/xinliangnote/go-gin-api/internal/pkg/cache"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/db"
"github.com/xinliangnote/go-gin-api/internal/services/cron"
"github.com/xinliangnote/go-gin-api/pkg/hash"
"go.uber.org/zap"
@@ -50,17 +50,17 @@ type Handler interface {
type handler struct {
logger *zap.Logger
cache cache.Repo
cache redis.Repo
hashids hash.Hash
cronService cron_service.Service
cronService cron.Service
}
func New(logger *zap.Logger, db db.Repo, cache cache.Repo, cron cron_server.Server) Handler {
func New(logger *zap.Logger, db db.Repo, cache redis.Repo, cronServer cron_server.Server) Handler {
return &handler{
logger: logger,
cache: cache,
hashids: hash.New(configs.Get().HashIds.Secret, configs.Get().HashIds.Length),
cronService: cron_service.New(db, cache, cron),
cronService: cron.New(db, cache, cronServer),
}
}

View File

@@ -3,9 +3,9 @@ package menu_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/menu_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
menu2 "github.com/xinliangnote/go-gin-api/internal/services/menu"
"github.com/xinliangnote/go-gin-api/pkg/errno"
"github.com/spf13/cast"
@@ -60,7 +60,7 @@ func (h *handler) Create() core.HandlerFunc {
id := int32(ids[0])
updateData := new(menu_service.UpdateMenuData)
updateData := new(menu2.UpdateMenuData)
updateData.Name = req.Name
updateData.Icon = req.Icon
updateData.Link = req.Link
@@ -88,7 +88,7 @@ func (h *handler) Create() core.HandlerFunc {
level = 1
}
createData := new(menu_service.CreateMenuData)
createData := new(menu2.CreateMenuData)
createData.Pid = pid
createData.Name = req.Name
createData.Icon = req.Icon

View File

@@ -3,9 +3,9 @@ package menu_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/menu_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
menu2 "github.com/xinliangnote/go-gin-api/internal/services/menu"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)
@@ -56,7 +56,7 @@ func (h *handler) CreateAction() core.HandlerFunc {
id := int32(ids[0])
searchOneData := new(menu_service.SearchOneData)
searchOneData := new(menu2.SearchOneData)
searchOneData.Id = id
menuInfo, err := h.menuService.Detail(c, searchOneData)
if err != nil {
@@ -68,7 +68,7 @@ func (h *handler) CreateAction() core.HandlerFunc {
return
}
createActionData := new(menu_service.CreateMenuActionData)
createActionData := new(menu2.CreateMenuActionData)
createActionData.MenuId = menuInfo.Id
createActionData.Method = req.Method
createActionData.API = req.API

View File

@@ -3,7 +3,7 @@ package menu_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)

View File

@@ -3,7 +3,7 @@ package menu_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)

View File

@@ -3,9 +3,9 @@ package menu_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/menu_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
menu2 "github.com/xinliangnote/go-gin-api/internal/services/menu"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)
@@ -56,7 +56,7 @@ func (h *handler) Detail() core.HandlerFunc {
id := int32(ids[0])
searchOneData := new(menu_service.SearchOneData)
searchOneData := new(menu2.SearchOneData)
searchOneData.Id = id
info, err := h.menuService.Detail(c, searchOneData)

View File

@@ -3,9 +3,9 @@ package menu_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/menu_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
menu2 "github.com/xinliangnote/go-gin-api/internal/services/menu"
"github.com/xinliangnote/go-gin-api/pkg/errno"
"github.com/spf13/cast"
@@ -38,7 +38,7 @@ type listResponse struct {
func (h *handler) List() core.HandlerFunc {
return func(c core.Context) {
res := new(listResponse)
resListData, err := h.menuService.List(c, new(menu_service.SearchData))
resListData, err := h.menuService.List(c, new(menu2.SearchData))
if err != nil {
c.AbortWithError(errno.NewError(
http.StatusBadRequest,

View File

@@ -3,9 +3,9 @@ package menu_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/service/menu_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
menu2 "github.com/xinliangnote/go-gin-api/internal/services/menu"
"github.com/xinliangnote/go-gin-api/pkg/errno"
"github.com/spf13/cast"
@@ -62,7 +62,7 @@ func (h *handler) ListAction() core.HandlerFunc {
id := int32(ids[0])
searchOneData := new(menu_service.SearchOneData)
searchOneData := new(menu2.SearchOneData)
searchOneData.Id = id
menuInfo, err := h.menuService.Detail(c, searchOneData)
@@ -77,7 +77,7 @@ func (h *handler) ListAction() core.HandlerFunc {
res.MenuName = menuInfo.Name
searchListData := new(menu_service.SearchListActionData)
searchListData := new(menu2.SearchListActionData)
searchListData.MenuId = menuInfo.Id
resListData, err := h.menuService.ListAction(c, searchListData)

View File

@@ -3,7 +3,7 @@ package menu_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)

View File

@@ -3,7 +3,7 @@ package menu_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)

View File

@@ -2,10 +2,10 @@ package menu_handler
import (
"github.com/xinliangnote/go-gin-api/configs"
"github.com/xinliangnote/go-gin-api/internal/api/service/menu_service"
"github.com/xinliangnote/go-gin-api/internal/pkg/cache"
"github.com/xinliangnote/go-gin-api/internal/api/repository/redis"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/db"
menu2 "github.com/xinliangnote/go-gin-api/internal/services/menu"
"github.com/xinliangnote/go-gin-api/pkg/hash"
"go.uber.org/zap"
@@ -64,17 +64,17 @@ type Handler interface {
type handler struct {
logger *zap.Logger
cache cache.Repo
cache redis.Repo
hashids hash.Hash
menuService menu_service.Service
menuService menu2.Service
}
func New(logger *zap.Logger, db db.Repo, cache cache.Repo) Handler {
func New(logger *zap.Logger, db db.Repo, cache redis.Repo) Handler {
return &handler{
logger: logger,
cache: cache,
hashids: hash.New(configs.Get().HashIds.Secret, configs.Get().HashIds.Length),
menuService: menu_service.New(db, cache),
menuService: menu2.New(db, cache),
}
}

View File

@@ -3,8 +3,8 @@ package tool_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/cache"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/api/repository/redis"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)
@@ -49,7 +49,7 @@ func (h *handler) ClearCache() core.HandlerFunc {
return
}
b := h.cache.Del(req.RedisKey, cache.WithTrace(c.Trace()))
b := h.cache.Del(req.RedisKey, redis.WithTrace(c.Trace()))
if b != true {
c.AbortWithError(errno.NewError(
http.StatusBadRequest,

View File

@@ -3,7 +3,7 @@ package tool_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)

View File

@@ -3,7 +3,7 @@ package tool_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"

View File

@@ -3,8 +3,8 @@ package tool_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/cache"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/api/repository/redis"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)
@@ -50,7 +50,7 @@ func (h *handler) SearchCache() core.HandlerFunc {
return
}
val, err := h.cache.Get(req.RedisKey, cache.WithTrace(c.Trace()))
val, err := h.cache.Get(req.RedisKey, redis.WithTrace(c.Trace()))
if err != nil {
c.AbortWithError(errno.NewError(
http.StatusBadRequest,

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strings"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"

View File

@@ -4,12 +4,12 @@ import (
"encoding/json"
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/validation"
"github.com/xinliangnote/go-gin-api/internal/websocket/socket_conn/system_message"
"github.com/xinliangnote/go-gin-api/pkg/errno"
"github.com/xinliangnote/go-gin-api/pkg/time_parse"
"github.com/xinliangnote/go-gin-api/pkg/timeutil"
)
type sendMessageRequest struct {
@@ -62,7 +62,7 @@ func (h *handler) SendMessage() core.HandlerFunc {
messageData := new(messageBody)
messageData.Username = ctx.UserName()
messageData.Message = req.Message
messageData.Time = time_parse.CSTLayoutString()
messageData.Time = timeutil.CSTLayoutString()
messageJsonData, err := json.Marshal(messageData)
if err != nil {

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"net/http"
"github.com/xinliangnote/go-gin-api/internal/pkg/code"
"github.com/xinliangnote/go-gin-api/internal/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)

View File

@@ -2,7 +2,7 @@ package tool_handler
import (
"github.com/xinliangnote/go-gin-api/configs"
"github.com/xinliangnote/go-gin-api/internal/pkg/cache"
"github.com/xinliangnote/go-gin-api/internal/api/repository/redis"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/internal/pkg/db"
"github.com/xinliangnote/go-gin-api/pkg/hash"
@@ -59,11 +59,11 @@ type Handler interface {
type handler struct {
logger *zap.Logger
db db.Repo
cache cache.Repo
cache redis.Repo
hashids hash.Hash
}
func New(logger *zap.Logger, db db.Repo, cache cache.Repo) Handler {
func New(logger *zap.Logger, db db.Repo, cache redis.Repo) Handler {
return &handler{
logger: logger,
db: db,

View File

@@ -1,22 +0,0 @@
## repository
#### 数据访问层。
- `./db_repo` 访问 DB 数据
- `./cache_repo` 访问 Cache 数据
#### SQL 建议:
- 建议每张表需包含字段:主键(id)、标记删除(is_deteled)、创建时间(created_at)、更新时间(updated_at)
```mysql
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`is_deleted` tinyint(1) NOT NULL DEFAULT '-1' COMMENT '是否删除 1:是 -1:否',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
```
#### 命名规范:
- 包名应以 `_repo` 结尾;
- `./db_repo` 目录下的包名以 `数据表名`+ `_repo` 命名;

View File

@@ -1,275 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: hello.proto
package hello
import (
context "context"
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// HelloRequest 请求结构
type HelloRequest struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *HelloRequest) Reset() { *m = HelloRequest{} }
func (m *HelloRequest) String() string { return proto.CompactTextString(m) }
func (*HelloRequest) ProtoMessage() {}
func (*HelloRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_61ef911816e0a8ce, []int{0}
}
func (m *HelloRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_HelloRequest.Unmarshal(m, b)
}
func (m *HelloRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_HelloRequest.Marshal(b, m, deterministic)
}
func (m *HelloRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_HelloRequest.Merge(m, src)
}
func (m *HelloRequest) XXX_Size() int {
return xxx_messageInfo_HelloRequest.Size(m)
}
func (m *HelloRequest) XXX_DiscardUnknown() {
xxx_messageInfo_HelloRequest.DiscardUnknown(m)
}
var xxx_messageInfo_HelloRequest proto.InternalMessageInfo
func (m *HelloRequest) GetName() string {
if m != nil {
return m.Name
}
return ""
}
// HelloResponse 响应结构
type HelloResponse struct {
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *HelloResponse) Reset() { *m = HelloResponse{} }
func (m *HelloResponse) String() string { return proto.CompactTextString(m) }
func (*HelloResponse) ProtoMessage() {}
func (*HelloResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_61ef911816e0a8ce, []int{1}
}
func (m *HelloResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_HelloResponse.Unmarshal(m, b)
}
func (m *HelloResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_HelloResponse.Marshal(b, m, deterministic)
}
func (m *HelloResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_HelloResponse.Merge(m, src)
}
func (m *HelloResponse) XXX_Size() int {
return xxx_messageInfo_HelloResponse.Size(m)
}
func (m *HelloResponse) XXX_DiscardUnknown() {
xxx_messageInfo_HelloResponse.DiscardUnknown(m)
}
var xxx_messageInfo_HelloResponse proto.InternalMessageInfo
func (m *HelloResponse) GetMessage() string {
if m != nil {
return m.Message
}
return ""
}
func init() {
proto.RegisterType((*HelloRequest)(nil), "hello.HelloRequest")
proto.RegisterType((*HelloResponse)(nil), "hello.HelloResponse")
}
func init() { proto.RegisterFile("hello.proto", fileDescriptor_61ef911816e0a8ce) }
var fileDescriptor_61ef911816e0a8ce = []byte{
// 154 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xce, 0x48, 0xcd, 0xc9,
0xc9, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x73, 0x94, 0x94, 0xb8, 0x78, 0x3c,
0x40, 0x8c, 0xa0, 0xd4, 0xc2, 0xd2, 0xd4, 0xe2, 0x12, 0x21, 0x21, 0x2e, 0x96, 0xbc, 0xc4, 0xdc,
0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x30, 0x5b, 0x49, 0x93, 0x8b, 0x17, 0xaa, 0xa6,
0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0x48, 0x82, 0x8b, 0x3d, 0x37, 0xb5, 0xb8, 0x38, 0x31, 0x1d,
0xa6, 0x0e, 0xc6, 0x35, 0x6a, 0x60, 0xe4, 0x62, 0x05, 0xab, 0x15, 0x32, 0xe7, 0xe2, 0x08, 0x4e,
0xac, 0x84, 0xb0, 0x85, 0xf5, 0x20, 0x36, 0x23, 0xdb, 0x24, 0x25, 0x82, 0x2a, 0x08, 0x31, 0x5a,
0x89, 0x41, 0xc8, 0x8e, 0x8b, 0xd7, 0x27, 0xbf, 0xa4, 0xd8, 0x3f, 0x2d, 0x28, 0xb5, 0x20, 0x27,
0x33, 0xb5, 0x98, 0x24, 0xdd, 0x06, 0x8c, 0x49, 0x6c, 0x60, 0xff, 0x19, 0x03, 0x02, 0x00, 0x00,
0xff, 0xff, 0x87, 0x17, 0x0f, 0x68, 0xee, 0x00, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// HelloClient is the client API for Hello service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type HelloClient interface {
// 定义 SayHello 方法
SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error)
// 定义 LotsOfReplies 方法
LotsOfReplies(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (Hello_LotsOfRepliesClient, error)
}
type helloClient struct {
cc *grpc.ClientConn
}
func NewHelloClient(cc *grpc.ClientConn) HelloClient {
return &helloClient{cc}
}
func (c *helloClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error) {
out := new(HelloResponse)
err := c.cc.Invoke(ctx, "/hello.Hello/SayHello", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *helloClient) LotsOfReplies(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (Hello_LotsOfRepliesClient, error) {
stream, err := c.cc.NewStream(ctx, &_Hello_serviceDesc.Streams[0], "/hello.Hello/LotsOfReplies", opts...)
if err != nil {
return nil, err
}
x := &helloLotsOfRepliesClient{stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
return x, nil
}
type Hello_LotsOfRepliesClient interface {
Recv() (*HelloResponse, error)
grpc.ClientStream
}
type helloLotsOfRepliesClient struct {
grpc.ClientStream
}
func (x *helloLotsOfRepliesClient) Recv() (*HelloResponse, error) {
m := new(HelloResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// HelloServer is the server API for Hello service.
type HelloServer interface {
// 定义 SayHello 方法
SayHello(context.Context, *HelloRequest) (*HelloResponse, error)
// 定义 LotsOfReplies 方法
LotsOfReplies(*HelloRequest, Hello_LotsOfRepliesServer) error
}
// UnimplementedHelloServer can be embedded to have forward compatible implementations.
type UnimplementedHelloServer struct {
}
func (*UnimplementedHelloServer) SayHello(ctx context.Context, req *HelloRequest) (*HelloResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented")
}
func (*UnimplementedHelloServer) LotsOfReplies(req *HelloRequest, srv Hello_LotsOfRepliesServer) error {
return status.Errorf(codes.Unimplemented, "method LotsOfReplies not implemented")
}
func RegisterHelloServer(s *grpc.Server, srv HelloServer) {
s.RegisterService(&_Hello_serviceDesc, srv)
}
func _Hello_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HelloRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HelloServer).SayHello(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/hello.Hello/SayHello",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HelloServer).SayHello(ctx, req.(*HelloRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Hello_LotsOfReplies_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(HelloRequest)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(HelloServer).LotsOfReplies(m, &helloLotsOfRepliesServer{stream})
}
type Hello_LotsOfRepliesServer interface {
Send(*HelloResponse) error
grpc.ServerStream
}
type helloLotsOfRepliesServer struct {
grpc.ServerStream
}
func (x *helloLotsOfRepliesServer) Send(m *HelloResponse) error {
return x.ServerStream.SendMsg(m)
}
var _Hello_serviceDesc = grpc.ServiceDesc{
ServiceName: "hello.Hello",
HandlerType: (*HelloServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "SayHello",
Handler: _Hello_SayHello_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "LotsOfReplies",
Handler: _Hello_LotsOfReplies_Handler,
ServerStreams: true,
},
},
Metadata: "hello.proto",
}

View File

@@ -1,23 +0,0 @@
syntax = "proto3"; // 指定 proto 版本
package hello; // 指定包名
// 定义 Hello 服务
service Hello {
// 定义 SayHello 方法
rpc SayHello(HelloRequest) returns (HelloResponse) {}
// 定义 LotsOfReplies 方法
rpc LotsOfReplies(HelloRequest) returns (stream HelloResponse){}
}
// HelloRequest 请求结构
message HelloRequest {
string name = 1;
}
// HelloResponse 响应结构
message HelloResponse {
string message = 1;
}

View File

@@ -1,11 +1,12 @@
package cache
package redis
import (
"strings"
"time"
"github.com/xinliangnote/go-gin-api/configs"
"github.com/xinliangnote/go-gin-api/pkg/errors"
"github.com/xinliangnote/go-gin-api/pkg/time_parse"
"github.com/xinliangnote/go-gin-api/pkg/timeutil"
"github.com/xinliangnote/go-gin-api/pkg/trace"
"github.com/go-redis/redis/v7"
@@ -37,6 +38,7 @@ type Repo interface {
Exists(keys ...string) bool
Incr(key string, options ...Option) int64
Close() error
Version() string
}
type cacheRepo struct {
@@ -80,7 +82,7 @@ func (c *cacheRepo) Set(key, value string, ttl time.Duration, options ...Option)
opt := newOption()
defer func() {
if opt.Trace != nil {
opt.Redis.Timestamp = time_parse.CSTLayoutString()
opt.Redis.Timestamp = timeutil.CSTLayoutString()
opt.Redis.Handle = "set"
opt.Redis.Key = key
opt.Redis.Value = value
@@ -107,7 +109,7 @@ func (c *cacheRepo) Get(key string, options ...Option) (string, error) {
opt := newOption()
defer func() {
if opt.Trace != nil {
opt.Redis.Timestamp = time_parse.CSTLayoutString()
opt.Redis.Timestamp = timeutil.CSTLayoutString()
opt.Redis.Handle = "get"
opt.Redis.Key = key
opt.Redis.CostSeconds = time.Since(ts).Seconds()
@@ -162,7 +164,7 @@ func (c *cacheRepo) Del(key string, options ...Option) bool {
opt := newOption()
defer func() {
if opt.Trace != nil {
opt.Redis.Timestamp = time_parse.CSTLayoutString()
opt.Redis.Timestamp = timeutil.CSTLayoutString()
opt.Redis.Handle = "del"
opt.Redis.Key = key
opt.Redis.CostSeconds = time.Since(ts).Seconds()
@@ -187,7 +189,7 @@ func (c *cacheRepo) Incr(key string, options ...Option) int64 {
opt := newOption()
defer func() {
if opt.Trace != nil {
opt.Redis.Timestamp = time_parse.CSTLayoutString()
opt.Redis.Timestamp = timeutil.CSTLayoutString()
opt.Redis.Handle = "incr"
opt.Redis.Key = key
opt.Redis.CostSeconds = time.Since(ts).Seconds()
@@ -216,3 +218,12 @@ func WithTrace(t Trace) Option {
}
}
}
// Version redis server version
func (c *cacheRepo) Version() string {
server := c.client.Info("server").Val()
spl1 := strings.Split(server, "# Server")
spl2 := strings.Split(spl1[1], "redis_version:")
spl3 := strings.Split(spl2[1], "redis_git_sha1:")
return spl3[0]
}

View File

@@ -1,10 +0,0 @@
## service
业务逻辑层。
处于 `controller` 层和 `repository` 层之间,依赖接口开发。
命令规范:
- 包名以 `_service` 结尾。

View File

@@ -1,6 +1,13 @@
package code
import "github.com/xinliangnote/go-gin-api/configs"
import (
_ "embed"
"github.com/xinliangnote/go-gin-api/configs"
)
//go:embed code.go
var ByteCodeFile []byte
// Failure 错误时返回结构
type Failure struct {

Some files were not shown because too many files have changed in this diff Show More