init
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"skeleton/utils"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// ExampleController 示例控制器
|
||||
type ExampleController struct {
|
||||
service *ExampleService
|
||||
}
|
||||
|
||||
// NewExampleController 创建示例控制器
|
||||
func NewExampleController() *ExampleController {
|
||||
return &ExampleController{
|
||||
service: NewExampleService(),
|
||||
}
|
||||
}
|
||||
|
||||
// Hello 示例接口
|
||||
func (c *ExampleController) Hello(ctx *gin.Context) {
|
||||
ctx.JSON(http.StatusOK, utils.Success(c.service.Hello()))
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
// ExampleService 示例服务
|
||||
type ExampleService struct{}
|
||||
|
||||
// NewExampleService 创建示例服务
|
||||
func NewExampleService() *ExampleService {
|
||||
return &ExampleService{}
|
||||
}
|
||||
|
||||
// Hello 返回示例消息
|
||||
func (s *ExampleService) Hello() HelloResponse {
|
||||
return HelloResponse{
|
||||
Message: "hello from skeleton example",
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package example
|
||||
|
||||
// HelloResponse 示例响应
|
||||
type HelloResponse struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package example
|
||||
|
||||
// normalizeMessage 示例模块私有工具
|
||||
func normalizeMessage(message string) string {
|
||||
return message
|
||||
}
|
||||
Reference in New Issue
Block a user