|
|
package commend
|
|
|
|
|
|
import (
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/time"
|
|
|
"opp/internal/repository"
|
|
|
"opp/models"
|
|
|
"opp/protocol"
|
|
|
"opp/services/agg"
|
|
|
)
|
|
|
|
|
|
func Commend(header *protocol.RequestHeader, request *protocol.CommendRequest) (rsp *protocol.CommendResponse, err error) {
|
|
|
var (
|
|
|
userBaseInfo *protocol.UserBaseInfoAggregation
|
|
|
user *models.User
|
|
|
commends []*models.Commend
|
|
|
)
|
|
|
rsp = &protocol.CommendResponse{}
|
|
|
user, err = repository.User.GetUsersById(header.Uid)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
if commends, rsp.Total, err = repository.Commend.GetCommends(user.CompanyId, request.LastId, request.PageSize); err != nil {
|
|
|
return
|
|
|
}
|
|
|
for i := 0; i < len(commends); i++ {
|
|
|
c := commends[i]
|
|
|
userBaseInfo, err = agg.GetUserBaseInfo(c.UserId)
|
|
|
if err != nil {
|
|
|
continue
|
|
|
}
|
|
|
user = userBaseInfo.User
|
|
|
cInfo := protocol.CommendInfo{
|
|
|
Id: c.Id,
|
|
|
Content: c.Content,
|
|
|
Company: userBaseInfo.Company.Name,
|
|
|
CommendAt: time.GetUnixTimeByNDayUnix(c.CommendAt.Unix(), 0),
|
|
|
Honored: protocol.HonoredUserInfo{
|
|
|
UserId: c.UserId,
|
|
|
NickName: user.NickName,
|
|
|
Department: userBaseInfo.Department.Name,
|
|
|
Position: userBaseInfo.Position.Name,
|
|
|
},
|
|
|
}
|
|
|
rsp.Lists = append(rsp.Lists, cInfo)
|
|
|
}
|
|
|
return
|
|
|
} |
...
|
...
|
|