作者 yangfu

注入用户无效

... ... @@ -12,12 +12,11 @@ type UserCompany struct {
CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司编号"`
UserId int64 `orm:"column(user_id)" description:"表user.id 用户编号"`
NickName string `orm:"column(nick_name);size(100)" description:"昵称"`
DepartmentId int `orm:"column(department_id)" description:"部门id"`
PositionId int `orm:"column(position_id)" description:"职位id"`
ChanceTotal int `orm:"column(chance_total)" description:"发表机会数"`
CommentTotal int `orm:"column(comment_total)" description:"发表评论总数"`
CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
Enable int8 `orm:"column(enable)" description:"有效状态"`
}
func (t *UserCompany) TableName() string {
... ...
... ... @@ -26,3 +26,25 @@ func CheckCompanyPermission(companyId int64) (err error) {
}
return
}
//检查用户权限
func CheckUserPermission(ucid int64) (err error) {
var (
user *models.UserCompany
)
if ucid == 0 {
return
}
if user, err = models.GetUserCompanyById(ucid); err != nil {
log.Error("用户不存在:", ucid, err)
return
}
if user.Enable == 1 {
return
}
if user.Enable == 0 || user.Enable == 2 {
err = fmt.Errorf("用户:%v 无权限,请联系管理员", ucid)
return
}
return
}
... ...
... ... @@ -27,7 +27,12 @@ func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCent
err = protocol.NewErrWithMessage(4141)
return
}
//注入用户检查
if err = agg.CheckUserPermission(header.UserId); err != nil {
log.Error(err)
err = protocol.NewErrWithMessage(4140)
return
}
if request.MsgType&protocol.MsgTypeInteraction > 0 {
if request.MsgType&protocol.MsgTypeThumbUp == 0 {
request.MsgType |= protocol.MsgTypeThumbUp
... ...