36
internal/handlers/category_text.go
Normal file
36
internal/handlers/category_text.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package handlers
|
||||
|
||||
import "net/http"
|
||||
|
||||
const categoryNameColsSQL = `
|
||||
COALESCE(c.name_zh,''), COALESCE(c.name_en,''), COALESCE(c.name_ja,''),
|
||||
COALESCE(c.name_ko,''), COALESCE(c.name_vi,''), COALESCE(c.name_id,''), COALESCE(c.name_ms,'')`
|
||||
|
||||
const categoryDescColsSQL = `
|
||||
COALESCE(c.description_zh,''), COALESCE(c.description_en,''), COALESCE(c.description_ja,''),
|
||||
COALESCE(c.description_ko,''), COALESCE(c.description_vi,''), COALESCE(c.description_id,''), COALESCE(c.description_ms,'')`
|
||||
|
||||
const categoryI18nColsSQL = categoryNameColsSQL + `, ` + categoryDescColsSQL
|
||||
|
||||
type categoryTextI18n struct {
|
||||
NameZh, NameEn, NameJa, NameKo, NameVi, NameId, NameMs string
|
||||
DescZh, DescEn, DescJa, DescKo, DescVi, DescId, DescMs string
|
||||
}
|
||||
|
||||
func (t categoryTextI18n) pickName(r *http.Request) string {
|
||||
return pickLangField(r, t.NameZh, t.NameEn, t.NameJa, t.NameKo, t.NameVi, t.NameId, t.NameMs)
|
||||
}
|
||||
|
||||
func (t categoryTextI18n) pickDesc(r *http.Request) string {
|
||||
return pickLangField(r, t.DescZh, t.DescEn, t.DescJa, t.DescKo, t.DescVi, t.DescId, t.DescMs)
|
||||
}
|
||||
|
||||
func scanCategoryTextI18n(
|
||||
nameZh, nameEn, nameJa, nameKo, nameVi, nameId, nameMs string,
|
||||
descZh, descEn, descJa, descKo, descVi, descId, descMs string,
|
||||
) categoryTextI18n {
|
||||
return categoryTextI18n{
|
||||
NameZh: nameZh, NameEn: nameEn, NameJa: nameJa, NameKo: nameKo, NameVi: nameVi, NameId: nameId, NameMs: nameMs,
|
||||
DescZh: descZh, DescEn: descEn, DescJa: descJa, DescKo: descKo, DescVi: descVi, DescId: descId, DescMs: descMs,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user