40 lines
689 B
Go
40 lines
689 B
Go
|
/**
|
||
|
* @Author: Echo
|
||
|
* @Email:1711788888@qq.com
|
||
|
* @Date: 2021/8/28 11:23 上午
|
||
|
* @Desc: TODO
|
||
|
*/
|
||
|
|
||
|
package profile
|
||
|
|
||
|
import (
|
||
|
"git.echol.cn/loser/tencent-im/internal/core"
|
||
|
"git.echol.cn/loser/tencent-im/internal/entity"
|
||
|
"git.echol.cn/loser/tencent-im/internal/enum"
|
||
|
)
|
||
|
|
||
|
type Profile struct {
|
||
|
entity.User
|
||
|
}
|
||
|
|
||
|
func NewProfile(userId ...string) *Profile {
|
||
|
p := &Profile{}
|
||
|
if len(userId) > 0 {
|
||
|
p.SetUserId(userId[0])
|
||
|
}
|
||
|
return p
|
||
|
}
|
||
|
|
||
|
// CheckError 检测错误
|
||
|
func (p *Profile) CheckError() (err error) {
|
||
|
if userId := p.GetUserId(); userId == "" {
|
||
|
return core.NewError(enum.InvalidParamsCode, "the userid is not set")
|
||
|
}
|
||
|
|
||
|
if err = p.GetError(); err != nil {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|