Exemplo n.º 1
0
func init() {
	pt.AddHandler("run", func(args ...interface{}) {
		if pt.Env == "dev" {
			pt.AddHandler("action", func(args ...interface{}) {
				r := args[0].(*pt.Request)
				user, _ := r.Session.Get("user").(*model.User)
				if user == nil {
					user = model.UserModel.UserByEmail("*****@*****.**")
					r.Session.Set("user", user)
				}
			})
		}
	})
}
Exemplo n.º 2
0
func init() {
	pt.AddHandler("after_init", func(args ...interface{}) {
		Conf = lib.NewTree()
		if e := Conf.LoadYaml(pt.ConfDir+"model.yml", true); e != nil {
			log.Fatal(e)
		}

		if v, has := Conf.Int("map.resource_max"); has {
			ResourceMax = v
		}
		if v, has := Conf.Int("map.resource_min"); has {
			ResourceMin = v
		}
		if v, has := Conf.Int("map.resource_rate"); has {
			ResourceRate = v
		}
		if v, has := Conf.Int("map.energe_rate"); has {
			EnergyRate = v
		}
	})

	pt.AddHandler("after_init", func(args ...interface{}) {
		MapModel = newMapModel()

		UserModel = &userModel{orm.NewModel("user", &User{})}

		RoleModel = &roleModel{orm.NewModel("role", &Role{})}

		UserRoleModel = &userRoleModel{orm.NewModel("user_role", &UserRole{})}

		BaseModel = &baseModel{orm.NewModel("base", &Base{})}

		CenterModel = &centerModel{orm.NewModel("main", &Center{})}

		LabModel = &labModel{orm.NewModel("lab", &Lab{})}

		ArmoryModel = &armoryModel{orm.NewModel("armory", &Armory{})}

		SupplyModel = &supplyModel{orm.NewModel("supply", &Supply{})}

		StopeModel = &stopeModel{orm.NewModel("stope", &Stope{})}

		StorageModel = &storageModel{orm.NewModel("storage", &Storage{})}
	})
}