Esempio n. 1
0
func (p *SysTable) Exec() {
	p.session, p.login, p.tx, p.ctx = util.GetSessionLogin(p.context, "sysTable")
	defer dfweb.ErrorRecover(p.context, p.tx)
	json := dfweb.GetBodyJson(p.context)
	operationType := (json["operationType"]).(string)
	var data map[string]interface{}
	if df.GetType(json["data"])[0:3] == "map" {
		data = (json["data"]).(map[string]interface{})
	}
	var id float64
	if df.GetType(json["data"]) == "float64" {
		id = (json["data"]).(float64)
	}
	switch operationType {
	case "fetch":
		p.Fetch(data)
	case "add":
		p.Insert(data)
	case "update":
		p.Update(data)
	case "remove":
		p.Delete(id)
	case "getdbs":
		p.GetDbs()
	default:
		panic("SysTable operationType が無効です。 :" + operationType)
	}
}
Esempio n. 2
0
func (p *Login) LoginauthExec(c *gin.Context) {
	tx, err := util.GetTx()
	defer dfweb.ErrorRecover(c, tx)
	if err != nil {
		panic("Get Transaction Error:" + err.Error())
	}
	json := dfweb.GetBodyJson(c)
	login := p.getLoginFromLoginId(json, tx)
	if login == nil {
		c.JSON(200, dfweb.SetErrorMessage("ユーザー IDが見つかりません"))
		return
	}
	password := json["password"]
	if password == nil {
		c.JSON(200, dfweb.SetErrorMessage("パスワードがありません"))
		return
	}
	pwd := dfweb.CreateMd5(password.(string))
	if login.GetPassword() != pwd {
		c.JSON(200, dfweb.SetErrorMessage("passwordが違います"))
		return
	}
	ctx := util.CreateContextFromLogin("loginauth", login)
	session := p.createNewSession(login, tx, ctx)
	loginInfo := p.createLoginInfo(login)
	p.addUuidCookie(c, session.GetUuid())
	c.JSON(200, dfweb.SetSingleFetchResult(loginInfo))
}
Esempio n. 3
0
func (p *Login) LogoutExec(c *gin.Context) {
	session, _, tx, ctx := util.GetSessionLogin(c, "logout")
	defer dfweb.ErrorRecover(c, tx)
	session.SetDelFlag(1)
	bhv.SessionBhv_I.Update(session, tx, ctx)
	c.JSON(200, dfweb.SetSingleFetchResult("OK"))
}
Esempio n. 4
0
func (p *Customer) Exec() {
	p.session, p.login, p.tx, p.ctx = util.GetSessionLogin(p.context, "godbfexan")
	defer dfweb.ErrorRecover(p.context, p.tx)
	json := dfweb.GetBodyJson(p.context)
	transactions := json["transactions"]
	if transactions != nil {
		p.Transaction(transactions.([]interface{}))
		return
	}
	operationType := (json["operationType"]).(string)
	var data map[string]interface{}
	if df.GetType(json["data"])[0:3] == "map" {
		data = (json["data"]).(map[string]interface{})
	}
	var id float64
	if df.GetType(json["data"]) == "float64" {
		id = (json["data"]).(float64)
	}
	switch operationType {
	case "fetch":
		p.Fetch(data)
	case "add":
		p.Insert(data)
	case "update":
		p.Update(data)
	case "remove":
		p.Delete(id)
	default:
		panic("Customer operationType が無効です。 :" + operationType)
	}
}