|
@@ -27,14 +27,15 @@ func NewGetCreditBalanceListLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
|
|
}
|
|
|
|
|
|
func (l *GetCreditBalanceListLogic) GetCreditBalanceList(req *types.CreditBalanceListReq) (*types.CreditBalanceListResp, error) {
|
|
|
+ organizationId := l.ctx.Value("organizationId").(uint64)
|
|
|
isAdmin := l.ctx.Value("isAdmin").(bool)
|
|
|
- if !isAdmin {
|
|
|
- return nil, errorx.NewInvalidArgumentError("权限不足")
|
|
|
- }
|
|
|
-
|
|
|
query := l.svcCtx.WechatDB.Find(&model.CreditBalance{})
|
|
|
- if req.OrganizationId != nil && *req.OrganizationId > 0 {
|
|
|
- query = query.Where("organization_id = ?", *req.OrganizationId)
|
|
|
+ if isAdmin {
|
|
|
+ if req.OrganizationId != nil && *req.OrganizationId > 0 {
|
|
|
+ query = query.Where("organization_id = ?", *req.OrganizationId)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ query = query.Where("organization_id = ?", organizationId)
|
|
|
}
|
|
|
creditBalanceList := make([]model.CreditBalance, 0)
|
|
|
err := query.Order("created_at DESC").Find(&creditBalanceList).Error
|
|
@@ -58,7 +59,7 @@ func (l *GetCreditBalanceListLogic) GetCreditBalanceList(req *types.CreditBalanc
|
|
|
for _, v := range creditBalanceList {
|
|
|
departmentInfo, err := l.svcCtx.CoreRpc.GetDepartmentById(l.ctx, &core.IDReq{Id: uint64(v.OrganizationID)})
|
|
|
if err != nil {
|
|
|
- return nil, err
|
|
|
+ continue
|
|
|
}
|
|
|
|
|
|
status := int(v.Status)
|