Browse Source

update

master
DengBiao 1 year ago
parent
commit
6bb761a090
5 changed files with 533 additions and 217 deletions
  1. +25
    -0
      internal/business/api/business_ext.go
  2. +17
    -0
      internal/logic/domain/group/model/group_complain.go
  3. +35
    -0
      internal/logic/domain/group/repo/group_complain_dao.go
  4. +434
    -217
      pkg/pb/business.ext.pb.go
  5. +22
    -0
      pkg/proto/business.ext.proto

+ 25
- 0
internal/business/api/business_ext.go View File

@@ -2,20 +2,45 @@ package api

import (
"context"
"encoding/json"
"errors"
"gim/internal/business/app"
comm "gim/internal/business/comm"
"gim/internal/business/comm/utils"
"gim/internal/business/domain/user/repo"
friend2 "gim/internal/logic/domain/friend"
"gim/internal/logic/domain/group/model"
repo2 "gim/internal/logic/domain/group/repo"
"gim/internal/logic/domain/message/service"
"gim/pkg/grpclib"
"gim/pkg/pb"
"strconv"
"time"
)

type BusinessExtServer struct{}

func (s *BusinessExtServer) ComplainGroup(ctx context.Context, req *pb.ComplainGroupReq) (*pb.Empty, error) {
now := time.Now()
userId, _, err := grpclib.GetCtxData(ctx)
if err != nil {
return nil, err
}
imageList, _ := json.Marshal(req.ImageList)
groupComplain := model.GroupComplain{
GroupId: req.GroupId,
UserId: userId,
ComplainType: int(req.ComplainType),
Text: req.Text,
ImageList: string(imageList),
Status: 0,
CreateTime: now,
UpdateTime: now,
}

return new(pb.Empty), repo2.GroupComplainDao.Save(&groupComplain)
}

func (s *BusinessExtServer) IsFriends(ctx context.Context, req *pb.IsFriendsReq) (*pb.IsFriendsResp, error) {
masterId, err := grpclib.GetCtxMasterId(ctx)
if err != nil {


+ 17
- 0
internal/logic/domain/group/model/group_complain.go View File

@@ -0,0 +1,17 @@
package model

import (
"time"
)

type GroupComplain struct {
Id int64 // 自增主键
GroupId int64 // 群组id
UserId int64 // 用户id
ComplainType int // 投诉类型(1:存在赌博行为 2:存在骗钱行为 3:不当信息骚扰 4:传播谣言 5:发布假冒商品信息 6:侵犯未成年人权益 7:其他)
Text string // 投诉内容
ImageList string // 图片
Status int // 状态
CreateTime time.Time // 创建时间
UpdateTime time.Time // 更新时间
}

+ 35
- 0
internal/logic/domain/group/repo/group_complain_dao.go View File

@@ -0,0 +1,35 @@
package repo

import (
"gim/internal/logic/domain/group/model"
"gim/pkg/db"
"gim/pkg/gerrors"

"github.com/jinzhu/gorm"
)

type groupComplainDao struct{}

var GroupComplainDao = new(groupComplainDao)

// Get 获取群组信息
func (*groupComplainDao) Get(id int64) (*model.GroupComplain, error) {
var group = model.GroupComplain{Id: id}
err := db.DB.First(&group).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, gerrors.WrapError(err)
}
if err == gorm.ErrRecordNotFound {
return nil, nil
}
return &group, nil
}

// Save 插入一条群组
func (*groupComplainDao) Save(group *model.GroupComplain) error {
err := db.DB.Save(&group).Error
if err != nil {
return gerrors.WrapError(err)
}
return nil
}

+ 434
- 217
pkg/pb/business.ext.pb.go
File diff suppressed because it is too large
View File


+ 22
- 0
pkg/proto/business.ext.proto View File

@@ -19,6 +19,28 @@ service BusinessExt {
rpc EmoticonList (Empty) returns (EmoticonListResp);
// 判断是否为好友关系
rpc IsFriends (IsFriendsReq) returns (IsFriendsResp);
// 投诉群
rpc ComplainGroup (ComplainGroupReq) returns (Empty);
}


message ComplainGroupReq {
int64 group_id = 1;
ComplainType complain_type = 2; // 投诉类型
string text = 3; // 投诉内容
repeated string image_list = 4; // 图片
}

// 消息类型
enum ComplainType {
CT_UNKNOWN = 0; // 未知
CT_GAMBLE = 1; // 存在赌博行为
MT_DEFRAUD = 2; // 存在骗钱行为
MT_HARASS = 3; // 不当信息骚扰
MT_RUMOUR = 4; // 传播谣言
MT_COUNTERFEIT_GOODS_INFO = 5; // 发布假冒商品信息
MT_VIOLATION_OF_MINORS = 6; // 侵犯未成年人权益
MT_OTHER = 7; // 其他
}




Loading…
Cancel
Save