feat: wecom message init

This commit is contained in:
zzw
2026-09-17 10:18:43 +08:00
parent 5a56eb2fe4
commit dd460f6be2
46 changed files with 2735 additions and 109 deletions
@@ -0,0 +1,55 @@
package utils
import (
"base-service/app/dao"
"base-service/pkg/wecom/message"
"base-service/utils"
"fmt"
)
func GetMapString(data map[string]interface{}, key string) string {
val, ok := data[key]
if !ok || val == nil {
return dao.StringEmpty
}
return fmt.Sprintf("%v", val)
}
func GetExtString(ext map[string]any, key string) string {
v, ok := ext[key].(string)
if !ok || v == "" {
return "无"
}
return v
}
func BuildContent(kvPairs ...struct{ Key, Value string }) []message.HorizontalContent {
const maxTotal = 6
const fixedItems = 1
maxInput := maxTotal - fixedItems
inputCount := len(kvPairs)
if inputCount > maxInput {
inputCount = maxInput
}
content := make([]message.HorizontalContent, 0, inputCount+fixedItems)
for i := 0; i < inputCount; i++ {
content = append(content, message.HorizontalContent{
KeyName: kvPairs[i].Key,
Value: kvPairs[i].Value,
})
}
content = append(content, message.HorizontalContent{
KeyName: "审核时间",
Value: utils.Now().Format(),
})
return content
}