func createCustomerPrefix(session *xorm.Session, customer Customer, customerId int) (err error) {
	newAddressRangeList := []*db_models.Prefix{}
	for _, v := range customer.CustomerNetworkInformation.AddressRange.Prefixes {
		newPrefix := db_models.CreateAddressRangeParam(v.Addr, v.PrefixLen)
		newPrefix.CustomerId = customerId
		newAddressRangeList = append(newAddressRangeList, newPrefix)
	}
	if len(newAddressRangeList) > 0 {
		_, err = session.Insert(&newAddressRangeList)
		if err != nil {
			session.Rollback()
			log.Infof("AddressRange insert err: %s", err)
			return
		}
	}
	return
}
/*
Register customer IP address information to the Prefix table.
Parameter:
session Session information
customer Customer
customer_id The ID of the customer
return:
err error
package models
import (
	"net"
	"errors"
	"github.com/go-xorm/xorm"
	"github.com/nttdots/go-dots/dots_server/db_models"
	log "github.com/sirupsen/logrus"
)
func CreateCustomer(customer Customer) (newCustomer db_models.Customer, err error) {
	engine, err := ConnectDB()
	if err != nil {
		log.Errorf("database connect error: %s", err)
		return
	}
	c := new(db_models.Customer)
	_, err = engine.Id(customer.Id).Get(c)
	if err != nil {
		return
	}
	if c.Id != 0 {
		err = UpdateCustomer(customer)
		return
	}
	session := engine.NewSession()
	defer session.Close()
	err = session.Begin()
	if err != nil {
		session.Rollback()
		return
	}
	newCustomer = db_models.Customer{
		Id:   customer.Id,
		CommonName: customer.CommonName,
	}
	_, err = session.Insert(&newCustomer)
	if err != nil {
		session.Rollback()
		log.Infof("customer insert err: %s", err)
		return
	}
	err = createCustomerParameterValue(session, customer, newCustomer.Id)
	if err != nil {
		return
	}
	err = createCustomerPrefix(session, customer, newCustomer.Id)
	if err != nil {
		return
	}
	err = session.Commit()
	return
}
func createCustomerParameterValue(session *xorm.Session, customer Customer, customerId int) (err error) {
	newFqdnList := []*db_models.ParameterValue{}
	for _, v := range customer.CustomerNetworkInformation.FQDN.List() {
		if v == "" {
			continue
		}
		newFqdn := db_models.CreateFqdnParam(v)
		newFqdn.CustomerId = customerId
		newFqdnList = append(newFqdnList, newFqdn)
	}
	if len(newFqdnList) > 0 {
		_, err = session.Insert(newFqdnList)
		if err != nil {
			session.Rollback()
			log.Infof("FQDN insert err: %s", err)
			return
		}
	}
	newUriList := []*db_models.ParameterValue{}
	for _, v := range customer.CustomerNetworkInformation.URI.List() {
		if v == "" {
			continue
		}
		newUri := db_models.CreateUriParam(v)
		newUri.CustomerId = customerId
		newUriList = append(newUriList, newUri)
	}
	if len(newUriList) > 0 {
		_, err = session.Insert(newUriList)
		if err != nil {
			session.Rollback()
			log.Infof("URI insert err: %s", err)
			return
		}
	}
	return
}