32 lines
637 B
Go
32 lines
637 B
Go
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 godoc
|
|
// @Summary 返回示例消息
|
|
// @Tags example
|
|
// @Produce json
|
|
// @Success 200 {object} utils.APIResponse{data=HelloResponse}
|
|
// @Router /example/hello [get]
|
|
func (c *ExampleController) Hello(ctx *gin.Context) {
|
|
ctx.JSON(http.StatusOK, utils.Success(c.service.Hello()))
|
|
}
|