|
@@ -2,6 +2,7 @@ package xunji_service
|
|
|
|
|
|
import (
|
|
import (
|
|
"context"
|
|
"context"
|
|
|
|
+ "github.com/zeromicro/go-zero/core/errorx"
|
|
|
|
|
|
"wechat-api/ent/predicate"
|
|
"wechat-api/ent/predicate"
|
|
"wechat-api/ent/xunjiservice"
|
|
"wechat-api/ent/xunjiservice"
|
|
@@ -30,15 +31,19 @@ func NewGetXunjiServiceListLogic(ctx context.Context, svcCtx *svc.ServiceContext
|
|
}
|
|
}
|
|
|
|
|
|
func (l *GetXunjiServiceListLogic) GetXunjiServiceList(req *types.XunjiServiceListReq) (*types.XunjiServiceListResp, error) {
|
|
func (l *GetXunjiServiceListLogic) GetXunjiServiceList(req *types.XunjiServiceListReq) (*types.XunjiServiceListResp, error) {
|
|
|
|
+ isAdmin := l.ctx.Value("isAdmin").(bool)
|
|
|
|
+
|
|
var predicates []predicate.XunjiService
|
|
var predicates []predicate.XunjiService
|
|
- if req.Wxid != nil {
|
|
|
|
- predicates = append(predicates, xunjiservice.WxidContains(*req.Wxid))
|
|
|
|
- }
|
|
|
|
- if req.ApiBase != nil {
|
|
|
|
- predicates = append(predicates, xunjiservice.APIBaseContains(*req.ApiBase))
|
|
|
|
- }
|
|
|
|
- if req.ApiKey != nil {
|
|
|
|
- predicates = append(predicates, xunjiservice.APIKeyContains(*req.ApiKey))
|
|
|
|
|
|
+
|
|
|
|
+ if isAdmin {
|
|
|
|
+ if req.XunjiID != nil && *req.XunjiID > 0 {
|
|
|
|
+ predicates = append(predicates, xunjiservice.XunjiID(*req.XunjiID))
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if req.XunjiID == nil || *req.XunjiID <= 0 {
|
|
|
|
+ return nil, errorx.NewInvalidArgumentError("父ID不能为空")
|
|
|
|
+ }
|
|
|
|
+ predicates = append(predicates, xunjiservice.XunjiID(*req.XunjiID))
|
|
}
|
|
}
|
|
data, err := l.svcCtx.DB.XunjiService.Query().Where(predicates...).WithAgent().Page(l.ctx, req.Page, req.PageSize)
|
|
data, err := l.svcCtx.DB.XunjiService.Query().Where(predicates...).WithAgent().Page(l.ctx, req.Page, req.PageSize)
|
|
|
|
|