Сохранена база ответов

This commit is contained in:
Anatoly Prohacky
2023-01-18 18:21:04 +10:00
parent 11072693c7
commit 93afb8d15b
3 changed files with 541 additions and 21 deletions

39
main.go
View File

@@ -12,19 +12,19 @@ import (
const (
url string = "https://digital.mchs.gov.ru/testing/api/instance/"
uidMchs string = "b400430a-07ce-4012-89ec-a2ddf0a2a208"
uidMchs string = "4e0d6bf6-50f2-4d67-8131-b99b3c4a3f39"
)
type ResMchsTestType struct {
Id uuid.UUID `json:"id"`
CurrentQuestion CQType `json:"current_question"`
CurrentAnswers []CAType `json:"current_answers"`
QuestionCount int `json:"questions_count"`
QuestionNumber int `json:"question_number"`
QuestionStatus []int `json:"questions_statuses"`
ValidAnswer uuid.UUID `json:"valid_answer"`
QuestionPassed int `json:"questions_passed"`
ValidAnswers []uuid.UUID `json:"valid_answers"`
Id uuid.UUID `json:"id"`
CurrentQuestion CQType `json:"current_question"`
CurrentAnswers []CAType `json:"current_answers"`
QuestionCount int `json:"questions_count"`
QuestionNumber int `json:"question_number"`
QuestionStatus []int `json:"questions_statuses"`
ValidAnswer uuid.UUID `json:"valid_answer"`
QuestionPassed int `json:"questions_passed"`
ValidAnswers string `json:"valid_answers"`
}
type CQType struct {
@@ -41,10 +41,10 @@ type CAType struct {
ResourcesPath []string `json:"resources_path"`
}
// func ResMchsTestToJSON(data ResMchsTestType) string {
// req, _ := json.Marshal(data)
// return string(req)
// }
func ResMchsTestToJSON(data *ResMchsTestType) string {
req, _ := json.Marshal(data)
return string(req)
}
func UnmarshalJSONToType(in []byte) *ResMchsTestType {
var data ResMchsTestType
@@ -64,19 +64,16 @@ func main() {
var rN ReqNull
var rA ReqAnswer
body, _ := ReqestToSiteJSON(rN)
fmt.Print("[")
fmt.Printf("%s", body)
fmt.Print(",\n")
fmt.Println("[")
for i := 0; i < 520; i++ {
d := UnmarshalJSONToType(body)
fmt.Print(ResMchsTestToJSON(d), ",\n")
rA.Answer = d.ValidAnswer
body, _ = ReqestToSiteJSON(rA)
fmt.Printf("%s", body)
fmt.Print(",\n")
}
d := UnmarshalJSONToType(body)
fmt.Println(ResMchsTestToJSON(d))
fmt.Println("]")
}
func ReqestToSiteJSON(req any) ([]byte, error) {