message.go 4.0 KB
package protocol

import (
	"encoding/json"
)

var errmessge ErrorMap = map[int]string{
	0:    "成功",
	1:    "系统异常",
	2:    "参数错误",
	101:  "clientId或clientSecret无效",
	113:  "签名验证失败",
	1009: "验证码已失效",
	1011: "获取验证码次数超出限制,请联系管理员",
	1012: "请输入正确的验证码",
	2001: "请输入正确的手机号码",
	2002: "您还不是正式用户,请联系管理员",
	2009: "上传的文件流为空",
	2021: "登录失败,手机号或密码错误",
	2025: "短信验证码验证失败",
	2026: "新密码与确认密码不一致",
	2027: "密码必须至少有6个字符",
	2028: "请输入正确的旧密码",
	2029: "当前手机号已存在,请重新输入",
	4139: "authCode无效或过期",
	4140: "refreshToken过期,需要重新登录授权",
	4141: "accessToken过期或无效,需要进行重新获取令牌",
	4142: "Uuid已存在,请求失败",
	4201: "无该公司",
	5000: "繁忙,请稍后再试",
}

/*MessageCenter */
type MessageCenterRequest struct {
	MsgType int `json:"msgType" valid:"Required"`
}
type MessageCenterResponse struct {
	Totals []*MessageTotal `json:"totals"`
}

type MessageTotal struct {
	MsgType  int `json:"msgType" orm:"column(msg_type)"`
	MsgTotal int `json:"msgTotal" orm:"column(total)"`
}

/*MsgCenterRead */
type MsgCenterReadRequest struct {
	MsgId   int64 `json:"msgId" valid:"Required"`
	MsgType int   `json:"msgType" valid:"Required"`
}
type MsgCenterReadResponse struct {
}

/*MsgCenterAllRead */
type MsgCenterAllReadRequest struct {
	MsgType int `json:"msgType" valid:"Required"`
}
type MsgCenterAllReadResponse struct {
}

/*互动消息*/
type MsgInteractiveRequest struct {
	LastId     int64 `json:"lastId"`
	PageSize   int   `json:"pageSize" valid:"Required"`
	MsgType    int   `json:"msgType" valid:"Required"`
	SourceType int   `json:"sourceType" valid:"Required"`
}
type MsgInteractiveResponse struct {
	Lists []*UserMsg `json:"lists"`
	Total int        `json:"total"`
}

type UserMsg struct {
	Id         int64  `json:"msgId"`
	SourceType int    `json:"msgType"`
	Content    string `json:"content"`
	CreateAt   int64  `json:"msgTime"`
	IsRead     int    `json:"isRead"`
	//机会 //评论
}

type Message struct {
	ErrorCode
	Data json.RawMessage `json:"data"`
}

func (m Message) Unmarshal(v interface{}) error {
	if len(m.Data) == 0 {
		m.Data = []byte("{}")
	}
	return json.Unmarshal(m.Data, v)
}

/**************公告****************/
type Question struct {
	Id      int               `json:"id"`
	Type    int               `json:"type" valid:"Required"`
	Title   string            `json:"title" valid:"Required"`
	Content []QuestionContent `json:"content" valid:"Required"`
}
type QuestionContent struct {
	Id      int    `json:"id" valid:"Required"`
	Content string `json:"content" valid:"Required"`
}
type Cover struct {
	Path string `json:"path" valid:"Required"`
	H    int    `json:"h"`
	W    int    `json:"w"`
}

/*公告列表 BulletinList */
type BulletinListRequest struct {
}
type BulletinListResponse struct {
	List  []*BulletinItem `json:"list"`
	Total int
}

type BulletinItem struct {
	Id       int        `json:"id"`
	Type     int8       `json:"type"`
	Title    string     `json:"title"`
	Status   int8       `json:"status"`
	Receiver []Receiver `json:"receiver" valid:"Required"`
	CreateAt string     `json:"time"`
}

/*GetBulletin */
type GetBulletinRequest struct {
}
type GetBulletinResponse struct {
	Id         int    `json:"id"`
	Type       int    `json:"type" valid:"Required"`
	Title      string `json:"title" valid:"Required"`
	Content    string `json:"content" valid:"Required"`
	AllowClose int    `json:"allow_close"`
	//AllowCondition int        `json:"allow_condition"`
	QuestionSwitch int        `json:"question_switch"`
	Receiver       []Receiver `json:"receiver" valid:"Required"`
	Question       Question   `json:"question"`
	Cover          Cover      `json:"cover" valid:"Required"`
}

type Receiver struct {
	Id       int64  `json:"id"`
	NickName string `json:"name"`
}