正在显示
3 个修改的文件
包含
29 行增加
和
3 行删除
| @@ -12,12 +12,11 @@ type UserCompany struct { | @@ -12,12 +12,11 @@ type UserCompany struct { | ||
| 12 | CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司编号"` | 12 | CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司编号"` |
| 13 | UserId int64 `orm:"column(user_id)" description:"表user.id 用户编号"` | 13 | UserId int64 `orm:"column(user_id)" description:"表user.id 用户编号"` |
| 14 | NickName string `orm:"column(nick_name);size(100)" description:"昵称"` | 14 | NickName string `orm:"column(nick_name);size(100)" description:"昵称"` |
| 15 | - DepartmentId int `orm:"column(department_id)" description:"部门id"` | ||
| 16 | - PositionId int `orm:"column(position_id)" description:"职位id"` | ||
| 17 | ChanceTotal int `orm:"column(chance_total)" description:"发表机会数"` | 15 | ChanceTotal int `orm:"column(chance_total)" description:"发表机会数"` |
| 18 | CommentTotal int `orm:"column(comment_total)" description:"发表评论总数"` | 16 | CommentTotal int `orm:"column(comment_total)" description:"发表评论总数"` |
| 19 | CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"` | 17 | CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"` |
| 20 | UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"` | 18 | UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"` |
| 19 | + Enable int8 `orm:"column(enable)" description:"有效状态"` | ||
| 21 | } | 20 | } |
| 22 | 21 | ||
| 23 | func (t *UserCompany) TableName() string { | 22 | func (t *UserCompany) TableName() string { |
| @@ -26,3 +26,25 @@ func CheckCompanyPermission(companyId int64) (err error) { | @@ -26,3 +26,25 @@ func CheckCompanyPermission(companyId int64) (err error) { | ||
| 26 | } | 26 | } |
| 27 | return | 27 | return |
| 28 | } | 28 | } |
| 29 | + | ||
| 30 | +//检查用户权限 | ||
| 31 | +func CheckUserPermission(ucid int64) (err error) { | ||
| 32 | + var ( | ||
| 33 | + user *models.UserCompany | ||
| 34 | + ) | ||
| 35 | + if ucid == 0 { | ||
| 36 | + return | ||
| 37 | + } | ||
| 38 | + if user, err = models.GetUserCompanyById(ucid); err != nil { | ||
| 39 | + log.Error("用户不存在:", ucid, err) | ||
| 40 | + return | ||
| 41 | + } | ||
| 42 | + if user.Enable == 1 { | ||
| 43 | + return | ||
| 44 | + } | ||
| 45 | + if user.Enable == 0 || user.Enable == 2 { | ||
| 46 | + err = fmt.Errorf("用户:%v 无权限,请联系管理员", ucid) | ||
| 47 | + return | ||
| 48 | + } | ||
| 49 | + return | ||
| 50 | +} |
| @@ -27,7 +27,12 @@ func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCent | @@ -27,7 +27,12 @@ func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCent | ||
| 27 | err = protocol.NewErrWithMessage(4141) | 27 | err = protocol.NewErrWithMessage(4141) |
| 28 | return | 28 | return |
| 29 | } | 29 | } |
| 30 | - | 30 | + //注入用户检查 |
| 31 | + if err = agg.CheckUserPermission(header.UserId); err != nil { | ||
| 32 | + log.Error(err) | ||
| 33 | + err = protocol.NewErrWithMessage(4140) | ||
| 34 | + return | ||
| 35 | + } | ||
| 31 | if request.MsgType&protocol.MsgTypeInteraction > 0 { | 36 | if request.MsgType&protocol.MsgTypeInteraction > 0 { |
| 32 | if request.MsgType&protocol.MsgTypeThumbUp == 0 { | 37 | if request.MsgType&protocol.MsgTypeThumbUp == 0 { |
| 33 | request.MsgType |= protocol.MsgTypeThumbUp | 38 | request.MsgType |= protocol.MsgTypeThumbUp |
-
请 注册 或 登录 后发表评论