feat(app): update

This commit is contained in:
Yangtao
2025-11-19 14:24:13 +08:00
parent 1eac66d7fd
commit 0c34585649
329 changed files with 10760 additions and 281 deletions

View File

@ -135,7 +135,7 @@ const (
RISK_TYPE_TEXT_COMMENT = "comment_detection" //评论检测
)
func LogJson(v interface{}) {
func LogJson(v any) {
b, _ := json.Marshal(v)
logs.Info(string(b))
}

View File

@ -14,7 +14,7 @@ func NewStringBuilder() *StringBuilder {
return &StringBuilder{buf: bytes.Buffer{}}
}
func (this *StringBuilder) Append(obj interface{}) *StringBuilder {
func (this *StringBuilder) Append(obj any) *StringBuilder {
this.buf.WriteString(fmt.Sprintf("%v", obj))
return this
}
@ -24,7 +24,7 @@ func (this *StringBuilder) ToString() string {
}
// 字符串转int32
func JsonStr(v interface{}) string {
func JsonStr(v any) string {
bys, _ := json.Marshal(v)
return string(bys)
}

View File

@ -37,15 +37,15 @@ type User struct {
WellNoIcon string
}
//字符串: text keyword
//整数 : byte, short, integer, long
//浮点数: float, double
//布尔型: boolean
//日期: date
var UserIndex = map[string]interface{}{
"settings": map[string]interface{}{"number_of_shards": 5, "number_of_replicas": 1},
"mappings": map[string]interface{}{
"properties": map[string]interface{}{
// 字符串: text keyword
// 整数 : byte, short, integer, long
// 浮点数: float, double
// 布尔型: boolean
// 日期: date
var UserIndex = map[string]any{
"settings": map[string]any{"number_of_shards": 5, "number_of_replicas": 1},
"mappings": map[string]any{
"properties": map[string]any{
"ActiveTime": map[string]string{"type": "date", "format": "yyyy-MM-dd HH:mm:ssZ||yyyy-MM-dd HH:mm:ss.SSSZ||yyyy-MM-ddZ||epoch_millis||epoch_second"},
"AlipayAccount": map[string]string{"type": "keyword"},
"AuthFailReason": map[string]string{"type": "text", "analyzer": "ik_max_word"},
@ -83,10 +83,10 @@ var UserIndex = map[string]interface{}{
},
}
var MessageIndex = map[string]interface{}{
"settings": map[string]interface{}{"number_of_shards": 5, "number_of_replicas": 1},
"mappings": map[string]interface{}{
"properties": map[string]interface{}{
var MessageIndex = map[string]any{
"settings": map[string]any{"number_of_shards": 5, "number_of_replicas": 1},
"mappings": map[string]any{
"properties": map[string]any{
"id": map[string]string{"type": "keyword"},
"curTime": map[string]string{"type": "date", "format": "yyyy-MM-dd HH:mm:ssZ||yyyy-MM-dd HH:mm:ss.SSSZ||yyyy-MM-ddZ||epoch_millis||epoch_second"},
},

View File

@ -70,7 +70,7 @@ func _connect() (c *elastic.Client) {
}
// 创建记录
func (*EsClient) Create(index, id string, model interface{}) (body string, success bool, msg string) {
func (*EsClient) Create(index, id string, model any) (body string, success bool, msg string) {
client := _connect()
_, e := client.Index().Index(index).Id(id).BodyJson(model).Do(context.Background())
if e != nil {
@ -99,7 +99,7 @@ func (*EsClient) Exists(index, id string) (exists, success bool, msg string, e e
}
// 更新记录
func (*EsClient) Update(index, id string, model interface{}) (body string, success bool, msg string) {
func (*EsClient) Update(index, id string, model any) (body string, success bool, msg string) {
client := _connect()
_, e := client.Update().Index(index).Id(id).Doc(model).Do(context.Background())
if e != nil {
@ -112,7 +112,7 @@ func (*EsClient) Update(index, id string, model interface{}) (body string, succe
}
// 搜索
func (*EsClient) Search(index string, key string, fields ...string) (body []interface{}, success bool, msg string) {
func (*EsClient) Search(index string, key string, fields ...string) (body []any, success bool, msg string) {
client := _connect()
logs.Info("ES Search index =", index, " key =", key, " fields =", fields)
var list []*elastic.WildcardQuery
@ -165,7 +165,7 @@ type ESSort struct {
}
// 搜索消息
func (*EsClient) SearchMulti(index string, filter ESFilter, page, size int) (result interface{}, success bool, msg string) {
func (*EsClient) SearchMulti(index string, filter ESFilter, page, size int) (result any, success bool, msg string) {
client := _connect()
var list []elastic.Query
for _, item := range filter.Queries {
@ -217,14 +217,14 @@ func (*EsClient) SearchMulti(index string, filter ESFilter, page, size int) (res
if e != nil {
return
}
var body []interface{}
var body []any
for _, item := range res.Hits.Hits {
b, _ := item.Source.MarshalJSON()
m := make(map[string]interface{})
m := make(map[string]any)
_ = json.Unmarshal(b, &m)
body = append(body, m)
}
result = map[string]interface{}{
result = map[string]any{
"Status": res.Status,
"Total": res.Hits.TotalHits,
"List": body,

View File

@ -45,7 +45,7 @@ func _testConnect() (c *elastic.Client) {
func TestClientNew(t *testing.T) {
var client EsClient
client.Create("es_index_message", "003", map[string]interface{}{
client.Create("es_index_message", "003", map[string]any{
"id": "003",
"curTime": 1440570500855,
"f1": 1234,

View File

@ -4,7 +4,7 @@ import "gitea.ddegame.cn/open/servicebase/pkg/common/http/dto"
type CommonResponse struct {
Code string
Result interface{}
Result any
Msg string
}
@ -22,15 +22,15 @@ type UserInviteSummaryResponse struct {
Msg string
}
func Success(data interface{}) (res CommonResponse) {
func Success(data any) (res CommonResponse) {
res.Code = "6000"
res.Result = data
return
}
func Page(data interface{}, count int64) (res CommonResponse) {
func Page(data any, count int64) (res CommonResponse) {
res.Code = "6000"
res.Result = map[string]interface{}{
res.Result = map[string]any{
"list": data,
"count": count,
}
@ -43,7 +43,7 @@ func Failed(msg string) (res CommonResponse) {
return
}
func Gen(code, msg string, result interface{}) (res CommonResponse) {
func Gen(code, msg string, result any) (res CommonResponse) {
res.Code = code
res.Msg = msg
res.Result = result

View File

@ -9,10 +9,10 @@ import (
// 事件
type Event struct {
MessageId string
Tag EventTag // 消息标签EventTagUser=用户
Flag EventFlag // 消息标签EventFlagCreate=创建 EventFlagUpdate=更新
EventId string // 事件ID
EventContent interface{} // 事件内容
Tag EventTag // 消息标签EventTagUser=用户
Flag EventFlag // 消息标签EventFlagCreate=创建 EventFlagUpdate=更新
EventId string // 事件ID
EventContent any // 事件内容
}
type EventTag string

View File

@ -108,7 +108,7 @@ func (client *ImClient) CreateImUser(userId, nickName, avatar string) error {
logs.Info("YunXin_SignUp_Success_AccID_%s:"+res, userId)
}
}
var body map[string]interface{}
var body map[string]any
if errJson := json.Unmarshal([]byte(res), &body); errJson != nil {
return errJson
}
@ -129,7 +129,7 @@ func (client *ImClient) GetImUserInfo(userId string) error {
sb.Append("accids=" + string(byteData))
res, err := HyTools.HttpDo(httpMethod, url, header, sb.ToString())
logs.Info("#" + "查询云信用户信息结果:" + res + "#")
var body map[string]interface{}
var body map[string]any
if errJson := json.Unmarshal([]byte(res), &body); errJson != nil {
return errJson
}
@ -423,7 +423,7 @@ func (client *ImClient) UpdateRoomInfo(request yunxin.UpdateRoomInfoRequest) (er
return
}
resMap := make(map[string]interface{})
resMap := make(map[string]any)
jsonErr := json.Unmarshal([]byte(res), &resMap)
if jsonErr != nil {

View File

@ -1,8 +1,8 @@
package Netease
type ImResponse struct {
Code int `json:"code"`
Desc interface{} `json:"desc"`
Code int `json:"code"`
Desc any `json:"desc"`
}
// 获取聊天室在线列表返回对象

View File

@ -13,7 +13,7 @@ const (
type Response struct {
Code string
Result interface{}
Result any
Msg string
}
@ -31,13 +31,13 @@ func Invalid() string {
return string(str)
}
func Success(data interface{}) Response {
func Success(data any) Response {
response := Response{Code: SuccessCode, Result: data}
return response
}
func Page(data interface{}, count int64) Response {
response := Response{Code: SuccessCode, Result: map[string]interface{}{
func Page(data any, count int64) Response {
response := Response{Code: SuccessCode, Result: map[string]any{
"List": data,
"Count": count,
}}

View File

@ -20,7 +20,7 @@ var (
)
var (
pinyinTemp map[vowel]interface{}
pinyinTemp map[vowel]any
toneTemp map[vowel]vowel
)
@ -38,7 +38,7 @@ func LoadingPYFile(filename string) {
if err != nil {
panic(err)
}
pinyinTemp = make(map[vowel]interface{}, 0)
pinyinTemp = make(map[vowel]any, 0)
toneTemp = make(map[vowel]vowel)
for i, t := range ys {
toneTemp[t] = ws[i]

View File

@ -73,12 +73,12 @@ func ListToSet(list []string) (set []string) {
return
}
func ToJson(source interface{}) []byte {
func ToJson(source any) []byte {
b, _ := json.Marshal(source)
return b
}
func ToJsonString(source interface{}) string {
func ToJsonString(source any) string {
return string(ToJson(source))
}