Exemple #1
0
func (r *GoReport) ReplacePageTotal() {
	if r.PageTotal == false {
		return
	}
	lines := strings.Split(r.Converter.Text, "\n")
	list := new(df.List)
	for i, line := range lines {
		if len(line) < 8 {
			continue
		}
		if line[0:7] == "v\tPAGE\t" {
			h := new(pagehist)
			h.line = i
			h.page = AtoiPanic(line[7:])
			list.Add(h)
			//fmt.Printf("hist %v \n", h)
		}
	}
	for i, line := range lines {
		if strings.Index(line, "{#TotalPage#}") > -1 {
			total := r.getTotalPage(i, list)
			//fmt.Printf("total :%v\n", total)
			lines[i] = strings.Replace(lines[i], "{#TotalPage#}", strconv.Itoa(total), -1)
		}
	}
	buf := new(bytes.Buffer)
	for _, line := range lines {
		buf.WriteString(line + "\n")
	}
	r.Converter.Text = buf.String()
}
func (p *Customer) Transaction(transactions []interface{}) {
	transactionResult := new(df.List)
	for _, transaction := range transactions {
		var tran map[string]interface{} = transaction.(map[string]interface{})
		res := p.executeEachTransaction(tran)
		transactionResult.Add(res)
	}
	p.context.JSON(200, dfweb.SetNormalFetchResult(transactionResult))
}
func (p *SysTable) GetDbs() {
	cbx := cb.CreateSysTableCB()
	cbx.Query().SetDelFlag_Equal(0)
	cbx.Query().SetTableName_Equal("DbName")
	cbx.Query().AddOrderBy_Key1_Asc()
	res, err := bhv.SysTableBhv_I.SelectList(cbx, p.tx)
	if err != nil {
		panic(err.Error())
	}
	reslist := new(df.List)
	for _, ent := range res.List.GetAsArray() {
		entx := ent.(*entity.SysTable)
		cmap := make(map[string]string)
		cmap["value"] = entx.GetKey1()
		cmap["label"] = entx.GetKey1()
		reslist.Add(cmap)
	}
	p.context.JSON(200, dfweb.SetNormalFetchResult(reslist))
}
func (p *Employee) getSecData() {
	cbx := cb.CreateUserTableCB()
	cbx.Query().SetDelFlag_Equal(0)
	cbx.Query().SetTableName_Equal("section")
	cbx.Query().AddOrderBy_Key1_Asc()
	res, err := bhv.UserTableBhv_I.SelectList(cbx, p.tx)
	if err != nil {
		panic(err.Error())
	}
	reslist := new(df.List)
	cmap := make(map[string]interface{})
	cmap["value"] = 0
	cmap["label"] = ""
	reslist.Add(cmap)
	for _, ent := range res.List.GetAsArray() {
		entx := ent.(*entity.UserTable)
		cmap := make(map[string]interface{})
		cmap["value"] = entx.GetId()
		cmap["label"] = entx.GetS1Data().String
		reslist.Add(cmap)
	}
	p.context.JSON(200, dfweb.SetNormalFetchResult(reslist))
}
Exemple #5
0
func (r *GoReport) getTotalPage(lineno int, list *df.List) int {
	count := 0
	page := 0
	for i, l := range list.GetAsArray() {
		if l.(*pagehist).line >= lineno {
			count = i
			break
		}
	}
	for i := count; i < list.Size(); i++ {
		newpage := list.Get(i).(*pagehist).page
		if newpage <= page {
			return page
		}
		page = newpage
		//fmt.Printf("page :%v\n", page)
	}
	return page
}
func SetNormalFetchResult(ar *df.List) map[string]interface{} {
	return SetFetchResult(ar.GetAsArray(), 0, 0, ar.Size())
}