package admin_agent

import (
	"context"

	"bdrp-server/app/main/api/internal/svc"
	"bdrp-server/app/main/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type AdminUpdateSystemConfigLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewAdminUpdateSystemConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminUpdateSystemConfigLogic {
	return &AdminUpdateSystemConfigLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AdminUpdateSystemConfigLogic) AdminUpdateSystemConfig(req *types.AdminUpdateSystemConfigReq) (resp *types.AdminUpdateSystemConfigResp, err error) {
	// 更新佣金安全防御模式配置
	if req.CommissionSafeMode != nil {
		l.svcCtx.Config.SystemConfig.CommissionSafeMode = *req.CommissionSafeMode
		logx.Infof("更新系统配置：佣金安全防御模式设置为 %v", *req.CommissionSafeMode)
	}

	resp = &types.AdminUpdateSystemConfigResp{
		Success: true,
	}
	return
}
