jimmyyem 2 months ago
parent
commit
dfaf98cc19

+ 2 - 16
desc/wechat/credit_balance.api

@@ -16,23 +16,9 @@ type (
 
         // organization_id | 租户ID 
         OrganizationId  *uint64 `json:"organizationId,optional"`
-
-		User BUserInfo `json:"user,optional"`
+		OrganizationName  *string `json:"organizationName,optional"`
     }
 
-	BUserInfo {
-		UserId  *string `json:"userId,optional"`
-
-		// User's name | 用户名
-		Username *string `json:"username,optional"`
-
-		// User's nickname | 用户的昵称
-		Nickname *string `json:"nickname,optional"`
-
-		// The user's avatar path | 用户的头像路径
-		Avatar *string `json:"avatar,optional"`
-	}
-
     // The response data of credit balance list | CreditBalance列表数据
     CreditBalanceListResp {
         BaseDataInfo
@@ -68,7 +54,7 @@ type (
     }
 
 	CreditBalanceOperateReq {
-		UserId  *string `json:"userId,optional"`
+		OrganizationId  *uint64 `json:"organizationId,optional"`
 		Number  *float32 `json:"number,optional"`
 		Reason *string `json:"reason,optional"`
 	}

+ 0 - 2
ent/creditbalance/creditbalance.go

@@ -68,8 +68,6 @@ var (
 	DefaultUpdatedAt func() time.Time
 	// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
 	UpdateDefaultUpdatedAt func() time.Time
-	// UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
-	UserIDValidator func(string) error
 	// DefaultStatus holds the default value on creation for the "status" field.
 	DefaultStatus int
 	// StatusValidator is a validator for the "status" field. It is called by the builders before save.

+ 10 - 0
ent/creditbalance/where.go

@@ -274,6 +274,16 @@ func UserIDHasSuffix(v string) predicate.CreditBalance {
 	return predicate.CreditBalance(sql.FieldHasSuffix(FieldUserID, v))
 }
 
+// UserIDIsNil applies the IsNil predicate on the "user_id" field.
+func UserIDIsNil() predicate.CreditBalance {
+	return predicate.CreditBalance(sql.FieldIsNull(FieldUserID))
+}
+
+// UserIDNotNil applies the NotNil predicate on the "user_id" field.
+func UserIDNotNil() predicate.CreditBalance {
+	return predicate.CreditBalance(sql.FieldNotNull(FieldUserID))
+}
+
 // UserIDEqualFold applies the EqualFold predicate on the "user_id" field.
 func UserIDEqualFold(v string) predicate.CreditBalance {
 	return predicate.CreditBalance(sql.FieldEqualFold(FieldUserID, v))

+ 28 - 8
ent/creditbalance_create.go

@@ -70,6 +70,14 @@ func (cbc *CreditBalanceCreate) SetUserID(s string) *CreditBalanceCreate {
 	return cbc
 }
 
+// SetNillableUserID sets the "user_id" field if the given value is not nil.
+func (cbc *CreditBalanceCreate) SetNillableUserID(s *string) *CreditBalanceCreate {
+	if s != nil {
+		cbc.SetUserID(*s)
+	}
+	return cbc
+}
+
 // SetBalance sets the "balance" field.
 func (cbc *CreditBalanceCreate) SetBalance(f float32) *CreditBalanceCreate {
 	cbc.mutation.SetBalance(f)
@@ -176,14 +184,6 @@ func (cbc *CreditBalanceCreate) check() error {
 	if _, ok := cbc.mutation.UpdatedAt(); !ok {
 		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "CreditBalance.updated_at"`)}
 	}
-	if _, ok := cbc.mutation.UserID(); !ok {
-		return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "CreditBalance.user_id"`)}
-	}
-	if v, ok := cbc.mutation.UserID(); ok {
-		if err := creditbalance.UserIDValidator(v); err != nil {
-			return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "CreditBalance.user_id": %w`, err)}
-		}
-	}
 	if _, ok := cbc.mutation.Balance(); !ok {
 		return &ValidationError{Name: "balance", err: errors.New(`ent: missing required field "CreditBalance.balance"`)}
 	}
@@ -347,6 +347,12 @@ func (u *CreditBalanceUpsert) UpdateUserID() *CreditBalanceUpsert {
 	return u
 }
 
+// ClearUserID clears the value of the "user_id" field.
+func (u *CreditBalanceUpsert) ClearUserID() *CreditBalanceUpsert {
+	u.SetNull(creditbalance.FieldUserID)
+	return u
+}
+
 // SetBalance sets the "balance" field.
 func (u *CreditBalanceUpsert) SetBalance(v float32) *CreditBalanceUpsert {
 	u.Set(creditbalance.FieldBalance, v)
@@ -513,6 +519,13 @@ func (u *CreditBalanceUpsertOne) UpdateUserID() *CreditBalanceUpsertOne {
 	})
 }
 
+// ClearUserID clears the value of the "user_id" field.
+func (u *CreditBalanceUpsertOne) ClearUserID() *CreditBalanceUpsertOne {
+	return u.Update(func(s *CreditBalanceUpsert) {
+		s.ClearUserID()
+	})
+}
+
 // SetBalance sets the "balance" field.
 func (u *CreditBalanceUpsertOne) SetBalance(v float32) *CreditBalanceUpsertOne {
 	return u.Update(func(s *CreditBalanceUpsert) {
@@ -856,6 +869,13 @@ func (u *CreditBalanceUpsertBulk) UpdateUserID() *CreditBalanceUpsertBulk {
 	})
 }
 
+// ClearUserID clears the value of the "user_id" field.
+func (u *CreditBalanceUpsertBulk) ClearUserID() *CreditBalanceUpsertBulk {
+	return u.Update(func(s *CreditBalanceUpsert) {
+		s.ClearUserID()
+	})
+}
+
 // SetBalance sets the "balance" field.
 func (u *CreditBalanceUpsertBulk) SetBalance(v float32) *CreditBalanceUpsertBulk {
 	return u.Update(func(s *CreditBalanceUpsert) {

+ 18 - 10
ent/creditbalance_update.go

@@ -68,6 +68,12 @@ func (cbu *CreditBalanceUpdate) SetNillableUserID(s *string) *CreditBalanceUpdat
 	return cbu
 }
 
+// ClearUserID clears the value of the "user_id" field.
+func (cbu *CreditBalanceUpdate) ClearUserID() *CreditBalanceUpdate {
+	cbu.mutation.ClearUserID()
+	return cbu
+}
+
 // SetBalance sets the "balance" field.
 func (cbu *CreditBalanceUpdate) SetBalance(f float32) *CreditBalanceUpdate {
 	cbu.mutation.ResetBalance()
@@ -192,11 +198,6 @@ func (cbu *CreditBalanceUpdate) defaults() error {
 
 // check runs all checks and user-defined validators on the builder.
 func (cbu *CreditBalanceUpdate) check() error {
-	if v, ok := cbu.mutation.UserID(); ok {
-		if err := creditbalance.UserIDValidator(v); err != nil {
-			return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "CreditBalance.user_id": %w`, err)}
-		}
-	}
 	if v, ok := cbu.mutation.Status(); ok {
 		if err := creditbalance.StatusValidator(v); err != nil {
 			return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "CreditBalance.status": %w`, err)}
@@ -229,6 +230,9 @@ func (cbu *CreditBalanceUpdate) sqlSave(ctx context.Context) (n int, err error)
 	if value, ok := cbu.mutation.UserID(); ok {
 		_spec.SetField(creditbalance.FieldUserID, field.TypeString, value)
 	}
+	if cbu.mutation.UserIDCleared() {
+		_spec.ClearField(creditbalance.FieldUserID, field.TypeString)
+	}
 	if value, ok := cbu.mutation.Balance(); ok {
 		_spec.SetField(creditbalance.FieldBalance, field.TypeFloat32, value)
 	}
@@ -313,6 +317,12 @@ func (cbuo *CreditBalanceUpdateOne) SetNillableUserID(s *string) *CreditBalanceU
 	return cbuo
 }
 
+// ClearUserID clears the value of the "user_id" field.
+func (cbuo *CreditBalanceUpdateOne) ClearUserID() *CreditBalanceUpdateOne {
+	cbuo.mutation.ClearUserID()
+	return cbuo
+}
+
 // SetBalance sets the "balance" field.
 func (cbuo *CreditBalanceUpdateOne) SetBalance(f float32) *CreditBalanceUpdateOne {
 	cbuo.mutation.ResetBalance()
@@ -450,11 +460,6 @@ func (cbuo *CreditBalanceUpdateOne) defaults() error {
 
 // check runs all checks and user-defined validators on the builder.
 func (cbuo *CreditBalanceUpdateOne) check() error {
-	if v, ok := cbuo.mutation.UserID(); ok {
-		if err := creditbalance.UserIDValidator(v); err != nil {
-			return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "CreditBalance.user_id": %w`, err)}
-		}
-	}
 	if v, ok := cbuo.mutation.Status(); ok {
 		if err := creditbalance.StatusValidator(v); err != nil {
 			return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "CreditBalance.status": %w`, err)}
@@ -504,6 +509,9 @@ func (cbuo *CreditBalanceUpdateOne) sqlSave(ctx context.Context) (_node *CreditB
 	if value, ok := cbuo.mutation.UserID(); ok {
 		_spec.SetField(creditbalance.FieldUserID, field.TypeString, value)
 	}
+	if cbuo.mutation.UserIDCleared() {
+		_spec.ClearField(creditbalance.FieldUserID, field.TypeString)
+	}
 	if value, ok := cbuo.mutation.Balance(); ok {
 		_spec.SetField(creditbalance.FieldBalance, field.TypeFloat32, value)
 	}

+ 1 - 1
ent/migrate/schema.go

@@ -289,7 +289,7 @@ var (
 		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
 		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
 		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"},
-		{Name: "user_id", Type: field.TypeString, Size: 255, Comment: "user_id | 用户ID"},
+		{Name: "user_id", Type: field.TypeString, Nullable: true, Comment: "user_id | 用户ID"},
 		{Name: "balance", Type: field.TypeFloat32, Comment: "role | 角色设定"},
 		{Name: "status", Type: field.TypeInt, Nullable: true, Comment: "status | 状态 1-正常 2-禁用", Default: 1},
 		{Name: "organization_id", Type: field.TypeUint64, Nullable: true, Comment: "organization_id | 租户ID"},

+ 19 - 0
ent/mutation.go

@@ -10520,9 +10520,22 @@ func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err er
 	return oldValue.UserID, nil
 }
 
+// ClearUserID clears the value of the "user_id" field.
+func (m *CreditBalanceMutation) ClearUserID() {
+	m.user_id = nil
+	m.clearedFields[creditbalance.FieldUserID] = struct{}{}
+}
+
+// UserIDCleared returns if the "user_id" field was cleared in this mutation.
+func (m *CreditBalanceMutation) UserIDCleared() bool {
+	_, ok := m.clearedFields[creditbalance.FieldUserID]
+	return ok
+}
+
 // ResetUserID resets all changes to the "user_id" field.
 func (m *CreditBalanceMutation) ResetUserID() {
 	m.user_id = nil
+	delete(m.clearedFields, creditbalance.FieldUserID)
 }
 
 // SetBalance sets the "balance" field.
@@ -10952,6 +10965,9 @@ func (m *CreditBalanceMutation) ClearedFields() []string {
 	if m.FieldCleared(creditbalance.FieldDeletedAt) {
 		fields = append(fields, creditbalance.FieldDeletedAt)
 	}
+	if m.FieldCleared(creditbalance.FieldUserID) {
+		fields = append(fields, creditbalance.FieldUserID)
+	}
 	if m.FieldCleared(creditbalance.FieldStatus) {
 		fields = append(fields, creditbalance.FieldStatus)
 	}
@@ -10975,6 +10991,9 @@ func (m *CreditBalanceMutation) ClearField(name string) error {
 	case creditbalance.FieldDeletedAt:
 		m.ClearDeletedAt()
 		return nil
+	case creditbalance.FieldUserID:
+		m.ClearUserID()
+		return nil
 	case creditbalance.FieldStatus:
 		m.ClearStatus()
 		return nil

+ 0 - 4
ent/runtime/runtime.go

@@ -429,10 +429,6 @@ func init() {
 	creditbalance.DefaultUpdatedAt = creditbalanceDescUpdatedAt.Default.(func() time.Time)
 	// creditbalance.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
 	creditbalance.UpdateDefaultUpdatedAt = creditbalanceDescUpdatedAt.UpdateDefault.(func() time.Time)
-	// creditbalanceDescUserID is the schema descriptor for user_id field.
-	creditbalanceDescUserID := creditbalanceFields[0].Descriptor()
-	// creditbalance.UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
-	creditbalance.UserIDValidator = creditbalanceDescUserID.Validators[0].(func(string) error)
 	// creditbalanceDescStatus is the schema descriptor for status field.
 	creditbalanceDescStatus := creditbalanceFields[2].Descriptor()
 	// creditbalance.DefaultStatus holds the default value on creation for the status field.

+ 1 - 1
ent/schema/credit_balance.go

@@ -17,7 +17,7 @@ type CreditBalance struct {
 
 func (CreditBalance) Fields() []ent.Field {
 	return []ent.Field{
-		field.String("user_id").MaxLen(255).Comment("user_id | 用户ID"),
+		field.String("user_id").Optional().Comment("user_id | 用户ID"),
 		field.Float32("balance").Comment("role | 角色设定"),
 		field.Int("status").Optional().Range(1, 2).Default(1).Comment("status | 状态 1-正常 2-禁用"),
 		field.Uint64("organization_id").Optional().Comment("organization_id | 租户ID"),

+ 7 - 14
internal/logic/credit_balance/get_credit_balance_by_id_logic.go

@@ -3,7 +3,6 @@ package credit_balance
 import (
 	"context"
 	"github.com/suyuan32/simple-admin-core/rpc/types/core"
-
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
 	"wechat-api/internal/utils/dberrorhandler"
@@ -34,15 +33,10 @@ func (l *GetCreditBalanceByIdLogic) GetCreditBalanceById(req *types.IDReq) (*typ
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
 	}
 
-	bUserinfo := types.BUserInfo{}
-	userInfo, _ := l.svcCtx.CoreRpc.GetUserById(l.ctx, &core.UUIDReq{Id: data.UserID})
-	if userInfo != nil {
-		bUserinfo.Nickname = userInfo.Nickname
-		bUserinfo.Avatar = userInfo.Avatar
-		bUserinfo.Username = userInfo.Username
-		bUserinfo.UserId = userInfo.Id
+	departmentInfo, err := l.svcCtx.CoreRpc.GetDepartmentById(l.ctx, &core.IDReq{Id: data.OrganizationID})
+	if err != nil {
+		return nil, err
 	}
-
 	return &types.CreditBalanceInfoResp{
 		BaseDataInfo: types.BaseDataInfo{
 			Code: 0,
@@ -54,11 +48,10 @@ func (l *GetCreditBalanceByIdLogic) GetCreditBalanceById(req *types.IDReq) (*typ
 				CreatedAt: pointy.GetPointer(data.CreatedAt.UnixMilli()),
 				UpdatedAt: pointy.GetPointer(data.UpdatedAt.UnixMilli()),
 			},
-			UserId:         &data.UserID,
-			Balance:        &data.Balance,
-			Status:         &data.Status,
-			OrganizationId: &data.OrganizationID,
-			User:           bUserinfo,
+			UserId:           &data.UserID,
+			Balance:          &data.Balance,
+			OrganizationId:   &data.OrganizationID,
+			OrganizationName: departmentInfo.Name,
 		},
 	}, nil
 }

+ 8 - 13
internal/logic/credit_balance/get_credit_balance_list_logic.go

@@ -3,7 +3,6 @@ package credit_balance
 import (
 	"context"
 	"github.com/suyuan32/simple-admin-core/rpc/types/core"
-
 	"wechat-api/ent/creditbalance"
 	"wechat-api/ent/predicate"
 	"wechat-api/internal/svc"
@@ -49,14 +48,11 @@ func (l *GetCreditBalanceListLogic) GetCreditBalanceList(req *types.CreditBalanc
 	resp.Data.Total = data.PageDetails.Total
 
 	for _, v := range data.List {
-		bUserinfo := types.BUserInfo{}
-		userInfo, _ := l.svcCtx.CoreRpc.GetUserById(l.ctx, &core.UUIDReq{Id: v.UserID})
-		if userInfo != nil {
-			bUserinfo.Nickname = userInfo.Nickname
-			bUserinfo.Avatar = userInfo.Avatar
-			bUserinfo.Username = userInfo.Username
-			bUserinfo.UserId = userInfo.Id
+		departmentInfo, err := l.svcCtx.CoreRpc.GetDepartmentById(l.ctx, &core.IDReq{Id: v.OrganizationID})
+		if err != nil {
+			return nil, err
 		}
+
 		resp.Data.Data = append(resp.Data.Data,
 			types.CreditBalanceInfo{
 				BaseIDInfo: types.BaseIDInfo{
@@ -64,11 +60,10 @@ func (l *GetCreditBalanceListLogic) GetCreditBalanceList(req *types.CreditBalanc
 					CreatedAt: pointy.GetPointer(v.CreatedAt.UnixMilli()),
 					UpdatedAt: pointy.GetPointer(v.UpdatedAt.UnixMilli()),
 				},
-				UserId:         &v.UserID,
-				Balance:        &v.Balance,
-				Status:         &v.Status,
-				OrganizationId: &v.OrganizationID,
-				User:           bUserinfo,
+				UserId:           &v.UserID,
+				Balance:          &v.Balance,
+				OrganizationId:   &v.OrganizationID,
+				OrganizationName: departmentInfo.Name,
 			})
 	}
 

+ 10 - 20
internal/logic/credit_balance/operate_credit_balance_logic.go

@@ -3,7 +3,6 @@ package credit_balance
 import (
 	"context"
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
-	"github.com/suyuan32/simple-admin-core/rpc/types/core"
 	"github.com/zeromicro/go-zero/core/errorx"
 	"wechat-api/ent/creditbalance"
 
@@ -30,11 +29,8 @@ func (l *OperateCreditBalanceLogic) OperateCreditBalance(req *types.CreditBalanc
 	if req.Number == nil || *req.Number == 0 {
 		return nil, errorx.NewInvalidArgumentError("Number参数非法")
 	}
-	if req.UserId == nil {
-		return nil, errorx.NewInvalidArgumentError("UserId参数非法")
-	}
 
-	creditBalance, err := l.svcCtx.DB.CreditBalance.Query().Where(creditbalance.UserID(*req.UserId)).Only(l.ctx)
+	creditBalance, err := l.svcCtx.DB.CreditBalance.Query().Where(creditbalance.OrganizationID(*req.OrganizationId)).Only(l.ctx)
 	if err != nil {
 		l.Logger.Errorf("query credit_balance error:%v\n", err)
 		return nil, errorx.NewInvalidArgumentError(err.Error())
@@ -47,53 +43,47 @@ func (l *OperateCreditBalanceLogic) OperateCreditBalance(req *types.CreditBalanc
 		ntype = 1
 	}
 
-	userInfo, err := l.svcCtx.CoreRpc.GetUserById(l.ctx, &core.UUIDReq{Id: *req.UserId})
-	if err != nil {
-		l.Logger.Errorf("query user error:%v\n", err)
-		return nil, errorx.NewInvalidArgumentError("用户不存在")
-	}
-
 	tx, err := l.svcCtx.DB.Tx(context.Background())
 	_, err = tx.CreditUsage.Create().
-		SetUserID(*req.UserId).
+		SetUserID("").
 		SetNumber(*req.Number).
 		SetNtype(ntype).
 		SetNid(0).
 		SetTable("").
 		SetReason(*req.Reason).
-		SetOrganizationID(*userInfo.DepartmentId).
+		SetOrganizationID(*req.OrganizationId).
 		Save(l.ctx)
 	if err != nil {
 		l.Logger.Errorf("create credit_usage error:%v\n", err)
 		_ = tx.Rollback()
-		return nil, errorx.NewInvalidArgumentError("创建户积分明细失败,请重试")
+		return nil, errorx.NewInvalidArgumentError("创建户积分明细失败,请重试")
 	}
 
 	if *req.Number > 0 {
 		if creditBalance == nil {
 			_, err = l.svcCtx.DB.CreditBalance.Create().
-				SetUserID(*req.UserId).
+				SetOrganizationID(*req.OrganizationId).
 				SetBalance(*req.Number).
 				Save(l.ctx)
 			if err != nil {
 				l.Logger.Errorf("create credit_balance error:%v\n", err)
 				_ = tx.Rollback()
-				return nil, errorx.NewInvalidArgumentError("创建户积分余额失败,请重试")
+				return nil, errorx.NewInvalidArgumentError("创建户积分余额失败,请重试")
 			}
 		} else {
-			_, err = l.svcCtx.DB.CreditBalance.Update().Where(creditbalance.UserID(*req.UserId)).SetBalance(creditBalance.Balance + *req.Number).Save(l.ctx)
+			_, err = l.svcCtx.DB.CreditBalance.Update().Where(creditbalance.OrganizationID(*req.OrganizationId)).SetBalance(creditBalance.Balance + *req.Number).Save(l.ctx)
 			if err != nil {
 				l.Logger.Errorf("update credit_balance error:%v\n", err)
 				_ = tx.Rollback()
-				return nil, errorx.NewInvalidArgumentError("修改户积分余额失败,请重试.")
+				return nil, errorx.NewInvalidArgumentError("修改户积分余额失败,请重试.")
 			}
 		}
 	} else {
-		_, err := l.svcCtx.DB.CreditBalance.Update().Where(creditbalance.UserID(*req.UserId)).SetBalance(creditBalance.Balance + *req.Number).Save(l.ctx)
+		_, err := l.svcCtx.DB.CreditBalance.Update().Where(creditbalance.OrganizationID(*req.OrganizationId)).SetBalance(creditBalance.Balance + *req.Number).Save(l.ctx)
 		if err != nil {
 			l.Logger.Errorf("update credit_balance error:%v\n", err)
 			_ = tx.Rollback()
-			return nil, errorx.NewInvalidArgumentError("修改户积分余额失败,请重试...")
+			return nil, errorx.NewInvalidArgumentError("修改户积分余额失败,请重试...")
 		}
 	}
 	_ = tx.Commit()

+ 8 - 10
internal/logic/credit_balance/update_credit_balance_logic.go

@@ -7,7 +7,6 @@ import (
 	"wechat-api/internal/types"
 	"wechat-api/internal/utils/dberrorhandler"
 
-
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
 	"github.com/zeromicro/go-zero/core/logx"
 )
@@ -27,16 +26,15 @@ func NewUpdateCreditBalanceLogic(ctx context.Context, svcCtx *svc.ServiceContext
 }
 
 func (l *UpdateCreditBalanceLogic) UpdateCreditBalance(req *types.CreditBalanceInfo) (*types.BaseMsgResp, error) {
-    err := l.svcCtx.DB.CreditBalance.UpdateOneID(*req.Id).
-			SetNotNilUserID(req.UserId).
-			SetNotNilBalance(req.Balance).
-			SetNotNilStatus(req.Status).
-			SetNotNilOrganizationID(req.OrganizationId).
-			Exec(l.ctx)
-
-    if err != nil {
+	err := l.svcCtx.DB.CreditBalance.UpdateOneID(*req.Id).
+		SetNotNilUserID(req.UserId).
+		SetNotNilBalance(req.Balance).
+		SetNotNilOrganizationID(req.OrganizationId).
+		Exec(l.ctx)
+
+	if err != nil {
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
 	}
 
-    return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
+	return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
 }

+ 5 - 16
internal/types/types.go

@@ -3254,19 +3254,8 @@ type CreditBalanceInfo struct {
 	// status | 状态 1-正常 2-禁用
 	Status *int `json:"status,optional"`
 	// organization_id | 租户ID
-	OrganizationId *uint64   `json:"organizationId,optional"`
-	User           BUserInfo `json:"user,optional"`
-}
-
-// swagger:model BUserInfo
-type BUserInfo struct {
-	UserId *string `json:"userId,optional"`
-	// User's name | 用户名
-	Username *string `json:"username,optional"`
-	// User's nickname | 用户的昵称
-	Nickname *string `json:"nickname,optional"`
-	// The user's avatar path | 用户的头像路径
-	Avatar *string `json:"avatar,optional"`
+	OrganizationId   *uint64 `json:"organizationId,optional"`
+	OrganizationName *string `json:"organizationName,optional"`
 }
 
 // The response data of credit balance list | CreditBalance列表数据
@@ -3304,9 +3293,9 @@ type CreditBalanceInfoResp struct {
 
 // swagger:model CreditBalanceOperateReq
 type CreditBalanceOperateReq struct {
-	UserId *string  `json:"userId,optional"`
-	Number *float32 `json:"number,optional"`
-	Reason *string  `json:"reason,optional"`
+	OrganizationId *uint64  `json:"organizationId,optional"`
+	Number         *float32 `json:"number,optional"`
+	Reason         *string  `json:"reason,optional"`
 }
 
 // The data of credit usage information | CreditUsage信息