|
@@ -35,7 +35,7 @@ func (l *GetCreditUsageListLogic) GetCreditUsageList(req *types.CreditUsageListR
|
|
|
isAdmin := l.ctx.Value("isAdmin").(bool)
|
|
|
var predicates []predicate.CreditUsage
|
|
|
if isAdmin {
|
|
|
- if req.OrganizationId != nil {
|
|
|
+ if req.OrganizationId != nil && *req.OrganizationId > 0 {
|
|
|
predicates = append(predicates, creditusage.OrganizationID(*req.OrganizationId))
|
|
|
}
|
|
|
} else {
|
|
@@ -75,12 +75,19 @@ func (l *GetCreditUsageListLogic) GetCreditUsageList(req *types.CreditUsageListR
|
|
|
resp.Msg = errormsg.Success
|
|
|
resp.Data.Total = data.PageDetails.Total
|
|
|
|
|
|
- departmentInfo, err := l.svcCtx.CoreRpc.GetDepartmentById(l.ctx, &core.IDReq{Id: *req.OrganizationId})
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
+ orgaMap := make(map[uint64]string)
|
|
|
|
|
|
for _, v := range data.List {
|
|
|
+ organizationName := ""
|
|
|
+ if oname, ok := orgaMap[v.OrganizationID]; ok {
|
|
|
+ organizationName = oname
|
|
|
+ } else {
|
|
|
+ departmentInfo, err := l.svcCtx.CoreRpc.GetDepartmentById(l.ctx, &core.IDReq{Id: v.OrganizationID})
|
|
|
+ if err == nil {
|
|
|
+ organizationName = *departmentInfo.Name
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
resp.Data.Data = append(resp.Data.Data,
|
|
|
types.CreditUsageInfo{
|
|
|
BaseIDInfo: types.BaseIDInfo{
|
|
@@ -97,7 +104,7 @@ func (l *GetCreditUsageListLogic) GetCreditUsageList(req *types.CreditUsageListR
|
|
|
Ntype: &v.Ntype,
|
|
|
Table: &v.Table,
|
|
|
OrganizationId: &v.OrganizationID,
|
|
|
- OrganizationName: departmentInfo.Name,
|
|
|
+ OrganizationName: &organizationName,
|
|
|
Nid: &v.Nid,
|
|
|
Reason: &v.Reason,
|
|
|
Operator: &v.Operator,
|