package restriction

import (
	"context"
	"kami/internal/errHandler"
	"kami/internal/service"

	"github.com/gogf/gf/v2/errors/gcode"
	"kami/api/restriction/v1"
)

func (c *ControllerV1) GetAESEncryptionParams(ctx context.Context, req *v1.GetAESEncryptionParamsReq) (res *v1.GetAESEncryptionParamsRes, err error) {
	params, err := service.SysConfigDict().GetAESKey(ctx)
	if err != nil {
		err = errHandler.WrapError(ctx, gcode.CodeInternalError, err, "获取 AES 加密参数失败")
		return
	}

	res = &v1.GetAESEncryptionParamsRes{
		Key: params.Key,
		IV:  params.IV,
	}
	return
}
