123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package logic
- import (
- "context"
- "log"
- "strings"
- "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
- cm "bp.jydev.jianyu360.cn/CRM/application/api/common"
- "bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
- "bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
- "bp.jydev.jianyu360.cn/CRM/application/service"
- "github.com/gogf/gf/v2/util/gconv"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type PushMsgLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewPushMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PushMsgLogic {
- return &PushMsgLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- func (l *PushMsgLogic) PushMsg(req *types.PushMsgReq) (resp *types.Reply, err error) {
- resp = &types.Reply{}
- status := -1
- baseUserIdArr := []int64{}
- for _, v := range req.User {
- resp, err := cm.UserCenterRpc.IdentityByEntUserId(l.ctx, &pb.IdentityReq{
- Id: v,
- })
- if err != nil {
- log.Println("获取用户职位id信息出错", v, "的信息出错", err)
- continue
- } else if resp == nil {
- log.Println("entuser用户", v, "没有找到职位信息")
- continue
- }
- baseUserIdArr = append(baseUserIdArr, resp.UserId)
- //查询mgo
- }
- u := &service.User{
- BaseUserIds: baseUserIdArr,
- }
- m := u.GetUserId(req.EntId)
- var kb strings.Builder
- var vb strings.Builder
- for k, v := range m {
- kb.WriteString(k + ",")
- vb.WriteString(gconv.String(v) + ",")
- userId := strings.TrimRight(kb.String(), ",")
- positionId := strings.TrimRight(vb.String(), ",")
- ok := service.StationMailPush(userId, positionId, req.Title, strings.Replace(req.Content, " ", "%20", -1), req.PcHref, req.MobileHref, req.MsgType)
- if ok {
- status = 1
- }
- }
- resp.Data = map[string]interface{}{
- "status": status,
- }
- return
- }
|