SUrvey now works
This commit is contained in:
43
db/advancedProfile.go
Normal file
43
db/advancedProfile.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package db
|
||||
|
||||
type AdvancedProfile struct {
|
||||
CompanyId int
|
||||
GeographicDistribution string
|
||||
CustomerConcentration string
|
||||
ProductServicePortfolio string
|
||||
OrganizationalCulture string
|
||||
SupplierDiversity string
|
||||
TechnologicalInfrastructure string
|
||||
IntellectualProperty string
|
||||
ManagementTeamExperience string
|
||||
}
|
||||
|
||||
// InsertAdvancedProfile inserts a new record into the AdvancedProfile table
|
||||
func InsertAdvancedProfile(profile AdvancedProfile) (int, error) {
|
||||
query := `
|
||||
INSERT INTO AdvancedProfile (
|
||||
CompanyId, GeographicDistribution, CustomerConcentration, ProductServicePortfolio, OrganizationalCulture,
|
||||
SupplierDiversity, TechnologicalInfrastructure, IntellectualProperty, ManagementTeamExperience
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
RETURNING id
|
||||
`
|
||||
|
||||
stmt, err := db.Prepare(query)
|
||||
if err != nil {
|
||||
return -2, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
id := 0
|
||||
err = stmt.QueryRow(
|
||||
profile.CompanyId, profile.GeographicDistribution, profile.CustomerConcentration, profile.ProductServicePortfolio,
|
||||
profile.OrganizationalCulture, profile.SupplierDiversity, profile.TechnologicalInfrastructure, profile.IntellectualProperty,
|
||||
profile.ManagementTeamExperience,
|
||||
).Scan(&id)
|
||||
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
return id, nil
|
||||
}
|
||||
@@ -1,24 +1,36 @@
|
||||
package db
|
||||
|
||||
type BasicProfile struct {
|
||||
CompanyId int
|
||||
Employees string
|
||||
Revenue string
|
||||
Applications string
|
||||
Compliance string
|
||||
Industry string
|
||||
ITDependency string
|
||||
DataSensitivity string
|
||||
DataVolume string
|
||||
NetworkSegmentation string
|
||||
LegacySystems string
|
||||
IoTIntegration string
|
||||
RemoteWork string
|
||||
BYOD string
|
||||
VPN string
|
||||
API string
|
||||
VendorAccess string
|
||||
InternalDev string
|
||||
CompanyId int // Company ID (foreign key reference)
|
||||
Employees string // Current employee headcount
|
||||
Revenue string // Annual revenue range
|
||||
Applications string // Critical business applications
|
||||
Compliance string // Regulatory frameworks
|
||||
Industry string // Primary industry sector
|
||||
ITDependency string // Technology dependency
|
||||
DataSensitivity string // Sensitive data level
|
||||
DataVolume string // Data volume (if applicable)
|
||||
NetworkSegmentation string // Network infrastructure model
|
||||
LegacySystems string // Legacy systems (if applicable)
|
||||
IoTIntegration string // IoT integration (if applicable)
|
||||
RemoteWork string // Remote work details
|
||||
BYOD string // Bring Your Own Device policy
|
||||
VPN string // VPN usage policy
|
||||
API string // API integration (if applicable)
|
||||
VendorAccess string // Third-party vendor access
|
||||
InternalDev string // Internal software development activities
|
||||
|
||||
// New fields from the advanced form
|
||||
GeoScope string // Geographic operational scope
|
||||
CustomerBase string // Customer base distribution
|
||||
CustomerType string // Primary customer type
|
||||
ProductPortfolio string // Product/service portfolio
|
||||
SupplierBase string // Supplier base structure
|
||||
ITInfrastructure string // IT infrastructure model (comma-separated values)
|
||||
IPProtection string // Intellectual property protection (comma-separated values)
|
||||
SensitiveData string // Sensitive data types (comma-separated values)
|
||||
IntegrationLevel string // Integration level of business systems
|
||||
RemotePolicy string // Remote work policy
|
||||
}
|
||||
|
||||
// InsertBasicProfile inserts a new record into the BasicProfile table
|
||||
|
||||
53
db/db.go
53
db/db.go
@@ -26,7 +26,8 @@ func InitDB() {
|
||||
}
|
||||
|
||||
func createTables() {
|
||||
companyTable := `
|
||||
tables := []string{
|
||||
`
|
||||
CREATE TABLE IF NOT EXISTS Company (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
UUID TEXT NOT NULL,
|
||||
@@ -34,9 +35,9 @@ func createTables() {
|
||||
TaxId TEXT NOT NULL,
|
||||
Email TEXT NOT NULL,
|
||||
Password TEXT NOT NULL
|
||||
);`
|
||||
);`,
|
||||
|
||||
basicProfileTable := `
|
||||
`
|
||||
CREATE TABLE IF NOT EXISTS BasicProfile (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
CompanyId INTEGER,
|
||||
@@ -57,37 +58,33 @@ func createTables() {
|
||||
API TEXT,
|
||||
VendorAccess TEXT,
|
||||
InternalDev TEXT,
|
||||
GeoScope TEXT, -- Geographic operational scope
|
||||
CustomerBase TEXT, -- Customer base distribution
|
||||
CustomerType TEXT, -- Primary customer type
|
||||
ProductPortfolio TEXT, -- Product/service portfolio
|
||||
SupplierBase TEXT, -- Supplier base structure
|
||||
ITInfrastructure TEXT, -- IT infrastructure model (comma-separated values)
|
||||
IPProtection TEXT, -- Intellectual property protection (comma-separated values)
|
||||
SensitiveData TEXT, -- Sensitive data types (comma-separated values)
|
||||
IntegrationLevel TEXT, -- Integration level of business systems
|
||||
RemotePolicy TEXT, -- Remote work policy
|
||||
FOREIGN KEY (CompanyId) REFERENCES Company(id)
|
||||
);`
|
||||
);`,
|
||||
|
||||
advancedProfileTable := `
|
||||
CREATE TABLE IF NOT EXISTS AdvancedProfile (
|
||||
`CREATE TABLE IF NOT EXISTS Session (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
CompanyId INTEGER,
|
||||
GeographicDistribution TEXT,
|
||||
CustomerConcentration TEXT,
|
||||
ProductServicePortfolio TEXT,
|
||||
OrganizationalCulture TEXT,
|
||||
SupplierDiversity TEXT,
|
||||
TechnologicalInfrastructure TEXT,
|
||||
IntellectualProperty TEXT,
|
||||
ManagementTeamExperience TEXT,
|
||||
FOREIGN KEY (CompanyId) REFERENCES Company(id)
|
||||
);`
|
||||
key TEXT NOT NULL,
|
||||
value TEXT NOT NULL
|
||||
);`,
|
||||
|
||||
_, err := db.Exec(companyTable)
|
||||
if err != nil {
|
||||
log.Fatalf("Error creating Company table: %v", err)
|
||||
`CREATE INDEX IF NOT EXISTS idx_session_key ON Session(key);`,
|
||||
}
|
||||
|
||||
_, err = db.Exec(basicProfileTable)
|
||||
if err != nil {
|
||||
log.Fatalf("Error creating BasicProfile table: %v", err)
|
||||
}
|
||||
|
||||
_, err = db.Exec(advancedProfileTable)
|
||||
if err != nil {
|
||||
log.Fatalf("Error creating AdvancedProfile table: %v", err)
|
||||
for _, table := range tables {
|
||||
_, err := db.Exec(table)
|
||||
if err != nil {
|
||||
log.Fatalf("Error creating table: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
15
db/utils.go
15
db/utils.go
@@ -1,16 +1,23 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"crypto/rand"
|
||||
"log"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
|
||||
|
||||
func GenerateRandomString() string {
|
||||
const n = 25
|
||||
const n = 38
|
||||
b := make([]rune, n)
|
||||
for i := range b {
|
||||
b[i] = letters[rand.Intn(len(letters))]
|
||||
num, err := rand.Int(rand.Reader, big.NewInt(int64(len(letters))))
|
||||
if err != nil {
|
||||
log.Println("Error generating random string: ", err)
|
||||
continue
|
||||
}
|
||||
b[i] = letters[num.Int64()]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user