test file Upload
This commit is contained in:
parent
86c11fc31d
commit
d26b0859d6
@ -48,7 +48,7 @@ func (a *Animals) Detail(context *gin.Context) {
|
||||
// 1. Get Params
|
||||
anmId := context.Param("anm_id")
|
||||
|
||||
animal := curd.CreateUserCurdFactory().Detail(anmId)
|
||||
animal := curd.CreateAnimalsCurdFactory().Detail(anmId)
|
||||
if animal != nil {
|
||||
response.Success(context, consts.CurdStatusOkMsg, animal)
|
||||
} else {
|
||||
|
@ -1,10 +1,6 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"catface/app/global/consts"
|
||||
"catface/app/model"
|
||||
"catface/app/utils/response"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@ -15,9 +11,9 @@ func (e *Encounters) Create(context *gin.Context) {
|
||||
// TODO 处理 Photos 文件,然后处理出 Avatar,并获取压缩后的 宽高,以及文件的存储路径。
|
||||
|
||||
// Real Insert
|
||||
if model.CreateEncounterFactory("").InsertDate(context) {
|
||||
response.Success(context, consts.CurdStatusOkMsg, "")
|
||||
} else {
|
||||
response.Fail(context, consts.CurdCreatFailCode, consts.CurdCreatFailMsg+",新增错误", "")
|
||||
}
|
||||
// if model.CreateEncounterFactory("").InsertDate(context) {
|
||||
// response.Success(context, consts.CurdStatusOkMsg, "")
|
||||
// } else {
|
||||
// response.Fail(context, consts.CurdCreatFailCode, consts.CurdCreatFailMsg+",新增错误", "")
|
||||
// }
|
||||
}
|
||||
|
@ -55,6 +55,6 @@ func WebRegisterValidator() {
|
||||
|
||||
// TAG Encounter
|
||||
key = consts.ValidatorPrefix + "EncounterStore"
|
||||
containers.Set(key, encounter.Store{})
|
||||
containers.Set(key, encounter.Create{})
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Store struct {
|
||||
type Create struct {
|
||||
UserId int `form:"user_id" json:"user_id" binding:"required,numeric"`
|
||||
AnimalsId string `form:"animals_id" json:"animals_id" binding:"required"`
|
||||
Title string `form:"title" json:"title" binding:"required"`
|
||||
@ -21,17 +21,17 @@ type Store struct {
|
||||
Longitude float64 `form:"longitude" json:"longitude"`
|
||||
}
|
||||
|
||||
func (e Store) CheckParams(context *gin.Context) {
|
||||
if err := context.ShouldBind(&e); err != nil {
|
||||
func (c Create) CheckParams(context *gin.Context) {
|
||||
if err := context.ShouldBind(&c); err != nil {
|
||||
response.ValidatorError(context, err)
|
||||
return
|
||||
}
|
||||
|
||||
extraAddBindDataContext := data_transfer.DataAddContext(e, consts.ValidatorPrefix, context)
|
||||
extraAddBindDataContext := data_transfer.DataAddContext(c, consts.ValidatorPrefix, context)
|
||||
if extraAddBindDataContext == nil {
|
||||
response.ErrorSystem(context, "EncounterStore表单验证器json化失败", "")
|
||||
} else {
|
||||
// 验证完成,调用控制器,并将验证器成员(字段)递给控制器,保持上下文数据一致性
|
||||
(&web.Encounters{}).Store(extraAddBindDataContext)
|
||||
(&web.Encounters{}).Create(extraAddBindDataContext)
|
||||
}
|
||||
}
|
@ -39,7 +39,6 @@ func Upload(context *gin.Context, savePath string) (r bool, finnalSavePath inter
|
||||
variable.ZapLog.Error("文件保存出错:" + saveErr.Error())
|
||||
}
|
||||
return false, nil
|
||||
|
||||
}
|
||||
|
||||
// 文件上传可以设置按照 xxx年-xx月 格式存储
|
||||
|
1
app/utils/image_handler/img_handler.go
Normal file
1
app/utils/image_handler/img_handler.go
Normal file
@ -0,0 +1 @@
|
||||
package image
|
@ -62,13 +62,13 @@ FileUploadSetting:
|
||||
AllowMimeType: #允许的文件mime类型列表
|
||||
- "image/jpeg" #jpg、jpeg图片格式
|
||||
- "image/png" #png图片格式
|
||||
- "image/x-icon" #ico图片
|
||||
# - "image/x-icon" #ico图片
|
||||
- "image/bmp" #bmp图片
|
||||
- "application/zip" #xlsx、docx、zip
|
||||
- "application/x-gzip" #tar.gz
|
||||
# - "application/zip" #xlsx、docx、zip
|
||||
# - "application/x-gzip" #tar.gz
|
||||
- "text/plain; charset=utf-8" #txt log json等文本文件
|
||||
- "video/mp4" #视频文件,例如:mp4
|
||||
- "audio/mpeg" #音频文件,例如: mp3
|
||||
# - "video/mp4" #视频文件,例如:mp4
|
||||
# - "audio/mpeg" #音频文件,例如: mp3
|
||||
|
||||
# casbin 权限控制api接口
|
||||
Casbin:
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
|
||||
// "catface/app/http/controller/captcha" // 验证码组件
|
||||
// "catface/app/http/middleware/authorization"
|
||||
|
||||
"catface/app/http/middleware/cors"
|
||||
validatorFactory "catface/app/http/validator/core/factory"
|
||||
|
||||
@ -97,6 +96,7 @@ func InitWebRouter() *gin.Engine {
|
||||
// // 刷新token,当过期的token在允许失效的延长时间范围内,用旧token换取新token
|
||||
// refreshToken.Use(authorization.RefreshTokenConditionCheck()).POST("refreshtoken", validatorFactory.Create(consts.ValidatorPrefix+"RefreshToken"))
|
||||
// }
|
||||
|
||||
// // 【需要token】中间件验证的路由
|
||||
// backend.Use(authorization.CheckTokenAuth())
|
||||
// {
|
||||
@ -112,11 +112,11 @@ func InitWebRouter() *gin.Engine {
|
||||
// // 删除
|
||||
// users.POST("delete", validatorFactory.Create(consts.ValidatorPrefix+"UsersDestroy"))
|
||||
// }
|
||||
// //文件上传公共路由
|
||||
// uploadFiles := backend.Group("upload/")
|
||||
// {
|
||||
// uploadFiles.POST("files", validatorFactory.Create(consts.ValidatorPrefix+"UploadFiles"))
|
||||
// }
|
||||
//文件上传公共路由
|
||||
uploadFiles := backend.Group("upload/")
|
||||
{
|
||||
uploadFiles.POST("files", validatorFactory.Create(consts.ValidatorPrefix+"UploadFiles"))
|
||||
}
|
||||
// }
|
||||
|
||||
animal := backend.Group("animal")
|
||||
@ -131,7 +131,7 @@ func InitWebRouter() *gin.Engine {
|
||||
{
|
||||
// GET 获取列表; POST 上传
|
||||
// encounter.GET("", validatorFactory.Create(consts.ValidatorPrefix+"EncounterList"))
|
||||
encounter.POST("", validatorFactory.Create(consts.ValidatorPrefix+"EnconterStore"))
|
||||
encounter.POST("", validatorFactory.Create(consts.ValidatorPrefix+"EncounterStore"))
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 618 KiB |
Loading…
x
Reference in New Issue
Block a user