refactor: organize service dto contracts
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"kra/internal/biz"
|
||||
"kra/internal/service"
|
||||
"kra/internal/service/dto"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/mojocn/base64Captcha"
|
||||
@@ -58,7 +59,7 @@ func (h *Public) Captcha(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *Public) Login(c *gin.Context) {
|
||||
var req service.LoginRequest
|
||||
var req dto.LoginRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
Fail(c, err.Error())
|
||||
return
|
||||
@@ -126,15 +127,15 @@ func (h *Public) InitializeDatabase(engine *gin.Engine) gin.HandlerFunc {
|
||||
Fail(c, "已存在数据库配置")
|
||||
return
|
||||
}
|
||||
var input service.DatabaseInitRequest
|
||||
var input dto.DatabaseInitRequest
|
||||
if c.ShouldBindJSON(&input) != nil {
|
||||
Fail(c, "参数校验不通过")
|
||||
return
|
||||
}
|
||||
routes := engine.Routes()
|
||||
values := make([]service.Route, 0, len(routes))
|
||||
values := make([]dto.Route, 0, len(routes))
|
||||
for _, route := range routes {
|
||||
values = append(values, service.Route{Path: route.Path, Method: route.Method})
|
||||
values = append(values, dto.Route{Path: route.Path, Method: route.Method})
|
||||
}
|
||||
if err := h.system.InitializeRoutes(c.Request.Context(), &input, values); err != nil {
|
||||
Fail(c, "自动创建数据库失败,请查看后台日志,检查后在进行初始化")
|
||||
|
||||
Reference in New Issue
Block a user