|
|
@ -303,6 +303,7 @@ func (s *officeServer) CreateOneWorkMoment(_ context.Context, req *pbOffice.Crea
|
|
|
|
UserID: workMoment.UserID,
|
|
|
|
UserID: workMoment.UserID,
|
|
|
|
FaceURL: createUser.FaceURL,
|
|
|
|
FaceURL: createUser.FaceURL,
|
|
|
|
UserName: createUser.Nickname,
|
|
|
|
UserName: createUser.Nickname,
|
|
|
|
|
|
|
|
CreateTime: workMoment.CreateTime,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
msg.WorkMomentSendNotification(req.OperationID, workMoment.UserID, atUser.UserID, workMomentNotificationMsg)
|
|
|
|
msg.WorkMomentSendNotification(req.OperationID, workMoment.UserID, atUser.UserID, workMomentNotificationMsg)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -375,13 +376,13 @@ func isUserCanSeeWorkMoment(userID string, workMoment db.WorkMoment) bool {
|
|
|
|
func (s *officeServer) LikeOneWorkMoment(_ context.Context, req *pbOffice.LikeOneWorkMomentReq) (resp *pbOffice.LikeOneWorkMomentResp, err error) {
|
|
|
|
func (s *officeServer) LikeOneWorkMoment(_ context.Context, req *pbOffice.LikeOneWorkMomentReq) (resp *pbOffice.LikeOneWorkMomentResp, err error) {
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
|
|
resp = &pbOffice.LikeOneWorkMomentResp{CommonResp: &pbOffice.CommonResp{}}
|
|
|
|
resp = &pbOffice.LikeOneWorkMomentResp{CommonResp: &pbOffice.CommonResp{}}
|
|
|
|
userName, err := imdb.GetUserNameByUserID(req.UserID)
|
|
|
|
user, err := imdb.GetUserByUserID(req.UserID)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserNameByUserID failed", err.Error())
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserNameByUserID failed", err.Error())
|
|
|
|
resp.CommonResp = &pbOffice.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
|
|
|
resp.CommonResp = &pbOffice.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
|
|
|
return resp, nil
|
|
|
|
return resp, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
workMoment, like, err := db.DB.LikeOneWorkMoment(req.UserID, userName, req.WorkMomentID)
|
|
|
|
workMoment, like, err := db.DB.LikeOneWorkMoment(req.UserID, user.Nickname, req.WorkMomentID)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "LikeOneWorkMoment failed ", err.Error())
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "LikeOneWorkMoment failed ", err.Error())
|
|
|
|
resp.CommonResp = &pbOffice.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
|
|
|
resp.CommonResp = &pbOffice.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
|
|
@ -391,9 +392,10 @@ func (s *officeServer) LikeOneWorkMoment(_ context.Context, req *pbOffice.LikeOn
|
|
|
|
NotificationMsgType: constant.WorkMomentLikeNotification,
|
|
|
|
NotificationMsgType: constant.WorkMomentLikeNotification,
|
|
|
|
WorkMomentID: workMoment.WorkMomentID,
|
|
|
|
WorkMomentID: workMoment.WorkMomentID,
|
|
|
|
WorkMomentContent: workMoment.Content,
|
|
|
|
WorkMomentContent: workMoment.Content,
|
|
|
|
UserID: workMoment.UserID,
|
|
|
|
UserID: user.UserID,
|
|
|
|
FaceURL: workMoment.FaceURL,
|
|
|
|
FaceURL: user.FaceURL,
|
|
|
|
UserName: workMoment.UserName,
|
|
|
|
UserName: user.Nickname,
|
|
|
|
|
|
|
|
CreateTime: int32(time.Now().Unix()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// send notification
|
|
|
|
// send notification
|
|
|
|
if like {
|
|
|
|
if like {
|
|
|
@ -442,16 +444,11 @@ func (s *officeServer) CommentOneWorkMoment(_ context.Context, req *pbOffice.Com
|
|
|
|
UserID: workMoment.UserID,
|
|
|
|
UserID: workMoment.UserID,
|
|
|
|
FaceURL: workMoment.FaceURL,
|
|
|
|
FaceURL: workMoment.FaceURL,
|
|
|
|
UserName: workMoment.UserName,
|
|
|
|
UserName: workMoment.UserName,
|
|
|
|
Comment: &pbOffice.Comment{
|
|
|
|
ReplyUserID: comment.ReplyUserID,
|
|
|
|
UserID: comment.UserID,
|
|
|
|
ReplyUserName: comment.ReplyUserName,
|
|
|
|
UserName: comment.UserName,
|
|
|
|
ContentID: comment.ContentID,
|
|
|
|
FaceURL: commentUser.FaceURL,
|
|
|
|
Content: comment.Content,
|
|
|
|
ReplyUserID: comment.ReplyUserID,
|
|
|
|
CreateTime: comment.CreateTime,
|
|
|
|
ReplyUserName: comment.ReplyUserName,
|
|
|
|
|
|
|
|
ContentID: comment.ContentID,
|
|
|
|
|
|
|
|
Content: comment.Content,
|
|
|
|
|
|
|
|
CreateTime: comment.CreateTime,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
msg.WorkMomentSendNotification(req.OperationID, req.UserID, workMoment.UserID, workMomentNotificationMsg)
|
|
|
|
msg.WorkMomentSendNotification(req.OperationID, req.UserID, workMoment.UserID, workMomentNotificationMsg)
|
|
|
|
if req.ReplyUserID != "" {
|
|
|
|
if req.ReplyUserID != "" {
|
|
|
@ -488,10 +485,14 @@ func (s *officeServer) GetWorkMomentByID(_ context.Context, req *pbOffice.GetWor
|
|
|
|
func (s *officeServer) GetUserWorkMoments(_ context.Context, req *pbOffice.GetUserWorkMomentsReq) (resp *pbOffice.GetUserWorkMomentsResp, err error) {
|
|
|
|
func (s *officeServer) GetUserWorkMoments(_ context.Context, req *pbOffice.GetUserWorkMomentsReq) (resp *pbOffice.GetUserWorkMomentsResp, err error) {
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
|
|
resp = &pbOffice.GetUserWorkMomentsResp{CommonResp: &pbOffice.CommonResp{}, WorkMoments: []*pbOffice.WorkMoment{}}
|
|
|
|
resp = &pbOffice.GetUserWorkMomentsResp{CommonResp: &pbOffice.CommonResp{}, WorkMoments: []*pbOffice.WorkMoment{}}
|
|
|
|
//resp.WorkMoments = make([]*pbOffice.WorkMoment, 0)
|
|
|
|
var workMoments []db.WorkMoment
|
|
|
|
workMoments, err := db.DB.GetUserWorkMoments(req.UserID, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
|
|
|
if req.UserID == req.OpUserID {
|
|
|
|
|
|
|
|
workMoments, err = db.DB.GetUserSelfWorkMoments(req.UserID, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
workMoments, err = db.DB.GetUserWorkMoments(req.OpUserID, req.UserID, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
|
|
|
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err)
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserWorkMoments failed", err.Error())
|
|
|
|
resp.CommonResp = &pbOffice.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
|
|
|
resp.CommonResp = &pbOffice.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
|
|
|
return resp, nil
|
|
|
|
return resp, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|