package service

import (
	"context"
	"dubbo.apache.org/dubbo-go/v3/common/logger"
	"errors"
	"fmt"
	account "github.com/fonchain_enterprise/micro-account/api/accountFiee"
	"github.com/fonchain_enterprise/micro-account/pkg/m"
	"github.com/fonchain_enterprise/micro-account/pkg/model"
)

func (a *AccountFieeProvider) SaveSubmitInfo(_ context.Context, in *account.SubmitInfoRequest) (*account.CommonResponse, error) {
	// 将信息 保存到数据库中
	fmt.Println(in)
	response := &account.CommonResponse{}

	err := model.DB.Create(&model.SubmitInfo{
		FirstName: in.FirstName,
		LastName:  in.LastName,
		Email:     in.Email,
		Company:   in.Company,
		Phone:     in.Phone,
	})
	if err != nil {
		logger.Error(err)
		return response, errors.New(m.SaveSubmitInfoFailedEn)
	}
	return response, nil
}
