mirror of
https://gitlab.52pay.top/go/easygoadmin.git
synced 2025-09-26 19:33:29 +08:00
fix: 增加通过id查询image信息方法
增加通过id查询image信息方法
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user