|
@@ -32,18 +32,28 @@ func (l *GetSelectWxListLogic) GetSelectWxList(req *types.WxSelectListReq) (resp
|
|
|
organizationId := l.ctx.Value("organizationId").(uint64)
|
|
|
isAdmin := l.ctx.Value("isAdmin").(bool)
|
|
|
var predicates []predicate.Wx
|
|
|
- var ctype uint64 = 1
|
|
|
+ ctype := uint64(1)
|
|
|
if req.Ctype != nil && *req.Ctype > 0 {
|
|
|
ctype = *req.Ctype
|
|
|
}
|
|
|
predicates = append(predicates, wx.Ctype(ctype))
|
|
|
+
|
|
|
+ // 组织 ID 条件逻辑
|
|
|
if !isAdmin {
|
|
|
+ // 普通用户:只能查自己的组织
|
|
|
predicates = append(predicates, wx.OrganizationIDEQ(organizationId))
|
|
|
} else {
|
|
|
- if req.OrganizationId != nil && *req.OrganizationId != 0 {
|
|
|
+ // 超管
|
|
|
+ if req.OrganizationId == nil {
|
|
|
+ // 未传,查自己的
|
|
|
+ predicates = append(predicates, wx.OrganizationIDEQ(organizationId))
|
|
|
+ } else if *req.OrganizationId > 0 {
|
|
|
+ // 传了正整数,查传入的
|
|
|
predicates = append(predicates, wx.OrganizationIDEQ(*req.OrganizationId))
|
|
|
}
|
|
|
+ // 传了 0:不加任何条件(查全部)
|
|
|
}
|
|
|
+
|
|
|
data, err := l.svcCtx.DB.Wx.Query().Where(predicates...).Order(ent.Desc(wx.FieldOrganizationID)).All(l.ctx)
|
|
|
if err != nil {
|
|
|
return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|