package logic import ( "app.yhyue.com/moapp/MessageCenter/entity" service "app.yhyue.com/moapp/MessageCenter/rpc/internal/common" "app.yhyue.com/moapp/jybase/common" "context" "github.com/gogf/gf/v2/util/gconv" "path" "strings" "app.yhyue.com/moapp/MessageCenter/rpc/internal/svc" "app.yhyue.com/moapp/MessageCenter/rpc/type/message" fpb "bp.jydev.jianyu360.cn/BaseService/fileCenter/rpc/pb" "github.com/zeromicro/go-zero/core/logx" ) type MlDetailsLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewMlDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MlDetailsLogic { return &MlDetailsLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } // 物料详情 func (l *MlDetailsLogic) MlDetails(in *message.MaterialDetailReq) (*message.MaterialDetailResp, error) { // todo: add your logic here and delete this line //先查询详情 data := service.MaterialDetail(in.MsgLogId, in.PositionId) if data != nil { attUrl := []string{} qrCodeUrl := common.InterfaceToStr(data["qrcode_url"]) fileUrl := common.InterfaceToStr(data["file_url"]) if qrCodeUrl != "" && common.InterfaceToStr(data["attUrl"]) == "" && len(strings.Split(fileUrl, ",")) != 0 { for _, val := range strings.Split(fileUrl, ",") { imgByte, err := service.PersonImgSaveComposite(val, qrCodeUrl, "", in.PositionId) if err != nil { return &message.MaterialDetailResp{ Code: 1, Message: "获取详情成功", Data: nil, }, nil } up, err := entity.FileCenterRpc.Upload(l.ctx, &fpb.UploadReq{ File: imgByte, OssBucketName: entity.OssBucketName, OssUrl: entity.OssUrl, Name: path.Base(fileUrl), NeedEncryption: false, }) if up == nil || up.Url == "" { return &message.MaterialDetailResp{ Code: -1, Message: "上传合成图片失败", Data: nil, }, nil } attUrl = append(attUrl, up.Url) ok := service.PersonImageSave(up.Url, common.Int64All(data["id"]), in.PositionId, common.Int64All(data["mid"])) if !ok { return &message.MaterialDetailResp{ Code: -1, Message: "保存个人图片失败", Data: nil, }, nil } } //} data["attUrl"] = strings.Join(attUrl, ",") } return &message.MaterialDetailResp{ Code: 1, Message: "获取详情成功", Data: &message.MaterialDetail{ Id: gconv.Int64(data["id"]), Title: gconv.String(data["title"]), Content: gconv.String(data["content"]), Link: gconv.String(data["link"]), Createtime: gconv.String(data["createtime"]), IsRead: gconv.Int64(data["isRead"]), MsgType: gconv.Int64(data["msgType"]), TaskName: gconv.String(data["task_name"]), TaskDescription: gconv.String(data["task_description"]), MaterialContent: gconv.String(data["material_content"]), QrcodeUrl: gconv.String(data["qrcode_url"]), ReceiveUserName: gconv.String(data["receive_user_name"]), ReceiveUserId: gconv.String(data["receive_user_id"]), FileUrl: gconv.String(data["file_url"]), AttUrl: gconv.String(data["attUrl"]), ImgWebpage: gconv.String(data["img_webpage"]), }, }, nil } return &message.MaterialDetailResp{ Code: 1, Message: "获取详情成功", Data: nil, }, nil }