Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 79 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ build:
@go build -ldflags "-w -s -X main.VERSION=$(RELEASE_TAG)" -o $(SERVER_BIN)

# go install github.com/google/wire/cmd/wire@latest
wire:
wire: installCli
@wire gen ./internal/wirex

# go install github.com/swaggo/swag/cmd/swag@latest
swagger:
swagger: installCli
@swag init --parseDependency --generalInfo ./main.go --output ./internal/swagger

# https://github.com/OpenAPITools/openapi-generator
Expand All @@ -45,4 +45,80 @@ serve-d: build
./$(SERVER_BIN) start $(START_ARGS) -d

stop:
./$(SERVER_BIN) stop
./$(SERVER_BIN) stop

installCli:
go install github.com/gin-admin/gin-admin-cli/v10@latest
go install github.com/swaggo/swag/cmd/swag@latest
go install github.com/google/wire/cmd/wire@latest

addStruct: installCli
@if [ ! -n "${m}" ]; then \
echo "补充参数: m=[模块名]"; \
exit 1; \
fi;
@if [ ! -n "${s}" ]; then \
echo "补充参数: s=[结构名(大驼峰命名)]"; \
exit 1; \
fi;
@if [ ! -n "${c}" ]; then \
echo "补充参数: c=[结构注释]"; \
exit 1; \
fi;
gin-admin-cli gen -d . -m ${m} --structs ${s} --structs-comment '${s} ${c}'
git add .

rmStruct: installCli
@if [ ! -n "${m}" ]; then \
echo "补充参数: m=[模块名]"; \
exit 1; \
fi;
@if [ ! -n "${s}" ]; then \
echo "补充参数: s=[结构名]"; \
exit 1; \
fi;
gin-admin-cli rm -d . -m ${m} --structs ${s}

rmModule:
@if [ ! -n "${m}" ]; then \
echo "补充参数: m=[模块名]"; \
exit 1; \
fi;
@if [ ! -d "internal/mods/${m}/api" ]; then \
rm -rf internal/mods/${m}; \
else \
read -p "模块不为空,确认删除?[y/n]" input; \
if [ "$${input}" = "y" ]; then \
rm -rf internal/mods/${m}; \
fi; \
fi;
read -p "手动删除 internal/mods/mods.go 中的模块,然后回车执行 make wire:"
make wire;

gitToDev:
@git add . && \
git commit ; \
git pull origin main && \
current_branch=`git symbolic-ref --short -q HEAD` && \
echo "当前分支:$${current_branch}" && \
git push --set-upstream origin $${current_branch} && \
git checkout dev && \
git pull origin dev && \
git merge $${current_branch} && \
git push origin dev && \
git checkout $${current_branch};


gitToMain:
@git add . && \
git commit ; \
git pull origin main && \
current_branch=`git symbolic-ref --short -q HEAD` && \
echo "当前分支:$${current_branch}" && \
git push --set-upstream origin $${current_branch} && \
git checkout main && \
git pull origin main && \
git merge $${current_branch} && \
git push origin main && \
git checkout $${current_branch};

2 changes: 1 addition & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/urfave/cli/v2"
)

// The function defines a CLI command to start a server with various flags and options, including the
// StartCmd The function defines a CLI command to start a server with various flags and options, including the
// ability to run as a daemon.
func StartCmd() *cli.Command {
return &cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/urfave/cli/v2"
)

// The function defines a CLI command to stop a server by reading a lock file, killing the process with
// StopCmd The function defines a CLI command to stop a server by reading a lock file, killing the process with
// the corresponding PID, and removing the lock file.
func StopCmd() *cli.Command {
return &cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/urfave/cli/v2"
)

// This function creates a CLI command that prints the version number.
// VersionCmd This function creates a CLI command that prints the version number.
func VersionCmd(v string) *cli.Command {
return &cli.Command{
Name: "version",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/stretchr/testify v1.8.4
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.0
github.com/swaggo/swag v1.8.12
github.com/swaggo/swag v1.16.2
github.com/urfave/cli/v2 v2.25.1
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.8.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE=
github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg=
github.com/swaggo/gin-swagger v1.6.0 h1:y8sxvQ3E20/RCyrXeFfg60r6H0Z+SwpTjMYsMm+zy8M=
github.com/swaggo/gin-swagger v1.6.0/go.mod h1:BG00cCEy294xtVpyIAHG6+e2Qzj/xKlRdOqDkvq0uzo=
github.com/swaggo/swag v1.8.12 h1:pctzkNPu0AlQP2royqX3apjKCQonAnf7KGoxeO4y64w=
github.com/swaggo/swag v1.8.12/go.mod h1:lNfm6Gg+oAq3zRJQNEMBE66LIJKM44mxFqhEEgy2its=
github.com/swaggo/swag v1.16.2 h1:28Pp+8DkQoV+HLzLx8RGJZXNGKbFqnuvSbAAtoxiY04=
github.com/swaggo/swag v1.16.2/go.mod h1:6YzXnDcpr0767iOejs318CwYkCQqyGer6BizOg03f+E=
github.com/tailscale/depaware v0.0.0-20210622194025-720c4b409502/go.mod h1:p9lPsd+cx33L3H9nNoecRRxPssFKUwwI50I3pZ0yT+8=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
Expand Down
2 changes: 1 addition & 1 deletion internal/config/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func MustLoad(dir string, names ...string) {
})
}

// Loads configuration files in various formats from a directory and parses them into
// Load configuration files in various formats from a directory and parses them into
// a struct.
func Load(dir string, names ...string) error {
// Set default values
Expand Down
2 changes: 1 addition & 1 deletion internal/mods/mods.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
apiPrefix = "/api/"
)

// Collection of wire providers
// Set Collection of wire providers
var Set = wire.NewSet(
wire.Struct(new(Mods), "*"),
rbac.Set,
Expand Down
9 changes: 9 additions & 0 deletions internal/mods/rbac/api/login.api.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Login struct {
LoginBIZ *biz.Login
}

// GetCaptcha
// @Tags LoginAPI
// @Summary Get captcha ID
// @Success 200 {object} util.ResponseResult{data=schema.Captcha}
Expand All @@ -25,6 +26,7 @@ func (a *Login) GetCaptcha(c *gin.Context) {
util.ResSuccess(c, data)
}

// ResponseCaptcha
// @Tags LoginAPI
// @Summary Response captcha image
// @Param id query string true "Captcha ID"
Expand All @@ -41,6 +43,7 @@ func (a *Login) ResponseCaptcha(c *gin.Context) {
}
}

// Login
// @Tags LoginAPI
// @Summary Login system with username and password
// @Param body body schema.LoginForm true "Request body"
Expand All @@ -64,6 +67,7 @@ func (a *Login) Login(c *gin.Context) {
util.ResSuccess(c, data)
}

// Logout
// @Tags LoginAPI
// @Security ApiKeyAuth
// @Summary Logout system
Expand All @@ -80,6 +84,7 @@ func (a *Login) Logout(c *gin.Context) {
util.ResOK(c)
}

// RefreshToken
// @Tags LoginAPI
// @Security ApiKeyAuth
// @Summary Refresh current access token
Expand All @@ -97,6 +102,7 @@ func (a *Login) RefreshToken(c *gin.Context) {
util.ResSuccess(c, data)
}

// GetUserInfo
// @Tags LoginAPI
// @Security ApiKeyAuth
// @Summary Get current user info
Expand All @@ -114,6 +120,7 @@ func (a *Login) GetUserInfo(c *gin.Context) {
util.ResSuccess(c, data)
}

// UpdatePassword
// @Tags LoginAPI
// @Security ApiKeyAuth
// @Summary Change current user password
Expand All @@ -139,6 +146,7 @@ func (a *Login) UpdatePassword(c *gin.Context) {
util.ResOK(c)
}

// QueryMenus
// @Tags LoginAPI
// @Security ApiKeyAuth
// @Summary Query current user menus based on the current user role
Expand All @@ -156,6 +164,7 @@ func (a *Login) QueryMenus(c *gin.Context) {
util.ResSuccess(c, data)
}

// UpdateUser
// @Tags LoginAPI
// @Security ApiKeyAuth
// @Summary Update current user info
Expand Down
5 changes: 5 additions & 0 deletions internal/mods/rbac/api/menu.api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Menu struct {
MenuBIZ *biz.Menu
}

// Query
// @Tags MenuAPI
// @Security ApiKeyAuth
// @Summary Query menu tree data
Expand All @@ -38,6 +39,7 @@ func (a *Menu) Query(c *gin.Context) {
util.ResPage(c, result.Data, result.PageResult)
}

// Get
// @Tags MenuAPI
// @Security ApiKeyAuth
// @Summary Get menu record by ID
Expand All @@ -56,6 +58,7 @@ func (a *Menu) Get(c *gin.Context) {
util.ResSuccess(c, item)
}

// Create
// @Tags MenuAPI
// @Security ApiKeyAuth
// @Summary Create menu record
Expand Down Expand Up @@ -84,6 +87,7 @@ func (a *Menu) Create(c *gin.Context) {
util.ResSuccess(c, result)
}

// Update
// @Tags MenuAPI
// @Security ApiKeyAuth
// @Summary Update menu record by ID
Expand Down Expand Up @@ -113,6 +117,7 @@ func (a *Menu) Update(c *gin.Context) {
util.ResOK(c)
}

// Delete
// @Tags MenuAPI
// @Security ApiKeyAuth
// @Summary Delete menu record by ID
Expand Down
5 changes: 5 additions & 0 deletions internal/mods/rbac/api/role.api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Role struct {
RoleBIZ *biz.Role
}

// Query
// @Tags RoleAPI
// @Security ApiKeyAuth
// @Summary Query role list
Expand Down Expand Up @@ -39,6 +40,7 @@ func (a *Role) Query(c *gin.Context) {
util.ResPage(c, result.Data, result.PageResult)
}

// Get
// @Tags RoleAPI
// @Security ApiKeyAuth
// @Summary Get role record by ID
Expand All @@ -57,6 +59,7 @@ func (a *Role) Get(c *gin.Context) {
util.ResSuccess(c, item)
}

// Create
// @Tags RoleAPI
// @Security ApiKeyAuth
// @Summary Create role record
Expand Down Expand Up @@ -85,6 +88,7 @@ func (a *Role) Create(c *gin.Context) {
util.ResSuccess(c, result)
}

// Update
// @Tags RoleAPI
// @Security ApiKeyAuth
// @Summary Update role record by ID
Expand Down Expand Up @@ -114,6 +118,7 @@ func (a *Role) Update(c *gin.Context) {
util.ResOK(c)
}

// Delete
// @Tags RoleAPI
// @Security ApiKeyAuth
// @Summary Delete role record by ID
Expand Down
6 changes: 6 additions & 0 deletions internal/mods/rbac/api/user.api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type User struct {
UserBIZ *biz.User
}

// Query
// @Tags UserAPI
// @Security ApiKeyAuth
// @Summary Query user list
Expand Down Expand Up @@ -40,6 +41,7 @@ func (a *User) Query(c *gin.Context) {
util.ResPage(c, result.Data, result.PageResult)
}

// Get
// @Tags UserAPI
// @Security ApiKeyAuth
// @Summary Get user record by ID
Expand All @@ -58,6 +60,7 @@ func (a *User) Get(c *gin.Context) {
util.ResSuccess(c, item)
}

// Create
// @Tags UserAPI
// @Security ApiKeyAuth
// @Summary Create user record
Expand Down Expand Up @@ -86,6 +89,7 @@ func (a *User) Create(c *gin.Context) {
util.ResSuccess(c, result)
}

// Update
// @Tags UserAPI
// @Security ApiKeyAuth
// @Summary Update user record by ID
Expand Down Expand Up @@ -115,6 +119,7 @@ func (a *User) Update(c *gin.Context) {
util.ResOK(c)
}

// Delete
// @Tags UserAPI
// @Security ApiKeyAuth
// @Summary Delete user record by ID
Expand All @@ -133,6 +138,7 @@ func (a *User) Delete(c *gin.Context) {
util.ResOK(c)
}

// ResetPassword
// @Tags UserAPI
// @Security ApiKeyAuth
// @Summary Reset user password by ID
Expand Down
Loading