|
@@ -2,6 +2,7 @@ package credit_usage
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
+ "github.com/suyuan32/simple-admin-core/rpc/types/core"
|
|
|
|
|
|
"wechat-api/ent/creditusage"
|
|
|
"wechat-api/ent/predicate"
|
|
@@ -31,14 +32,8 @@ func NewGetCreditUsageListLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|
|
|
|
|
func (l *GetCreditUsageListLogic) GetCreditUsageList(req *types.CreditUsageListReq) (*types.CreditUsageListResp, error) {
|
|
|
var predicates []predicate.CreditUsage
|
|
|
- if req.UserId != nil {
|
|
|
- predicates = append(predicates, creditusage.UserID(*req.UserId))
|
|
|
- }
|
|
|
- if req.Table != nil {
|
|
|
- predicates = append(predicates, creditusage.TableEQ(*req.Table))
|
|
|
- }
|
|
|
- if req.Reason != nil {
|
|
|
- predicates = append(predicates, creditusage.ReasonContains(*req.Reason))
|
|
|
+ if req.OrganizationId != nil {
|
|
|
+ predicates = append(predicates, creditusage.OrganizationID(*req.OrganizationId))
|
|
|
}
|
|
|
data, err := l.svcCtx.DB.CreditUsage.Query().Where(predicates...).Page(l.ctx, req.Page, req.PageSize)
|
|
|
|
|
@@ -50,6 +45,11 @@ 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
|
|
|
+ }
|
|
|
+
|
|
|
for _, v := range data.List {
|
|
|
resp.Data.Data = append(resp.Data.Data,
|
|
|
types.CreditUsageInfo{
|
|
@@ -58,15 +58,16 @@ func (l *GetCreditUsageListLogic) GetCreditUsageList(req *types.CreditUsageListR
|
|
|
CreatedAt: pointy.GetPointer(v.CreatedAt.UnixMilli()),
|
|
|
UpdatedAt: pointy.GetPointer(v.UpdatedAt.UnixMilli()),
|
|
|
},
|
|
|
- UserId: &v.UserID,
|
|
|
- Number: &v.Number,
|
|
|
- Status: &v.Status,
|
|
|
- Ntype: &v.Ntype,
|
|
|
- Table: &v.Table,
|
|
|
- OrganizationId: &v.OrganizationID,
|
|
|
- Nid: &v.Nid,
|
|
|
- Reason: &v.Reason,
|
|
|
- Operator: &v.Operator,
|
|
|
+ UserId: &v.UserID,
|
|
|
+ Number: &v.Number,
|
|
|
+ Status: &v.Status,
|
|
|
+ Ntype: &v.Ntype,
|
|
|
+ Table: &v.Table,
|
|
|
+ OrganizationId: &v.OrganizationID,
|
|
|
+ OrganizationName: departmentInfo.Name,
|
|
|
+ Nid: &v.Nid,
|
|
|
+ Reason: &v.Reason,
|
|
|
+ Operator: &v.Operator,
|
|
|
})
|
|
|
}
|
|
|
|