...
|
...
|
@@ -2,9 +2,12 @@ package comment |
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
"sort"
|
|
|
"strings"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
...
|
...
|
@@ -24,6 +27,7 @@ func NewMiniArticleCommentAtWhoLogic(ctx context.Context, svcCtx *svc.ServiceCon |
|
|
}
|
|
|
}
|
|
|
|
|
|
// MiniArticleCommentAtWho 填写评估时@谁 的可选择者列表
|
|
|
func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniArticleCommentAtWhoRequest) (resp *types.MiniArticleCommentAtWhoResponse, err error) {
|
|
|
var conn = l.svcCtx.DefaultDBConn()
|
|
|
articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId)
|
...
|
...
|
@@ -35,11 +39,42 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr |
|
|
return resp, nil
|
|
|
}
|
|
|
|
|
|
// userList := []*domain.User{}
|
|
|
// if len(articleInfo.WhoRead) == 0 {
|
|
|
var userList []*domain.User
|
|
|
if len(articleInfo.WhoRead) == 0 {
|
|
|
//获取所有人
|
|
|
queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("companyId", articleInfo.CompanyId)
|
|
|
_, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
|
|
|
if err != nil {
|
|
|
resp = &types.MiniArticleCommentAtWhoResponse{}
|
|
|
return resp, nil
|
|
|
}
|
|
|
} else {
|
|
|
queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("ids", articleInfo.WhoRead)
|
|
|
_, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
|
|
|
if err != nil {
|
|
|
resp = &types.MiniArticleCommentAtWhoResponse{}
|
|
|
return resp, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// return
|
|
|
// }
|
|
|
uList := make([]types.CommentAtWho, len(userList))
|
|
|
|
|
|
return
|
|
|
for i := range userList {
|
|
|
uList[i] = types.CommentAtWho{
|
|
|
Id: userList[i].Id,
|
|
|
Name: userList[i].Name,
|
|
|
FirstLetter: "",
|
|
|
}
|
|
|
for _, val := range userList[i].PinYinName {
|
|
|
uList[i].FirstLetter = strings.ToUpper(string(val))
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
sort.Slice(uList, func(i, j int) bool {
|
|
|
return uList[i].FirstLetter < uList[j].FirstLetter
|
|
|
})
|
|
|
resp = &types.MiniArticleCommentAtWhoResponse{
|
|
|
List: uList,
|
|
|
}
|
|
|
return resp, nil
|
|
|
} |
...
|
...
|
|