router_no_check_role.go.template 1.0 KB

123456789101112131415161718192021222324252627282930
  1. package router
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "go-admin/app/{{.PackageName}}/middleware"
  5. "go-admin/app/{{.PackageName}}/models"
  6. "go-admin/app/{{.PackageName}}/service/dto"
  7. "go-admin/common/actions"
  8. )
  9. func init() {
  10. routerNoCheckRole = append(routerNoCheckRole, register{{.ClassName}}Router)
  11. }
  12. // 无需认证的路由代码
  13. func register{{.ClassName}}Router(v1 *gin.RouterGroup) {
  14. r := v1.Group("/{{.ModuleName}}")
  15. {
  16. model := &models.{{.ClassName}}{}
  17. r.GET("", actions.IndexAction(model, new(dto.{{.ClassName}}Search), func() interface{} {
  18. list := make([]models.{{.ClassName}}, 0)
  19. return &list
  20. }))
  21. r.GET("/:id", actions.ViewAction(new(dto.{{.ClassName}}ById), nil))
  22. r.POST("", actions.CreateAction(new(dto.{{.ClassName}}Control)))
  23. r.PUT("/:id", actions.UpdateAction(new(dto.{{.ClassName}}Control)))
  24. r.DELETE("", actions.DeleteAction(new(dto.{{.ClassName}}ById)))
  25. }
  26. }