12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package logic
- import (
- "app.yhyue.com/moapp/MessageCenter/api/internal/svc"
- "app.yhyue.com/moapp/MessageCenter/api/internal/types"
- "app.yhyue.com/moapp/MessageCenter/rpc/messageclient"
- "app.yhyue.com/moapp/MessageCenter/util"
- "context"
- "encoding/json"
- "github.com/tal-tech/go-zero/core/logx"
- "log"
- )
- type MultipleSaveMsgLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewMultipleSaveMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) MultipleSaveMsgLogic {
- return MultipleSaveMsgLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- func (l *MultipleSaveMsgLogic) MultipleSaveMsg(req types.MultipleSaveMsgReq) (*types.MultipleSaveMsgResp, error) {
- // todo: add your logic here and delete this line
- log.Println("请求参数:", req)
- //var reqData = []map[string]interface{}{}
- //err := json.Unmarshal([]byte(req.SaveData), reqData)
- //if err != nil {
- // return &types.MultipleSaveMsgResp{
- // Code: 0,
- // Message: "失败",
- // ErrCount: 0,
- // }, nil
- //}
- errCount := 0
- lsi := l.svcCtx.MessageCenter
- msgInfo := req.MsgInfo
- var showBuoyValue int64 = 0
- if value, ok := msgInfo["showBuoy"].(json.Number); ok {
- showBuoyValue, _ = value.Int64()
- }
- _, err := lsi.MultipleSaveMsg(l.ctx, &messageclient.MultipleSaveMsgReq{
- Appid: util.ObjToString(msgInfo["appid"]),
- SendUserId: util.ObjToString(msgInfo["sendUserId"]),
- SendName: util.ObjToString(msgInfo["sendName"]),
- Title: util.ObjToString(msgInfo["title"]),
- Content: util.ObjToString(msgInfo["content"]),
- MsgType: int64(util.IntAll(msgInfo["msgType"])),
- Link: util.ObjToString(msgInfo["link"]),
- CiteId: 0,
- UserIds: req.UserIds,
- UserNames: req.UserNames,
- MsgLogId: int64(util.IntAll(msgInfo["msgLogId"])),
- ShowBuoy: showBuoyValue,
- ShowContent: util.ObjToString(msgInfo["showContent"]),
- })
- if err != nil {
- errCount++
- }
- return &types.MultipleSaveMsgResp{
- Code: 1,
- Message: "保存成功",
- ErrCount: int64(errCount),
- }, nil
- }
|