fix: 增加通过id查询image信息方法

增加通过id查询image信息方法
This commit is contained in:
yaoyilin
2022-11-07 11:33:12 +08:00
parent c703fe535b
commit 020eece0b8
2 changed files with 17 additions and 0 deletions

View File

@@ -96,6 +96,14 @@ func (u *UserImage) GetByPath(path string) error {
return nil
}
func ExportUserImageId(url string) string {
img := ExportUserImage(url)
if img != nil {
return img.Id()
}
return ""
}
func ExportUserImage(url string) *UserImage {
parts := strings.Split(url, "/")
if len(parts) < 3 {

View File

@@ -53,3 +53,12 @@ func TestExportUserImage(t *testing.T) {
}
fmt.Println(img.FileType)
}
func TestExportUserImageId(t *testing.T) {
imgUrl := "http://127.0.0.1:9011/img/avatar/6367d24adff5ddb91b5e07f9.png"
id := model.ExportUserImageId(imgUrl)
if id == "" {
t.Error("查询失败")
return
}
}