func main() { ctx := context.Background() authservice.Init() database.InitDb("./student-hostel-admin.db") // http.Handle("/static", http.FileServer(http.Dir("/data/go-public/student-hostel-admin/frontend-polymer"))) http.Handle("/authservice", authservice.AuthentificationHandler(ctx)) var hh = helloHandler("halu") hellofunc := http_req_res.CORS.Handler(hh) http.Handle("/hello", hellofunc) http.Handle("/loadall", adminservice.MakeLoadAllHandler(ctx)) http.Handle("/saveall", adminservice.MakeSaveAllHandler(ctx)) http.Handle("/createall", adminservice.MakeCreateAllHandler(ctx)) log.Fatal(http.ListenAndServe(":2000", nil)) }
func main() { database.InitDb("./student-hostel-admin.db") // Create ORM engine and database var err error var x = database.GetDB() // Sync tables if err = x.Sync(new(entity.User)); err != nil { log.Fatalf("Fail to sync database: %v\n", err) } if err = x.Sync(new(entity.Room)); err != nil { log.Fatalf("Fail to sync database: %v\n", err) } if err = x.Sync(new(entity.Expense)); err != nil { log.Fatalf("Fail to sync database: %v\n", err) } if err = x.Sync(new(entity.Deposit)); err != nil { log.Fatalf("Fail to sync database: %v\n", err) } for i := 0; i < 20; i++ { _, err = x.Insert(&entity.Expense{Year: 2015, Month: 9, Amount: 0, Notice: ""}) _, err = x.Insert(&entity.Deposit{Year: 2015, Month: 9, Amount: 0, Notice: ""}) } for i := 0; i < len(names); i++ { _, err = x.Insert(&entity.Room{Year: 2015, Month: 9, Roomnumber: int32(i + 1), Name: names[i], Rent: 0, Notice: ""}) } x.Insert(&entity.User{Username: "******", Password: encodeBase64("sugianto"), Role: "admin", Name: "Jony Sugianto"}) x.Insert(&entity.User{Username: "******", Password: encodeBase64("nugroho"), Role: "user", Name: "Widi Nugroho"}) x.Insert(&entity.User{Username: "******", Password: encodeBase64("wicaksono"), Role: "user", Name: "Kukuh Wicaksono"}) x.Insert(&entity.User{Username: "******", Password: encodeBase64("seto nugroho"), Role: "user", Name: "Pandu Seto Nugroho"}) }