Exemplo n.º 1
0
func (p *Employee) Insert(data map[string]interface{}) {
	p.ctx.Put("Process", "employee:insert")
	entityx := entity.CreateEmployee()
	var e df.Entity = entityx
	dfweb.MapToEntity(data, &e, "Employee", false)
	//DupCheck
	if p.DupCheck(entityx) {
		panic("この XXXXは既に使用されています。")
	}
	_, err := bhv.EmployeeBhv_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))
}
Exemplo n.º 2
0
func (p *Employee) Update(data map[string]interface{}) {
	p.ctx.Put("Process", "employee:update")
	entityx := entity.CreateEmployee()
	var e df.Entity = entityx
	dfweb.MapToEntity(data, &e, "Employee", true)
	//DupCheck
	old := p.getOld(entityx.GetId())
	if entityx.GetEmpCd() != old.GetEmpCd() &&
		p.DupCheck(entityx) {
		panic("この EmpCdは既に使用されています。")
	}
	_, err := bhv.EmployeeBhv_I.Update(entityx, p.tx, p.ctx)
	if err != nil {
		panic("Update Error:" + err.Error())
	}
	ut := p.GetUserTableSec(entityx.GetSecId())
	var ee df.Entity = entityx
	rmap := p.EntityToMap(&ee)
	rmap["sec"] = dfweb.ConvWebData(ut.GetS1Data())
	p.context.JSON(200, dfweb.SetSingleFetchResult(rmap))
}