当前位置: 首页>>代码示例>>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;未经允许,请勿转载。