當前位置: 首頁>>代碼示例>>Golang>>正文


Golang global.GetConnection函數代碼示例

本文整理匯總了Golang中com/papersns/global.GetConnection函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetConnection函數的具體用法?Golang GetConnection怎麽用?Golang GetConnection使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了GetConnection函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: validateMasterDataDuplicate

func (o FinanceService) validateMasterDataDuplicate(sessionId int, dataSource DataSource, bo map[string]interface{}) string {
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	session, _ := global.GetConnection(sessionId)

	message := ""
	modelTemplateFactory := ModelTemplateFactory{}
	strId := modelTemplateFactory.GetStrId(bo)
	andQueryLi := []map[string]interface{}{}
	qb := QuerySupport{}
	andQueryLi = append(andQueryLi, map[string]interface{}{
		"deleteFlag": map[string]interface{}{
			"$ne": 9,
		},
		"A.createUnit": qb.GetCreateUnitByUserId(session, userId),
	})
	andFieldNameLi := []string{}
	modelIterator := ModelIterator{}
	var result interface{} = ""
	modelIterator.IterateAllFieldBo(dataSource, &bo, &result, func(fieldGroup FieldGroup, data *map[string]interface{}, rowIndex int, result *interface{}) {
		if fieldGroup.IsMasterField() {
			if fieldGroup.AllowDuplicate == "false" && fieldGroup.Id != "id" {
				andQueryLi = append(andQueryLi, map[string]interface{}{
					"A." + fieldGroup.Id: (*data)[fieldGroup.Id],
				})
				andFieldNameLi = append(andFieldNameLi, fieldGroup.DisplayName)
			}
		}
	})
	if len(andFieldNameLi) > 0 {
		if !(strId == "" || strId == "0") {
			andQueryLi = append(andQueryLi, map[string]interface{}{
				"_id": map[string]interface{}{
					"$ne": bo["id"],
				},
			})
		}
		duplicateQuery := map[string]interface{}{
			"$and": andQueryLi,
		}
		collectionName := modelTemplateFactory.GetCollectionName(dataSource)
		_, db := global.GetConnection(sessionId)
		duplicateQueryByte, err := json.MarshalIndent(duplicateQuery, "", "\t")
		if err != nil {
			panic(err)
		}
		log.Println("validateMasterDataDuplicate,collectionName:" + collectionName + ", query:" + string(duplicateQueryByte))
		count, err := db.C(collectionName).Find(duplicateQuery).Limit(1).Count()
		if err != nil {
			panic(err)
		}
		if count > 0 {
			message = strings.Join(andFieldNameLi, "+") + "不允許重複"
		}
	}

	return message
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:60,代碼來源:service.go

示例2: addOrUpdateBbsPostRead

func (c BbsPostSupport) addOrUpdateBbsPostRead(sessionId int, bbsPostId int) {
	session, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	bbsPost := BbsPost{}
	modelTemplateFactory := ModelTemplateFactory{}
	bbsPostReadDS := modelTemplateFactory.GetDataSource("BbsPostRead")

	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	dateUtil := DateUtil{}
	qb := QuerySupport{}

	bbsPostRead, found := qb.FindByMapWithSession(session, "BbsPostRead", map[string]interface{}{
		"A.bbsPostId": bbsPostId,
		"A.readBy":    userId,
	})
	if found {
		bbsPost.RSetModifyFixFieldValue(sessionId, bbsPostReadDS, &bbsPostRead)
		bbsPostReadA := bbsPostRead["A"].(map[string]interface{})
		bbsPostRead["A"] = bbsPostReadA

		bbsPostReadA["lastReadTime"] = dateUtil.GetCurrentYyyyMMddHHmmss()
		_, updateResult := txnManager.Update(txnId, "BbsPostRead", bbsPostRead)
		if !updateResult {
			panic(BusinessError{Message: "更新意見反饋閱讀記錄失敗"})
		}
	} else {
		c.addBbsPostRead(sessionId, bbsPostId)
	}
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:33,代碼來源:bbspost.go

示例3: RAfterNewData

func (o AccountInOutDisplaySupport) RAfterNewData(sessionId int, dataSource DataSource, formTemplate FormTemplate, bo *map[string]interface{}) {
	masterData := (*bo)["A"].(map[string]interface{})
	(*bo)["A"] = masterData

	session, _ := global.GetConnection(sessionId)
	qb := QuerySupport{}
	query := map[string]interface{}{
		"A.code": "RMB",
	}
	permissionSupport := PermissionSupport{}
	permissionQueryDict := permissionSupport.GetPermissionQueryDict(sessionId, formTemplate.Security)
	for k, v := range permissionQueryDict {
		query[k] = v
	}

	collectionName := "CurrencyType"
	{
		queryByte, err := json.MarshalIndent(&query, "", "\t")
		if err != nil {
			panic(err)
		}
		log.Println("RAfterNewData,collectionName:" + collectionName + ", query:" + string(queryByte))
	}
	result, found := qb.FindByMapWithSession(session, collectionName, query)
	if found {
		masterData["currencyTypeId"] = result["id"]
	}
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:28,代碼來源:accountinoutdisplay.go

示例4: addFinAccountInOutForCash

/**
 * 添加現金賬戶會計期匯總(月檔)記錄
 * @param sessionId
 * @param accountInOutParam 參數對象
 */
func (o AccountInOutService) addFinAccountInOutForCash(sessionId int, accountInOutParam AccountInOutParam) map[string]interface{} {
	accountInOut := map[string]interface{}{
		"accountType":           accountInOutParam.AccountType,
		"accountId":             accountInOutParam.AccountId,
		"currencyTypeId":        accountInOutParam.CurrencyTypeId,
		"exchangeRateShow":      accountInOutParam.ExchangeRateShow,
		"exchangeRate":          accountInOutParam.ExchangeRate,
		"accountingPeriodYear":  accountInOutParam.AccountingPeriodYear,
		"accountingPeriodMonth": accountInOutParam.AccountingPeriodMonth,
		"amtIncrease":           "0",
		"amtReduce":             "0",
		"createBy":              accountInOutParam.CreateBy,
		"createTime":            accountInOutParam.CreateTime,
		"createUnit":            accountInOutParam.CreateUnit,
	}
	_, db := global.GetConnection(sessionId)
	dataSourceModelId := "AccountInOut"
	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	masterSeqName := GetMasterSequenceName(dataSource)
	masterSeqId := GetSequenceNo(db, masterSeqName)
	accountInOut["id"] = masterSeqId
	bo := map[string]interface{}{
		"_id": masterSeqId,
		"id":  masterSeqId,
		"A":   accountInOut,
	}
	modelTemplateFactory.ConvertDataType(dataSource, &bo)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	return txnManager.Insert(txnId, collectionName, bo)
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:38,代碼來源:accountinoutservice.go

示例5: deleteCashBankDailyInOut

/**
 * 刪除日記帳明細
 * @param sessionId
 * @param accountInOutItemParam 日記帳明細業務參數
 */
func (o AccountInOutService) deleteCashBankDailyInOut(sessionId int, accountInOutItemParam AccountInOutItemParam) {
	_, db := global.GetConnection(sessionId)
	query := map[string]interface{}{
		"A.accountId":      accountInOutItemParam.AccountId,
		"A.currencyTypeId": accountInOutItemParam.CurrencyTypeId,
		"A.accountType":    accountInOutItemParam.AccountType,
		"A.billId":         accountInOutItemParam.BillId,
		"A.billTypeId":     accountInOutItemParam.BillTypeId,
	}
	if accountInOutItemParam.BillDetailId != 0 {
		query["A.billDetailId"] = accountInOutItemParam.BillDetailId
		query["A.billDetailName"] = accountInOutItemParam.BillDetailName
	} else {
		query["A.billDetailId"] = 0 // 主數據集記錄
	}
	dataSourceModelId := "AccountInOutItem"
	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	_, result := txnManager.RemoveAll(txnId, collectionName, query)
	if !result {
		queryByte, err := json.MarshalIndent(&query, "", "\t")
		if err != nil {
			panic(err)
		}
		panic("刪除日記賬明細失敗,查詢語句為:" + string(queryByte))
	}
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:35,代碼來源:accountinoutservice.go

示例6: GetFirstAccountingPeriodStartEndDate

func (o AccountInOutService) GetFirstAccountingPeriodStartEndDate(sessionId int, year int) (int, int) {
	session, _ := global.GetConnection(sessionId)
	dataSourceModelId := "AccountingPeriod"
	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	qb := QuerySupport{}
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	queryMap := map[string]interface{}{
		"A.accountingYear": year,
		"A.createUnit":     qb.GetCreateUnitByUserId(session, userId),
	}
	accountingPeriod, found := qb.FindByMapWithSession(session, collectionName, queryMap)
	if !found {
		panic(BusinessError{Message: "會計年度:" + fmt.Sprint(year) + "未找到對應會計期"})
		//		log.Println("會計年度:" + fmt.Sprint(year) + "未找到對應會計期")
		//		return 0, 0
	}
	var startDate int
	var endDate int
	bDataSetLi := accountingPeriod["B"].([]interface{})
	commonUtil := CommonUtil{}
	for _, item := range bDataSetLi {
		line := item.(map[string]interface{})
		startDate = commonUtil.GetIntFromMap(line, "startDate")
		endDate = commonUtil.GetIntFromMap(line, "endDate")
		break
	}
	return startDate, endDate
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:33,代碼來源:accountinoutservice.go

示例7: MenuList

func (c App) MenuList() revel.Result {
	sessionId := global.GetSessionId()
	defer global.CloseSession(sessionId)

	_, db := global.GetConnection(sessionId)
	menuResultLi := []map[string]interface{}{}
	err := db.C("Menu").Find(nil).Sort("level").All(&menuResultLi)
	if err != nil {
		panic(err)
	}

	menuLi := []map[string]interface{}{}
	for _, item := range menuResultLi {
		level := fmt.Sprint(item["level"])
		if len(level) == 3 {
			menuLi = append(menuLi, item)

			subMenuLi := []map[string]interface{}{}
			for _, subItem := range menuResultLi {
				subLevel := fmt.Sprint(subItem["level"])
				if len(subLevel) == 6 && subLevel[0:3] == level {
					subMenuLi = append(subMenuLi, subItem)
				}
			}
			item["subMenuLi"] = subMenuLi
		}
	}

	result := map[string]interface{}{
		"menuLi": menuLi,
	}
	return c.Render(result)
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:33,代碼來源:app.go

示例8: addBbsPostRead

func (c BbsPostSupport) addBbsPostRead(sessionId int, bbsPostId int) {
	_, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	bbsPost := BbsPost{}
	modelTemplateFactory := ModelTemplateFactory{}
	bbsPostReadDS := modelTemplateFactory.GetDataSource("BbsPostRead")

	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	dateUtil := DateUtil{}
	sequenceNo := mongo.GetSequenceNo(db, "bbsPostReadId")
	bbsPostRead := map[string]interface{}{
		"_id": sequenceNo,
		"id":  sequenceNo,
		"A": map[string]interface{}{
			"id":           sequenceNo,
			"bbsPostId":    bbsPostId,
			"readBy":       userId,
			"lastReadTime": dateUtil.GetCurrentYyyyMMddHHmmss(),
		},
	}
	bbsPost.RSetCreateFixFieldValue(sessionId, bbsPostReadDS, &bbsPostRead)
	txnManager.Insert(txnId, "BbsPostRead", bbsPostRead)
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:27,代碼來源:bbspost.go

示例9: Login

func (c Hjq) Login() revel.Result {
	if strings.ToLower(c.Request.Method) == "get" {
		//c.Response.ContentType = "text/html; charset=utf-8"
		return c.Render()
	}
	username := c.Params.Get("username")
	password := c.Params.Get("password")

	hash := sha1.New()
	_, err := io.WriteString(hash, password)
	if err != nil {
		panic(err)
	}
	encryPassword := fmt.Sprintf("%x", hash.Sum(nil))

	sessionId := global.GetSessionId()
	defer global.CloseSession(sessionId)

	session, _ := global.GetConnection(sessionId)
	qb := QuerySupport{}
	user, found := qb.FindByMapWithSession(session, "SysUser", map[string]interface{}{
		"A.type":     1,
		"A.name":     username,
		"A.password": encryPassword,
	})
	if !found {
		c.Response.ContentType = "text/plain; charset=utf-8"
		return c.RenderText("用戶名密碼錯誤")
	}
	c.Session["adminUserId"] = fmt.Sprint(user["id"])
	c.Session["userId"] = fmt.Sprint(user["id"])

	return c.Redirect("/console/[email protected]=LastSessionData&cookie=false")
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:34,代碼來源:admin.go

示例10: GetAccountingPeriodStartEndDate

func (o AccountInOutItemInterceptor) GetAccountingPeriodStartEndDate(sessionId int, year int, sequenceNo int) (int, int) {
	session, _ := global.GetConnection(sessionId)
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	collectionName := "AccountingPeriod"
	queryMap := map[string]interface{}{
		"A.accountingYear": year,
		"B.sequenceNo":     sequenceNo,
		"A.createUnit":     InterceptorCommon{}.GetCreateUnitByUserId(session, userId),
	}
	accountingPeriod, found := InterceptorCommon{}.FindByMapWithSession(session, collectionName, queryMap)
	if !found {
		//		panic(BusinessError{Message: "會計年度:" + fmt.Sprint(year) + ",會計期序號:" + fmt.Sprint(sequenceNo) + "未找到對應會計期"})
		log.Println("會計年度:" + fmt.Sprint(year) + ",會計期序號:" + fmt.Sprint(sequenceNo) + "未找到對應會計期")
		return 0, 0
	}
	var startDate int
	var endDate int
	bDataSetLi := accountingPeriod["B"].([]interface{})
	commonUtil := CommonUtil{}
	for _, item := range bDataSetLi {
		line := item.(map[string]interface{})
		if fmt.Sprint(line["sequenceNo"]) == fmt.Sprint(sequenceNo) {
			startDate = commonUtil.GetIntFromMap(line, "startDate")
			endDate = commonUtil.GetIntFromMap(line, "endDate")
			break
		}
	}
	return startDate, endDate
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:32,代碼來源:AccountInOutItemInterceptor.go

示例11: GetLayerForListTemplate

// TODO
func (o TemplateManager) GetLayerForListTemplate(sId int, listTemplate ListTemplate) map[string]interface{} {
	_, db := global.GetConnection(sId)

	result := map[string]interface{}{}
	resultLi := map[string]interface{}{}
	layerManager := layer.GetInstance()

	listTemplateIterator := ListTemplateIterator{}
	var iterateResult interface{} = ""
	listTemplateIterator.IterateTemplateColumn(listTemplate, &iterateResult, func(column Column, iterateResult *interface{}) {
		if column.Dictionary != "" {
			layerMap := layerManager.GetLayerBySession(sId, db, column.Dictionary)
			if layerMap != nil {
				items := layerMap["items"]
				if items != nil {
					dictMap := map[string]interface{}{}
					for _, item := range items.([]map[string]interface{}) {
						dictMap[fmt.Sprint(item["code"])] = item
					}
					result[column.Dictionary] = dictMap
					resultLi[column.Dictionary] = items
				} else {
					result[column.Dictionary] = map[string]interface{}{}
					resultLi[column.Dictionary] = []interface{}{}
				}
			}
		}
	})

	return map[string]interface{}{
		"layerBo":   result,
		"layerBoLi": resultLi,
	}
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:35,代碼來源:TemplateManager.go

示例12: GetLayerForFormTemplate

func (o TemplateManager) GetLayerForFormTemplate(sId int, formTemplate FormTemplate) map[string]interface{} {
	_, db := global.GetConnection(sId)

	result := map[string]interface{}{}
	resultLi := map[string]interface{}{}
	layerManager := layer.GetInstance()
	for _, item := range formTemplate.FormElemLi {
		if item.XMLName.Local == "column-model" {
			for _, column := range item.ColumnModel.ColumnLi {
				if column.Dictionary != "" {
					layerMap := layerManager.GetLayerBySession(sId, db, column.Dictionary)
					if layerMap != nil {
						items := layerMap["items"]
						if items != nil {
							dictMap := map[string]interface{}{}
							for _, item := range items.([]map[string]interface{}) {
								dictMap[fmt.Sprint(item["code"])] = item
							}
							result[column.Dictionary] = dictMap
							resultLi[column.Dictionary] = items
						} else {
							result[column.Dictionary] = map[string]interface{}{}
							resultLi[column.Dictionary] = []interface{}{}
						}
					}
				}
			}
		}
	}

	return map[string]interface{}{
		"layerBo":   result,
		"layerBoLi": resultLi,
	}
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:35,代碼來源:TemplateManager.go

示例13: Insert

func (o UsedCheck) Insert(sessionId int, fieldGroupLi []FieldGroup, bo *map[string]interface{}, data *map[string]interface{}) {
	_, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	createTime := DateUtil{}.GetCurrentYyyyMMddHHmmss()
	for _, fieldGroup := range fieldGroupLi {
		if fieldGroup.IsRelationField() {
			modelTemplateFactory := ModelTemplateFactory{}
			relationItem, found := modelTemplateFactory.ParseRelationExpr(fieldGroup, *bo, *data)
			if !found {
				panic("數據源:" + fieldGroup.GetDataSource().Id + ",數據集:" + fieldGroup.GetDataSetId() + ",字段:" + fieldGroup.Id + ",配置的關聯模型列表,不存在返回true的記錄")
			}
			referenceData := map[string]interface{}{
				"A": map[string]interface{}{
					"createBy":   (*data)["createBy"],
					"createTime": createTime,
					"createUnit": (*data)["createUnit"],
				},
				"reference":   o.GetSourceReferenceLi(db, fieldGroup, bo, data),
				"beReference": o.GetBeReferenceLi(db, fieldGroup, relationItem, data),
			}
			txnManager.Insert(txnId, "PubReferenceLog", referenceData)
		}
	}
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:25,代碼來源:UsedCheck.go

示例14: RAfterNewData

func (c BankAccountSupport) RAfterNewData(sessionId int, dataSource DataSource, formTemplate FormTemplate, bo *map[string]interface{}) {
	modelTemplateFactory := ModelTemplateFactory{}
	dataSetId := "B"
	data := modelTemplateFactory.GetDataSetNewData(dataSource, dataSetId, *bo)

	// 設置默認的幣別
	qb := QuerySupport{}
	session, _ := global.GetConnection(sessionId)
	collection := "CurrencyType"
	query := map[string]interface{}{
		"A.code": "RMB",
	}
	permissionSupport := PermissionSupport{}
	permissionQueryDict := permissionSupport.GetPermissionQueryDict(sessionId, formTemplate.Security)
	for k, v := range permissionQueryDict {
		query[k] = v
	}

	currencyType, found := qb.FindByMapWithSession(session, collection, query)
	if !found {
		panic(BusinessError{Message: "沒有找到幣別人民幣,請先配置默認幣別"})
	}
	data["currencyTypeId"] = currencyType["id"]

	(*bo)["B"] = []interface{}{
		data,
	}
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:28,代碼來源:bankaccount.go

示例15: deleteReference

func (o UsedCheck) deleteReference(sessionId int, referenceQueryLi []interface{}) {
	_, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	//	deleteQuery := map[string]interface{}{
	//		"reference": referenceQueryLi,
	//	}
	deleteQuery := map[string]interface{}{
	//"$and": referenceQueryLi,
	}
	andQuery := []interface{}{}
	for _, item := range referenceQueryLi {
		andQuery = append(andQuery, map[string]interface{}{
			"reference": item,
		})
	}
	deleteQuery["$and"] = andQuery
	deleteByte, err := json.MarshalIndent(&deleteQuery, "", "\t")
	if err != nil {
		panic(err)
	}
	log.Println("deleteReference,collection:PubReferenceLog,query is:" + string(deleteByte))
	count, err := db.C("PubReferenceLog").Find(deleteQuery).Limit(1).Count()
	if err != nil {
		panic(err)
	}
	if count > 0 {
		_, result := txnManager.RemoveAll(txnId, "PubReferenceLog", deleteQuery)
		if !result {
			panic("刪除失敗")
		}
	}
}
開發者ID:hongjinqiu,項目名稱:finance,代碼行數:33,代碼來源:UsedCheck.go


注:本文中的com/papersns/global.GetConnection函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。