Example #1
0
func (p *Login) Insert(data map[string]interface{}) {
	p.ctx.Put("Process", "login:insert")
	entityx := entity.CreateLogin()
	var e df.Entity = entityx
	dfweb.MapToEntity(data, &e, "Login", false)
	if p.DupCheck(entityx) {
		panic("この 社員番号は既に使用されています。")
	}
	entityx.SetPassword(dfweb.CreateMd5(entityx.GetPassword()))
	_, err := bhv.LoginBhv_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))
}
Example #2
0
func (p *Login) Update(data map[string]interface{}) {
	p.ctx.Put("Process", "login:update")
	entityx := entity.CreateLogin()
	var e df.Entity = entityx
	dfweb.MapToEntity(data, &e, "Login", true)
	p.convertPassword(entityx)
	old := p.getOld(entityx.GetId())
	if entityx.GetLoginId() != old.GetLoginId() && p.DupCheck(entityx) {
		panic("この 社員番号は既に使用されています。")
	}
	_, err := bhv.LoginBhv_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))
}