Compare commits
10 Commits
5e41df7dc2
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| b343856b58 | |||
| 7e282b36d7 | |||
| 237ac665e6 | |||
| 79c19bc47c | |||
| 6beb915adf | |||
| 9be75d53fe | |||
| 2ec091bf59 | |||
| ab51ba91bc | |||
| 75e9157e5e | |||
| 77405783c6 |
@@ -0,0 +1,81 @@
|
|||||||
|
package codegen
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/model/codegen"
|
||||||
|
"sundynix-go/model/commom/response"
|
||||||
|
"sundynix-go/service"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CodegenApi struct{}
|
||||||
|
|
||||||
|
var codegenService = service.ServiceGroupApp.CodegenServiceGroup.CodegenService
|
||||||
|
|
||||||
|
// TestConnection
|
||||||
|
// @Tags 代码生成
|
||||||
|
// @Summary 测试数据库连接
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body codegen.TestConnectionReq true "数据库连接配置"
|
||||||
|
// @Success 200 {object} response.Response "连接成功"
|
||||||
|
// @Router /api/codegen/testConnection [post]
|
||||||
|
func (a *CodegenApi) TestConnection(c *gin.Context) {
|
||||||
|
var req codegen.TestConnectionReq
|
||||||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := codegenService.TestConnection(req.DbConfig); err != nil {
|
||||||
|
response.FailWithMsg("连接失败:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("连接成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preview
|
||||||
|
// @Tags 代码生成
|
||||||
|
// @Summary 预览生成代码(不写文件)
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body codegen.PreviewReq true "代码生成配置"
|
||||||
|
// @Success 200 {object} response.Response{data=[]codegen.PreviewFile} "预览成功"
|
||||||
|
// @Router /api/codegen/preview [post]
|
||||||
|
func (a *CodegenApi) Preview(c *gin.Context) {
|
||||||
|
var req codegen.PreviewReq
|
||||||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
files, err := codegenService.Preview(req.GenConfig)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg("预览失败:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(files, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate
|
||||||
|
// @Tags 代码生成
|
||||||
|
// @Summary 生成并写入代码文件
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body codegen.GenConfig true "代码生成配置(含 outputDir)"
|
||||||
|
// @Success 200 {object} response.Response{data=codegen.GenResult} "生成成功"
|
||||||
|
// @Router /api/codegen/generate [post]
|
||||||
|
func (a *CodegenApi) Generate(c *gin.Context) {
|
||||||
|
var req codegen.GenConfig
|
||||||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
result, err := codegenService.Generate(req)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg("生成失败:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(result, c)
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package codegen
|
||||||
|
|
||||||
|
type ApiGroup struct {
|
||||||
|
CodegenApi
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/api/v1/codegen"
|
||||||
|
"sundynix-go/api/v1/order"
|
||||||
|
"sundynix-go/api/v1/system"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ApiGroupApp = new(ApiGroup)
|
||||||
|
|
||||||
|
// ApiGroup 路由组
|
||||||
|
type ApiGroup struct {
|
||||||
|
SystemApiGroup system.ApiGroup
|
||||||
|
CodegenApiGroup codegen.ApiGroup
|
||||||
|
OrderApiGroup order.ApiGroup
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
type ApiGroup struct {
|
||||||
|
OrderApi
|
||||||
|
RefundApi
|
||||||
|
StockApi
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/commom/response"
|
||||||
|
req "sundynix-go/model/order/request"
|
||||||
|
"sundynix-go/service"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OrderApi struct{}
|
||||||
|
|
||||||
|
var orderService = service.ServiceGroupApp.OrderServiceGroup.OrderService
|
||||||
|
|
||||||
|
// Save
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 新增
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body req.SaveOrderReq true "新增参数"
|
||||||
|
// @Success 200 {object} response.Response "新增成功"
|
||||||
|
// @Router /order/order/save [post]
|
||||||
|
func (a *OrderApi) Save(c *gin.Context) {
|
||||||
|
var r req.SaveOrderReq
|
||||||
|
if err := c.ShouldBindJSON(&r); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := orderService.Save(r); err != nil {
|
||||||
|
global.Logger.Error("新增失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("新增成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 更新
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body req.UpdateOrderReq true "更新参数"
|
||||||
|
// @Success 200 {object} response.Response "更新成功"
|
||||||
|
// @Router /order/order/update [post]
|
||||||
|
func (a *OrderApi) Update(c *gin.Context) {
|
||||||
|
var r req.UpdateOrderReq
|
||||||
|
if err := c.ShouldBindJSON(&r); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := orderService.Update(r); err != nil {
|
||||||
|
global.Logger.Error("更新失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("更新成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 删除(支持批量)
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body object{ids=[]string} true "id列表"
|
||||||
|
// @Success 200 {object} response.Response "删除成功"
|
||||||
|
// @Router /order/order/delete [post]
|
||||||
|
func (a *OrderApi) Delete(c *gin.Context) {
|
||||||
|
var req struct {
|
||||||
|
Ids []string `json:"ids" binding:"required,min=1"`
|
||||||
|
}
|
||||||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := orderService.Delete(req.Ids); err != nil {
|
||||||
|
global.Logger.Error("删除失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("删除成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 获取详情
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Produce json
|
||||||
|
// @Param id query string true "ID"
|
||||||
|
// @Success 200 {object} response.Response "获取详情成功"
|
||||||
|
// @Router /order/order/detail [get]
|
||||||
|
func (a *OrderApi) Detail(c *gin.Context) {
|
||||||
|
id := c.Query("id")
|
||||||
|
data, err := orderService.Detail(id)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取详情失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(data, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 分页获取列表
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body req.ListOrderReq true "分页参数"
|
||||||
|
// @Success 200 {object} response.Response{data=response.PageResult} "获取列表成功"
|
||||||
|
// @Router /order/order/list [post]
|
||||||
|
func (a *OrderApi) List(c *gin.Context) {
|
||||||
|
var r req.ListOrderReq
|
||||||
|
if err := c.ShouldBindJSON(&r); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
list, total, err := orderService.List(r)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取列表失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(response.PageResult{
|
||||||
|
List: list,
|
||||||
|
Total: total,
|
||||||
|
Page: r.Current,
|
||||||
|
PageSize: r.PageSize,
|
||||||
|
}, c)
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/commom/response"
|
||||||
|
req "sundynix-go/model/order/request"
|
||||||
|
"sundynix-go/service"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RefundApi struct{}
|
||||||
|
|
||||||
|
var refundService = service.ServiceGroupApp.OrderServiceGroup.RefundService
|
||||||
|
|
||||||
|
// Save
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 新增
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body req.SaveRefundReq true "新增参数"
|
||||||
|
// @Success 200 {object} response.Response "新增成功"
|
||||||
|
// @Router /order/refund/save [post]
|
||||||
|
func (a *RefundApi) Save(c *gin.Context) {
|
||||||
|
var r req.SaveRefundReq
|
||||||
|
if err := c.ShouldBindJSON(&r); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := refundService.Save(r); err != nil {
|
||||||
|
global.Logger.Error("新增失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("新增成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 更新
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body req.UpdateRefundReq true "更新参数"
|
||||||
|
// @Success 200 {object} response.Response "更新成功"
|
||||||
|
// @Router /order/refund/update [post]
|
||||||
|
func (a *RefundApi) Update(c *gin.Context) {
|
||||||
|
var r req.UpdateRefundReq
|
||||||
|
if err := c.ShouldBindJSON(&r); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := refundService.Update(r); err != nil {
|
||||||
|
global.Logger.Error("更新失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("更新成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 删除(支持批量)
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body object{ids=[]string} true "id列表"
|
||||||
|
// @Success 200 {object} response.Response "删除成功"
|
||||||
|
// @Router /order/refund/delete [post]
|
||||||
|
func (a *RefundApi) Delete(c *gin.Context) {
|
||||||
|
var req struct {
|
||||||
|
Ids []string `json:"ids" binding:"required,min=1"`
|
||||||
|
}
|
||||||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := refundService.Delete(req.Ids); err != nil {
|
||||||
|
global.Logger.Error("删除失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("删除成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 获取详情
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Produce json
|
||||||
|
// @Param id query string true "ID"
|
||||||
|
// @Success 200 {object} response.Response "获取详情成功"
|
||||||
|
// @Router /order/refund/detail [get]
|
||||||
|
func (a *RefundApi) Detail(c *gin.Context) {
|
||||||
|
id := c.Query("id")
|
||||||
|
data, err := refundService.Detail(id)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取详情失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(data, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 分页获取列表
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body req.ListRefundReq true "分页参数"
|
||||||
|
// @Success 200 {object} response.Response{data=response.PageResult} "获取列表成功"
|
||||||
|
// @Router /order/refund/list [post]
|
||||||
|
func (a *RefundApi) List(c *gin.Context) {
|
||||||
|
var r req.ListRefundReq
|
||||||
|
if err := c.ShouldBindJSON(&r); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
list, total, err := refundService.List(r)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取列表失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(response.PageResult{
|
||||||
|
List: list,
|
||||||
|
Total: total,
|
||||||
|
Page: r.Current,
|
||||||
|
PageSize: r.PageSize,
|
||||||
|
}, c)
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/commom/response"
|
||||||
|
req "sundynix-go/model/order/request"
|
||||||
|
"sundynix-go/service"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
type StockApi struct{}
|
||||||
|
|
||||||
|
var stockService = service.ServiceGroupApp.OrderServiceGroup.StockService
|
||||||
|
|
||||||
|
// Save
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 新增
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body req.SaveStockReq true "新增参数"
|
||||||
|
// @Success 200 {object} response.Response "新增成功"
|
||||||
|
// @Router /order/stock/save [post]
|
||||||
|
func (a *StockApi) Save(c *gin.Context) {
|
||||||
|
var r req.SaveStockReq
|
||||||
|
if err := c.ShouldBindJSON(&r); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := stockService.Save(r); err != nil {
|
||||||
|
global.Logger.Error("新增失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("新增成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 更新
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body req.UpdateStockReq true "更新参数"
|
||||||
|
// @Success 200 {object} response.Response "更新成功"
|
||||||
|
// @Router /order/stock/update [post]
|
||||||
|
func (a *StockApi) Update(c *gin.Context) {
|
||||||
|
var r req.UpdateStockReq
|
||||||
|
if err := c.ShouldBindJSON(&r); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := stockService.Update(r); err != nil {
|
||||||
|
global.Logger.Error("更新失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("更新成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 删除(支持批量)
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body object{ids=[]string} true "id列表"
|
||||||
|
// @Success 200 {object} response.Response "删除成功"
|
||||||
|
// @Router /order/stock/delete [post]
|
||||||
|
func (a *StockApi) Delete(c *gin.Context) {
|
||||||
|
var req struct {
|
||||||
|
Ids []string `json:"ids" binding:"required,min=1"`
|
||||||
|
}
|
||||||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := stockService.Delete(req.Ids); err != nil {
|
||||||
|
global.Logger.Error("删除失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("删除成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 获取详情
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Produce json
|
||||||
|
// @Param id query string true "ID"
|
||||||
|
// @Success 200 {object} response.Response "获取详情成功"
|
||||||
|
// @Router /order/stock/detail [get]
|
||||||
|
func (a *StockApi) Detail(c *gin.Context) {
|
||||||
|
id := c.Query("id")
|
||||||
|
data, err := stockService.Detail(id)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取详情失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(data, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List
|
||||||
|
// @Tags 管理
|
||||||
|
// @Summary 分页获取列表
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body req.ListStockReq true "分页参数"
|
||||||
|
// @Success 200 {object} response.Response{data=response.PageResult} "获取列表成功"
|
||||||
|
// @Router /order/stock/list [post]
|
||||||
|
func (a *StockApi) List(c *gin.Context) {
|
||||||
|
var r req.ListStockReq
|
||||||
|
if err := c.ShouldBindJSON(&r); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
list, total, err := stockService.List(r)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取列表失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(response.PageResult{
|
||||||
|
List: list,
|
||||||
|
Total: total,
|
||||||
|
Page: r.Current,
|
||||||
|
PageSize: r.PageSize,
|
||||||
|
}, c)
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/commom/response"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
systemReq "sundynix-go/model/system/request"
|
||||||
|
systemRes "sundynix-go/model/system/response"
|
||||||
|
"sundynix-go/utils/jwt"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/mojocn/base64Captcha"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
var store = base64Captcha.DefaultMemStore
|
||||||
|
|
||||||
|
type AuthApi struct{}
|
||||||
|
|
||||||
|
// Login
|
||||||
|
// @Tags 登录相关
|
||||||
|
// @Summary pc登录
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body systemReq.Login true "用户名, 密码, 验证码,验证码id"
|
||||||
|
// @Success 200 {object} response.Response{msg=string} "登录成功"
|
||||||
|
// @Router /api/auth/login [post]
|
||||||
|
func (a *AuthApi) Login(c *gin.Context) {
|
||||||
|
var l systemReq.Login
|
||||||
|
err := c.ShouldBindJSON(&l)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证码校验:enable-captcha=0 时跳过
|
||||||
|
captchaOk := global.Config.System.EnableCaptcha == 0 ||
|
||||||
|
(l.CaptchaId != "" && l.Captcha != "" && store.Verify(l.CaptchaId, l.Captcha, true))
|
||||||
|
|
||||||
|
if !captchaOk {
|
||||||
|
response.FailWithMsg("验证码错误", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
u := &system.User{Account: l.Account, Password: l.Password}
|
||||||
|
user, err := userService.Login(u)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("登录失败! 用户名不存在或者密码错误!", zap.Error(err))
|
||||||
|
response.FailWithMsg("用户名不存在或者密码错误", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
a.GetToken(c, *user)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logout
|
||||||
|
// @Tags 登录相关
|
||||||
|
// @Summary pc登出
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Produce application/json
|
||||||
|
// @Success 200 {object} response.Response{msg=string} "登出成功"
|
||||||
|
// @Router /api/auth/logout [get]
|
||||||
|
func (a *AuthApi) Logout(c *gin.Context) {
|
||||||
|
token := jwt.GetToken(c)
|
||||||
|
userId := jwt.GetUserId(c)
|
||||||
|
err := jwtService.PutBlacklist(userId, token)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("登出失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg("登出失败", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
jwt.ClearToken(c)
|
||||||
|
response.OkWithMsg("登出成功", c)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Captcha
|
||||||
|
// @Tags 登录相关
|
||||||
|
// @Summary 获取验证码
|
||||||
|
// @Produce application/json
|
||||||
|
// @Success 200 {object} response.Response{data=systemRes.CaptchaRes} "获取验证码"
|
||||||
|
// @Router /api/auth/captcha [get]
|
||||||
|
func (u *AuthApi) Captcha(c *gin.Context) {
|
||||||
|
var driver = base64Captcha.DriverString{
|
||||||
|
Height: 80,
|
||||||
|
Width: 240,
|
||||||
|
NoiseCount: 2,
|
||||||
|
ShowLineOptions: 4,
|
||||||
|
Length: 4,
|
||||||
|
Source: "1234567890",
|
||||||
|
}
|
||||||
|
|
||||||
|
cp := base64Captcha.NewCaptcha(&driver, store)
|
||||||
|
id, b64s, _, err := cp.Generate()
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("GenerateCaptcha err", zap.Error(err))
|
||||||
|
response.FailWithMsg("GenerateCaptcha err", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(systemRes.CaptchaRes{
|
||||||
|
CaptchaId: id,
|
||||||
|
Captcha: b64s,
|
||||||
|
}, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AuthApi) GetToken(c *gin.Context, user system.User) {
|
||||||
|
token, claims, err := jwt.GetLoginToken(&user)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("GetToken err", zap.Error(err))
|
||||||
|
response.FailWithMsg("GetToken err", c)
|
||||||
|
}
|
||||||
|
response.OkWithData(systemRes.LoginResponse{
|
||||||
|
ExpiresAt: claims.RegisteredClaims.ExpiresAt.Unix() * 1000,
|
||||||
|
Token: token,
|
||||||
|
User: user,
|
||||||
|
}, c)
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import "sundynix-go/service"
|
||||||
|
|
||||||
|
type ApiGroup struct {
|
||||||
|
AuthApi
|
||||||
|
UserApi
|
||||||
|
ClientApi
|
||||||
|
RoleApi
|
||||||
|
MenuApi
|
||||||
|
OperationRecordApi
|
||||||
|
OssApi
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
jwtService = service.ServiceGroupApp.SystemServiceGroup.JwtService
|
||||||
|
userService = service.ServiceGroupApp.SystemServiceGroup.UserService
|
||||||
|
clientService = service.ServiceGroupApp.SystemServiceGroup.ClientService
|
||||||
|
roleService = service.ServiceGroupApp.SystemServiceGroup.RoleService
|
||||||
|
menuService = service.ServiceGroupApp.SystemServiceGroup.MenuService
|
||||||
|
operationRecordService = service.ServiceGroupApp.SystemServiceGroup.OperationRecordService
|
||||||
|
ossService = service.ServiceGroupApp.SystemServiceGroup.OssService
|
||||||
|
)
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/commom/request"
|
||||||
|
"sundynix-go/model/commom/response"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
sysReq "sundynix-go/model/system/request"
|
||||||
|
sysResp "sundynix-go/model/system/response"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OssApi struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// UploadFile
|
||||||
|
// @tags 文件相关
|
||||||
|
// @Summary 文件上传
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept multipart/form-data
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param file formData file true "上传文件"
|
||||||
|
// @Success 200 {object} response.Response{msg=string} "上传文件"
|
||||||
|
// @router /api/oss/upload [post]
|
||||||
|
func (o *OssApi) UploadFile(c *gin.Context) {
|
||||||
|
var file system.Oss
|
||||||
|
_, header, err := c.Request.FormFile("file")
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("接收文件失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg("接收文件失败!", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
file, err = ossService.Upload(header) //上传完成后拿到文件信息
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("上传文件失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg("上传文件失败!", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(sysResp.UploadFileResponse{File: file}, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteFile
|
||||||
|
// @tags 文件相关
|
||||||
|
// @Summary 删除文件
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body request.IdsReq true "批量删除文件"
|
||||||
|
// @Success 200 {object} response.Response{msg=string} "删除文件"
|
||||||
|
// @router /api/oss/delete [post]
|
||||||
|
func (o *OssApi) DeleteFile(c *gin.Context) {
|
||||||
|
var ids request.IdsReq
|
||||||
|
err := c.ShouldBindJSON(&ids)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = ossService.DeleteFileByIds(ids)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("删除文件失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg("删除文件失败!", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("删除文件成功!", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetFileList
|
||||||
|
// @tags 文件相关
|
||||||
|
// @Summary 文件列表
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body sysReq.GetOssFileList true "文件列表"
|
||||||
|
// @Success 200 {object} response.Response{data=string} "文件列表"
|
||||||
|
// @router /api/oss/getFileList [post]
|
||||||
|
func (o *OssApi) GetFileList(c *gin.Context) {
|
||||||
|
var pageInfo sysReq.GetOssFileList
|
||||||
|
err := c.ShouldBindJSON(&pageInfo)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
list, total, err := ossService.GetFileList(pageInfo)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取文件列表失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg("获取文件列表失败!", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(response.PageResult{
|
||||||
|
List: list,
|
||||||
|
Total: total,
|
||||||
|
Page: pageInfo.Current,
|
||||||
|
PageSize: pageInfo.PageSize,
|
||||||
|
}, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail
|
||||||
|
// @tags 文件相关
|
||||||
|
// @Summary 文件详情
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param id query string true "文件id"
|
||||||
|
// @Success 200 {object} response.Response{data=string} "文件详情"
|
||||||
|
// @router /api/oss/detail [get]
|
||||||
|
func (o *OssApi) Detail(c *gin.Context) {
|
||||||
|
id := c.Query("id")
|
||||||
|
file, err := ossService.GetById(id)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取文件详情失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(file, c)
|
||||||
|
}
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/commom/request"
|
||||||
|
"sundynix-go/model/commom/response"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
systemReq "sundynix-go/model/system/request"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ClientApi struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveClient
|
||||||
|
// @Tags 客户端管理
|
||||||
|
// @Summary 创建client
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body system.Client true "client"
|
||||||
|
// @Success 200 {object} response.Response{msg=string} "创建client"
|
||||||
|
// @Router /api/client/save [post]
|
||||||
|
func (s *ClientApi) SaveClient(c *gin.Context) {
|
||||||
|
var client system.Client
|
||||||
|
err := c.ShouldBindJSON(&client)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = clientService.SaveClient(client)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("保存客户端失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("保存客户端成功!", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateClient
|
||||||
|
// @Tags 客户端管理
|
||||||
|
// @Summary 更新client
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body system.Client true "client"
|
||||||
|
// @Success 200 {object} response.Response{msg=string} "更新client"
|
||||||
|
// @Router /api/client/update [post]
|
||||||
|
func (s *ClientApi) UpdateClient(c *gin.Context) {
|
||||||
|
var client system.Client
|
||||||
|
err := c.ShouldBindJSON(&client)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = clientService.UpdateClient(client)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("更新客户端失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("更新客户端成功!", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetClientList
|
||||||
|
// @Tags 客户端管理
|
||||||
|
// @Summary 获取client列表
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body systemReq.GetClientList true "client"
|
||||||
|
// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取client列表"
|
||||||
|
// @Router /api/client/getClientList [post]
|
||||||
|
func (s *ClientApi) GetClientList(c *gin.Context) {
|
||||||
|
var pageInfo systemReq.GetClientList
|
||||||
|
err := c.ShouldBindJSON(&pageInfo)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
list, total, err := clientService.GetClientList(pageInfo)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取客户端列表失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(response.PageResult{
|
||||||
|
List: list,
|
||||||
|
Total: total,
|
||||||
|
Page: pageInfo.Current,
|
||||||
|
PageSize: pageInfo.PageSize,
|
||||||
|
}, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
// @Tags 客户端管理
|
||||||
|
// @Summary 删除client
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body request.IdsReq true "ids"
|
||||||
|
// @Success 200 {object} response.Response{msg=string} "删除client"
|
||||||
|
// @Router /api/client/delete [post]
|
||||||
|
func (s *ClientApi) Delete(c *gin.Context) {
|
||||||
|
var ids request.IdsReq
|
||||||
|
err := c.ShouldBindJSON(&ids)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = clientService.DeleteClientByIds(ids)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("删除客户端失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("删除客户端成功!", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail
|
||||||
|
// @Tags 客户端管理
|
||||||
|
// @Summary 获取client详情
|
||||||
|
// @Description id获取详情
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param id query string true "id"
|
||||||
|
// @Success 200 {object} response.Response{data=system.Client,msg=string} "获取client详情"
|
||||||
|
// @Router /api/client/detail [get]
|
||||||
|
func (s *ClientApi) Detail(c *gin.Context) {
|
||||||
|
id := c.Query("id")
|
||||||
|
client, err := clientService.GetClientById(id)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取客户端详情失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(client, c)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/commom/response"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
systemReq "sundynix-go/model/system/request"
|
||||||
|
"sundynix-go/utils/jwt"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MenuApi struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveMenu
|
||||||
|
// @Tags 菜单管理
|
||||||
|
// @Summary 新增菜单
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body system.Menu false "menu"
|
||||||
|
// @Success 200 {object} response.Response{msg=string} "新建菜单/按钮"
|
||||||
|
// @Router /api/menu/save [post]
|
||||||
|
func (m *MenuApi) SaveMenu(c *gin.Context) {
|
||||||
|
var menu system.Menu
|
||||||
|
err := c.ShouldBindJSON(&menu)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = menuService.SaveMenu(menu); err != nil {
|
||||||
|
global.Logger.Error("保存菜单失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
response.OkWithMsg("保存菜单成功!", c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateMenu
|
||||||
|
// @Tags 菜单管理
|
||||||
|
// @Summary 更新菜单
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body system.Menu false "menu"
|
||||||
|
// @Success 200 {object} response.Response{msg=string} "更新菜单"
|
||||||
|
// @Router /menu/update [post]
|
||||||
|
func (m *MenuApi) UpdateMenu(c *gin.Context) {
|
||||||
|
var menu system.Menu
|
||||||
|
err := c.ShouldBindJSON(&menu)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = menuService.UpdateMenu(&menu); err != nil {
|
||||||
|
global.Logger.Error("更新菜单失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
response.OkWithMsg("更新菜单成功!", c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteMenu
|
||||||
|
// @Tags 菜单管理
|
||||||
|
// @Summary 删除menu
|
||||||
|
// @Description 删除menu
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param id query string true "id"
|
||||||
|
// @Success 200 {object} response.Response{msg=string} "详情"
|
||||||
|
// @Router /api/menu/delete [get]
|
||||||
|
func (m *MenuApi) DeleteMenu(c *gin.Context) {
|
||||||
|
id := c.Query("id")
|
||||||
|
err := menuService.DeleteMenu(id)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("删除菜单失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("删除菜单成功!", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail
|
||||||
|
// @Tags 菜单管理
|
||||||
|
// @Summary 获取menu详情
|
||||||
|
// @Description id获取详情
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param id query string true "id"
|
||||||
|
// @Success 200 {object} response.Response{data=system.Menu,msg=string} "详情"
|
||||||
|
// @Router /api/menu/detail [get]
|
||||||
|
func (m *MenuApi) Detail(c *gin.Context) {
|
||||||
|
id := c.Query("id")
|
||||||
|
menu, err := menuService.GetMenuById(id)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取菜单详情失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(menu, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAllMenuTree
|
||||||
|
// @Tags 菜单管理
|
||||||
|
// @Summary 获取所有菜单树
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body systemReq.GetMenuTree true "菜单信息"
|
||||||
|
// @Success 200 {object} response.Response{data=[]system.Menu,msg=string} "获取所有菜单树"
|
||||||
|
// @Router /api/menu/getAllMenuTree [post]
|
||||||
|
func (m *MenuApi) GetAllMenuTree(c *gin.Context) {
|
||||||
|
var param systemReq.GetMenuTree
|
||||||
|
err := c.ShouldBindJSON(¶m)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
menus, err := menuService.GetAllMenuTree(param.Category, param.ParentId)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取菜单树结构失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(menus, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserMenuTree
|
||||||
|
// @Tags 菜单管理
|
||||||
|
// @Summary 用户菜单数据
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {object} response.Response{data=[]system.Menu,msg=string} "用户菜单数据"
|
||||||
|
// @Router /api/menu/getUserMenuTree [get]
|
||||||
|
func (m *MenuApi) GetUserMenuTree(c *gin.Context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Route
|
||||||
|
// @Tags 菜单管理
|
||||||
|
// @Summary 用户路由
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {object} response.Response{data=[]system.Menu,msg=string} "用户route"
|
||||||
|
// @Router /api/menu/route [get]
|
||||||
|
func (m *MenuApi) Route(c *gin.Context) {
|
||||||
|
userId := jwt.GetUserId(c)
|
||||||
|
routes, err := menuService.GetUserRoutes(userId)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取用户菜单失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(routes, c)
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/commom/request"
|
||||||
|
"sundynix-go/model/commom/response"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
systemReq "sundynix-go/model/system/request"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OperationRecordApi struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *OperationRecordApi) CreateOperationRecord(c *gin.Context) {
|
||||||
|
var sysOperationRecord system.SysOperationRecord
|
||||||
|
err := c.ShouldBindJSON(&sysOperationRecord)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = operationRecordService.CreateOperationRecord(sysOperationRecord)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("创建操作记录失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("创建操作记录成功!", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *OperationRecordApi) GetRecordList(c *gin.Context) {
|
||||||
|
var pageInfo systemReq.GetOperationRecordList
|
||||||
|
err := c.ShouldBindJSON(&pageInfo)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
list, total, err := operationRecordService.GetRecordList(pageInfo)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取操作记录列表失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(response.PageResult{
|
||||||
|
List: list,
|
||||||
|
Total: total,
|
||||||
|
Page: pageInfo.Current,
|
||||||
|
PageSize: pageInfo.PageSize,
|
||||||
|
}, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *OperationRecordApi) GetRecordById(c *gin.Context) {
|
||||||
|
id := c.Query("id")
|
||||||
|
record, err := operationRecordService.GetRecordById(id)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取操作记录详情失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(record, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *OperationRecordApi) DeleteRecordsByIds(c *gin.Context) {
|
||||||
|
var ids request.IdsReq
|
||||||
|
err := c.ShouldBindJSON(&ids)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = operationRecordService.DeleteRecordsByIds(ids)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("删除操作记录失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("删除操作记录成功!", c)
|
||||||
|
}
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/commom/request"
|
||||||
|
"sundynix-go/model/commom/response"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
systemreq "sundynix-go/model/system/request"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RoleApi struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveRole
|
||||||
|
// @tags 角色管理
|
||||||
|
// @Summary 创建角色
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body system.Role true "角色信息"
|
||||||
|
// @Success 200 {object} response.Response
|
||||||
|
// @Router /api/role/save [post]
|
||||||
|
func (a *RoleApi) SaveRole(context *gin.Context) {
|
||||||
|
var role system.Role
|
||||||
|
err := context.ShouldBindJSON(&role)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg("参数错误"+err.Error(), context)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = roleService.SaveRole(role)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("保存角色失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), context)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("保存角色成功!", context)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateRole
|
||||||
|
// @tags 角色管理
|
||||||
|
// @Summary 修改角色
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body system.Role true "角色ID"
|
||||||
|
// @Success 200 {object} response.Response"
|
||||||
|
// @Router /api/role/update [post]
|
||||||
|
func (a *RoleApi) UpdateRole(context *gin.Context) {
|
||||||
|
var role system.Role
|
||||||
|
err := context.ShouldBindJSON(&role)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), context)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = roleService.UpdateRole(role)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("更新角色失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), context)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("更新角色成功!", context)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRoleList
|
||||||
|
// @tags 角色管理
|
||||||
|
// @Summary 获取角色列表
|
||||||
|
// @Description 获取角色列表
|
||||||
|
// @Accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body systemreq.GetRoleList true "页码, 每页大小, 搜索条件"
|
||||||
|
// @success 200 {object} response.Response{data=response.PageResult,msg=string} "获取角色列表,返回包括列表,总数,页码,每页大小"
|
||||||
|
// @Router /api/role/getRoleList [post]
|
||||||
|
func (a *RoleApi) GetRoleList(c *gin.Context) {
|
||||||
|
var pageInfo systemreq.GetRoleList
|
||||||
|
err := c.ShouldBindJSON(&pageInfo)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
list, total, err := roleService.GetRoleList(pageInfo)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取角色列表失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
}
|
||||||
|
response.OkWithData(response.PageResult{
|
||||||
|
List: list,
|
||||||
|
Total: total,
|
||||||
|
Page: pageInfo.Current,
|
||||||
|
PageSize: pageInfo.PageSize,
|
||||||
|
}, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
// @Tags 角色管理
|
||||||
|
// @Summary 删除角色
|
||||||
|
// @Description 删除角色
|
||||||
|
// @Accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body request.IdsReq true "批量删除角色"
|
||||||
|
// @Success 200 {object} response.Response{msg=string} "删除角色"
|
||||||
|
// @Router /api/role/delete [post]
|
||||||
|
func (a *RoleApi) Delete(context *gin.Context) {
|
||||||
|
var ids request.IdsReq
|
||||||
|
err := context.ShouldBindJSON(&ids)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), context)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = roleService.DeleteRoleByIds(ids)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("删除角色失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), context)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("删除角色成功!", context)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail
|
||||||
|
// @Tags 角色管理
|
||||||
|
// @Summary 角色详情
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param id query string true "id"
|
||||||
|
// @Success 200 {object} response.Response{data=system.Role} "角色详情"
|
||||||
|
// @Router /api/role/detail [get]
|
||||||
|
func (a *RoleApi) Detail(context *gin.Context) {
|
||||||
|
id := context.Query("id")
|
||||||
|
role, err := roleService.GetRoleById(id)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取角色详情失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), context)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(role, context)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantMenu
|
||||||
|
// @tags 角色管理
|
||||||
|
// @Summary 授权菜单给角色
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body systemreq.GrantMenu true "授权菜单给角色"
|
||||||
|
// @success 200 {object} response.Response "授权菜单给角色"
|
||||||
|
// @Router /api/role/grantMenu [post]
|
||||||
|
func (a *RoleApi) GrantMenu(c *gin.Context) {
|
||||||
|
var grantMenu systemreq.GrantMenu
|
||||||
|
err := c.ShouldBindJSON(&grantMenu)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = roleService.GrantMenu(grantMenu.RoleId, grantMenu.MenuIds)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("授权菜单失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("授权菜单成功!", c)
|
||||||
|
}
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/commom/request"
|
||||||
|
"sundynix-go/model/commom/response"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
systemReq "sundynix-go/model/system/request"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserApi struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveUser
|
||||||
|
// @tags 用户管理
|
||||||
|
// @Summary 新增用户
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body system.User true "用户信息"
|
||||||
|
// @Success 200 {object} response.Response "{"code": 200, "data": {}, "msg": "添加成功"}"
|
||||||
|
// @Router /api/user/save [post]
|
||||||
|
func (u *UserApi) SaveUser(c *gin.Context) {
|
||||||
|
var user system.User
|
||||||
|
err := c.ShouldBindJSON(&user)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = userService.SaveUser(user); err != nil {
|
||||||
|
global.Logger.Error("保存用户失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
} else {
|
||||||
|
response.OkWithMsg("保存用户成功!", c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateUser
|
||||||
|
// @tags 用户管理
|
||||||
|
// @Summary 更新用户
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body system.User true "用户ID,用户信息"
|
||||||
|
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||||
|
// @Router /api/user/update [post]
|
||||||
|
func (u *UserApi) UpdateUser(c *gin.Context) {
|
||||||
|
var user system.User
|
||||||
|
err := c.ShouldBindJSON(&user)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = userService.UpdateUser(&user); err != nil {
|
||||||
|
global.Logger.Error("更新用户失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
} else {
|
||||||
|
response.OkWithMsg("更新用户成功!", c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserList
|
||||||
|
// @tags 用户管理
|
||||||
|
// @Summary 获取用户列表
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body systemReq.GetUserList true "页码, 每页大小, 搜索条件"
|
||||||
|
// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取用户列表,返回包括列表,总数,页码,每页大小"
|
||||||
|
// @Router /api/user/getUserList [post]
|
||||||
|
func (u *UserApi) GetUserList(c *gin.Context) {
|
||||||
|
var pageInfo systemReq.GetUserList
|
||||||
|
err := c.ShouldBindJSON(&pageInfo)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
list, total, err := userService.GetUserList(pageInfo)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取用户列表失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(response.PageResult{
|
||||||
|
List: list,
|
||||||
|
Total: total,
|
||||||
|
Page: pageInfo.Current,
|
||||||
|
PageSize: pageInfo.PageSize,
|
||||||
|
}, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
// @Tags 用户管理
|
||||||
|
// @Summary 删除用户
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body request.IdsReq true "批量删除用户"
|
||||||
|
// @Success 200 {object} response.Response{msg=string} "删除用户"
|
||||||
|
// @Router /api/user/delete [post]
|
||||||
|
func (u *UserApi) Delete(c *gin.Context) {
|
||||||
|
var ids request.IdsReq
|
||||||
|
err := c.ShouldBindJSON(&ids)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = userService.DeleteUserByIds(ids)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("删除用户失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("删除用户成功!", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail
|
||||||
|
// @Tags 用户管理
|
||||||
|
// @Summary 获取用户详情
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param id query string true "id"
|
||||||
|
// @Success 200 {object} response.Response{data=system.User} "获取用户详情成功"
|
||||||
|
// @Router /api/user/detail [get]
|
||||||
|
func (u *UserApi) Detail(c *gin.Context) {
|
||||||
|
id := c.Query("id")
|
||||||
|
user, err := userService.GetUserById(id)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取用户详情失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(user, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChangePassword
|
||||||
|
// @Tags 用户管理
|
||||||
|
// @Summary 修改密码
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Description 修改密码
|
||||||
|
// @accept json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body request.ChangePwd true "用户id"
|
||||||
|
// @Success 200 {object} response.Response{data=system.User} "修改密码成功"
|
||||||
|
// @Router /api/user/changePassword [post]
|
||||||
|
func (u *UserApi) ChangePassword(c *gin.Context) {
|
||||||
|
var changePwd systemReq.ChangePwd
|
||||||
|
err := c.ShouldBindJSON(&changePwd)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = userService.ChangePassword(changePwd.Id, changePwd.NewPwd)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("修改密码失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("修改密码成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantRole
|
||||||
|
// @Tags 用户管理
|
||||||
|
// @Summary 给用户分配角色
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// @Param data body systemReq.GrantRole true "用户ID, 角色ID"
|
||||||
|
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||||
|
// @Router /api/user/grantRole [post]
|
||||||
|
func (u *UserApi) GrantRole(c *gin.Context) {
|
||||||
|
var grantRole systemReq.GrantRole
|
||||||
|
err := c.ShouldBindJSON(&grantRole)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = roleService.GrantRole(grantRole.UserId, grantRole.RoleIds)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("授权角色失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("授权角色成功!", c)
|
||||||
|
}
|
||||||
+13
-2
@@ -1,6 +1,17 @@
|
|||||||
system:
|
system:
|
||||||
addr: 8888
|
addr: 8889
|
||||||
db-type: mysql
|
db-type: mysql
|
||||||
|
router-prefix: "api"
|
||||||
|
enable-captcha: 0
|
||||||
|
oss-type: minio
|
||||||
|
|
||||||
|
jwt:
|
||||||
|
buffer-time: 1d
|
||||||
|
expires-time: 7d
|
||||||
|
issuer: sunfynix
|
||||||
|
signing-key: 9149f2eb-d517-4a50-a03a-231dbcf0d872
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mysql:
|
mysql:
|
||||||
config: charset=utf8mb4&parseTime=True&loc=Local
|
config: charset=utf8mb4&parseTime=True&loc=Local
|
||||||
@@ -12,7 +23,7 @@ mysql:
|
|||||||
max-open-conns: 100
|
max-open-conns: 100
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
port: "3306"
|
port: "3306"
|
||||||
prefix: "sundynix-"
|
prefix: "sundynix_"
|
||||||
singular: true
|
singular: true
|
||||||
user: root
|
user: root
|
||||||
password: root
|
password: root
|
||||||
|
|||||||
+8
-1
@@ -2,6 +2,13 @@ system:
|
|||||||
addr: 8888
|
addr: 8888
|
||||||
db-type: mysql
|
db-type: mysql
|
||||||
|
|
||||||
|
captcha:
|
||||||
|
img-height: 80
|
||||||
|
img-width: 240
|
||||||
|
key-long: 6
|
||||||
|
open-captcha: 0
|
||||||
|
open-captcha-timeout: 3600
|
||||||
|
|
||||||
mysql:
|
mysql:
|
||||||
config: charset=utf8mb4&parseTime=True&loc=Local
|
config: charset=utf8mb4&parseTime=True&loc=Local
|
||||||
db-name: sundynix_go
|
db-name: sundynix_go
|
||||||
@@ -10,7 +17,7 @@ mysql:
|
|||||||
log-zap: true
|
log-zap: true
|
||||||
max-idle-conns: 10
|
max-idle-conns: 10
|
||||||
max-open-conns: 100
|
max-open-conns: 100
|
||||||
host: 92.168.100.127
|
host: 127.0.0.1
|
||||||
port: "3306"
|
port: "3306"
|
||||||
prefix: "sundynix-"
|
prefix: "sundynix-"
|
||||||
singular: false
|
singular: false
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
JWT JWT `mapstructure:"jwt" json:"jwt" yaml:"jwt"`
|
||||||
System System `mapstructure:"system" json:"system" yaml:"system"`
|
System System `mapstructure:"system" json:"system" yaml:"system"`
|
||||||
Mysql Mysql `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
|
Mysql Mysql `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
|
||||||
Pgsql Pgsql `mapstructure:"pgsql" json:"pgsql" yaml:"pgsql"`
|
Pgsql Pgsql `mapstructure:"pgsql" json:"pgsql" yaml:"pgsql"`
|
||||||
Sqlite Sqlite `mapstructure:"sqlite" json:"sqlite" yaml:"sqlite"`
|
Sqlite Sqlite `mapstructure:"sqlite" json:"sqlite" yaml:"sqlite"`
|
||||||
Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"`
|
Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"`
|
||||||
Zap Zap `mapstructure:"zap" json:"zap" yaml:"zap"`
|
Zap Zap `mapstructure:"zap" json:"zap" yaml:"zap"`
|
||||||
|
|
||||||
|
Minio Minio `mapstructure:"minio" json:"minio" yaml:"minio"`
|
||||||
|
RocketMQConfig RocketMQConfig `mapstructure:"rocket-mq" json:"rocket-mq" yaml:"rocket-mq"`
|
||||||
|
TencentCOS TencentCOS `mapstructure:"tencent-cos" json:"tencent-cos" yaml:"tencent-cos"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
type JWT struct {
|
||||||
|
SigningKey string `mapstructure:"signing-key" json:"signing-key" yaml:"signing-key"` // jwt签名
|
||||||
|
ExpiresTime string `mapstructure:"expires-time" json:"expires-time" yaml:"expires-time"` // 过期时间
|
||||||
|
BufferTime string `mapstructure:"buffer-time" json:"buffer-time" yaml:"buffer-time"` // 缓冲时间
|
||||||
|
Issuer string `mapstructure:"issuer" json:"issuer" yaml:"issuer"` // 签发者
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
type Minio struct {
|
||||||
|
Endpoint string `mapstructure:"endpoint" json:"endpoint" yaml:"endpoint"`
|
||||||
|
AccessKeyId string `mapstructure:"access-key-id" json:"access-key-id" yaml:"access-key-id"`
|
||||||
|
AccessKeySecret string `mapstructure:"access-key-secret" json:"access-key-secret" yaml:"access-key-secret"`
|
||||||
|
BucketName string `mapstructure:"bucket-name" json:"bucket-name" yaml:"bucket-name"`
|
||||||
|
UseSSL bool `mapstructure:"use-ssl" json:"use-ssl" yaml:"use-ssl"`
|
||||||
|
BasePath string `mapstructure:"base-path" json:"base-path" yaml:"base-path"`
|
||||||
|
BucketUrl string `mapstructure:"bucket-url" json:"bucket-url" yaml:"bucket-url"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
type TencentCOS struct {
|
||||||
|
Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"`
|
||||||
|
Region string `mapstructure:"region" json:"region" yaml:"region"`
|
||||||
|
SecretID string `mapstructure:"secret-id" json:"secret-id" yaml:"secret-id"`
|
||||||
|
SecretKey string `mapstructure:"secret-key" json:"secret-key" yaml:"secret-key"`
|
||||||
|
BaseURL string `mapstructure:"base-url" json:"base-url" yaml:"base-url"`
|
||||||
|
PathPrefix string `mapstructure:"path-prefix" json:"path-prefix" yaml:"path-prefix"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
type RocketMQConfig struct {
|
||||||
|
NameSpace string `mapstructure:"name-space" json:"nameSpace" yaml:"name-space"`
|
||||||
|
Endpoint string `mapstructure:"endpoint" json:"endpoint" yaml:"endpoint"`
|
||||||
|
ConsumerGroup string `mapstructure:"consumer-group" json:"consumerGroup" yaml:"consumer-group"`
|
||||||
|
AccessKey string `mapstructure:"access-key" json:"accessKey" yaml:"access-key"`
|
||||||
|
SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"`
|
||||||
|
Topic string `mapstructure:"topic" json:"topic" yaml:"topic"`
|
||||||
|
EnableSSL bool `mapstructure:"enable-ssl" json:"enableSSL" yaml:"enable-ssl"`
|
||||||
|
LogEnabled bool `mapstructure:"log-enabled" json:"logEnabled" yaml:"log-enabled"`
|
||||||
|
}
|
||||||
+5
-2
@@ -1,6 +1,9 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
type System struct {
|
type System struct {
|
||||||
Port int `mapstructure:"port" json:"port" yaml:"port"`
|
Addr int `mapstructure:"addr" json:"addr" yaml:"addr"`
|
||||||
DbType string `mapstructure:"db-type" json:"db-type" yaml:"db-type"`
|
DbType string `mapstructure:"db-type" json:"db-type" yaml:"db-type"`
|
||||||
|
RouterPrefix string `mapstructure:"router-prefix" json:"router-prefix" yaml:"router-prefix"`
|
||||||
|
EnableCaptcha int `mapstructure:"enable-captcha" json:"enable-captcha" yaml:"enable-captcha"`
|
||||||
|
OssType string `mapstructure:"oss-type" json:"oss-type" yaml:"oss-type"`
|
||||||
}
|
}
|
||||||
|
|||||||
+1636
File diff suppressed because it is too large
Load Diff
+1610
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,951 @@
|
|||||||
|
definitions:
|
||||||
|
request.ChangePwd:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
newPwd:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
request.GetClientList:
|
||||||
|
properties:
|
||||||
|
clientId:
|
||||||
|
type: string
|
||||||
|
current:
|
||||||
|
description: 页码
|
||||||
|
type: integer
|
||||||
|
keyword:
|
||||||
|
description: 关键字
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
pageSize:
|
||||||
|
description: 每页大小
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
request.GetMenuTree:
|
||||||
|
properties:
|
||||||
|
category:
|
||||||
|
type: integer
|
||||||
|
parentId:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
request.GetRoleList:
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
type: string
|
||||||
|
current:
|
||||||
|
description: 页码
|
||||||
|
type: integer
|
||||||
|
keyword:
|
||||||
|
description: 关键字
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
pageSize:
|
||||||
|
description: 每页大小
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
request.GetUserList:
|
||||||
|
properties:
|
||||||
|
account:
|
||||||
|
type: string
|
||||||
|
current:
|
||||||
|
description: 页码
|
||||||
|
type: integer
|
||||||
|
keyword:
|
||||||
|
description: 关键字
|
||||||
|
type: string
|
||||||
|
pageSize:
|
||||||
|
description: 每页大小
|
||||||
|
type: integer
|
||||||
|
phone:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
request.GrantMenu:
|
||||||
|
properties:
|
||||||
|
menuIds:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
roleId:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
request.GrantRole:
|
||||||
|
properties:
|
||||||
|
roleIds:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
userId:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
request.IdsReq:
|
||||||
|
properties:
|
||||||
|
ids:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
request.Login:
|
||||||
|
properties:
|
||||||
|
account:
|
||||||
|
type: string
|
||||||
|
captcha:
|
||||||
|
type: string
|
||||||
|
captchaId:
|
||||||
|
type: string
|
||||||
|
password:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
response.CaptchaRes:
|
||||||
|
properties:
|
||||||
|
captcha:
|
||||||
|
type: string
|
||||||
|
captchaId:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
response.PageResult:
|
||||||
|
properties:
|
||||||
|
list: {}
|
||||||
|
page:
|
||||||
|
type: integer
|
||||||
|
pageSize:
|
||||||
|
type: integer
|
||||||
|
total:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
response.Response:
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
type: integer
|
||||||
|
data: {}
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
system.Client:
|
||||||
|
properties:
|
||||||
|
activeTimeout:
|
||||||
|
type: integer
|
||||||
|
additionalInfo:
|
||||||
|
type: string
|
||||||
|
clientId:
|
||||||
|
type: string
|
||||||
|
createdAt:
|
||||||
|
type: string
|
||||||
|
grantType:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
description: 主键ID
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
updatedAt:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
system.Menu:
|
||||||
|
properties:
|
||||||
|
category:
|
||||||
|
type: integer
|
||||||
|
children:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/system.Menu'
|
||||||
|
type: array
|
||||||
|
code:
|
||||||
|
type: string
|
||||||
|
createdAt:
|
||||||
|
type: string
|
||||||
|
icon:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
description: 主键ID
|
||||||
|
type: string
|
||||||
|
locale:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
parentId:
|
||||||
|
type: string
|
||||||
|
permission:
|
||||||
|
type: string
|
||||||
|
sort:
|
||||||
|
type: integer
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
|
updatedAt:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
system.Role:
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
type: string
|
||||||
|
createdAt:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
description: 主键ID
|
||||||
|
type: string
|
||||||
|
menus:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/system.Menu'
|
||||||
|
type: array
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
sort:
|
||||||
|
type: integer
|
||||||
|
updatedAt:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
system.User:
|
||||||
|
properties:
|
||||||
|
account:
|
||||||
|
type: string
|
||||||
|
clientId:
|
||||||
|
type: string
|
||||||
|
createdAt:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
description: 主键ID
|
||||||
|
type: string
|
||||||
|
phone:
|
||||||
|
type: string
|
||||||
|
roles:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/system.Role'
|
||||||
|
type: array
|
||||||
|
tenantId:
|
||||||
|
type: string
|
||||||
|
updatedAt:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
info:
|
||||||
|
contact: {}
|
||||||
|
description: 使用gin+gorm进行极速开发的全栈开发基础平台
|
||||||
|
title: RBAC Swagger API接口文档
|
||||||
|
version: v1.0.0
|
||||||
|
paths:
|
||||||
|
/api/auth/captcha:
|
||||||
|
get:
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 获取验证码
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/response.CaptchaRes'
|
||||||
|
type: object
|
||||||
|
summary: 获取验证码
|
||||||
|
tags:
|
||||||
|
- 登录相关
|
||||||
|
/api/auth/login:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: 用户名, 密码, 验证码,验证码id
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/request.Login'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 登录成功
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
summary: pc登录
|
||||||
|
tags:
|
||||||
|
- 登录相关
|
||||||
|
/api/auth/logout:
|
||||||
|
get:
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 登出成功
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: pc登出
|
||||||
|
tags:
|
||||||
|
- 登录相关
|
||||||
|
/api/client/delete:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: ids
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/request.IdsReq'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 删除client
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 删除client
|
||||||
|
tags:
|
||||||
|
- 客户端管理
|
||||||
|
/api/client/detail:
|
||||||
|
get:
|
||||||
|
description: id获取详情
|
||||||
|
parameters:
|
||||||
|
- description: id
|
||||||
|
in: query
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 获取client详情
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/system.Client'
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 获取client详情
|
||||||
|
tags:
|
||||||
|
- 客户端管理
|
||||||
|
/api/client/getClientList:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: client
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/request.GetClientList'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 获取client列表
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/response.PageResult'
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 获取client列表
|
||||||
|
tags:
|
||||||
|
- 客户端管理
|
||||||
|
/api/client/save:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: client
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/system.Client'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 创建client
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 创建client
|
||||||
|
tags:
|
||||||
|
- 客户端管理
|
||||||
|
/api/client/update:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: client
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/system.Client'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 更新client
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 更新client
|
||||||
|
tags:
|
||||||
|
- 客户端管理
|
||||||
|
/api/menu/delete:
|
||||||
|
get:
|
||||||
|
description: 删除menu
|
||||||
|
parameters:
|
||||||
|
- description: id
|
||||||
|
in: query
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 详情
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 删除menu
|
||||||
|
tags:
|
||||||
|
- 菜单管理
|
||||||
|
/api/menu/detail:
|
||||||
|
get:
|
||||||
|
description: id获取详情
|
||||||
|
parameters:
|
||||||
|
- description: id
|
||||||
|
in: query
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 详情
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/system.Menu'
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 获取menu详情
|
||||||
|
tags:
|
||||||
|
- 菜单管理
|
||||||
|
/api/menu/getAllMenuTree:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: 菜单信息
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/request.GetMenuTree'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 获取所有菜单树
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/system.Menu'
|
||||||
|
type: array
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 获取所有菜单树
|
||||||
|
tags:
|
||||||
|
- 菜单管理
|
||||||
|
/api/menu/getUserMenuTree:
|
||||||
|
get:
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 用户菜单数据
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/system.Menu'
|
||||||
|
type: array
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 用户菜单数据
|
||||||
|
tags:
|
||||||
|
- 菜单管理
|
||||||
|
/api/menu/route:
|
||||||
|
get:
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 用户route
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/system.Menu'
|
||||||
|
type: array
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 用户路由
|
||||||
|
tags:
|
||||||
|
- 菜单管理
|
||||||
|
/api/menu/save:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: menu
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/system.Menu'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 新建菜单/按钮
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 新增菜单
|
||||||
|
tags:
|
||||||
|
- 菜单管理
|
||||||
|
/api/role/delete:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: 删除角色
|
||||||
|
parameters:
|
||||||
|
- description: 批量删除角色
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/request.IdsReq'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 删除角色
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
summary: 删除角色
|
||||||
|
tags:
|
||||||
|
- 角色管理
|
||||||
|
/api/role/detail:
|
||||||
|
get:
|
||||||
|
parameters:
|
||||||
|
- description: id
|
||||||
|
in: query
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 角色详情
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/system.Role'
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 角色详情
|
||||||
|
tags:
|
||||||
|
- 角色管理
|
||||||
|
/api/role/getRoleList:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: 获取角色列表
|
||||||
|
parameters:
|
||||||
|
- description: 页码, 每页大小, 搜索条件
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/request.GetRoleList'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 获取角色列表,返回包括列表,总数,页码,每页大小
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/response.PageResult'
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
summary: 获取角色列表
|
||||||
|
tags:
|
||||||
|
- 角色管理
|
||||||
|
/api/role/grantMenu:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: 授权菜单给角色
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/request.GrantMenu'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 授权菜单给角色
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.Response'
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 授权菜单给角色
|
||||||
|
tags:
|
||||||
|
- 角色管理
|
||||||
|
/api/role/save:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: 角色信息
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/system.Role'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.Response'
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 创建角色
|
||||||
|
tags:
|
||||||
|
- 角色管理
|
||||||
|
/api/role/update:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: 角色ID
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/system.Role'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.Response'
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 修改角色
|
||||||
|
tags:
|
||||||
|
- 角色管理
|
||||||
|
/api/user/changePassword:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: 修改密码
|
||||||
|
parameters:
|
||||||
|
- description: 用户id
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/request.ChangePwd'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 修改密码成功
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/system.User'
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 修改密码
|
||||||
|
tags:
|
||||||
|
- 用户管理
|
||||||
|
/api/user/delete:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: 批量删除用户
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/request.IdsReq'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 删除用户
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 删除用户
|
||||||
|
tags:
|
||||||
|
- 用户管理
|
||||||
|
/api/user/detail:
|
||||||
|
get:
|
||||||
|
parameters:
|
||||||
|
- description: id
|
||||||
|
in: query
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 获取用户详情成功
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/system.User'
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 获取用户详情
|
||||||
|
tags:
|
||||||
|
- 用户管理
|
||||||
|
/api/user/getUserList:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: 页码, 每页大小, 搜索条件
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/request.GetUserList'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 获取用户列表,返回包括列表,总数,页码,每页大小
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/response.PageResult'
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 获取用户列表
|
||||||
|
tags:
|
||||||
|
- 用户管理
|
||||||
|
/api/user/grantRole:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: 用户ID, 角色ID
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/request.GrantRole'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{"code": 200, "data": [...]}'
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.Response'
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 给用户分配角色
|
||||||
|
tags:
|
||||||
|
- 用户管理
|
||||||
|
/api/user/save:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: 用户信息
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/system.User'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{"code": 200, "data": {}, "msg": "添加成功"}'
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.Response'
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 新增用户
|
||||||
|
tags:
|
||||||
|
- 用户管理
|
||||||
|
/api/user/update:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: 用户ID,用户信息
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/system.User'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{"code": 200, "data": [...]}'
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.Response'
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 更新用户
|
||||||
|
tags:
|
||||||
|
- 用户管理
|
||||||
|
/menu/update:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: menu
|
||||||
|
in: body
|
||||||
|
name: data
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/system.Menu'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 更新菜单
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
msg:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 更新菜单
|
||||||
|
tags:
|
||||||
|
- 菜单管理
|
||||||
|
securityDefinitions:
|
||||||
|
ApiKeyAuth:
|
||||||
|
in: header
|
||||||
|
name: Authorization
|
||||||
|
type: apiKey
|
||||||
|
swagger: "2.0"
|
||||||
+7
-5
@@ -4,15 +4,17 @@ import (
|
|||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
"golang.org/x/sync/singleflight"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"sundynix-go/config"
|
"sundynix-go/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 全局变量 加载在内存中
|
// 全局变量 加载在内存中
|
||||||
var (
|
var (
|
||||||
Viper *viper.Viper
|
Viper *viper.Viper
|
||||||
Logger *zap.Logger
|
Logger *zap.Logger
|
||||||
Config *config.Config
|
Config *config.Config
|
||||||
DB *gorm.DB
|
DB *gorm.DB
|
||||||
Redis redis.UniversalClient
|
Redis redis.UniversalClient
|
||||||
|
ConcurrencyControl = &singleflight.Group{}
|
||||||
)
|
)
|
||||||
|
|||||||
+8
-4
@@ -1,19 +1,23 @@
|
|||||||
package global
|
package global
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gorm.io/gorm"
|
"sundynix-go/utils/uniqueid"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BaseModel struct {
|
type BaseModel struct {
|
||||||
ID uint `gorm:"primarykey" json:"ID"` // 主键ID
|
Id string `gorm:"size:50;primaryKey" json:"id"` // 主键ID
|
||||||
CreatedAt time.Time // 创建时间
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
UpdatedAt time.Time // 更新时间
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // 删除时间
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // 删除时间
|
||||||
}
|
}
|
||||||
|
|
||||||
// BeforeCreate 定义一个钩子,在创建之前执行自动插入字段
|
// BeforeCreate 定义一个钩子,在创建之前执行自动插入字段
|
||||||
func (model BaseModel) BeforeCreate(db *gorm.DB) (err error) {
|
func (model BaseModel) BeforeCreate(db *gorm.DB) (err error) {
|
||||||
|
//生成主键的string uniqueid
|
||||||
|
db.Statement.SetColumn("id", uniqueid.GenerateId())
|
||||||
db.Statement.SetColumn("created_at", time.Now())
|
db.Statement.SetColumn("created_at", time.Now())
|
||||||
db.Statement.SetColumn("updated_at", time.Now())
|
db.Statement.SetColumn("updated_at", time.Now())
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,12 +1,26 @@
|
|||||||
module sundynix-go
|
module sundynix-go
|
||||||
|
|
||||||
go 1.24
|
go 1.24.0
|
||||||
|
|
||||||
|
toolchain go1.24.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/fsnotify/fsnotify v1.8.0
|
github.com/fsnotify/fsnotify v1.8.0
|
||||||
|
github.com/gin-gonic/gin v1.10.1
|
||||||
github.com/glebarez/sqlite v1.11.0
|
github.com/glebarez/sqlite v1.11.0
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.2.3
|
||||||
|
github.com/google/uuid v1.6.0
|
||||||
|
github.com/minio/minio-go/v7 v7.0.95
|
||||||
|
github.com/mojocn/base64Captcha v1.3.8
|
||||||
|
github.com/redis/go-redis/v9 v9.7.3
|
||||||
github.com/spf13/viper v1.20.1
|
github.com/spf13/viper v1.20.1
|
||||||
|
github.com/swaggo/files v1.0.1
|
||||||
|
github.com/swaggo/gin-swagger v1.6.1
|
||||||
|
github.com/swaggo/swag v1.16.6
|
||||||
|
github.com/tencentyun/cos-go-sdk-v5 v0.7.70
|
||||||
go.uber.org/zap v1.27.0
|
go.uber.org/zap v1.27.0
|
||||||
|
golang.org/x/crypto v0.42.0
|
||||||
|
golang.org/x/sync v0.17.0
|
||||||
gorm.io/driver/mysql v1.5.7
|
gorm.io/driver/mysql v1.5.7
|
||||||
gorm.io/driver/postgres v1.5.11
|
gorm.io/driver/postgres v1.5.11
|
||||||
gorm.io/gorm v1.26.0
|
gorm.io/gorm v1.26.0
|
||||||
@@ -14,36 +28,85 @@ require (
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
filippo.io/edwards25519 v1.1.0 // indirect
|
filippo.io/edwards25519 v1.1.0 // indirect
|
||||||
|
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||||
|
github.com/bytedance/gopkg v0.1.3 // indirect
|
||||||
|
github.com/bytedance/sonic v1.14.1 // indirect
|
||||||
|
github.com/bytedance/sonic/loader v0.3.0 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
|
github.com/clbanning/mxj v1.8.4 // indirect
|
||||||
|
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
|
||||||
|
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||||
github.com/glebarez/go-sqlite v1.22.0 // indirect
|
github.com/glebarez/go-sqlite v1.22.0 // indirect
|
||||||
|
github.com/go-ini/ini v1.67.0 // indirect
|
||||||
|
github.com/go-openapi/jsonpointer v0.22.0 // indirect
|
||||||
|
github.com/go-openapi/jsonreference v0.21.1 // indirect
|
||||||
|
github.com/go-openapi/spec v0.21.0 // indirect
|
||||||
|
github.com/go-openapi/swag v0.24.1 // indirect
|
||||||
|
github.com/go-openapi/swag/cmdutils v0.24.0 // indirect
|
||||||
|
github.com/go-openapi/swag/conv v0.24.0 // indirect
|
||||||
|
github.com/go-openapi/swag/fileutils v0.24.0 // indirect
|
||||||
|
github.com/go-openapi/swag/jsonname v0.24.0 // indirect
|
||||||
|
github.com/go-openapi/swag/jsonutils v0.24.0 // indirect
|
||||||
|
github.com/go-openapi/swag/loading v0.24.0 // indirect
|
||||||
|
github.com/go-openapi/swag/mangling v0.24.0 // indirect
|
||||||
|
github.com/go-openapi/swag/netutils v0.24.0 // indirect
|
||||||
|
github.com/go-openapi/swag/stringutils v0.24.0 // indirect
|
||||||
|
github.com/go-openapi/swag/typeutils v0.24.0 // indirect
|
||||||
|
github.com/go-openapi/swag/yamlutils v0.24.0 // indirect
|
||||||
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
|
github.com/go-playground/validator/v10 v10.27.0 // indirect
|
||||||
github.com/go-sql-driver/mysql v1.9.2 // indirect
|
github.com/go-sql-driver/mysql v1.9.2 // indirect
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/goccy/go-json v0.10.5 // indirect
|
||||||
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
||||||
|
github.com/google/go-querystring v1.0.0 // indirect
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||||
github.com/jackc/pgx/v5 v5.7.4 // indirect
|
github.com/jackc/pgx/v5 v5.7.4 // indirect
|
||||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
|
github.com/josharian/intern v1.0.0 // indirect
|
||||||
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
|
github.com/klauspost/compress v1.18.0 // indirect
|
||||||
|
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||||
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
|
github.com/mailru/easyjson v0.9.1 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/minio/crc64nvme v1.0.2 // indirect
|
||||||
|
github.com/minio/md5-simd v1.1.2 // indirect
|
||||||
|
github.com/mitchellh/mapstructure v1.4.3 // indirect
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
|
github.com/mozillazg/go-httpheader v0.2.1 // indirect
|
||||||
github.com/ncruces/go-strftime v0.1.9 // indirect
|
github.com/ncruces/go-strftime v0.1.9 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||||
github.com/redis/go-redis/v9 v9.7.3 // indirect
|
github.com/philhofer/fwd v1.2.0 // indirect
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||||
|
github.com/rs/xid v1.6.0 // indirect
|
||||||
github.com/sagikazarmark/locafero v0.7.0 // indirect
|
github.com/sagikazarmark/locafero v0.7.0 // indirect
|
||||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||||
github.com/spf13/afero v1.12.0 // indirect
|
github.com/spf13/afero v1.12.0 // indirect
|
||||||
github.com/spf13/cast v1.7.1 // indirect
|
github.com/spf13/cast v1.7.1 // indirect
|
||||||
github.com/spf13/pflag v1.0.6 // indirect
|
github.com/spf13/pflag v1.0.6 // indirect
|
||||||
github.com/subosito/gotenv v1.6.0 // indirect
|
github.com/subosito/gotenv v1.6.0 // indirect
|
||||||
|
github.com/tinylib/msgp v1.3.0 // indirect
|
||||||
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
|
github.com/ugorji/go/codec v1.3.0 // indirect
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
golang.org/x/crypto v0.37.0 // indirect
|
golang.org/x/arch v0.21.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
|
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
|
||||||
golang.org/x/sync v0.13.0 // indirect
|
golang.org/x/image v0.26.0 // indirect
|
||||||
golang.org/x/sys v0.32.0 // indirect
|
golang.org/x/mod v0.28.0 // indirect
|
||||||
golang.org/x/text v0.24.0 // indirect
|
golang.org/x/net v0.44.0 // indirect
|
||||||
|
golang.org/x/sys v0.36.0 // indirect
|
||||||
|
golang.org/x/text v0.29.0 // indirect
|
||||||
|
golang.org/x/tools v0.37.0 // indirect
|
||||||
|
google.golang.org/protobuf v1.36.9 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
modernc.org/libc v1.64.0 // indirect
|
modernc.org/libc v1.64.0 // indirect
|
||||||
modernc.org/mathutil v1.7.1 // indirect
|
modernc.org/mathutil v1.7.1 // indirect
|
||||||
|
|||||||
@@ -1,7 +1,23 @@
|
|||||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||||
|
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
|
||||||
|
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
|
||||||
|
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||||
|
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||||
|
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||||
|
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||||
|
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
|
||||||
|
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
||||||
|
github.com/bytedance/sonic v1.14.1 h1:FBMC0zVz5XUmE4z9wF4Jey0An5FueFvOsTKKKtwIl7w=
|
||||||
|
github.com/bytedance/sonic v1.14.1/go.mod h1:gi6uhQLMbTdeP0muCnrjHLeCUPyb70ujhnNlhOylAFc=
|
||||||
|
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
|
||||||
|
github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
|
github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I=
|
||||||
|
github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
|
||||||
|
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
||||||
|
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@@ -13,19 +29,78 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk
|
|||||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||||
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
|
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
|
||||||
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0=
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||||
|
github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4=
|
||||||
|
github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk=
|
||||||
|
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||||
|
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
||||||
|
github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ=
|
||||||
|
github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||||
github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ=
|
github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ=
|
||||||
github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc=
|
github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc=
|
||||||
github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw=
|
github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw=
|
||||||
github.com/glebarez/sqlite v1.11.0/go.mod h1:h8/o8j5wiAsqSPoWELDUdJXhjAhsVliSn7bWZjOhrgQ=
|
github.com/glebarez/sqlite v1.11.0/go.mod h1:h8/o8j5wiAsqSPoWELDUdJXhjAhsVliSn7bWZjOhrgQ=
|
||||||
|
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
|
||||||
|
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||||
|
github.com/go-openapi/jsonpointer v0.22.0 h1:TmMhghgNef9YXxTu1tOopo+0BGEytxA+okbry0HjZsM=
|
||||||
|
github.com/go-openapi/jsonpointer v0.22.0/go.mod h1:xt3jV88UtExdIkkL7NloURjRQjbeUgcxFblMjq2iaiU=
|
||||||
|
github.com/go-openapi/jsonreference v0.21.1 h1:bSKrcl8819zKiOgxkbVNRUBIr6Wwj9KYrDbMjRs0cDA=
|
||||||
|
github.com/go-openapi/jsonreference v0.21.1/go.mod h1:PWs8rO4xxTUqKGu+lEvvCxD5k2X7QYkKAepJyCmSTT8=
|
||||||
|
github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9ZY=
|
||||||
|
github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk=
|
||||||
|
github.com/go-openapi/swag v0.24.1 h1:DPdYTZKo6AQCRqzwr/kGkxJzHhpKxZ9i/oX0zag+MF8=
|
||||||
|
github.com/go-openapi/swag v0.24.1/go.mod h1:sm8I3lCPlspsBBwUm1t5oZeWZS0s7m/A+Psg0ooRU0A=
|
||||||
|
github.com/go-openapi/swag/cmdutils v0.24.0 h1:KlRCffHwXFI6E5MV9n8o8zBRElpY4uK4yWyAMWETo9I=
|
||||||
|
github.com/go-openapi/swag/cmdutils v0.24.0/go.mod h1:uxib2FAeQMByyHomTlsP8h1TtPd54Msu2ZDU/H5Vuf8=
|
||||||
|
github.com/go-openapi/swag/conv v0.24.0 h1:ejB9+7yogkWly6pnruRX45D1/6J+ZxRu92YFivx54ik=
|
||||||
|
github.com/go-openapi/swag/conv v0.24.0/go.mod h1:jbn140mZd7EW2g8a8Y5bwm8/Wy1slLySQQ0ND6DPc2c=
|
||||||
|
github.com/go-openapi/swag/fileutils v0.24.0 h1:U9pCpqp4RUytnD689Ek/N1d2N/a//XCeqoH508H5oak=
|
||||||
|
github.com/go-openapi/swag/fileutils v0.24.0/go.mod h1:3SCrCSBHyP1/N+3oErQ1gP+OX1GV2QYFSnrTbzwli90=
|
||||||
|
github.com/go-openapi/swag/jsonname v0.24.0 h1:2wKS9bgRV/xB8c62Qg16w4AUiIrqqiniJFtZGi3dg5k=
|
||||||
|
github.com/go-openapi/swag/jsonname v0.24.0/go.mod h1:GXqrPzGJe611P7LG4QB9JKPtUZ7flE4DOVechNaDd7Q=
|
||||||
|
github.com/go-openapi/swag/jsonutils v0.24.0 h1:F1vE1q4pg1xtO3HTyJYRmEuJ4jmIp2iZ30bzW5XgZts=
|
||||||
|
github.com/go-openapi/swag/jsonutils v0.24.0/go.mod h1:vBowZtF5Z4DDApIoxcIVfR8v0l9oq5PpYRUuteVu6f0=
|
||||||
|
github.com/go-openapi/swag/loading v0.24.0 h1:ln/fWTwJp2Zkj5DdaX4JPiddFC5CHQpvaBKycOlceYc=
|
||||||
|
github.com/go-openapi/swag/loading v0.24.0/go.mod h1:gShCN4woKZYIxPxbfbyHgjXAhO61m88tmjy0lp/LkJk=
|
||||||
|
github.com/go-openapi/swag/mangling v0.24.0 h1:PGOQpViCOUroIeak/Uj/sjGAq9LADS3mOyjznmHy2pk=
|
||||||
|
github.com/go-openapi/swag/mangling v0.24.0/go.mod h1:Jm5Go9LHkycsz0wfoaBDkdc4CkpuSnIEf62brzyCbhc=
|
||||||
|
github.com/go-openapi/swag/netutils v0.24.0 h1:Bz02HRjYv8046Ycg/w80q3g9QCWeIqTvlyOjQPDjD8w=
|
||||||
|
github.com/go-openapi/swag/netutils v0.24.0/go.mod h1:WRgiHcYTnx+IqfMCtu0hy9oOaPR0HnPbmArSRN1SkZM=
|
||||||
|
github.com/go-openapi/swag/stringutils v0.24.0 h1:i4Z/Jawf9EvXOLUbT97O0HbPUja18VdBxeadyAqS1FM=
|
||||||
|
github.com/go-openapi/swag/stringutils v0.24.0/go.mod h1:5nUXB4xA0kw2df5PRipZDslPJgJut+NjL7D25zPZ/4w=
|
||||||
|
github.com/go-openapi/swag/typeutils v0.24.0 h1:d3szEGzGDf4L2y1gYOSSLeK6h46F+zibnEas2Jm/wIw=
|
||||||
|
github.com/go-openapi/swag/typeutils v0.24.0/go.mod h1:q8C3Kmk/vh2VhpCLaoR2MVWOGP8y7Jc8l82qCTd1DYI=
|
||||||
|
github.com/go-openapi/swag/yamlutils v0.24.0 h1:bhw4894A7Iw6ne+639hsBNRHg9iZg/ISrOVr+sJGp4c=
|
||||||
|
github.com/go-openapi/swag/yamlutils v0.24.0/go.mod h1:DpKv5aYuaGm/sULePoeiG8uwMpZSfReo1HR3Ik0yaG8=
|
||||||
|
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||||
|
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||||
|
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||||
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
|
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||||
|
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||||
|
github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4=
|
||||||
|
github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
|
||||||
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||||
github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU=
|
github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU=
|
||||||
github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
|
github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
|
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||||
|
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.2.3 h1:kkGXqQOBSDDWRhWNXTFpqGSCMyh/PLnqUvMGJPDJDs0=
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.2.3/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||||
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||||
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
|
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
||||||
|
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||||
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
|
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
|
||||||
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
|
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
|
||||||
|
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||||
@@ -40,24 +115,59 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
|
|||||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
|
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
||||||
|
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||||
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
|
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
||||||
|
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||||
|
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||||
|
github.com/mailru/easyjson v0.9.1 h1:LbtsOm5WAswyWbvTEOqhypdPeZzHavpZx96/n553mR8=
|
||||||
|
github.com/mailru/easyjson v0.9.1/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/minio/crc64nvme v1.0.2 h1:6uO1UxGAD+kwqWWp7mBFsi5gAse66C4NXO8cmcVculg=
|
||||||
|
github.com/minio/crc64nvme v1.0.2/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg=
|
||||||
|
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||||
|
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||||
|
github.com/minio/minio-go/v7 v7.0.95 h1:ywOUPg+PebTMTzn9VDsoFJy32ZuARN9zhB+K3IYEvYU=
|
||||||
|
github.com/minio/minio-go/v7 v7.0.95/go.mod h1:wOOX3uxS334vImCNRVyIDdXX9OsXDm89ToynKgqUKlo=
|
||||||
|
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
|
||||||
|
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
|
github.com/mojocn/base64Captcha v1.3.8 h1:rrN9BhCwXKS8ht1e21kvR3iTaMgf4qPC9sRoV52bqEg=
|
||||||
|
github.com/mojocn/base64Captcha v1.3.8/go.mod h1:QFZy927L8HVP3+VV5z2b1EAEiv1KxVJKZbAucVgLUy4=
|
||||||
|
github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ=
|
||||||
|
github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60=
|
||||||
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
|
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
|
||||||
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||||
|
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
|
||||||
|
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM=
|
github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM=
|
||||||
github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA=
|
github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
|
||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
||||||
|
github.com/rs/dnscache v0.0.0-20230804202142-fc85eb664529/go.mod h1:qe5TWALJ8/a1Lqznoc5BDHpYX/8HU60Hm2AwRmqzxqA=
|
||||||
|
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
|
||||||
|
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
|
||||||
github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo=
|
github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo=
|
||||||
github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k=
|
github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k=
|
||||||
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
||||||
@@ -71,33 +181,125 @@ github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
|
|||||||
github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4=
|
github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4=
|
||||||
github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4=
|
github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||||
|
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.1 h1:Ri06G4gc9N4t4k8hekMigJ9zKTFSlqj/9paAQCQs7cY=
|
||||||
|
github.com/swaggo/gin-swagger v1.6.1/go.mod h1:LQ+hJStHakCWRiK/YNYtJOu4mR2FP+pxLnILT/qNiTw=
|
||||||
|
github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI=
|
||||||
|
github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg=
|
||||||
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
|
||||||
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0=
|
||||||
|
github.com/tencentyun/cos-go-sdk-v5 v0.7.70 h1:gkBkSfrDvUg4ZIjwYAfjbNCCclen9LCRNHhBNz+yjEQ=
|
||||||
|
github.com/tencentyun/cos-go-sdk-v5 v0.7.70/go.mod h1:STbTNaNKq03u+gscPEGOahKzLcGSYOj6Dzc5zNay7Pg=
|
||||||
|
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20250515025012-e0eec8a5d123/go.mod h1:b18KQa4IxHbxeseW1GcZox53d7J0z39VNONTxvvlkXw=
|
||||||
|
github.com/tinylib/msgp v1.3.0 h1:ULuf7GPooDaIlbyvgAxBV/FI7ynli6LZ1/nVUNu+0ww=
|
||||||
|
github.com/tinylib/msgp v1.3.0/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0=
|
||||||
|
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=
|
||||||
|
github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
|
||||||
|
github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||||
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||||
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
|
golang.org/x/arch v0.21.0 h1:iTC9o7+wP6cPWpDWkivCvQFGAHDQ59SrSxsLPcnkArw=
|
||||||
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
|
golang.org/x/arch v0.21.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||||
|
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||||
|
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||||
|
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
|
||||||
|
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
|
||||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM=
|
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM=
|
||||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8=
|
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8=
|
||||||
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
|
golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY=
|
||||||
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
|
golang.org/x/image v0.26.0 h1:4XjIFEZWQmCZi6Wv8BoxsDhRU3RVnLX04dToTDAEPlY=
|
||||||
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
|
golang.org/x/image v0.26.0/go.mod h1:lcxbMFAovzpnJxzXS3nyL83K27tmqtKzIJpctK8YO5c=
|
||||||
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
|
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
|
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
|
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
|
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
|
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
|
||||||
|
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
|
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
|
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||||
|
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||||
|
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||||
|
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||||
|
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
|
||||||
|
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||||
|
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
||||||
|
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
|
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
|
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU=
|
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
||||||
golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s=
|
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
|
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
|
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||||
|
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||||
|
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||||
|
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
|
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||||
|
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
|
||||||
|
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
|
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||||
|
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||||
|
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||||
|
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
|
||||||
|
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
|
||||||
|
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
|
|||||||
+16
-2
@@ -1,11 +1,14 @@
|
|||||||
package initialize
|
package initialize
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.uber.org/zap"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
"os"
|
"os"
|
||||||
"sundynix-go/global"
|
"sundynix-go/global"
|
||||||
"sundynix-go/model/system"
|
"sundynix-go/model/system"
|
||||||
|
|
||||||
|
"sundynix-go/model/order"
|
||||||
|
|
||||||
|
"go.uber.org/zap"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Gorm 根据全局配置中的数据库类型返回对应的 *gorm.DB 实例。
|
// Gorm 根据全局配置中的数据库类型返回对应的 *gorm.DB 实例。
|
||||||
@@ -31,6 +34,17 @@ func MigrateTable() {
|
|||||||
db := global.DB
|
db := global.DB
|
||||||
err := db.AutoMigrate(
|
err := db.AutoMigrate(
|
||||||
system.User{},
|
system.User{},
|
||||||
|
system.Client{},
|
||||||
|
system.Role{},
|
||||||
|
system.Menu{},
|
||||||
|
system.SysOperationRecord{},
|
||||||
|
system.Oss{},
|
||||||
|
|
||||||
|
order.Order{},
|
||||||
|
|
||||||
|
order.Refund{},
|
||||||
|
|
||||||
|
order.Stock{},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
global.Logger.Error("Migrate table failed,err:", zap.Error(err))
|
global.Logger.Error("Migrate table failed,err:", zap.Error(err))
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package initialize
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sundynix-go/docs"
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/middleware"
|
||||||
|
"sundynix-go/router"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
swaggerFiles "github.com/swaggo/files"
|
||||||
|
ginSwagger "github.com/swaggo/gin-swagger"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Routers 初始化总路由
|
||||||
|
func Routers() {
|
||||||
|
Router := gin.New()
|
||||||
|
|
||||||
|
Router.Use(gin.Recovery())
|
||||||
|
if gin.Mode() == gin.DebugMode {
|
||||||
|
Router.Use(gin.Logger())
|
||||||
|
}
|
||||||
|
docs.SwaggerInfo.BasePath = global.Config.System.RouterPrefix
|
||||||
|
Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||||
|
|
||||||
|
// 系统组路由
|
||||||
|
systemRouter := router.GroupApp.System
|
||||||
|
codegenRouter := router.GroupApp.Codegen
|
||||||
|
|
||||||
|
orderRouter := router.GroupApp.Order
|
||||||
|
|
||||||
|
NeedAuthGroup := Router.Group(global.Config.System.RouterPrefix)
|
||||||
|
PublicGroup := Router.Group(global.Config.System.RouterPrefix)
|
||||||
|
|
||||||
|
//鉴权中间件
|
||||||
|
NeedAuthGroup.Use(middleware.AuthMiddleware())
|
||||||
|
{
|
||||||
|
//无须鉴权的路由
|
||||||
|
systemRouter.InitAuthRouter(PublicGroup) //登录和验证码不需要鉴权
|
||||||
|
//systemRouter.InitMenuRouter(PublicGroup)
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
//需要鉴权的路由
|
||||||
|
systemRouter.InitUserRouter(NeedAuthGroup) //用户相关
|
||||||
|
systemRouter.InitClientRouter(NeedAuthGroup) //客户端相关
|
||||||
|
systemRouter.InitRoleRouter(NeedAuthGroup) //角色相关
|
||||||
|
systemRouter.InitMenuRouter(NeedAuthGroup) //菜单相关
|
||||||
|
codegenRouter.InitCodegenRouter(NeedAuthGroup) //代码生成
|
||||||
|
orderRouter.InitOrderRouter(NeedAuthGroup)
|
||||||
|
orderRouter.InitRefundRouter(NeedAuthGroup)
|
||||||
|
orderRouter.InitStockRouter(NeedAuthGroup)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
address := fmt.Sprintf(":%d", global.Config.System.Addr)
|
||||||
|
fmt.Printf(`
|
||||||
|
欢迎使用 sundynix-go
|
||||||
|
项目地址:
|
||||||
|
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
|
||||||
|
默认前端文件运行地址:http://127.0.0.1:8080
|
||||||
|
`, address)
|
||||||
|
|
||||||
|
err := Router.Run(address)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("Gin run failed", zap.Error(err))
|
||||||
|
}
|
||||||
|
global.Logger.Info("Gin run success", zap.String("address", address))
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,12 +3,18 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"go.uber.org/zap"
|
|
||||||
"sundynix-go/core"
|
"sundynix-go/core"
|
||||||
"sundynix-go/global"
|
"sundynix-go/global"
|
||||||
"sundynix-go/initialize"
|
"sundynix-go/initialize"
|
||||||
|
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// @title RBAC Swagger API接口文档
|
||||||
|
// @version v1.0.0
|
||||||
|
// @description 使用gin+gorm进行极速开发的全栈开发基础平台
|
||||||
|
// @securityDefinitions.basic BasicAuth
|
||||||
|
// @BasePath /
|
||||||
func main() {
|
func main() {
|
||||||
//初始化viper
|
//初始化viper
|
||||||
global.Viper = core.Viper()
|
global.Viper = core.Viper()
|
||||||
@@ -20,7 +26,9 @@ func main() {
|
|||||||
global.DB = initialize.Gorm()
|
global.DB = initialize.Gorm()
|
||||||
//redis连接
|
//redis连接
|
||||||
initialize.Redis()
|
initialize.Redis()
|
||||||
global.Redis.Set(context.Background(), "test", 0, -1)
|
if global.Redis != nil {
|
||||||
|
global.Redis.Set(context.Background(), "test", 0, -1)
|
||||||
|
}
|
||||||
|
|
||||||
//迁移数据库
|
//迁移数据库
|
||||||
if global.DB != nil {
|
if global.DB != nil {
|
||||||
@@ -32,7 +40,8 @@ func main() {
|
|||||||
global.Logger.Error("db close failed", zap.Error(err))
|
global.Logger.Error("db close failed", zap.Error(err))
|
||||||
}
|
}
|
||||||
}(db)
|
}(db)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//初始化路由
|
||||||
|
initialize.Routers()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package middleware
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"sundynix-go/model/commom/response"
|
||||||
|
"sundynix-go/service"
|
||||||
|
"sundynix-go/utils/jwt"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
var jwtService = service.ServiceGroupApp.SystemServiceGroup.JwtService
|
||||||
|
|
||||||
|
// AuthMiddleware 验证token有效性
|
||||||
|
func AuthMiddleware() gin.HandlerFunc {
|
||||||
|
return func(c *gin.Context) {
|
||||||
|
token := jwt.GetToken(c)
|
||||||
|
if token == "" {
|
||||||
|
response.NoAuth("未登录或非法访问", c)
|
||||||
|
c.Abort()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
userId := jwt.GetUserId(c)
|
||||||
|
if jwtService.IsInBlacklist(userId, token) {
|
||||||
|
response.NoAuth("未登录或令牌失效", c)
|
||||||
|
c.Abort()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
j := jwt.NewJWT()
|
||||||
|
// 解析token信息
|
||||||
|
claims, err := j.ParseToken(token)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, jwt.TokenExpired) {
|
||||||
|
response.NoAuth("登录过期", c)
|
||||||
|
jwt.ClearToken(c)
|
||||||
|
c.Abort()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.NoAuth(err.Error(), c)
|
||||||
|
jwt.ClearToken(c)
|
||||||
|
c.Abort()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Set("claims", claims)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package middleware
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
"sundynix-go/service"
|
||||||
|
"sundynix-go/utils/jwt"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
var operationService = service.ServiceGroupApp.SystemServiceGroup.OperationRecordService
|
||||||
|
|
||||||
|
var respPool sync.Pool
|
||||||
|
var bufferSize = 1024
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
respPool = sync.Pool{
|
||||||
|
New: func() interface{} {
|
||||||
|
return make([]byte, bufferSize)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func OperationRecord() gin.HandlerFunc {
|
||||||
|
return func(c *gin.Context) {
|
||||||
|
var body []byte
|
||||||
|
var userId string
|
||||||
|
if c.Request.Method != http.MethodGet {
|
||||||
|
var err error
|
||||||
|
body, err = io.ReadAll(c.Request.Body)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("read body from request error:", zap.Error(err))
|
||||||
|
} else {
|
||||||
|
c.Request.Body = io.NopCloser(bytes.NewBuffer(body))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
query := c.Request.URL.RawQuery
|
||||||
|
query, _ = url.QueryUnescape(query)
|
||||||
|
split := strings.Split(query, "&")
|
||||||
|
m := make(map[string]string)
|
||||||
|
for _, v := range split {
|
||||||
|
kv := strings.Split(v, "=")
|
||||||
|
if len(kv) == 2 {
|
||||||
|
m[kv[0]] = kv[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
body, _ = json.Marshal(&m)
|
||||||
|
}
|
||||||
|
claims, _ := jwt.GetClaims(c)
|
||||||
|
if claims != nil && claims.BaseClaims.ID != "" {
|
||||||
|
userId = claims.BaseClaims.ID
|
||||||
|
} else {
|
||||||
|
userId = c.Request.Header.Get("x-user-id")
|
||||||
|
}
|
||||||
|
record := system.SysOperationRecord{
|
||||||
|
Ip: c.ClientIP(),
|
||||||
|
Method: c.Request.Method,
|
||||||
|
Path: c.Request.URL.Path,
|
||||||
|
Agent: c.Request.UserAgent(),
|
||||||
|
Body: string(body),
|
||||||
|
UserId: userId,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := operationService.CreateOperationRecord(record); err != nil {
|
||||||
|
global.Logger.Error("create operation record error:", zap.Error(err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package codegen
|
||||||
|
|
||||||
|
// GenConfig 代码生成完整配置
|
||||||
|
type GenConfig struct {
|
||||||
|
DbConfig DbConfig `json:"dbConfig"`
|
||||||
|
OutputDir string `json:"outputDir"` // 后端输出目录,绝对路径,为空则输出到项目根目录
|
||||||
|
FrontendOutputDir string `json:"frontendOutputDir"` // 前端输出目录,绝对路径,为空则跳过前端生成
|
||||||
|
Overwrite bool `json:"overwrite"` // true=覆盖已有文件 false=增量模式(跳过已存在文件)
|
||||||
|
Modules []Module `json:"modules"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DbConfig 目标数据库连接配置
|
||||||
|
type DbConfig struct {
|
||||||
|
Host string `json:"host"`
|
||||||
|
Port string `json:"port"`
|
||||||
|
User string `json:"user"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
DbName string `json:"dbName"`
|
||||||
|
DbType string `json:"dbType"` // mysql / postgres / sqlite
|
||||||
|
}
|
||||||
|
|
||||||
|
// Module 模块定义(对应一组功能)
|
||||||
|
type Module struct {
|
||||||
|
Name string `json:"name"` // 模块名(PascalCase),如 "Order"
|
||||||
|
PackageName string `json:"packageName"` // 包名(lowercase),如 "order"
|
||||||
|
Description string `json:"description"`
|
||||||
|
Features []Feature `json:"features"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Feature 功能单元(对应一张表 / 一个实体)
|
||||||
|
type Feature struct {
|
||||||
|
Name string `json:"name"` // 实体名(PascalCase),如 "Product"
|
||||||
|
TableName string `json:"tableName"` // 数据库表名,如 "product"
|
||||||
|
Comment string `json:"comment"`
|
||||||
|
Fields []Field `json:"fields"`
|
||||||
|
Relations []Relation `json:"relations"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field 字段定义
|
||||||
|
type Field struct {
|
||||||
|
Name string `json:"name"` // Go 字段名(PascalCase),如 "OrderNo"
|
||||||
|
ColumnName string `json:"columnName"` // 数据库列名(snake_case),如 "order_no"
|
||||||
|
Type string `json:"type"` // Go 类型,如 string / int / float64 / bool / time.Time
|
||||||
|
GormTag string `json:"gormTag"` // gorm tag 附加内容,如 "size:100;not null"
|
||||||
|
JsonTag string `json:"jsonTag"` // json tag,如 "orderNo"
|
||||||
|
Comment string `json:"comment"` // 字段注释
|
||||||
|
Required bool `json:"required"` // 是否必填(影响 not null)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Relation 表关系定义
|
||||||
|
type Relation struct {
|
||||||
|
Type string `json:"type"` // OneToOne / OneToMany / ManyToMany
|
||||||
|
TargetFeature string `json:"targetFeature"` // 目标实体名(PascalCase)
|
||||||
|
ForeignKey string `json:"foreignKey"` // 外键字段名,如 "UserId"
|
||||||
|
JoinTable string `json:"joinTable"` // ManyToMany 中间表名
|
||||||
|
FieldName string `json:"fieldName"` // Go 中关联字段名,如 "Tags"
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestConnectionReq 测试连接请求
|
||||||
|
type TestConnectionReq struct {
|
||||||
|
DbConfig DbConfig `json:"dbConfig"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PreviewReq 预览代码请求
|
||||||
|
type PreviewReq struct {
|
||||||
|
GenConfig
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package codegen
|
||||||
|
|
||||||
|
// PreviewFile 预览的单个文件
|
||||||
|
type PreviewFile struct {
|
||||||
|
FilePath string `json:"filePath"` // 相对于输出目录的路径
|
||||||
|
Content string `json:"content"` // 文件内容
|
||||||
|
AlwaysOverwrite bool `json:"alwaysOverwrite,omitempty"` // 聚合文件(如 enter.go),始终覆盖
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenResult 代码生成结果
|
||||||
|
type GenResult struct {
|
||||||
|
OutputDir string `json:"outputDir"` // 实际输出目录
|
||||||
|
Files []PreviewFile `json:"files"` // 生成的文件列表
|
||||||
|
Message string `json:"message"` // 生成结果说明
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package request
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PageInfo Paging common input parameter structure
|
||||||
|
type PageInfo struct {
|
||||||
|
Current int `json:"current" form:"current"` // 页码
|
||||||
|
PageSize int `json:"pageSize" form:"pageSize"` // 每页大小
|
||||||
|
Keyword string `json:"keyword" form:"keyword"` // 关键字
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *PageInfo) Paginate() func(db *gorm.DB) *gorm.DB {
|
||||||
|
return func(db *gorm.DB) *gorm.DB {
|
||||||
|
if r.Current <= 0 {
|
||||||
|
r.Current = 1
|
||||||
|
}
|
||||||
|
switch {
|
||||||
|
case r.PageSize > 100:
|
||||||
|
r.PageSize = 100
|
||||||
|
case r.PageSize <= 0:
|
||||||
|
r.PageSize = 10
|
||||||
|
}
|
||||||
|
offset := (r.Current - 1) * r.PageSize
|
||||||
|
return db.Offset(offset).Limit(r.PageSize)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetById Find by id structure
|
||||||
|
type GetById struct {
|
||||||
|
ID string `json:"id" form:"id"` // 主键ID
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *GetById) Uint() string {
|
||||||
|
return string(r.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
type IdsReq struct {
|
||||||
|
Ids []string `json:"ids" form:"ids"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAuthorityId Get role by id structure
|
||||||
|
type GetAuthorityId struct {
|
||||||
|
AuthorityId string `json:"authorityId" form:"authorityId"` // 角色ID
|
||||||
|
}
|
||||||
|
|
||||||
|
type Empty struct{}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
type PageResult struct {
|
||||||
|
List interface{} `json:"list"`
|
||||||
|
Total int64 `json:"total"`
|
||||||
|
Page int `json:"page"`
|
||||||
|
PageSize int `json:"pageSize"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Response struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Data interface{} `json:"data"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
SUCCESS = 200
|
||||||
|
ERROR = 7
|
||||||
|
)
|
||||||
|
|
||||||
|
// Result 返回结果
|
||||||
|
func Result(code int, data interface{}, msg string, c *gin.Context) {
|
||||||
|
c.JSON(http.StatusOK, Response{
|
||||||
|
code,
|
||||||
|
data,
|
||||||
|
msg,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ok 成功返回
|
||||||
|
func Ok(c *gin.Context) {
|
||||||
|
Result(SUCCESS, map[string]interface{}{}, "操作成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OkWithData 带数据成功返回
|
||||||
|
func OkWithData(data interface{}, c *gin.Context) {
|
||||||
|
Result(SUCCESS, data, "操作成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OkWithMsg 带信息成功返回
|
||||||
|
func OkWithMsg(msg string, c *gin.Context) {
|
||||||
|
Result(SUCCESS, map[string]interface{}{}, msg, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fail 失败返回
|
||||||
|
func Fail(code int, msg string, c *gin.Context) {
|
||||||
|
Result(code, map[string]interface{}{}, "操作失败", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailWithMsg 带信息失败返回
|
||||||
|
func FailWithMsg(msg string, c *gin.Context) {
|
||||||
|
Result(ERROR, map[string]interface{}{}, msg, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoAuth 未授权返回
|
||||||
|
func NoAuth(message string, c *gin.Context) {
|
||||||
|
c.JSON(http.StatusUnauthorized, Response{
|
||||||
|
7,
|
||||||
|
nil,
|
||||||
|
message,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import "sundynix-go/global"
|
||||||
|
|
||||||
|
// Order
|
||||||
|
type Order struct {
|
||||||
|
global.BaseModel
|
||||||
|
UserId string `gorm:"column:user_id;size:50" json:"userId"` //
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Order) TableName() string {
|
||||||
|
return "sundynix_order"
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import "sundynix-go/global"
|
||||||
|
|
||||||
|
// Refund
|
||||||
|
type Refund struct {
|
||||||
|
global.BaseModel
|
||||||
|
UserId string `gorm:"column:user_id;size:50" json:"userId"` //
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Refund) TableName() string {
|
||||||
|
return "sundynix_refund"
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package request
|
||||||
|
|
||||||
|
// ---- ----
|
||||||
|
|
||||||
|
// SaveRefundReq 新增请求
|
||||||
|
type SaveRefundReq struct {
|
||||||
|
UserId string `json:"userId" form:"userId"` //
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateRefundReq 更新请求
|
||||||
|
type UpdateRefundReq struct {
|
||||||
|
Id string `json:"id" binding:"required"` // ID
|
||||||
|
UserId string `json:"userId" form:"userId"` //
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRefundReq 分页查询请求
|
||||||
|
type ListRefundReq struct {
|
||||||
|
Current int `json:"current" form:"current"` // 页码
|
||||||
|
PageSize int `json:"pageSize" form:"pageSize"` // 每页大小
|
||||||
|
Keyword string `json:"keyword" form:"keyword"` // 关键字搜索
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- ----
|
||||||
|
|
||||||
|
// SaveStockReq 新增请求
|
||||||
|
type SaveStockReq struct {
|
||||||
|
Amount int64 `json:"amount" form:"amount"` //
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStockReq 更新请求
|
||||||
|
type UpdateStockReq struct {
|
||||||
|
Id string `json:"id" binding:"required"` // ID
|
||||||
|
Amount int64 `json:"amount" form:"amount"` //
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListStockReq 分页查询请求
|
||||||
|
type ListStockReq struct {
|
||||||
|
Current int `json:"current" form:"current"` // 页码
|
||||||
|
PageSize int `json:"pageSize" form:"pageSize"` // 每页大小
|
||||||
|
Keyword string `json:"keyword" form:"keyword"` // 关键字搜索
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import "sundynix-go/global"
|
||||||
|
|
||||||
|
// Stock
|
||||||
|
type Stock struct {
|
||||||
|
global.BaseModel
|
||||||
|
Amount int64 `gorm:"column:amount" json:"amount"` //
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Stock) TableName() string {
|
||||||
|
return "sundynix_stock"
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Oss struct {
|
||||||
|
//global.BaseModel
|
||||||
|
Id string `gorm:"size:50;primaryKey" json:"id"` // 主键ID
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // 删除时间
|
||||||
|
Name string `json:"name" form:"name" gorm:"column:name;comment:文件名"`
|
||||||
|
Url string `json:"url" form:"url" gorm:"column:url;comment:文件地址"`
|
||||||
|
Tag string `json:"tag" form:"tag" gorm:"column:tag;comment:文件标签"`
|
||||||
|
Key string `json:"key" form:"key" gorm:"column:key;comment:文件key"`
|
||||||
|
Suffix string `json:"suffix" form:"suffix" gorm:"column:suffix;comment:文件后缀"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package request
|
||||||
|
|
||||||
|
import "github.com/mojocn/base64Captcha"
|
||||||
|
|
||||||
|
// configJsonBody json request body.
|
||||||
|
type CaptchaReqBody struct {
|
||||||
|
Id string
|
||||||
|
CaptchaType string
|
||||||
|
VerifyValue string
|
||||||
|
DriverAudio *base64Captcha.DriverAudio
|
||||||
|
DriverString *base64Captcha.DriverString
|
||||||
|
DriverChinese *base64Captcha.DriverChinese
|
||||||
|
DriverMath *base64Captcha.DriverMath
|
||||||
|
DriverDigit *base64Captcha.DriverDigit
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package request
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/golang-jwt/jwt/v5"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CustomClaims struct {
|
||||||
|
BaseClaims
|
||||||
|
BufferTime int64
|
||||||
|
jwt.RegisteredClaims
|
||||||
|
}
|
||||||
|
|
||||||
|
type BaseClaims struct {
|
||||||
|
UUID uuid.UUID
|
||||||
|
ID string
|
||||||
|
Account string
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package request
|
||||||
|
|
||||||
|
import common "sundynix-go/model/commom/request"
|
||||||
|
|
||||||
|
type GetOssFileList struct {
|
||||||
|
common.PageInfo
|
||||||
|
Name string `json:"name" form:"name"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package request
|
||||||
|
|
||||||
|
import common "sundynix-go/model/commom/request"
|
||||||
|
|
||||||
|
type GetClientList struct {
|
||||||
|
common.PageInfo
|
||||||
|
ClientId string `json:"clientId" form:"clientId"`
|
||||||
|
Name string `json:"name" form:"name"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package request
|
||||||
|
|
||||||
|
type GetMenuTree struct {
|
||||||
|
Category int `json:"category" form:"category"`
|
||||||
|
ParentId string `json:"parentId" form:"parentId"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package request
|
||||||
|
|
||||||
|
import (
|
||||||
|
common "sundynix-go/model/commom/request"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetOperationRecordList struct {
|
||||||
|
common.PageInfo
|
||||||
|
Ip string `json:"ip" form:"ip"`
|
||||||
|
Method string `json:"method" form:"method"`
|
||||||
|
Path string `json:"path" form:"path"`
|
||||||
|
UserId string `json:"userId" form:"userId"`
|
||||||
|
Status int `json:"status" form:"status"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package request
|
||||||
|
|
||||||
|
import common "sundynix-go/model/commom/request"
|
||||||
|
|
||||||
|
type GetRoleList struct {
|
||||||
|
common.PageInfo
|
||||||
|
Code string `json:"code" form:"code"`
|
||||||
|
Name string `json:"name" form:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GrantMenu struct {
|
||||||
|
RoleId string `json:"roleId"`
|
||||||
|
MenuIds []string `json:"menuIds"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package request
|
||||||
|
|
||||||
|
import common "sundynix-go/model/commom/request"
|
||||||
|
|
||||||
|
type Login struct {
|
||||||
|
Account string `json:"account"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
Captcha string `json:"captcha"`
|
||||||
|
CaptchaId string `json:"captchaId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUserList struct {
|
||||||
|
common.PageInfo
|
||||||
|
Account string `json:"account" form:"account"`
|
||||||
|
Phone string `json:"phone" form:"phone"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChangePwd struct {
|
||||||
|
Id string `json:"id"`
|
||||||
|
NewPwd string `json:"newPwd"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GrantRole struct {
|
||||||
|
UserId string `json:"userId"`
|
||||||
|
RoleIds []string `json:"roleIds"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
import "sundynix-go/model/system"
|
||||||
|
|
||||||
|
type UploadFileResponse struct {
|
||||||
|
File system.Oss `json:"file"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
type CaptchaRes struct {
|
||||||
|
CaptchaId string `json:"captchaId"`
|
||||||
|
Captcha string `json:"captcha"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
import "sundynix-go/model/system"
|
||||||
|
|
||||||
|
type LoginResponse struct {
|
||||||
|
User system.User `json:"user"`
|
||||||
|
Token string `json:"token"`
|
||||||
|
ExpiresAt int64 `json:"expiresAt"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import "sundynix-go/global"
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
global.BaseModel
|
||||||
|
ClientId string `gorm:"size:20;" json:"clientId"`
|
||||||
|
Name string `gorm:"size:50;" json:"name"`
|
||||||
|
GrantType string `gorm:"size:50;" json:"grantType"`
|
||||||
|
AdditionalInfo string `gorm:"type:text" json:"additionalInfo"`
|
||||||
|
ActiveTimeout int64 `json:"activeTimeout"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import "sundynix-go/global"
|
||||||
|
|
||||||
|
type Menu struct {
|
||||||
|
global.BaseModel
|
||||||
|
ParentId string `gorm:"size:100;default:'0'" json:"parentId" form:"parentId"`
|
||||||
|
Category int `json:"category" form:"category"`
|
||||||
|
Name string `gorm:"size:20" json:"name" form:"name"`
|
||||||
|
Title string `gorm:"size:20" json:"title" form:"title"`
|
||||||
|
Code string `gorm:"size:20" json:"code" form:"code"`
|
||||||
|
Permission string `gorm:"size:20" json:"permission" form:"permission"`
|
||||||
|
Locale string `gorm:"size:50" json:"locale" form:"locale"`
|
||||||
|
Icon string `gorm:"size:20" json:"icon" form:"icon"`
|
||||||
|
Sort int `json:"sort" form:"sort"`
|
||||||
|
Children []*Menu `json:"children" gorm:"-"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SysOperationRecord struct {
|
||||||
|
global.BaseModel
|
||||||
|
Ip string `json:"ip" form:"ip" gorm:"column:ip;comment:请求ip"` // 请求ip
|
||||||
|
Method string `json:"method" form:"method" gorm:"column:method;comment:请求方法"` // 请求方法
|
||||||
|
Path string `json:"path" form:"path" gorm:"column:path;comment:请求路径"` // 请求路径
|
||||||
|
Status int `json:"status" form:"status" gorm:"column:status;comment:请求状态"` // 请求状态
|
||||||
|
Latency time.Duration `json:"latency" form:"latency" gorm:"column:latency;comment:延迟" swaggertype:"string"` // 延迟
|
||||||
|
Agent string `json:"agent" form:"agent" gorm:"type:text;column:agent;comment:代理"` // 代理
|
||||||
|
ErrorMessage string `json:"erroMessage" form:"error_message" gorm:"column:error_message;comment:错误信息"` // 错误信息
|
||||||
|
Body string `json:"body" form:"body" gorm:"type:text;column:body;comment:请求Body"` // 请求Body
|
||||||
|
Resp string `json:"resp" form:"resp" gorm:"type:text;column:resp;comment:响应Body"` // 响应Body
|
||||||
|
UserId string `json:"userId" form:"user_id" gorm:"column:user_id;comment:用户id"` // 用户id
|
||||||
|
User User `json:"user"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import "sundynix-go/global"
|
||||||
|
|
||||||
|
type Role struct {
|
||||||
|
global.BaseModel
|
||||||
|
Name string `gorm:"size:20" json:"name" form:"name"`
|
||||||
|
Code string `gorm:"size:20" json:"code" form:"code"`
|
||||||
|
Sort int `json:"sort" form:"sort"`
|
||||||
|
Menus []Menu `gorm:"many2many:role_menu;"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
type RoleMenu struct {
|
||||||
|
RoleId string `json:"roleId" gorm:"size:100;column:role_id;comment:角色id"`
|
||||||
|
MenuId string `json:"menuId" gorm:"size:100;column:menu_id;comment:菜单id"`
|
||||||
|
}
|
||||||
@@ -1,11 +1,31 @@
|
|||||||
package system
|
package system
|
||||||
|
|
||||||
import "sundynix-go/global"
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Login interface {
|
||||||
|
GetAccount() string
|
||||||
|
GetUserId() string
|
||||||
|
GetUserInfo() any
|
||||||
|
}
|
||||||
type User struct {
|
type User struct {
|
||||||
global.BaseModel
|
global.BaseModel
|
||||||
|
TenantId string `gorm:"size:20;" json:"tenantId" form:"tenantId"`
|
||||||
ClientId string `gorm:"size:20;" json:"clientId"`
|
ClientId string `gorm:"size:20;" json:"clientId"`
|
||||||
Account string `gorm:"size:11;unique;" json:"account" form:"account"`
|
Account string `gorm:"size:11;unique;" json:"account" form:"account"`
|
||||||
Password string `gorm:"size:32;" json:"-" form:"password"`
|
Password string `gorm:"size:100;" json:"-" form:"password"`
|
||||||
Phone string `gorm:"size:11;" json:"phone" form:"phone"`
|
Phone string `gorm:"size:11;" json:"phone" form:"phone"`
|
||||||
|
Roles []Role `gorm:"many2many:user_role;" json:"roles"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) GetAccount() string {
|
||||||
|
return u.Account
|
||||||
|
}
|
||||||
|
func (u *User) GetUserId() string {
|
||||||
|
return u.Id
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) GetUserInfo() any {
|
||||||
|
return *u
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
type UserRole struct {
|
||||||
|
UserId string `json:"userId" gorm:"size:100;column:user_id;comment:用户id"`
|
||||||
|
RoleId string `json:"roleId" gorm:"size:100;column:role_id;comment:角色id"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package codegen
|
||||||
|
|
||||||
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
type CodegenRouter struct{}
|
||||||
|
|
||||||
|
func (r *CodegenRouter) InitCodegenRouter(Router *gin.RouterGroup) {
|
||||||
|
codegenRouter := Router.Group("codegen")
|
||||||
|
{
|
||||||
|
codegenRouter.POST("testConnection", codegenApi.TestConnection)
|
||||||
|
codegenRouter.POST("preview", codegenApi.Preview)
|
||||||
|
codegenRouter.POST("generate", codegenApi.Generate)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package codegen
|
||||||
|
|
||||||
|
import v1 "sundynix-go/api/v1"
|
||||||
|
|
||||||
|
type RouterGroup struct {
|
||||||
|
CodegenRouter
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
codegenApi = v1.ApiGroupApp.CodegenApiGroup.CodegenApi
|
||||||
|
)
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package router
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/router/codegen"
|
||||||
|
"sundynix-go/router/order"
|
||||||
|
"sundynix-go/router/system"
|
||||||
|
)
|
||||||
|
|
||||||
|
var GroupApp = new(Group)
|
||||||
|
|
||||||
|
// Group 路由组
|
||||||
|
type Group struct {
|
||||||
|
System system.RouterGroup
|
||||||
|
Codegen codegen.RouterGroup
|
||||||
|
Order order.RouterGroup
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import v1 "sundynix-go/api/v1"
|
||||||
|
|
||||||
|
type RouterGroup struct {
|
||||||
|
OrderRouter
|
||||||
|
RefundRouter
|
||||||
|
StockRouter
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
orderApi = v1.ApiGroupApp.OrderApiGroup.OrderApi
|
||||||
|
refundApi = v1.ApiGroupApp.OrderApiGroup.RefundApi
|
||||||
|
stockApi = v1.ApiGroupApp.OrderApiGroup.StockApi
|
||||||
|
)
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
type OrderRouter struct{}
|
||||||
|
|
||||||
|
func (r *OrderRouter) InitOrderRouter(Router *gin.RouterGroup) {
|
||||||
|
orderRouter := Router.Group("order")
|
||||||
|
{
|
||||||
|
orderRouter.POST("save", orderApi.Save)
|
||||||
|
orderRouter.POST("update", orderApi.Update)
|
||||||
|
orderRouter.POST("delete", orderApi.Delete)
|
||||||
|
orderRouter.GET("detail", orderApi.Detail)
|
||||||
|
orderRouter.POST("list", orderApi.List)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
type RefundRouter struct{}
|
||||||
|
|
||||||
|
func (r *RefundRouter) InitRefundRouter(Router *gin.RouterGroup) {
|
||||||
|
refundRouter := Router.Group("refund")
|
||||||
|
{
|
||||||
|
refundRouter.POST("save", refundApi.Save)
|
||||||
|
refundRouter.POST("update", refundApi.Update)
|
||||||
|
refundRouter.POST("delete", refundApi.Delete)
|
||||||
|
refundRouter.GET("detail", refundApi.Detail)
|
||||||
|
refundRouter.POST("list", refundApi.List)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
type StockRouter struct{}
|
||||||
|
|
||||||
|
func (r *StockRouter) InitStockRouter(Router *gin.RouterGroup) {
|
||||||
|
stockRouter := Router.Group("stock")
|
||||||
|
{
|
||||||
|
stockRouter.POST("save", stockApi.Save)
|
||||||
|
stockRouter.POST("update", stockApi.Update)
|
||||||
|
stockRouter.POST("delete", stockApi.Delete)
|
||||||
|
stockRouter.GET("detail", stockApi.Detail)
|
||||||
|
stockRouter.POST("list", stockApi.List)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AuthRouter struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// InitAuthRouter 初始化登录路由
|
||||||
|
func (s *AuthRouter) InitAuthRouter(Router *gin.RouterGroup) {
|
||||||
|
loginRouter := Router.Group("auth")
|
||||||
|
{
|
||||||
|
loginRouter.POST("login", authApi.Login)
|
||||||
|
loginRouter.GET("captcha", authApi.Captcha)
|
||||||
|
loginRouter.GET("logout", authApi.Logout) // 服务端不保存任何登录状态 退出实际是禁用了当前的jwt
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
type ClientRouter struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClientRouter) InitClientRouter(Router *gin.RouterGroup) {
|
||||||
|
clientRouter := Router.Group("client")
|
||||||
|
{
|
||||||
|
clientRouter.POST("save", clientApi.SaveClient)
|
||||||
|
clientRouter.POST("update", clientApi.UpdateClient)
|
||||||
|
clientRouter.POST("getClientList", clientApi.GetClientList)
|
||||||
|
clientRouter.POST("delete", clientApi.Delete)
|
||||||
|
clientRouter.GET("detail", clientApi.Detail)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import v1 "sundynix-go/api/v1"
|
||||||
|
|
||||||
|
type RouterGroup struct {
|
||||||
|
AuthRouter
|
||||||
|
UserRouter
|
||||||
|
ClientRouter
|
||||||
|
RoleRouter
|
||||||
|
MenuRouter
|
||||||
|
OperationRecordRouter
|
||||||
|
OssRouter
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化路由
|
||||||
|
var (
|
||||||
|
authApi = v1.ApiGroupApp.SystemApiGroup.AuthApi
|
||||||
|
userApi = v1.ApiGroupApp.SystemApiGroup.UserApi
|
||||||
|
clientApi = v1.ApiGroupApp.SystemApiGroup.ClientApi
|
||||||
|
roleApi = v1.ApiGroupApp.SystemApiGroup.RoleApi
|
||||||
|
menuApi = v1.ApiGroupApp.SystemApiGroup.MenuApi
|
||||||
|
operationRecordApi = v1.ApiGroupApp.SystemApiGroup.OperationRecordApi
|
||||||
|
ossApi = v1.ApiGroupApp.SystemApiGroup.OssApi
|
||||||
|
)
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
type MenuRouter struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MenuRouter) InitMenuRouter(Router *gin.RouterGroup) {
|
||||||
|
menuRouter := Router.Group("menu")
|
||||||
|
{
|
||||||
|
menuRouter.GET("route", menuApi.Route)
|
||||||
|
menuRouter.POST("getAllMenuTree", menuApi.GetAllMenuTree)
|
||||||
|
menuRouter.GET("getUserMenuTree", menuApi.GetUserMenuTree)
|
||||||
|
menuRouter.POST("save", menuApi.SaveMenu)
|
||||||
|
menuRouter.POST("update", menuApi.UpdateMenu)
|
||||||
|
menuRouter.GET("delete", menuApi.DeleteMenu)
|
||||||
|
menuRouter.GET("detail", menuApi.Detail)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
type OperationRecordRouter struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OperationRecordRouter) InitOperationRecordRouter(Router *gin.RouterGroup) {
|
||||||
|
operationRecordRouter := Router.Group("operationRecord")
|
||||||
|
{
|
||||||
|
operationRecordRouter.POST("createOperationRecord", operationRecordApi.CreateOperationRecord) // 新增操作记录
|
||||||
|
operationRecordRouter.GET("getOperationRecordList", operationRecordApi.GetRecordList) // 获取操作记录列表
|
||||||
|
operationRecordRouter.GET("getOperationRecordById", operationRecordApi.GetRecordById) // 获取操作记录
|
||||||
|
operationRecordRouter.DELETE("delete", operationRecordApi.DeleteRecordsByIds) // 批量删除操作记录
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
type OssRouter struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *OssRouter) InitOssRouter(Router *gin.RouterGroup) {
|
||||||
|
ossRouter := Router.Group("oss")
|
||||||
|
{
|
||||||
|
ossRouter.POST("upload", ossApi.UploadFile)
|
||||||
|
ossRouter.POST("delete", ossApi.DeleteFile)
|
||||||
|
ossRouter.POST("getFileList", ossApi.GetFileList)
|
||||||
|
ossRouter.GET("getFile", ossApi.Detail)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
type RoleRouter struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *RoleRouter) InitRoleRouter(router *gin.RouterGroup) {
|
||||||
|
roleRouter := router.Group("role")
|
||||||
|
{
|
||||||
|
roleRouter.POST("save", roleApi.SaveRole)
|
||||||
|
roleRouter.POST("update", roleApi.UpdateRole)
|
||||||
|
roleRouter.POST("getRoleList", roleApi.GetRoleList)
|
||||||
|
roleRouter.POST("delete", roleApi.Delete)
|
||||||
|
roleRouter.GET("detail", roleApi.Detail)
|
||||||
|
roleRouter.POST("grantMenu", roleApi.GrantMenu)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserRouter struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *UserRouter) InitUserRouter(Router *gin.RouterGroup) {
|
||||||
|
userRouter := Router.Group("user")
|
||||||
|
{
|
||||||
|
userRouter.POST("save", userApi.SaveUser)
|
||||||
|
userRouter.POST("update", userApi.UpdateUser)
|
||||||
|
userRouter.POST("getUserList", userApi.GetUserList)
|
||||||
|
userRouter.POST("delete", userApi.Delete)
|
||||||
|
userRouter.GET("detail", userApi.Detail)
|
||||||
|
userRouter.POST("changePassword", userApi.ChangePassword)
|
||||||
|
userRouter.POST("grantRole", userApi.GrantRole)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
package codegen
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
codegenModel "sundynix-go/model/codegen"
|
||||||
|
)
|
||||||
|
|
||||||
|
// autoRegister 在代码生成后自动修改项目的注册文件
|
||||||
|
// 包括:initialize/gorm.go, initialize/router.go, api/v1/enter.go, router/enter.go, service/enter.go
|
||||||
|
// 以及子模块的 enter.go 文件(增量追加新 feature)
|
||||||
|
func (s *CodegenService) autoRegister(outputDir string, config codegenModel.GenConfig) error {
|
||||||
|
for _, module := range config.Modules {
|
||||||
|
if strings.TrimSpace(module.PackageName) == "" || strings.TrimSpace(module.Name) == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
pkg := module.PackageName
|
||||||
|
pascalModule := module.Name
|
||||||
|
|
||||||
|
// 判断是否新模块:检查 router/{pkg}/enter.go 是否已存在
|
||||||
|
routerEnterPath := filepath.Join(outputDir, "router", pkg, "enter.go")
|
||||||
|
isNewModule := !fileExistsOnDisk(routerEnterPath)
|
||||||
|
|
||||||
|
if isNewModule {
|
||||||
|
// 新模块:注册到 5 个顶级文件
|
||||||
|
if err := s.registerGorm(outputDir, module); err != nil {
|
||||||
|
return fmt.Errorf("注册 gorm 迁移失败: %w", err)
|
||||||
|
}
|
||||||
|
if err := s.registerTopEnter(outputDir, pkg, pascalModule); err != nil {
|
||||||
|
return fmt.Errorf("注册顶级 enter 失败: %w", err)
|
||||||
|
}
|
||||||
|
if err := s.registerRouter(outputDir, pkg, pascalModule, module.Features); err != nil {
|
||||||
|
return fmt.Errorf("注册路由初始化失败: %w", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 已有模块:增量注册新 feature
|
||||||
|
if err := s.registerGormIncremental(outputDir, module); err != nil {
|
||||||
|
return fmt.Errorf("增量注册 gorm 迁移失败: %w", err)
|
||||||
|
}
|
||||||
|
if err := s.registerRouterIncremental(outputDir, pkg, pascalModule, module.Features); err != nil {
|
||||||
|
return fmt.Errorf("增量注册路由失败: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// registerGorm 向 initialize/gorm.go 的 AutoMigrate 中追加所有 feature
|
||||||
|
func (s *CodegenService) registerGorm(outputDir string, module codegenModel.Module) error {
|
||||||
|
gormPath := filepath.Join(outputDir, "initialize", "gorm.go")
|
||||||
|
content, err := os.ReadFile(gormPath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("读取 %s 失败: %w", gormPath, err)
|
||||||
|
}
|
||||||
|
text := string(content)
|
||||||
|
pkg := module.PackageName
|
||||||
|
|
||||||
|
// 1. 添加 import
|
||||||
|
importLine := fmt.Sprintf("\t\"sundynix-go/model/%s\"", pkg)
|
||||||
|
if !strings.Contains(text, importLine) {
|
||||||
|
text = strings.Replace(text, "\"go.uber.org/zap\"", importLine+"\n\n\t\"go.uber.org/zap\"", 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 在 AutoMigrate 闭合 ) 前插入 model
|
||||||
|
for _, feature := range module.Features {
|
||||||
|
if strings.TrimSpace(feature.Name) == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
modelEntry := fmt.Sprintf("\t\t%s.%s{},", pkg, feature.Name)
|
||||||
|
if !strings.Contains(text, modelEntry) {
|
||||||
|
// 找最后一个 ) 之前的位置(AutoMigrate 结束)
|
||||||
|
closeIdx := strings.LastIndex(text, "\t)")
|
||||||
|
if closeIdx > 0 {
|
||||||
|
text = text[:closeIdx] + "\n" + modelEntry + "\n" + text[closeIdx:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return os.WriteFile(gormPath, []byte(text), 0644)
|
||||||
|
}
|
||||||
|
|
||||||
|
// registerGormIncremental 增量模式:只追加新 feature 到 AutoMigrate
|
||||||
|
func (s *CodegenService) registerGormIncremental(outputDir string, module codegenModel.Module) error {
|
||||||
|
return s.registerGorm(outputDir, module) // 逻辑相同,Contains 检查保证幂等
|
||||||
|
}
|
||||||
|
|
||||||
|
// registerTopEnter 向 api/v1/enter.go、router/enter.go、service/enter.go 追加新模块
|
||||||
|
func (s *CodegenService) registerTopEnter(outputDir string, pkg, pascalModule string) error {
|
||||||
|
// --- api/v1/enter.go ---
|
||||||
|
apiEnterPath := filepath.Join(outputDir, "api", "v1", "enter.go")
|
||||||
|
if err := appendToEnterFile(apiEnterPath,
|
||||||
|
fmt.Sprintf("\t\"sundynix-go/api/v1/%s\"", pkg),
|
||||||
|
fmt.Sprintf("\t%sApiGroup %s.ApiGroup", pascalModule, pkg),
|
||||||
|
); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- router/enter.go ---
|
||||||
|
routerEnterPath := filepath.Join(outputDir, "router", "enter.go")
|
||||||
|
if err := appendToEnterFile(routerEnterPath,
|
||||||
|
fmt.Sprintf("\t\"sundynix-go/router/%s\"", pkg),
|
||||||
|
fmt.Sprintf("\t%s %s.RouterGroup", pascalModule, pkg),
|
||||||
|
); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- service/enter.go ---
|
||||||
|
svcEnterPath := filepath.Join(outputDir, "service", "enter.go")
|
||||||
|
if err := appendToEnterFile(svcEnterPath,
|
||||||
|
fmt.Sprintf("\t\"sundynix-go/service/%s\"", pkg),
|
||||||
|
fmt.Sprintf("\t%sServiceGroup %s.ServiceGroup", pascalModule, pkg),
|
||||||
|
); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// appendToEnterFile 向 enter.go 文件追加 import 和 struct 字段
|
||||||
|
func appendToEnterFile(filePath, importLine, structField string) error {
|
||||||
|
content, err := os.ReadFile(filePath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("读取 %s 失败: %w", filePath, err)
|
||||||
|
}
|
||||||
|
text := string(content)
|
||||||
|
|
||||||
|
// 添加 import(如果不存在)
|
||||||
|
if !strings.Contains(text, importLine) {
|
||||||
|
// 在最后一个 import 之前插入
|
||||||
|
lastImportIdx := strings.LastIndex(text, "\t\"")
|
||||||
|
if lastImportIdx > 0 {
|
||||||
|
// 找这行的换行符
|
||||||
|
nlIdx := strings.Index(text[lastImportIdx:], "\n")
|
||||||
|
if nlIdx > 0 {
|
||||||
|
insertPos := lastImportIdx + nlIdx + 1
|
||||||
|
text = text[:insertPos] + importLine + "\n" + text[insertPos:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加 struct 字段(如果不存在)
|
||||||
|
if !strings.Contains(text, structField) {
|
||||||
|
// 在 struct 的 } 之前插入
|
||||||
|
closeBrace := strings.Index(text, "\n}")
|
||||||
|
if closeBrace > 0 {
|
||||||
|
text = text[:closeBrace] + "\n" + structField + text[closeBrace:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return os.WriteFile(filePath, []byte(text), 0644)
|
||||||
|
}
|
||||||
|
|
||||||
|
// registerRouter 向 initialize/router.go 追加路由注册代码
|
||||||
|
func (s *CodegenService) registerRouter(outputDir, pkg, pascalModule string, features []codegenModel.Feature) error {
|
||||||
|
routerPath := filepath.Join(outputDir, "initialize", "router.go")
|
||||||
|
content, err := os.ReadFile(routerPath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("读取 %s 失败: %w", routerPath, err)
|
||||||
|
}
|
||||||
|
text := string(content)
|
||||||
|
|
||||||
|
// 1. 添加变量声明:xxxRouter := router.GroupApp.Xxx
|
||||||
|
varLine := fmt.Sprintf("\t%sRouter := router.GroupApp.%s", lowerFirst(pkg), pascalModule)
|
||||||
|
if !strings.Contains(text, varLine) {
|
||||||
|
// 在 NeedAuthGroup 行之前插入
|
||||||
|
needAuthIdx := strings.Index(text, "NeedAuthGroup := Router.Group")
|
||||||
|
if needAuthIdx > 0 {
|
||||||
|
text = text[:needAuthIdx] + varLine + "\n\n\t" + text[needAuthIdx:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 添加路由注册:xxxRouter.InitXxxRouter(NeedAuthGroup)
|
||||||
|
for _, feature := range features {
|
||||||
|
if strings.TrimSpace(feature.Name) == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
routerCall := fmt.Sprintf("\t\t%sRouter.Init%sRouter(NeedAuthGroup)", lowerFirst(pkg), feature.Name)
|
||||||
|
if !strings.Contains(text, routerCall) {
|
||||||
|
// 在最后一个 Init...Router 行之后插入
|
||||||
|
lastInitIdx := strings.LastIndex(text, "Router(NeedAuthGroup)")
|
||||||
|
if lastInitIdx > 0 {
|
||||||
|
nlIdx := strings.Index(text[lastInitIdx:], "\n")
|
||||||
|
if nlIdx > 0 {
|
||||||
|
insertPos := lastInitIdx + nlIdx
|
||||||
|
comment := fmt.Sprintf(" //%s", feature.Comment)
|
||||||
|
if feature.Comment == "" {
|
||||||
|
comment = ""
|
||||||
|
}
|
||||||
|
text = text[:insertPos] + "\n" + routerCall + comment + text[insertPos:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return os.WriteFile(routerPath, []byte(text), 0644)
|
||||||
|
}
|
||||||
|
|
||||||
|
// registerRouterIncremental 增量模式:只追加新 feature 的路由注册
|
||||||
|
func (s *CodegenService) registerRouterIncremental(outputDir, pkg, pascalModule string, features []codegenModel.Feature) error {
|
||||||
|
return s.registerRouter(outputDir, pkg, pascalModule, features) // Contains 检查保证幂等
|
||||||
|
}
|
||||||
|
|
||||||
|
// fileExistsOnDisk 检查文件是否已存在
|
||||||
|
func fileExistsOnDisk(path string) bool {
|
||||||
|
_, err := os.Stat(path)
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,979 @@
|
|||||||
|
package codegen
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"text/template"
|
||||||
|
|
||||||
|
codegenModel "sundynix-go/model/codegen"
|
||||||
|
|
||||||
|
"github.com/glebarez/sqlite"
|
||||||
|
"gorm.io/driver/mysql"
|
||||||
|
"gorm.io/driver/postgres"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CodegenService struct{}
|
||||||
|
|
||||||
|
var CodegenServiceApp = new(CodegenService)
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// 模板:model 实体(继承 global.BaseModel)
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
const modelTmpl = `package {{.PackageName}}
|
||||||
|
|
||||||
|
import "sundynix-go/global"
|
||||||
|
{{if .HasTimeField}}import "time"
|
||||||
|
{{end}}
|
||||||
|
// {{.Feature.Name}} {{.Feature.Comment}}
|
||||||
|
type {{.Feature.Name}} struct {
|
||||||
|
global.BaseModel
|
||||||
|
{{- range .Feature.Fields}}
|
||||||
|
{{.Name}} {{.Type}} ` + "`" + `gorm:"column:{{.ColumnName}}{{if .GormTag}};{{.GormTag}}{{end}}" json:"{{.JsonTag}}"` + "`" + ` // {{.Comment}}
|
||||||
|
{{- end}}
|
||||||
|
{{- range .Feature.Relations}}
|
||||||
|
{{- if eq .Type "OneToOne"}}
|
||||||
|
{{.FieldName}} *{{.TargetFeature}} ` + "`" + `gorm:"foreignKey:{{.ForeignKey}}" json:"{{lowerFirst .FieldName}}"` + "`" + `
|
||||||
|
{{- else if eq .Type "OneToMany"}}
|
||||||
|
{{.FieldName}} []{{.TargetFeature}} ` + "`" + `gorm:"foreignKey:{{.ForeignKey}}" json:"{{lowerFirst .FieldName}}"` + "`" + `
|
||||||
|
{{- else if eq .Type "ManyToMany"}}
|
||||||
|
{{.FieldName}} []{{.TargetFeature}} ` + "`" + `gorm:"many2many:{{.JoinTable}};" json:"{{lowerFirst .FieldName}}"` + "`" + `
|
||||||
|
{{- end}}
|
||||||
|
{{- end}}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ({{.Feature.Name}}) TableName() string {
|
||||||
|
return "{{.Feature.TableName}}"
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// 模板:request 结构体(每个模块一个文件,包含所有实体的请求结构体)
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
const requestTmpl = `package request
|
||||||
|
{{range .Features}}
|
||||||
|
// ---- {{.Comment}} ----
|
||||||
|
|
||||||
|
// Save{{.Name}}Req 新增{{.Comment}}请求
|
||||||
|
type Save{{.Name}}Req struct {
|
||||||
|
{{- range .Fields}}
|
||||||
|
{{.Name}} {{.Type}} ` + "`" + `json:"{{.JsonTag}}" form:"{{.JsonTag}}"{{if .Required}} binding:"required"{{end}}` + "`" + ` // {{.Comment}}
|
||||||
|
{{- end}}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update{{.Name}}Req 更新{{.Comment}}请求
|
||||||
|
type Update{{.Name}}Req struct {
|
||||||
|
Id string ` + "`" + `json:"id" binding:"required"` + "`" + ` // ID
|
||||||
|
{{- range .Fields}}
|
||||||
|
{{.Name}} {{.Type}} ` + "`" + `json:"{{.JsonTag}}" form:"{{.JsonTag}}"` + "`" + ` // {{.Comment}}
|
||||||
|
{{- end}}
|
||||||
|
}
|
||||||
|
|
||||||
|
// List{{.Name}}Req 分页查询{{.Comment}}请求
|
||||||
|
type List{{.Name}}Req struct {
|
||||||
|
Current int ` + "`" + `json:"current" form:"current"` + "`" + ` // 页码
|
||||||
|
PageSize int ` + "`" + `json:"pageSize" form:"pageSize"` + "`" + ` // 每页大小
|
||||||
|
Keyword string ` + "`" + `json:"keyword" form:"keyword"` + "`" + ` // 关键字搜索
|
||||||
|
}
|
||||||
|
{{end}}`
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// 模板:service 层(使用 request 包的结构体)
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
const serviceTmpl = `package {{.PackageName}}
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
model "sundynix-go/model/{{.PackageName}}"
|
||||||
|
req "sundynix-go/model/{{.PackageName}}/request"
|
||||||
|
)
|
||||||
|
|
||||||
|
type {{.Feature.Name}}Service struct{}
|
||||||
|
|
||||||
|
var {{.Feature.Name}}ServiceApp = new({{.Feature.Name}}Service)
|
||||||
|
|
||||||
|
func (s *{{.Feature.Name}}Service) Save(r req.Save{{.Feature.Name}}Req) error {
|
||||||
|
data := model.{{.Feature.Name}}{
|
||||||
|
{{- range .Feature.Fields}}
|
||||||
|
{{.Name}}: r.{{.Name}},
|
||||||
|
{{- end}}
|
||||||
|
}
|
||||||
|
return global.DB.Create(&data).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *{{.Feature.Name}}Service) Update(r req.Update{{.Feature.Name}}Req) error {
|
||||||
|
updates := map[string]any{
|
||||||
|
{{- range .Feature.Fields}}
|
||||||
|
"{{.ColumnName}}": r.{{.Name}},
|
||||||
|
{{- end}}
|
||||||
|
}
|
||||||
|
return global.DB.Model(&model.{{.Feature.Name}}{}).Where("id = ?", r.Id).Updates(updates).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *{{.Feature.Name}}Service) Delete(ids []string) error {
|
||||||
|
return global.DB.Where("id IN ?", ids).Delete(&model.{{.Feature.Name}}{}).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *{{.Feature.Name}}Service) Detail(id string) (data *model.{{.Feature.Name}}, err error) {
|
||||||
|
var record model.{{.Feature.Name}}
|
||||||
|
err = global.DB.Where("id = ?", id).First(&record).Error
|
||||||
|
return &record, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *{{.Feature.Name}}Service) List(r req.List{{.Feature.Name}}Req) (list []model.{{.Feature.Name}}, total int64, err error) {
|
||||||
|
if r.PageSize <= 0 {
|
||||||
|
r.PageSize = 10
|
||||||
|
}
|
||||||
|
if r.Current <= 0 {
|
||||||
|
r.Current = 1
|
||||||
|
}
|
||||||
|
db := global.DB.Model(&model.{{.Feature.Name}}{})
|
||||||
|
if r.Keyword != "" {
|
||||||
|
db = db.Where("id LIKE ?", "%"+r.Keyword+"%")
|
||||||
|
}
|
||||||
|
if err = db.Count(&total).Error; err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = db.Limit(r.PageSize).Offset(r.PageSize * (r.Current - 1)).Find(&list).Error
|
||||||
|
return
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// 模板:service enter.go
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
const serviceEnterTmpl = `package {{.PackageName}}
|
||||||
|
|
||||||
|
type ServiceGroup struct {
|
||||||
|
{{- range .Features}}
|
||||||
|
{{.Name}}Service
|
||||||
|
{{- end}}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// 模板:api handler 层(使用 request 包的结构体)
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
const apiTmpl = `package {{.PackageName}}
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/commom/response"
|
||||||
|
req "sundynix-go/model/{{.PackageName}}/request"
|
||||||
|
"sundynix-go/service"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
type {{.Feature.Name}}Api struct{}
|
||||||
|
|
||||||
|
var {{.LowerName}}Service = service.ServiceGroupApp.{{.PascalModuleName}}ServiceGroup.{{.Feature.Name}}Service
|
||||||
|
|
||||||
|
// Save
|
||||||
|
// @Tags {{.Feature.Comment}}管理
|
||||||
|
// @Summary 新增{{.Feature.Comment}}
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body req.Save{{.Feature.Name}}Req true "新增{{.Feature.Comment}}参数"
|
||||||
|
// @Success 200 {object} response.Response "新增成功"
|
||||||
|
// @Router /{{.RouterPrefix}}/save [post]
|
||||||
|
func (a *{{.Feature.Name}}Api) Save(c *gin.Context) {
|
||||||
|
var r req.Save{{.Feature.Name}}Req
|
||||||
|
if err := c.ShouldBindJSON(&r); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := {{.LowerName}}Service.Save(r); err != nil {
|
||||||
|
global.Logger.Error("新增{{.Feature.Comment}}失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("新增成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update
|
||||||
|
// @Tags {{.Feature.Comment}}管理
|
||||||
|
// @Summary 更新{{.Feature.Comment}}
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body req.Update{{.Feature.Name}}Req true "更新{{.Feature.Comment}}参数"
|
||||||
|
// @Success 200 {object} response.Response "更新成功"
|
||||||
|
// @Router /{{.RouterPrefix}}/update [post]
|
||||||
|
func (a *{{.Feature.Name}}Api) Update(c *gin.Context) {
|
||||||
|
var r req.Update{{.Feature.Name}}Req
|
||||||
|
if err := c.ShouldBindJSON(&r); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := {{.LowerName}}Service.Update(r); err != nil {
|
||||||
|
global.Logger.Error("更新{{.Feature.Comment}}失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("更新成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
// @Tags {{.Feature.Comment}}管理
|
||||||
|
// @Summary 删除{{.Feature.Comment}}(支持批量)
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body object{ids=[]string} true "id列表"
|
||||||
|
// @Success 200 {object} response.Response "删除成功"
|
||||||
|
// @Router /{{.RouterPrefix}}/delete [post]
|
||||||
|
func (a *{{.Feature.Name}}Api) Delete(c *gin.Context) {
|
||||||
|
var req struct {
|
||||||
|
Ids []string ` + "`" + `json:"ids" binding:"required,min=1"` + "`" + `
|
||||||
|
}
|
||||||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := {{.LowerName}}Service.Delete(req.Ids); err != nil {
|
||||||
|
global.Logger.Error("删除{{.Feature.Comment}}失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithMsg("删除成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detail
|
||||||
|
// @Tags {{.Feature.Comment}}管理
|
||||||
|
// @Summary 获取{{.Feature.Comment}}详情
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @Produce json
|
||||||
|
// @Param id query string true "ID"
|
||||||
|
// @Success 200 {object} response.Response "获取详情成功"
|
||||||
|
// @Router /{{.RouterPrefix}}/detail [get]
|
||||||
|
func (a *{{.Feature.Name}}Api) Detail(c *gin.Context) {
|
||||||
|
id := c.Query("id")
|
||||||
|
data, err := {{.LowerName}}Service.Detail(id)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取{{.Feature.Comment}}详情失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(data, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List
|
||||||
|
// @Tags {{.Feature.Comment}}管理
|
||||||
|
// @Summary 分页获取{{.Feature.Comment}}列表
|
||||||
|
// @Security BasicAuth
|
||||||
|
// @accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param data body req.List{{.Feature.Name}}Req true "分页参数"
|
||||||
|
// @Success 200 {object} response.Response{data=response.PageResult} "获取列表成功"
|
||||||
|
// @Router /{{.RouterPrefix}}/list [post]
|
||||||
|
func (a *{{.Feature.Name}}Api) List(c *gin.Context) {
|
||||||
|
var r req.List{{.Feature.Name}}Req
|
||||||
|
if err := c.ShouldBindJSON(&r); err != nil {
|
||||||
|
response.FailWithMsg("参数错误:"+err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
list, total, err := {{.LowerName}}Service.List(r)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Error("获取{{.Feature.Comment}}列表失败!", zap.Error(err))
|
||||||
|
response.FailWithMsg(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(response.PageResult{
|
||||||
|
List: list,
|
||||||
|
Total: total,
|
||||||
|
Page: r.Current,
|
||||||
|
PageSize: r.PageSize,
|
||||||
|
}, c)
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// 模板:api enter.go
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
const apiEnterTmpl = `package {{.PackageName}}
|
||||||
|
|
||||||
|
type ApiGroup struct {
|
||||||
|
{{- range .Features}}
|
||||||
|
{{.Name}}Api
|
||||||
|
{{- end}}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// 模板:router
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
const routerTmpl = `package {{.PackageName}}
|
||||||
|
|
||||||
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
type {{.Feature.Name}}Router struct{}
|
||||||
|
|
||||||
|
func (r *{{.Feature.Name}}Router) Init{{.Feature.Name}}Router(Router *gin.RouterGroup) {
|
||||||
|
{{.LowerName}}Router := Router.Group("{{.RouterGroup}}")
|
||||||
|
{
|
||||||
|
{{.LowerName}}Router.POST("save", {{.LowerName}}Api.Save)
|
||||||
|
{{.LowerName}}Router.POST("update", {{.LowerName}}Api.Update)
|
||||||
|
{{.LowerName}}Router.POST("delete", {{.LowerName}}Api.Delete)
|
||||||
|
{{.LowerName}}Router.GET("detail", {{.LowerName}}Api.Detail)
|
||||||
|
{{.LowerName}}Router.POST("list", {{.LowerName}}Api.List)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// 模板:router enter.go
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
const routerEnterTmpl = `package {{.PackageName}}
|
||||||
|
|
||||||
|
import v1 "sundynix-go/api/v1"
|
||||||
|
|
||||||
|
type RouterGroup struct {
|
||||||
|
{{- range .Features}}
|
||||||
|
{{.Name}}Router
|
||||||
|
{{- end}}
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
{{- range .Features}}
|
||||||
|
{{lowerFirst .Name}}Api = v1.ApiGroupApp.{{.PascalModuleName}}ApiGroup.{{.Name}}Api
|
||||||
|
{{- end}}
|
||||||
|
)
|
||||||
|
`
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// 前端模板:TypeScript 类型定义
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
const feTsTypeTmpl = `// {{.Module.Name}} 模块类型定义(自动生成,请勿手动修改)
|
||||||
|
import type { BaseModel } from '@/types'
|
||||||
|
{{range .Features}}
|
||||||
|
// ---- {{.Comment}} ----
|
||||||
|
|
||||||
|
/** {{.Comment}}实体 */
|
||||||
|
export interface {{.Name}} extends BaseModel {
|
||||||
|
{{- range .Fields}}
|
||||||
|
{{.JsonTag}}: {{goTypeToTs .Type}} // {{.Comment}}
|
||||||
|
{{- end}}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增{{.Comment}}请求 */
|
||||||
|
export interface Save{{.Name}}Req {
|
||||||
|
{{- range .Fields}}
|
||||||
|
{{.JsonTag}}{{if not .Required}}?{{end}}: {{goTypeToTs .Type}} // {{.Comment}}
|
||||||
|
{{- end}}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新{{.Comment}}请求 */
|
||||||
|
export interface Update{{.Name}}Req {
|
||||||
|
id: string
|
||||||
|
{{- range .Fields}}
|
||||||
|
{{.JsonTag}}?: {{goTypeToTs .Type}} // {{.Comment}}
|
||||||
|
{{- end}}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 分页查询{{.Comment}}请求 */
|
||||||
|
export interface List{{.Name}}Req {
|
||||||
|
current?: number
|
||||||
|
pageSize?: number
|
||||||
|
keyword?: string
|
||||||
|
}
|
||||||
|
{{end}}`
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// 前端模板:API service (Axios)
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
const feApiTmpl = `import { get, post } from '@/lib/request'
|
||||||
|
import type {
|
||||||
|
{{.Feature.Name}},
|
||||||
|
Save{{.Feature.Name}}Req,
|
||||||
|
Update{{.Feature.Name}}Req,
|
||||||
|
List{{.Feature.Name}}Req,
|
||||||
|
} from '@/types/{{.Module.PackageName}}'
|
||||||
|
import type { PageResult } from '@/types'
|
||||||
|
|
||||||
|
const BASE = '/{{.Module.PackageName}}/{{.SnakeName}}'
|
||||||
|
|
||||||
|
export const {{lowerFirst .Feature.Name}}Api = {
|
||||||
|
save: (data: Save{{.Feature.Name}}Req) =>
|
||||||
|
post<void>(` + "`" + `${BASE}/save` + "`" + `, data),
|
||||||
|
|
||||||
|
update: (data: Update{{.Feature.Name}}Req) =>
|
||||||
|
post<void>(` + "`" + `${BASE}/update` + "`" + `, data),
|
||||||
|
|
||||||
|
delete: (ids: string[]) =>
|
||||||
|
post<void>(` + "`" + `${BASE}/delete` + "`" + `, { ids }),
|
||||||
|
|
||||||
|
detail: (id: string) =>
|
||||||
|
get<{{.Feature.Name}}>(` + "`" + `${BASE}/detail` + "`" + `, { id }),
|
||||||
|
|
||||||
|
list: (params: List{{.Feature.Name}}Req) =>
|
||||||
|
post<PageResult<{{.Feature.Name}}>>(` + "`" + `${BASE}/list` + "`" + `, params),
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// 前端模板:React 管理页面
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
const fePageTmpl = `import { useState, useEffect } from 'react'
|
||||||
|
import { {{lowerFirst .Feature.Name}}Api } from '@/api/{{.Module.PackageName}}/{{.SnakeName}}'
|
||||||
|
import type { {{.Feature.Name}}, List{{.Feature.Name}}Req } from '@/types/{{.Module.PackageName}}'
|
||||||
|
import { Button } from '@/components/ui/button'
|
||||||
|
import { Input } from '@/components/ui/input'
|
||||||
|
import { Card, CardContent } from '@/components/ui/card'
|
||||||
|
import { toast } from 'sonner'
|
||||||
|
import { Plus, Pencil, Trash2, Search, RefreshCw } from 'lucide-react'
|
||||||
|
|
||||||
|
export default function {{.Feature.Name}}Page() {
|
||||||
|
const [list, setList] = useState<{{.Feature.Name}}[]>([])
|
||||||
|
const [total, setTotal] = useState(0)
|
||||||
|
const [loading, setLoading] = useState(false)
|
||||||
|
const [params, setParams] = useState<List{{.Feature.Name}}Req>({ current: 1, pageSize: 10, keyword: '' })
|
||||||
|
|
||||||
|
const load = async () => {
|
||||||
|
setLoading(true)
|
||||||
|
try {
|
||||||
|
const res = await {{lowerFirst .Feature.Name}}Api.list(params)
|
||||||
|
setList(res.list)
|
||||||
|
setTotal(res.total)
|
||||||
|
} catch {}
|
||||||
|
finally { setLoading(false) }
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => { load() }, [params.current])
|
||||||
|
|
||||||
|
const handleDelete = async (id: string) => {
|
||||||
|
if (!confirm('确认删除?')) return
|
||||||
|
try {
|
||||||
|
await {{lowerFirst .Feature.Name}}Api.delete([id])
|
||||||
|
toast.success('删除成功')
|
||||||
|
load()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
const totalPages = Math.ceil(total / (params.pageSize ?? 10))
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<h2 className="text-xl font-semibold">{{.Feature.Comment}}管理</h2>
|
||||||
|
<p className="text-sm text-muted-foreground">共 {total} 条记录</p>
|
||||||
|
</div>
|
||||||
|
<Button size="sm" className="gap-1"><Plus className="h-4 w-4" /> 新增</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<CardContent className="pt-4">
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Input
|
||||||
|
placeholder="关键字搜索"
|
||||||
|
value={params.keyword}
|
||||||
|
onChange={e => setParams(p => ({ ...p, keyword: e.target.value, current: 1 }))}
|
||||||
|
className="max-w-60"
|
||||||
|
/>
|
||||||
|
<Button variant="outline" size="sm" onClick={load}><Search className="h-4 w-4 mr-1" />搜索</Button>
|
||||||
|
<Button variant="ghost" size="sm" onClick={() => setParams(p => ({ ...p, keyword: '', current: 1 }))}>
|
||||||
|
<RefreshCw className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<CardContent className="p-0">
|
||||||
|
<table className="w-full text-sm">
|
||||||
|
<thead className="border-b bg-muted/40">
|
||||||
|
<tr>
|
||||||
|
{{- range .Feature.Fields}}{{if .Comment}}
|
||||||
|
<th className="px-4 py-3 text-left font-medium text-muted-foreground">{{.Comment}}</th>
|
||||||
|
{{- end}}{{end}}
|
||||||
|
<th className="px-4 py-3 text-left font-medium text-muted-foreground">创建时间</th>
|
||||||
|
<th className="px-4 py-3 text-left font-medium text-muted-foreground">操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{loading ? (
|
||||||
|
<tr><td colSpan={ {{- .ColCount -}} } className="py-12 text-center text-muted-foreground">加载中…</td></tr>
|
||||||
|
) : list.length === 0 ? (
|
||||||
|
<tr><td colSpan={ {{- .ColCount -}} } className="py-12 text-center text-muted-foreground">暂无数据</td></tr>
|
||||||
|
) : list.map(item => (
|
||||||
|
<tr key={item.id} className="border-b last:border-b-0 hover:bg-muted/30 transition-colors">
|
||||||
|
{{- range .Feature.Fields}}{{if .JsonTag}}<td className="px-4 py-3">{String(item.{{.JsonTag}} ?? '—')}</td>{{end}}{{end}}
|
||||||
|
<td className="px-4 py-3 text-xs text-muted-foreground">{new Date(item.createdAt).toLocaleString()}</td>
|
||||||
|
<td className="px-4 py-3">
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<Button variant="ghost" size="icon" className="h-7 w-7"><Pencil className="h-3.5 w-3.5" /></Button>
|
||||||
|
<Button variant="ghost" size="icon" className="h-7 w-7 text-destructive" onClick={() => handleDelete(item.id)}>
|
||||||
|
<Trash2 className="h-3.5 w-3.5" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{totalPages > 1 && (
|
||||||
|
<div className="flex items-center justify-between border-t px-4 py-3">
|
||||||
|
<span className="text-xs text-muted-foreground">第 {params.current} / {totalPages} 页</span>
|
||||||
|
<div className="flex gap-1">
|
||||||
|
<Button variant="outline" size="sm" disabled={(params.current ?? 1) <= 1}
|
||||||
|
onClick={() => setParams(p => ({ ...p, current: (p.current ?? 1) - 1 }))}>上一页</Button>
|
||||||
|
<Button variant="outline" size="sm" disabled={(params.current ?? 1) >= totalPages}
|
||||||
|
onClick={() => setParams(p => ({ ...p, current: (p.current ?? 1) + 1 }))}>下一页</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// 辅助函数
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
func lowerFirst(s string) string {
|
||||||
|
if s == "" {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
return strings.ToLower(s[:1]) + s[1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
func hasTimeField(feature codegenModel.Feature) bool {
|
||||||
|
for _, f := range feature.Fields {
|
||||||
|
if f.Type == "time.Time" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// goTypeToTs 将 Go 类型映射为 TypeScript 类型
|
||||||
|
func goTypeToTs(goType string) string {
|
||||||
|
switch goType {
|
||||||
|
case "int", "int8", "int16", "int32", "int64",
|
||||||
|
"uint", "uint8", "uint16", "uint32", "uint64",
|
||||||
|
"float32", "float64":
|
||||||
|
return "number"
|
||||||
|
case "bool":
|
||||||
|
return "boolean"
|
||||||
|
case "time.Time":
|
||||||
|
return "string"
|
||||||
|
default:
|
||||||
|
return "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// TestConnection 测试数据库连接
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
func (s *CodegenService) TestConnection(cfg codegenModel.DbConfig) error {
|
||||||
|
_, err := openDB(cfg)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func openDB(cfg codegenModel.DbConfig) (*gorm.DB, error) {
|
||||||
|
switch strings.ToLower(cfg.DbType) {
|
||||||
|
case "mysql":
|
||||||
|
dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local",
|
||||||
|
cfg.User, cfg.Password, cfg.Host, cfg.Port, cfg.DbName)
|
||||||
|
return gorm.Open(mysql.Open(dsn), &gorm.Config{})
|
||||||
|
case "postgres", "postgresql":
|
||||||
|
dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable",
|
||||||
|
cfg.Host, cfg.User, cfg.Password, cfg.DbName, cfg.Port)
|
||||||
|
return gorm.Open(postgres.Open(dsn), &gorm.Config{})
|
||||||
|
case "sqlite":
|
||||||
|
return gorm.Open(sqlite.Open(cfg.DbName), &gorm.Config{})
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("不支持的数据库类型: %s", cfg.DbType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// Preview 预览生成代码
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
func (s *CodegenService) Preview(config codegenModel.GenConfig) ([]codegenModel.PreviewFile, error) {
|
||||||
|
backendFiles, err := s.renderAll(config, config.OutputDir)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if config.FrontendOutputDir != "" {
|
||||||
|
feFiles, err := s.renderFrontend(config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
backendFiles = append(backendFiles, feFiles...)
|
||||||
|
}
|
||||||
|
return backendFiles, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// Generate 生成并写入文件
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
func (s *CodegenService) Generate(config codegenModel.GenConfig) (*codegenModel.GenResult, error) {
|
||||||
|
outputDir := config.OutputDir
|
||||||
|
if outputDir == "" {
|
||||||
|
cwd, _ := os.Getwd()
|
||||||
|
outputDir = cwd
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. 渲染后端文件
|
||||||
|
backendFiles, err := s.renderAll(config, outputDir)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 自动注册(必须在写入文件之前,否则 enter.go 已存在导致误判为已有模块)
|
||||||
|
regMsg := ""
|
||||||
|
if err := s.autoRegister(outputDir, config); err != nil {
|
||||||
|
regMsg = fmt.Sprintf("⚠️ 自动注册失败: %s", err.Error())
|
||||||
|
} else {
|
||||||
|
regMsg = "✅ 自动注册成功(gorm/router/enter)"
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 写入后端文件(增量模式下跳过已存在文件)
|
||||||
|
written, skipped := writeFilesIncremental(outputDir, backendFiles, config.Overwrite)
|
||||||
|
|
||||||
|
allFiles := backendFiles
|
||||||
|
|
||||||
|
// 4. 生成前端文件(如果配置了前端输出目录)
|
||||||
|
if config.FrontendOutputDir != "" {
|
||||||
|
feFiles, err := s.renderFrontend(config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
w, sk := writeFilesIncremental(config.FrontendOutputDir, feFiles, config.Overwrite)
|
||||||
|
written += w
|
||||||
|
skipped += sk
|
||||||
|
allFiles = append(allFiles, feFiles...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &codegenModel.GenResult{
|
||||||
|
OutputDir: outputDir,
|
||||||
|
Files: allFiles,
|
||||||
|
Message: fmt.Sprintf("写入 %d 个文件,跳过 %d 个已存在文件。%s", written, skipped, regMsg),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// writeFilesIncremental 写入文件,支持增量模式
|
||||||
|
// overwrite=false 时,已存在的文件会被跳过
|
||||||
|
// 返回 (写入数, 跳过数)
|
||||||
|
func writeFilesIncremental(baseDir string, files []codegenModel.PreviewFile, overwrite bool) (written int, skipped int) {
|
||||||
|
for _, f := range files {
|
||||||
|
fullPath := filepath.Join(baseDir, f.FilePath)
|
||||||
|
// 增量模式下跳过已存在文件(但 AlwaysOverwrite 的聚合文件始终覆盖)
|
||||||
|
if !overwrite && !f.AlwaysOverwrite {
|
||||||
|
if _, err := os.Stat(fullPath); err == nil {
|
||||||
|
skipped++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := os.MkdirAll(filepath.Dir(fullPath), 0755); err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := os.WriteFile(fullPath, []byte(f.Content), 0644); err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
written++
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// renderFrontend 渲染前端 TypeScript / React 文件
|
||||||
|
func (s *CodegenService) renderFrontend(config codegenModel.GenConfig) ([]codegenModel.PreviewFile, error) {
|
||||||
|
var result []codegenModel.PreviewFile
|
||||||
|
|
||||||
|
funcMap := template.FuncMap{
|
||||||
|
"lowerFirst": lowerFirst,
|
||||||
|
"goTypeToTs": goTypeToTs,
|
||||||
|
"not": func(b bool) bool { return !b },
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, module := range config.Modules {
|
||||||
|
// 跳过未填写包名的模块
|
||||||
|
if strings.TrimSpace(module.PackageName) == "" || strings.TrimSpace(module.Name) == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// ---- TypeScript 类型(模块级,所有实体合并到 index.ts)----
|
||||||
|
tsData := struct {
|
||||||
|
Module codegenModel.Module
|
||||||
|
Features []codegenModel.Feature
|
||||||
|
}{module, module.Features}
|
||||||
|
tsContent, err := renderTmpl("fe_ts_type", feTsTypeTmpl, funcMap, tsData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result = append(result, codegenModel.PreviewFile{
|
||||||
|
FilePath: filepath.Join("src", "types", module.PackageName, "index.ts"),
|
||||||
|
Content: tsContent,
|
||||||
|
AlwaysOverwrite: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, feature := range module.Features {
|
||||||
|
// 跳过未命名的实体
|
||||||
|
if strings.TrimSpace(feature.Name) == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
snakeName := toSnake(feature.Name)
|
||||||
|
|
||||||
|
feData := struct {
|
||||||
|
Module codegenModel.Module
|
||||||
|
Feature codegenModel.Feature
|
||||||
|
SnakeName string
|
||||||
|
ColCount int
|
||||||
|
}{module, feature, snakeName, len(feature.Fields) + 2}
|
||||||
|
|
||||||
|
// API service
|
||||||
|
apiContent, err := renderTmpl("fe_api", feApiTmpl, funcMap, feData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result = append(result, codegenModel.PreviewFile{
|
||||||
|
FilePath: filepath.Join("src", "api", module.PackageName, snakeName+".ts"),
|
||||||
|
Content: apiContent,
|
||||||
|
})
|
||||||
|
|
||||||
|
// React page
|
||||||
|
pageContent, err := renderTmpl("fe_page", fePageTmpl, funcMap, feData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result = append(result, codegenModel.PreviewFile{
|
||||||
|
FilePath: filepath.Join("src", "pages", module.PackageName, feature.Name+"Page.tsx"),
|
||||||
|
Content: pageContent,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// renderAll 渲染所有模块的所有文件
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
func (s *CodegenService) renderAll(config codegenModel.GenConfig, outputDir string) ([]codegenModel.PreviewFile, error) {
|
||||||
|
var result []codegenModel.PreviewFile
|
||||||
|
|
||||||
|
funcMap := template.FuncMap{
|
||||||
|
"lowerFirst": lowerFirst,
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, module := range config.Modules {
|
||||||
|
// 跳过未填写包名的模块
|
||||||
|
if strings.TrimSpace(module.PackageName) == "" || strings.TrimSpace(module.Name) == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
pkg := module.PackageName
|
||||||
|
pascalModule := module.Name
|
||||||
|
|
||||||
|
type featureEntry struct {
|
||||||
|
Name string
|
||||||
|
PascalModuleName string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发现已存在的 feature(扫描 service/{pkg}/ 下的 *_service.go 文件)
|
||||||
|
existingFeatures := discoverExistingFeatures(outputDir, pkg)
|
||||||
|
|
||||||
|
// 合并:已有 feature + 当前配置中的 feature(去重)
|
||||||
|
featureSet := make(map[string]bool)
|
||||||
|
var allFeatureEntries []featureEntry
|
||||||
|
for _, name := range existingFeatures {
|
||||||
|
if !featureSet[name] {
|
||||||
|
featureSet[name] = true
|
||||||
|
allFeatureEntries = append(allFeatureEntries, featureEntry{name, pascalModule})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, f := range module.Features {
|
||||||
|
if strings.TrimSpace(f.Name) == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !featureSet[f.Name] {
|
||||||
|
featureSet[f.Name] = true
|
||||||
|
allFeatureEntries = append(allFeatureEntries, featureEntry{f.Name, pascalModule})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enterData := struct {
|
||||||
|
PackageName string
|
||||||
|
Features []featureEntry
|
||||||
|
}{pkg, allFeatureEntries}
|
||||||
|
|
||||||
|
// service/enter.go(始终覆盖,包含所有已有+新增 feature)
|
||||||
|
svcEnter, err := renderTmpl("service_enter", serviceEnterTmpl, funcMap, enterData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result = append(result, codegenModel.PreviewFile{
|
||||||
|
FilePath: filepath.Join("service", pkg, "enter.go"),
|
||||||
|
Content: svcEnter,
|
||||||
|
AlwaysOverwrite: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
// api/v1/enter.go
|
||||||
|
apiEnter, err := renderTmpl("api_enter", apiEnterTmpl, funcMap, enterData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result = append(result, codegenModel.PreviewFile{
|
||||||
|
FilePath: filepath.Join("api", "v1", pkg, "enter.go"),
|
||||||
|
Content: apiEnter,
|
||||||
|
AlwaysOverwrite: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
// router/enter.go
|
||||||
|
routerEnter, err := renderTmpl("router_enter", routerEnterTmpl, funcMap, enterData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result = append(result, codegenModel.PreviewFile{
|
||||||
|
FilePath: filepath.Join("router", pkg, "enter.go"),
|
||||||
|
Content: routerEnter,
|
||||||
|
AlwaysOverwrite: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
// ---- request 结构体(按 feature 分文件,增量安全)----
|
||||||
|
for _, feature := range module.Features {
|
||||||
|
if strings.TrimSpace(feature.Name) == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
reqData := struct {
|
||||||
|
PackageName string
|
||||||
|
Features []codegenModel.Feature
|
||||||
|
}{pkg, []codegenModel.Feature{feature}}
|
||||||
|
reqContent, err := renderTmpl("request", requestTmpl, funcMap, reqData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result = append(result, codegenModel.PreviewFile{
|
||||||
|
FilePath: filepath.Join("model", pkg, "request", toSnake(feature.Name)+"_request.go"),
|
||||||
|
Content: reqContent,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 每个 Feature 生成:model / service / api / router
|
||||||
|
for _, feature := range module.Features {
|
||||||
|
// 跳过未命名的实体
|
||||||
|
if strings.TrimSpace(feature.Name) == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
lower := lowerFirst(feature.Name)
|
||||||
|
snakeName := toSnake(feature.Name)
|
||||||
|
routerGroup := snakeName
|
||||||
|
routerPrefix := pkg + "/" + snakeName
|
||||||
|
|
||||||
|
// ---- model ----
|
||||||
|
modelData := struct {
|
||||||
|
PackageName string
|
||||||
|
Feature codegenModel.Feature
|
||||||
|
HasTimeField bool
|
||||||
|
}{pkg, feature, hasTimeField(feature)}
|
||||||
|
modelContent, err := renderTmpl("model", modelTmpl, funcMap, modelData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result = append(result, codegenModel.PreviewFile{
|
||||||
|
FilePath: filepath.Join("model", pkg, snakeName+".go"),
|
||||||
|
Content: modelContent,
|
||||||
|
})
|
||||||
|
|
||||||
|
// ---- service ----
|
||||||
|
svcData := struct {
|
||||||
|
PackageName string
|
||||||
|
Feature codegenModel.Feature
|
||||||
|
}{pkg, feature}
|
||||||
|
svcContent, err := renderTmpl("service", serviceTmpl, funcMap, svcData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result = append(result, codegenModel.PreviewFile{
|
||||||
|
FilePath: filepath.Join("service", pkg, snakeName+"_service.go"),
|
||||||
|
Content: svcContent,
|
||||||
|
})
|
||||||
|
|
||||||
|
// ---- api handler ----
|
||||||
|
apiData := struct {
|
||||||
|
PackageName string
|
||||||
|
Feature codegenModel.Feature
|
||||||
|
LowerName string
|
||||||
|
RouterPrefix string
|
||||||
|
PascalModuleName string
|
||||||
|
}{pkg, feature, lower, routerPrefix, pascalModule}
|
||||||
|
apiContent, err := renderTmpl("api", apiTmpl, funcMap, apiData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result = append(result, codegenModel.PreviewFile{
|
||||||
|
FilePath: filepath.Join("api", "v1", pkg, snakeName+".go"),
|
||||||
|
Content: apiContent,
|
||||||
|
})
|
||||||
|
|
||||||
|
// ---- router ----
|
||||||
|
routerData := struct {
|
||||||
|
PackageName string
|
||||||
|
Feature codegenModel.Feature
|
||||||
|
LowerName string
|
||||||
|
RouterGroup string
|
||||||
|
}{pkg, feature, lower, routerGroup}
|
||||||
|
routerContent, err := renderTmpl("router", routerTmpl, funcMap, routerData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result = append(result, codegenModel.PreviewFile{
|
||||||
|
FilePath: filepath.Join("router", pkg, snakeName+"_router.go"),
|
||||||
|
Content: routerContent,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func renderTmpl(name, tmplStr string, funcMap template.FuncMap, data any) (string, error) {
|
||||||
|
t, err := template.New(name).Funcs(funcMap).Parse(tmplStr)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("解析模板 [%s] 失败: %w", name, err)
|
||||||
|
}
|
||||||
|
var buf bytes.Buffer
|
||||||
|
if err = t.Execute(&buf, data); err != nil {
|
||||||
|
return "", fmt.Errorf("渲染模板 [%s] 失败: %w", name, err)
|
||||||
|
}
|
||||||
|
return buf.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// toSnake 将 PascalCase 转为 snake_case
|
||||||
|
func toSnake(s string) string {
|
||||||
|
var result []rune
|
||||||
|
for i, r := range s {
|
||||||
|
if r >= 'A' && r <= 'Z' {
|
||||||
|
if i > 0 {
|
||||||
|
result = append(result, '_')
|
||||||
|
}
|
||||||
|
result = append(result, r+32)
|
||||||
|
} else {
|
||||||
|
result = append(result, r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string(result)
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package codegen
|
||||||
|
|
||||||
|
type ServiceGroup struct {
|
||||||
|
CodegenService
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/service/codegen"
|
||||||
|
"sundynix-go/service/order"
|
||||||
|
"sundynix-go/service/system"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ServiceGroupApp = new(ServiceGroup)
|
||||||
|
|
||||||
|
type ServiceGroup struct {
|
||||||
|
SystemServiceGroup system.ServiceGroup
|
||||||
|
CodegenServiceGroup codegen.ServiceGroup
|
||||||
|
OrderServiceGroup order.ServiceGroup
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
type ServiceGroup struct {
|
||||||
|
OrderService
|
||||||
|
RefundService
|
||||||
|
StockService
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
model "sundynix-go/model/order"
|
||||||
|
req "sundynix-go/model/order/request"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OrderService struct{}
|
||||||
|
|
||||||
|
var OrderServiceApp = new(OrderService)
|
||||||
|
|
||||||
|
func (s *OrderService) Save(r req.SaveOrderReq) error {
|
||||||
|
data := model.Order{
|
||||||
|
UserId: r.UserId,
|
||||||
|
}
|
||||||
|
return global.DB.Create(&data).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *OrderService) Update(r req.UpdateOrderReq) error {
|
||||||
|
updates := map[string]any{
|
||||||
|
"user_id": r.UserId,
|
||||||
|
}
|
||||||
|
return global.DB.Model(&model.Order{}).Where("id = ?", r.Id).Updates(updates).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *OrderService) Delete(ids []string) error {
|
||||||
|
return global.DB.Where("id IN ?", ids).Delete(&model.Order{}).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *OrderService) Detail(id string) (data *model.Order, err error) {
|
||||||
|
var record model.Order
|
||||||
|
err = global.DB.Where("id = ?", id).First(&record).Error
|
||||||
|
return &record, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *OrderService) List(r req.ListOrderReq) (list []model.Order, total int64, err error) {
|
||||||
|
if r.PageSize <= 0 {
|
||||||
|
r.PageSize = 10
|
||||||
|
}
|
||||||
|
if r.Current <= 0 {
|
||||||
|
r.Current = 1
|
||||||
|
}
|
||||||
|
db := global.DB.Model(&model.Order{})
|
||||||
|
if r.Keyword != "" {
|
||||||
|
db = db.Where("id LIKE ?", "%"+r.Keyword+"%")
|
||||||
|
}
|
||||||
|
if err = db.Count(&total).Error; err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = db.Limit(r.PageSize).Offset(r.PageSize * (r.Current - 1)).Find(&list).Error
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
model "sundynix-go/model/order"
|
||||||
|
req "sundynix-go/model/order/request"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RefundService struct{}
|
||||||
|
|
||||||
|
var RefundServiceApp = new(RefundService)
|
||||||
|
|
||||||
|
func (s *RefundService) Save(r req.SaveRefundReq) error {
|
||||||
|
data := model.Refund{
|
||||||
|
UserId: r.UserId,
|
||||||
|
}
|
||||||
|
return global.DB.Create(&data).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RefundService) Update(r req.UpdateRefundReq) error {
|
||||||
|
updates := map[string]any{
|
||||||
|
"user_id": r.UserId,
|
||||||
|
}
|
||||||
|
return global.DB.Model(&model.Refund{}).Where("id = ?", r.Id).Updates(updates).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RefundService) Delete(ids []string) error {
|
||||||
|
return global.DB.Where("id IN ?", ids).Delete(&model.Refund{}).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RefundService) Detail(id string) (data *model.Refund, err error) {
|
||||||
|
var record model.Refund
|
||||||
|
err = global.DB.Where("id = ?", id).First(&record).Error
|
||||||
|
return &record, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RefundService) List(r req.ListRefundReq) (list []model.Refund, total int64, err error) {
|
||||||
|
if r.PageSize <= 0 {
|
||||||
|
r.PageSize = 10
|
||||||
|
}
|
||||||
|
if r.Current <= 0 {
|
||||||
|
r.Current = 1
|
||||||
|
}
|
||||||
|
db := global.DB.Model(&model.Refund{})
|
||||||
|
if r.Keyword != "" {
|
||||||
|
db = db.Where("id LIKE ?", "%"+r.Keyword+"%")
|
||||||
|
}
|
||||||
|
if err = db.Count(&total).Error; err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = db.Limit(r.PageSize).Offset(r.PageSize * (r.Current - 1)).Find(&list).Error
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
model "sundynix-go/model/order"
|
||||||
|
req "sundynix-go/model/order/request"
|
||||||
|
)
|
||||||
|
|
||||||
|
type StockService struct{}
|
||||||
|
|
||||||
|
var StockServiceApp = new(StockService)
|
||||||
|
|
||||||
|
func (s *StockService) Save(r req.SaveStockReq) error {
|
||||||
|
data := model.Stock{
|
||||||
|
Amount: r.Amount,
|
||||||
|
}
|
||||||
|
return global.DB.Create(&data).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *StockService) Update(r req.UpdateStockReq) error {
|
||||||
|
updates := map[string]any{
|
||||||
|
"amount": r.Amount,
|
||||||
|
}
|
||||||
|
return global.DB.Model(&model.Stock{}).Where("id = ?", r.Id).Updates(updates).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *StockService) Delete(ids []string) error {
|
||||||
|
return global.DB.Where("id IN ?", ids).Delete(&model.Stock{}).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *StockService) Detail(id string) (data *model.Stock, err error) {
|
||||||
|
var record model.Stock
|
||||||
|
err = global.DB.Where("id = ?", id).First(&record).Error
|
||||||
|
return &record, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *StockService) List(r req.ListStockReq) (list []model.Stock, total int64, err error) {
|
||||||
|
if r.PageSize <= 0 {
|
||||||
|
r.PageSize = 10
|
||||||
|
}
|
||||||
|
if r.Current <= 0 {
|
||||||
|
r.Current = 1
|
||||||
|
}
|
||||||
|
db := global.DB.Model(&model.Stock{})
|
||||||
|
if r.Keyword != "" {
|
||||||
|
db = db.Where("id LIKE ?", "%"+r.Keyword+"%")
|
||||||
|
}
|
||||||
|
if err = db.Count(&total).Error; err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = db.Limit(r.PageSize).Offset(r.PageSize * (r.Current - 1)).Find(&list).Error
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
type ServiceGroup struct {
|
||||||
|
JwtService
|
||||||
|
UserService
|
||||||
|
ClientService
|
||||||
|
RoleService
|
||||||
|
MenuService
|
||||||
|
OperationRecordService
|
||||||
|
OssService
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"mime/multipart"
|
||||||
|
"strings"
|
||||||
|
"sundynix-go/global"
|
||||||
|
common "sundynix-go/model/commom/request"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
sysReq "sundynix-go/model/system/request"
|
||||||
|
"sundynix-go/utils/uniqueid"
|
||||||
|
"sundynix-go/utils/upload"
|
||||||
|
|
||||||
|
"go.uber.org/zap"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OssService struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
var OssServiceApp = new(OssService)
|
||||||
|
|
||||||
|
func (o *OssService) Save(file system.Oss) error {
|
||||||
|
return global.DB.Create(&file).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OssService) Upload(header *multipart.FileHeader) (file system.Oss, err error) {
|
||||||
|
instance := upload.OssInstance()
|
||||||
|
filepath, key, uploadErr := instance.UploadFile(header)
|
||||||
|
if uploadErr != nil {
|
||||||
|
return file, uploadErr
|
||||||
|
}
|
||||||
|
//文件后缀
|
||||||
|
s := strings.Split(header.Filename, ".")
|
||||||
|
f := system.Oss{
|
||||||
|
Id: uniqueid.GenerateId(),
|
||||||
|
Key: key, // uploads/2025-09-17/
|
||||||
|
Name: header.Filename,
|
||||||
|
Suffix: s[len(s)-1],
|
||||||
|
Tag: s[len(s)-1],
|
||||||
|
Url: filepath, // http://127.0.0.1:9000/planting-fun/uploads/2025-09-17/211476f3837fc7acbaebf0f901c1bd68.png
|
||||||
|
}
|
||||||
|
return f, o.Save(f)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OssService) DeleteFileByIds(ids common.IdsReq) error {
|
||||||
|
//循环删除
|
||||||
|
instance := upload.OssInstance()
|
||||||
|
for _, id := range ids.Ids {
|
||||||
|
file, err := o.GetById(id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err = instance.DeleteFile(file.Key); err != nil {
|
||||||
|
global.Logger.Error("删除文件失败!", zap.Error(err))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err := global.DB.Where("id IN (?)", ids.Ids).Delete(&system.Oss{}).Error
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OssService) GetById(id string) (system.Oss, error) {
|
||||||
|
var file system.Oss
|
||||||
|
err := global.DB.Where("id = ?", id).First(&file).Error
|
||||||
|
//不存在的时候不要返回错误,而是返回nil
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return file, nil
|
||||||
|
}
|
||||||
|
return file, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OssService) GetFileList(info sysReq.GetOssFileList) (list interface{}, total int64, err error) {
|
||||||
|
limit := info.PageSize
|
||||||
|
offset := info.PageSize * (info.Current - 1)
|
||||||
|
db := global.DB.Model(&system.Oss{})
|
||||||
|
var files []system.Oss
|
||||||
|
if info.Name != "" {
|
||||||
|
db = db.Where("name LIKE ?", "%"+info.Name+"%")
|
||||||
|
}
|
||||||
|
err = db.Count(&total).Error
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = db.Limit(limit).Offset(offset).Order("created_at desc").Find(&files).Error
|
||||||
|
return files, total, err
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"sundynix-go/global"
|
||||||
|
common "sundynix-go/model/commom/request"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
systemReq "sundynix-go/model/system/request"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ClientService struct{}
|
||||||
|
|
||||||
|
var ClientServiceApp = new(ClientService)
|
||||||
|
|
||||||
|
func (s *ClientService) SaveClient(client system.Client) error {
|
||||||
|
if !errors.Is(global.DB.Where("client_id = ?", client.ClientId).First(&system.Client{}).Error, gorm.ErrRecordNotFound) {
|
||||||
|
return errors.New("存在重复clientId,请修改clientId")
|
||||||
|
}
|
||||||
|
return global.DB.Create(&client).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClientService) UpdateClient(client system.Client) error {
|
||||||
|
return global.DB.Model(&client).Where("id = ?", client.Id).Updates(&client).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClientService) GetClientList(info systemReq.GetClientList) (list interface{}, total int64, err error) {
|
||||||
|
limit := info.PageSize
|
||||||
|
offset := info.PageSize * (info.Current - 1)
|
||||||
|
db := global.DB.Model(&system.Client{})
|
||||||
|
var clientList []system.Client
|
||||||
|
if info.ClientId != "" {
|
||||||
|
db = db.Where("client_id = ?", info.ClientId)
|
||||||
|
}
|
||||||
|
if info.Name != "" {
|
||||||
|
db = db.Where("name LIKE ?", "%"+info.Name+"%")
|
||||||
|
}
|
||||||
|
err = db.Count(&total).Error
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = db.Limit(limit).Offset(offset).Find(&clientList).Error
|
||||||
|
return clientList, total, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClientService) DeleteClientByIds(ids common.IdsReq) (err error) {
|
||||||
|
return global.DB.Where("id IN (?)", ids.Ids).Delete(&system.Client{}).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClientService) GetClientById(id string) (client *system.Client, err error) {
|
||||||
|
var c system.Client
|
||||||
|
err = global.DB.Where("id = ?", id).First(&c).Error
|
||||||
|
return &c, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ClientService) GetClientByClientId(clientId string) (client *system.Client, err error) {
|
||||||
|
var c system.Client
|
||||||
|
err = global.DB.Where("client_id = ?", clientId).First(&c).Error
|
||||||
|
return &c, err
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
type JwtService struct{}
|
||||||
|
|
||||||
|
var JwtServiceApp = new(JwtService)
|
||||||
|
|
||||||
|
// 登出,禁用jwt
|
||||||
|
func (s *JwtService) PutBlacklist(userId string, token string) (err error) {
|
||||||
|
expire, err := utils.ParseDuration(global.Config.JWT.ExpiresTime)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = global.Redis.Set(context.Background(), userId, token, expire).Err()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *JwtService) IsInBlacklist(userId string, token string) bool {
|
||||||
|
val, err := global.Redis.Get(context.Background(), userId).Result()
|
||||||
|
return err == nil && val == token
|
||||||
|
}
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MenuService struct{}
|
||||||
|
|
||||||
|
var MenuServiceApp = new(MenuService)
|
||||||
|
|
||||||
|
func (s *MenuService) SaveMenu(menu system.Menu) error {
|
||||||
|
//1.根据code和name查询是否存在重名
|
||||||
|
if err := global.DB.Where("code = ? or name = ?", menu.Code, menu.Name).First(&system.Menu{}).Error; err == nil {
|
||||||
|
return errors.New("菜单已存在")
|
||||||
|
}
|
||||||
|
return global.DB.Create(&menu).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MenuService) UpdateMenu(menu *system.Menu) (err error) {
|
||||||
|
var sysMenu system.Menu
|
||||||
|
menuMap := map[string]interface{}{
|
||||||
|
"Category": menu.Category,
|
||||||
|
"Name": menu.Name,
|
||||||
|
"Title": menu.Title,
|
||||||
|
"Code": menu.Code,
|
||||||
|
"Permission": menu.Permission,
|
||||||
|
"Locale": menu.Locale,
|
||||||
|
"Icon": menu.Icon,
|
||||||
|
"Sort": menu.Sort,
|
||||||
|
}
|
||||||
|
err = global.DB.Where("id = ?", menu.Id).First(&sysMenu).Error
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Debug(err.Error())
|
||||||
|
return errors.New("查询菜单失败")
|
||||||
|
}
|
||||||
|
err = global.DB.Model(&sysMenu).Updates(menuMap).Error
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MenuService) DeleteMenu(id string) (err error) {
|
||||||
|
err = global.DB.First(&system.Menu{}, "parent_id = ?", id).Error
|
||||||
|
if err == nil {
|
||||||
|
return errors.New("请先删除子菜单")
|
||||||
|
}
|
||||||
|
var menu system.Menu
|
||||||
|
err = global.DB.Where("id = ?", id).First(&menu).Error
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("菜单记录不存在")
|
||||||
|
}
|
||||||
|
// 同步删除menu表和role-menu表数据
|
||||||
|
return global.DB.Transaction(func(tx *gorm.DB) error {
|
||||||
|
if err = tx.Where("id = ?", id).Delete(&system.Menu{}).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err = tx.Where("menu_id = ?", id).Delete(&system.RoleMenu{}).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MenuService) GetMenuById(id string) (menu *system.Menu, err error) {
|
||||||
|
var m system.Menu
|
||||||
|
err = global.DB.Where("id = ?", id).First(&m).Error
|
||||||
|
return &m, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MenuService) GetAllMenuTree(category int, parentId string) (menus []*system.Menu, err error) {
|
||||||
|
//1,先根据category和parentId获取所有菜单 category默认为0,parentId默认为0
|
||||||
|
//2.讲查询出的列表构建为树结构
|
||||||
|
var menuList []*system.Menu
|
||||||
|
db := global.DB.Model(&system.Menu{})
|
||||||
|
if category != 0 {
|
||||||
|
db.Where("category = ?", category)
|
||||||
|
}
|
||||||
|
if parentId != "0" {
|
||||||
|
db.Where("parent_id = ?", parentId)
|
||||||
|
}
|
||||||
|
err = db.Order("sort asc").Find(&menuList).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
tree := buildMenuTree(menuList)
|
||||||
|
return tree, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MenuService) GetUserRoutes(userId string) (menus []*system.Menu, err error) {
|
||||||
|
//1.根据userId 查询角色 根据角色查询菜单 去重
|
||||||
|
//2.构建树结构
|
||||||
|
var roleIds []string
|
||||||
|
err = global.DB.Model(&system.UserRole{}).Where("user_id = ?", userId).Pluck("role_id", &roleIds).Error
|
||||||
|
var menuIds []string
|
||||||
|
err = global.DB.Model(&system.RoleMenu{}).Where("role_id in ?", roleIds).Pluck("menu_id", &menuIds).Error
|
||||||
|
var menuList []*system.Menu
|
||||||
|
err = global.DB.Model(&system.Menu{}).Where("id in ?", menuIds).Find(&menuList).Error
|
||||||
|
return buildMenuTree(menuList), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildMenuTree(list []*system.Menu) []*system.Menu {
|
||||||
|
//1.定义一个map
|
||||||
|
menuMap := make(map[string]*system.Menu)
|
||||||
|
for _, item := range list {
|
||||||
|
menuMap[item.Id] = item
|
||||||
|
}
|
||||||
|
//构建树结构
|
||||||
|
var treeList []*system.Menu
|
||||||
|
for _, item := range list {
|
||||||
|
if item.ParentId == "0" {
|
||||||
|
// 如果没有父节点,直接添加到树中
|
||||||
|
treeList = append(treeList, item)
|
||||||
|
} else {
|
||||||
|
if parent, exists := menuMap[item.ParentId]; exists {
|
||||||
|
// 如果有父节点,将当前节点添加到父节点的Children中
|
||||||
|
parent.Children = append(parent.Children, item)
|
||||||
|
} else {
|
||||||
|
// 如果没有父节点,将当前节点添加到树中
|
||||||
|
treeList = append(treeList, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return treeList
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sundynix-go/global"
|
||||||
|
common "sundynix-go/model/commom/request"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
systemReq "sundynix-go/model/system/request"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OperationRecordService struct{}
|
||||||
|
|
||||||
|
var OperationRecordServiceApp = new(OperationRecordService)
|
||||||
|
|
||||||
|
func (o *OperationRecordService) CreateOperationRecord(operationRecord system.SysOperationRecord) (err error) {
|
||||||
|
return global.DB.Create(&operationRecord).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OperationRecordService) GetRecordList(info systemReq.GetOperationRecordList) (list interface{}, total int64, err error) {
|
||||||
|
limit := info.PageSize
|
||||||
|
offset := info.PageSize * (info.Current - 1)
|
||||||
|
db := global.DB.Model(&system.SysOperationRecord{})
|
||||||
|
var operationRecordList []system.SysOperationRecord
|
||||||
|
|
||||||
|
if info.Ip != "" {
|
||||||
|
db = db.Where("ip = ?", info.Method)
|
||||||
|
}
|
||||||
|
if info.Method != "" {
|
||||||
|
db = db.Where("method = ?", info.Method)
|
||||||
|
}
|
||||||
|
if info.Path != "" {
|
||||||
|
db = db.Where("path = ?", info.Path)
|
||||||
|
}
|
||||||
|
if info.UserId != "" {
|
||||||
|
db = db.Where("status = ?", info.UserId)
|
||||||
|
}
|
||||||
|
if info.Status != 0 {
|
||||||
|
db = db.Where("status = ?", info.Status)
|
||||||
|
}
|
||||||
|
err = db.Count(&total).Error
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = db.Limit(limit).Offset(offset).Find(&operationRecordList).Error
|
||||||
|
return operationRecordList, total, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OperationRecordService) GetRecordById(id string) (record *system.SysOperationRecord, err error) {
|
||||||
|
var r system.SysOperationRecord
|
||||||
|
err = global.DB.Where("id = ?", id).First(&r).Error
|
||||||
|
return &r, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OperationRecordService) DeleteRecordsByIds(ids common.IdsReq) (err error) {
|
||||||
|
// Unscoped()禁用软删除 --> 永久物理删除
|
||||||
|
err = global.DB.Where("id in ?", ids.Ids).Unscoped().Delete(&system.SysOperationRecord{}).Error
|
||||||
|
return err
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"sundynix-go/global"
|
||||||
|
common "sundynix-go/model/commom/request"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
systemReq "sundynix-go/model/system/request"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RoleService struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
var RoleServiceApp = new(RoleService)
|
||||||
|
|
||||||
|
func (s *RoleService) SaveRole(role system.Role) error {
|
||||||
|
if !errors.Is(global.DB.Where("code = ?", role.Code).First(&system.Role{}).Error, gorm.ErrRecordNotFound) {
|
||||||
|
return errors.New("存在重复角色")
|
||||||
|
}
|
||||||
|
return global.DB.Create(&role).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RoleService) UpdateRole(role system.Role) error {
|
||||||
|
return global.DB.Model(&role).Where("id = ?", role.Id).Updates(&role).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RoleService) GetRoleList(info systemReq.GetRoleList) (list interface{}, total int64, err error) {
|
||||||
|
limit := info.PageSize
|
||||||
|
offset := info.PageSize * (info.Current - 1)
|
||||||
|
db := global.DB.Model(&system.Role{})
|
||||||
|
var roleList []system.Role
|
||||||
|
if info.Code != "" {
|
||||||
|
db = db.Where("code = ?", info.Code)
|
||||||
|
}
|
||||||
|
if info.Name != "" {
|
||||||
|
db = db.Where("name LIKE ?", "%"+info.Name+"%")
|
||||||
|
}
|
||||||
|
err = db.Count(&total).Error
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = db.Limit(limit).Offset(offset).Find(&roleList).Error
|
||||||
|
return roleList, total, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RoleService) DeleteRoleByIds(ids common.IdsReq) error {
|
||||||
|
return global.DB.Where("id in ?", ids.Ids).Delete(&system.Role{}).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RoleService) GetRoleById(id string) (role *system.Role, err error) {
|
||||||
|
var r system.Role
|
||||||
|
err = global.DB.Where("id = ?", id).First(&r).Error
|
||||||
|
return &r, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RoleService) GrantRole(userId string, roleIds []string) error {
|
||||||
|
//1. 检查是否存在userid的授权记录 存在就删除 不存在就插入
|
||||||
|
//2. 插入新的数据
|
||||||
|
return global.DB.Transaction(func(tx *gorm.DB) error {
|
||||||
|
if err := tx.Where("user_id = ?", userId).Delete(&system.UserRole{}).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, roleId := range roleIds {
|
||||||
|
if err := tx.Create(&system.UserRole{UserId: userId, RoleId: roleId}).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RoleService) GrantMenu(roleId string, menuIds []string) error {
|
||||||
|
//1. 检查是否存在userid的授权记录 存在就删除 不存在就插入
|
||||||
|
//2. 插入新的数据
|
||||||
|
return global.DB.Transaction(func(tx *gorm.DB) error {
|
||||||
|
if err := tx.Where("role_id = ?", roleId).Delete(&system.RoleMenu{}).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, menuId := range menuIds {
|
||||||
|
if err := tx.Create(&system.RoleMenu{RoleId: roleId, MenuId: menuId}).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"sundynix-go/global"
|
||||||
|
common "sundynix-go/model/commom/request"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
systemReq "sundynix-go/model/system/request"
|
||||||
|
"sundynix-go/utils"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserService struct{}
|
||||||
|
|
||||||
|
var UserServiceApp = new(UserService)
|
||||||
|
|
||||||
|
func (userService *UserService) Login(u *system.User) (userInfo *system.User, err error) {
|
||||||
|
var user system.User
|
||||||
|
// 查询出用户信息的同时查询出角色信息
|
||||||
|
err = global.DB.Model(&system.User{}).Preload("Roles").Where("account = ?", u.Account).First(&user).Error
|
||||||
|
if err == nil {
|
||||||
|
if ok := utils.BcryptCheck(u.Password, user.Password); !ok {
|
||||||
|
return nil, errors.New("密码错误")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &user, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (userService *UserService) SaveUser(user system.User) error {
|
||||||
|
if !errors.Is(global.DB.Where("account = ?", user.Account).First(&system.User{}).Error, gorm.ErrRecordNotFound) {
|
||||||
|
return errors.New("存在重复Account,请修改Account")
|
||||||
|
}
|
||||||
|
user.Password = utils.BcryptHash(user.Password)
|
||||||
|
return global.DB.Create(&user).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (userService *UserService) UpdateUser(user *system.User) (err error) {
|
||||||
|
var sysUser system.User
|
||||||
|
userMap := map[string]interface{}{
|
||||||
|
"Account": user.Account,
|
||||||
|
"Phone": user.Phone,
|
||||||
|
}
|
||||||
|
err = global.DB.Where("id = ?", user.Id).First(&sysUser).Error
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Debug(err.Error())
|
||||||
|
return errors.New("查询用户失败")
|
||||||
|
}
|
||||||
|
err = global.DB.Model(&sysUser).Updates(userMap).Error
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (userService *UserService) GetUserList(info systemReq.GetUserList) (list interface{}, total int64, err error) {
|
||||||
|
limit := info.PageSize
|
||||||
|
offset := info.PageSize * (info.Current - 1)
|
||||||
|
db := global.DB.Model(&system.User{})
|
||||||
|
var userList []system.User
|
||||||
|
|
||||||
|
if info.Account != "" {
|
||||||
|
db = db.Where("account LIKE ?", "%"+info.Account+"%")
|
||||||
|
}
|
||||||
|
if info.Phone != "" {
|
||||||
|
db = db.Where("phone LIKE ?", "%"+info.Phone+"%")
|
||||||
|
}
|
||||||
|
err = db.Count(&total).Error
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = db.Limit(limit).Offset(offset).Find(&userList).Error
|
||||||
|
return userList, total, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (userService *UserService) DeleteUserByIds(ids common.IdsReq) error {
|
||||||
|
return global.DB.Where("id IN (?)", ids.Ids).Delete(&system.User{}).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (userService *UserService) GetUserById(id string) (user *system.User, err error) {
|
||||||
|
var u system.User
|
||||||
|
err = global.DB.Where("id = ?", id).Preload("Roles").First(&u).Error
|
||||||
|
return &u, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (userService *UserService) ChangePassword(id string, pwd string) (err error) {
|
||||||
|
return global.DB.Model(&system.User{}).Where("id = ?", id).Update("password", utils.BcryptHash(pwd)).Error
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package captcha
|
||||||
|
|
||||||
|
import "github.com/mojocn/base64Captcha"
|
||||||
|
|
||||||
|
var CaptchaStore = base64Captcha.DefaultMemStore
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
|
"golang.org/x/crypto/bcrypt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BcryptHash 使用 bcrypt 对密码进行加密
|
||||||
|
func BcryptHash(password string) string {
|
||||||
|
bytes, _ := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||||
|
return string(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// BcryptCheck 对比明文密码和数据库的哈希值
|
||||||
|
func BcryptCheck(password, hash string) bool {
|
||||||
|
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//@author: [piexlmax](https://github.com/piexlmax)
|
||||||
|
//@function: MD5V
|
||||||
|
//@description: md5加密
|
||||||
|
//@param: str []byte
|
||||||
|
//@return: string
|
||||||
|
|
||||||
|
func MD5V(str []byte, b ...byte) string {
|
||||||
|
h := md5.New()
|
||||||
|
h.Write(str)
|
||||||
|
return hex.EncodeToString(h.Sum(b))
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sundynix-go/utils/uniqueid"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestHashPwd(t *testing.T) {
|
||||||
|
hash := BcryptHash("sundynix")
|
||||||
|
fmt.Println(hash) // $2a$10$QC/zkQ/ohPmvjF/goDyicu7cHgAEj8gHg6OTDHWhbYQMHHn4dwxX2
|
||||||
|
|
||||||
|
check := BcryptCheck("admin", "$2a$10$QC/zkQ/ohPmvjF/goDyicu7cHgAEj8gHg6OTDHWhbYQMHHn4dwxX2")
|
||||||
|
fmt.Println(check)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUuid(t *testing.T) {
|
||||||
|
id := uniqueid.GenerateId()
|
||||||
|
fmt.Println(id)
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ParseDuration 解析时间
|
||||||
|
func ParseDuration(d string) (time.Duration, error) {
|
||||||
|
d = strings.TrimSpace(d)
|
||||||
|
dr, err := time.ParseDuration(d)
|
||||||
|
if err == nil {
|
||||||
|
return dr, nil
|
||||||
|
}
|
||||||
|
if strings.Contains(d, "d") {
|
||||||
|
index := strings.Index(d, "d")
|
||||||
|
|
||||||
|
hour, _ := strconv.Atoi(d[:index])
|
||||||
|
dr = time.Hour * 24 * time.Duration(hour)
|
||||||
|
ndr, err := time.ParseDuration(d[index+1:])
|
||||||
|
if err != nil {
|
||||||
|
return dr, nil
|
||||||
|
}
|
||||||
|
return dr + ndr, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
dv, err := strconv.ParseInt(d, 10, 64)
|
||||||
|
return time.Duration(dv), err
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
"strings"
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/system"
|
||||||
|
systemReq "sundynix-go/model/system/request"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetLoginToken 获取登录token
|
||||||
|
func GetLoginToken(user system.Login) (token string, claims systemReq.CustomClaims, err error) {
|
||||||
|
j := NewJWT()
|
||||||
|
claims = j.CreateClaims(systemReq.BaseClaims{
|
||||||
|
Account: user.GetAccount(),
|
||||||
|
ID: user.GetUserId(),
|
||||||
|
})
|
||||||
|
token, err = j.CreateToken(claims)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetToken 从请求头中获取JWT token,并确保其有效性
|
||||||
|
//
|
||||||
|
// 参数:
|
||||||
|
// - c: *gin.Context, Gin框架的上下文对象,用于获取请求信息和设置响应。
|
||||||
|
//
|
||||||
|
// 返回值:
|
||||||
|
// - string: 获取到的JWT token,如果获取失败则返回空字符串。
|
||||||
|
func GetToken(c *gin.Context) string {
|
||||||
|
// 从请求头中获取Authorization字段的值
|
||||||
|
token := c.Request.Header.Get("Authorization")
|
||||||
|
prefix := strings.HasPrefix(token, "Bearer ")
|
||||||
|
if prefix {
|
||||||
|
token = strings.TrimPrefix(token, "Bearer ")
|
||||||
|
}
|
||||||
|
// 返回获取到的token
|
||||||
|
return token
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearToken 清除Cookie中的token
|
||||||
|
func ClearToken(c *gin.Context) {
|
||||||
|
host, _, err := net.SplitHostPort(c.Request.Host)
|
||||||
|
if err != nil {
|
||||||
|
host = c.Request.Host
|
||||||
|
}
|
||||||
|
if net.ParseIP(host) != nil {
|
||||||
|
c.SetCookie("sundynix-token", "", -1, "/", "", false, false)
|
||||||
|
} else {
|
||||||
|
c.SetCookie("sundynix-token", "", -1, "/", host, false, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserInfo 从 gin.Context 中获取用户信息,并返回 CustomClaims 类型的指针。
|
||||||
|
// 该函数首先尝试从上下文中获取已存在的 claims,如果不存在,则调用 GetClaims 函数获取 claims。
|
||||||
|
// 如果获取 claims 失败,则返回 nil。
|
||||||
|
//
|
||||||
|
// 参数:
|
||||||
|
// - c: *gin.Context, gin 框架的上下文对象,用于获取请求相关的信息。
|
||||||
|
//
|
||||||
|
// 返回值:
|
||||||
|
// - *systemReq.CustomClaims: 返回用户的自定义 claims 信息,如果获取失败则返回 nil。
|
||||||
|
func GetUserInfo(c *gin.Context) *systemReq.CustomClaims {
|
||||||
|
// 尝试从上下文中获取已存在的 claims
|
||||||
|
if claims, exists := c.Get("claims"); !exists {
|
||||||
|
// 如果 claims 不存在,则调用 GetClaims 函数获取 claims
|
||||||
|
if cl, err := GetClaims(c); err != nil {
|
||||||
|
// 如果获取 claims 失败,返回 nil
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
// 成功获取 claims,返回 claims
|
||||||
|
return cl
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 如果 claims 存在,将其转换为 CustomClaims 类型并返回
|
||||||
|
waitUse := claims.(*systemReq.CustomClaims)
|
||||||
|
return waitUse
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserId 从 gin.Context 中获取用户 ID,并返回 uint 类型的 ID。
|
||||||
|
// 该函数首先尝试从上下文中获取已存在的 claims,如果不存在,则调用 GetClaims 函数获取 claims。
|
||||||
|
// 如果获取 claims 失败,则返回 0。
|
||||||
|
//
|
||||||
|
// 参数:
|
||||||
|
// - c: *gin.Context, gin 框架的上下文对象,用于获取请求相关的信息。
|
||||||
|
//
|
||||||
|
// 返回值:
|
||||||
|
// - uint: 返回用户的 ID,如果获取失败则返回 0。
|
||||||
|
func GetUserId(c *gin.Context) string {
|
||||||
|
if claims, exists := c.Get("claims"); !exists {
|
||||||
|
if cl, err := GetClaims(c); err != nil {
|
||||||
|
return "0"
|
||||||
|
} else {
|
||||||
|
return cl.BaseClaims.ID
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
waitUse := claims.(*systemReq.CustomClaims)
|
||||||
|
return waitUse.BaseClaims.ID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetClaims 从 Gin 上下文中提取并解析 JWT 令牌,返回自定义的 claims 信息。
|
||||||
|
// 该函数首先从请求头中获取 JWT 令牌,然后使用 JWT 解析器解析令牌并返回 claims。
|
||||||
|
// 如果解析过程中发生错误,函数会记录错误日志并返回错误信息。
|
||||||
|
//
|
||||||
|
// 参数:
|
||||||
|
// - c: *gin.Context, Gin 上下文对象,用于获取请求头中的 JWT 令牌。
|
||||||
|
//
|
||||||
|
// 返回值:
|
||||||
|
// - *systemReq.CustomClaims: 解析后的自定义 claims 信息。
|
||||||
|
// - error: 解析过程中发生的错误,如果解析成功则为 nil。
|
||||||
|
func GetClaims(c *gin.Context) (*systemReq.CustomClaims, error) {
|
||||||
|
// 从 Gin 上下文中获取 JWT 令牌
|
||||||
|
token := GetToken(c)
|
||||||
|
|
||||||
|
// 创建新的 JWT 解析器
|
||||||
|
j := NewJWT()
|
||||||
|
|
||||||
|
// 解析 JWT 令牌并获取 claims 信息
|
||||||
|
claims, err := j.ParseToken(token)
|
||||||
|
if err != nil {
|
||||||
|
// 如果解析失败,记录错误日志
|
||||||
|
global.Logger.Error("获取用户信息失败,请检查请求头是否存在x-token且claims是否为规定结构")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回解析后的 claims 信息和可能的错误
|
||||||
|
return claims, err
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"sundynix-go/global"
|
||||||
|
"sundynix-go/model/system/request"
|
||||||
|
"sundynix-go/utils"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/golang-jwt/jwt/v5"
|
||||||
|
)
|
||||||
|
|
||||||
|
type JWT struct {
|
||||||
|
SigningKey []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
TokenValid = errors.New("未知错误")
|
||||||
|
TokenExpired = errors.New("token已过期")
|
||||||
|
TokenNotValidYet = errors.New("token尚未激活")
|
||||||
|
TokenMalformed = errors.New("这不是一个token")
|
||||||
|
TokenSignatureInvalid = errors.New("无效签名")
|
||||||
|
TokenInvalid = errors.New("无法处理此token")
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewJWT 初始化JWT
|
||||||
|
func NewJWT() *JWT {
|
||||||
|
return &JWT{
|
||||||
|
SigningKey: []byte("gin-blog-key"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateClaims 创建Claims
|
||||||
|
func (j *JWT) CreateClaims(baseClaims request.BaseClaims) request.CustomClaims {
|
||||||
|
bf, _ := utils.ParseDuration(global.Config.JWT.BufferTime)
|
||||||
|
ep, _ := utils.ParseDuration(global.Config.JWT.ExpiresTime)
|
||||||
|
claims := request.CustomClaims{
|
||||||
|
BaseClaims: baseClaims,
|
||||||
|
BufferTime: int64(bf / time.Second), // 缓冲时间1天 缓冲时间内会获得新的token刷新令牌 此时一个用户会存在两个有效令牌 但是前端只留一个 另一个会丢失
|
||||||
|
RegisteredClaims: jwt.RegisteredClaims{
|
||||||
|
Audience: jwt.ClaimStrings{"sundynix"},
|
||||||
|
NotBefore: jwt.NewNumericDate(time.Now().Add(-1000)), // 签名生效时间
|
||||||
|
ExpiresAt: jwt.NewNumericDate(time.Now().Add(ep)), // 过期时间 7天 配置文件
|
||||||
|
Issuer: global.Config.JWT.Issuer,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return claims
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateToken 创建一个token
|
||||||
|
func (j *JWT) CreateToken(claims request.CustomClaims) (string, error) {
|
||||||
|
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||||
|
return token.SignedString(j.SigningKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RefreshToken 刷新token
|
||||||
|
func (j *JWT) RefreshToken(oldTokenString string, claims request.CustomClaims) (string, error) {
|
||||||
|
v, err, _ := global.ConcurrencyControl.Do("JWT:"+oldTokenString, func() (interface{}, error) {
|
||||||
|
return j.CreateToken(claims)
|
||||||
|
})
|
||||||
|
return v.(string), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseToken 解析token
|
||||||
|
func (j *JWT) ParseToken(tokenString string) (*request.CustomClaims, error) {
|
||||||
|
token, err := jwt.ParseWithClaims(tokenString, &request.CustomClaims{}, func(token *jwt.Token) (i interface{}, e error) {
|
||||||
|
return j.SigningKey, nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
switch {
|
||||||
|
case errors.Is(err, jwt.ErrTokenExpired):
|
||||||
|
return nil, TokenExpired
|
||||||
|
case errors.Is(err, jwt.ErrTokenNotValidYet):
|
||||||
|
return nil, TokenNotValidYet
|
||||||
|
case errors.Is(err, jwt.ErrTokenMalformed):
|
||||||
|
return nil, TokenMalformed
|
||||||
|
case errors.Is(err, jwt.ErrTokenSignatureInvalid):
|
||||||
|
return nil, TokenSignatureInvalid
|
||||||
|
default:
|
||||||
|
return nil, TokenInvalid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if token != nil {
|
||||||
|
if claims, ok := token.Claims.(*request.CustomClaims); ok && token.Valid {
|
||||||
|
return claims, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, TokenInvalid
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user