Esempio n. 1
0
func (p *SysTable) Insert(data map[string]interface{}) {
	p.ctx.Put("Process", "login:insert")
	entityx := entity.CreateSysTable()
	var e df.Entity = entityx
	dfweb.MapToEntity(data, &e, "SysTable", false)
	//DupCheck
	if p.DupCheck(entityx) {
		panic("この tableName,Key1,Key2 は既に使用されています。")
	}
	_, err := bhv.SysTableBhv_I.Insert(entityx, p.tx, p.ctx)
	if err != nil {
		panic("Insert Error:" + err.Error())
	}
	var ee df.Entity = entityx
	rmap := p.EntityToMap(&ee)
	p.context.JSON(200, dfweb.SetSingleFetchResult(rmap))
}
Esempio n. 2
0
func (p *SysTable) Update(data map[string]interface{}) {
	p.ctx.Put("Process", "login:update")
	entityx := entity.CreateSysTable()
	var e df.Entity = entityx
	dfweb.MapToEntity(data, &e, "SysTable", true)
	//DupCheck
	old := p.getOld(entityx.GetId())
	if (entityx.GetTableName() != old.GetTableName() ||
		entityx.GetKey1() != old.GetKey1() ||
		entityx.GetKey2() != old.GetKey2()) &&
		p.DupCheck(entityx) {
		panic("この tableName,Key1,Key2 は既に使用されています。")
	}
	_, err := bhv.SysTableBhv_I.Update(entityx, p.tx, p.ctx)
	if err != nil {
		panic("Update Error:" + err.Error())
	}
	var ee df.Entity = entityx
	rmap := p.EntityToMap(&ee)
	p.context.JSON(200, dfweb.SetSingleFetchResult(rmap))
}