This commit is contained in:
2023-04-08 14:07:35 +08:00
parent 4ac65db98a
commit 0463d3be41
2 changed files with 77 additions and 4 deletions

View File

@@ -29,9 +29,19 @@ func (m *MysqlConnection) Init() (err error) {
return
}
// 根据 id 获取图片的 content
func (m *MysqlConnection) GetImageContent(id string) (key string, err error) {
var content string
err = m.db.QueryRow("SELECT content FROM web_images WHERE id=" + id).Scan(&content)
// 根据图片 id 获取图片的 content
func (m *MysqlConnection) GetImageContent(group string, id string) (content string, err error) {
switch group {
case "article":
err = m.db.QueryRow("SELECT image FROM web_article WHERE id=" + id).Scan(&content)
case "article_attribute":
err = m.db.QueryRow("SELECT image FROM web_article_attribute WHERE id=" + id).Scan(&content)
case "ad":
err = m.db.QueryRow("SELECT image FROM web_ad WHERE id=" + id).Scan(&content)
case "user":
err = m.db.QueryRow("SELECT avatar FROM web_member WHERE id=" + id).Scan(&content)
case "image":
err = m.db.QueryRow("SELECT content FROM web_images WHERE id=" + id).Scan(&content)
}
return content, err
}