fix: UID 类型混用统一(uint ↔ string)
- Comment.ReplyToUID string→uint, 移除 varchar(36) gorm 约束 - CommentMention.UID string→uint, 移除 varchar(36) gorm 约束 - UserSearchResult.UID string→uint - 移除 SearchUsersByLevel 中 strconv.FormatUint 转换 - 删除 GetUserUIDByID 方法,CreateReply 直接使用 parent.UserID - fillReplyToNames 使用 map[uint]string 替代 map[string]string - 更新 commentStore 接口声明 - 修复前端 mention 下拉 show.html 中 u.id→u.uid
This commit is contained in:
@ -96,7 +96,7 @@ func (r *CommentRepo) fillReplyToNames(list []model.Comment) {
|
||||
return
|
||||
}
|
||||
type nameRow struct {
|
||||
UID string
|
||||
UID uint
|
||||
Username string
|
||||
}
|
||||
var rows []nameRow
|
||||
@ -105,12 +105,12 @@ func (r *CommentRepo) fillReplyToNames(list []model.Comment) {
|
||||
Where("id IN (SELECT reply_to_uid FROM comments WHERE root_id IN (?) AND parent_id IS NOT NULL)", r.rootIDsFromList(list)).
|
||||
Find(&rows)
|
||||
|
||||
m := make(map[string]string)
|
||||
m := make(map[uint]string)
|
||||
for _, row := range rows {
|
||||
m[row.UID] = row.Username
|
||||
}
|
||||
for i := range list {
|
||||
if list[i].ReplyToUID != "" {
|
||||
if list[i].ReplyToUID != 0 {
|
||||
list[i].ReplyToName = m[list[i].ReplyToUID]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user