本文整理汇总了Golang中com/papersns/global.GetGlobalAttr函数的典型用法代码示例。如果您正苦于以下问题:Golang GetGlobalAttr函数的具体用法?Golang GetGlobalAttr怎么用?Golang GetGlobalAttr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetGlobalAttr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetPermissionQueryDict
func (o PermissionSupport) GetPermissionQueryDict(sessionId int, security Security) map[string]interface{} {
if security.ByUnit == "true" {
userIdI := global.GetGlobalAttr(sessionId, "userId")
userId, err := strconv.Atoi(fmt.Sprint(userIdI))
if err != nil {
panic(err)
}
querySupport := QuerySupport{}
session, _ := global.GetConnection(sessionId)
collectionName := "SysUser"
sysUser, found := querySupport.FindByMapWithSession(session, collectionName, map[string]interface{}{
"_id": userId,
})
if found {
sysUserMaster := sysUser["A"].(map[string]interface{})
return map[string]interface{}{
"A.createUnit": sysUserMaster["createUnit"],
}
}
return map[string]interface{}{
"_id": -1,
}
}
if security.ByAdmin == "true" {
adminUserId := global.GetGlobalAttr(sessionId, "adminUserId")
if adminUserId != nil && fmt.Sprint(adminUserId) != "" {
return map[string]interface{}{}
}
return map[string]interface{}{
"_id": -1,
}
}
return map[string]interface{}{}
}
示例2: RSetCreateFixFieldValue
func (c BaseDataAction) RSetCreateFixFieldValue(sessionId int, dataSource DataSource, bo *map[string]interface{}) {
var result interface{} = ""
userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
if err != nil {
panic(err)
}
createTime, err := strconv.ParseInt(time.Now().Format("20060102150405"), 10, 64)
if err != nil {
panic(err)
}
_, db := global.GetConnection(sessionId)
sysUser := map[string]interface{}{}
query := map[string]interface{}{
"_id": userId,
}
err = db.C("SysUser").Find(query).One(&sysUser)
if err != nil {
panic(err)
}
sysUserMaster := sysUser["A"].(map[string]interface{})
modelIterator := ModelIterator{}
modelIterator.IterateDataBo(dataSource, bo, &result, func(fieldGroupLi []FieldGroup, data *map[string]interface{}, rowIndex int, result *interface{}) {
(*data)["createBy"] = userId
(*data)["createTime"] = createTime
(*data)["createUnit"] = sysUserMaster["createUnit"]
})
}
示例3: AfterQueryData
func (o BbsPostInterceptor) AfterQueryData(sessionId int, dataSetId string, items []interface{}) []interface{} {
session, _ := global.GetConnection(sessionId)
userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
if err != nil {
panic(err)
}
collectionName := "BbsPostRead"
interceptorCommon := InterceptorCommon{}
commonUtil := CommonUtil{}
for i, item := range items {
data := item.(map[string]interface{})
dataA := data["A"].(map[string]interface{})
data["A"] = dataA
items[i] = data
bbsPostReadQuery := map[string]interface{}{
"A.bbsPostId": data["id"],
"A.readBy": userId,
}
bbsPostRead, found := interceptorCommon.FindByMapWithSession(session, collectionName, bbsPostReadQuery)
if !found {
data["bbsPostReadType"] = 1 // 未读
} else {
bbsPostReadA := bbsPostRead["A"].(map[string]interface{})
lastReadTime := commonUtil.GetFloat64FromMap(bbsPostReadA, "lastReadTime")
lastReplyTime := commonUtil.GetFloat64FromMap(dataA, "lastReplyTime")
if lastReadTime < lastReplyTime {
dataA["bbsPostReadType"] = 1 // 未读
} else {
dataA["bbsPostReadType"] = 2 // 已读
}
}
}
return items
}
示例4: 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
}
示例5: 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)
}
示例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
}
示例7: 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)
}
}
示例8: 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
}
示例9: CommitTxn
func (c BaseDataAction) CommitTxn(sessionId int) {
txnId := global.GetGlobalAttr(sessionId, "txnId")
if txnId != nil {
_, db := global.GetConnection(sessionId)
txnManager := TxnManager{db}
txnManager.Commit(txnId.(int))
}
}
示例10: RSetModifyFixFieldValue
func (c Console) RSetModifyFixFieldValue(sessionId int, dataSource DataSource, bo *map[string]interface{}) {
var result interface{} = ""
userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
if err != nil {
panic(err)
}
modifyTime, err := strconv.ParseInt(time.Now().Format("20060102150405"), 10, 64)
if err != nil {
panic(err)
}
_, db := global.GetConnection(sessionId)
sysUser := map[string]interface{}{}
query := map[string]interface{}{
"_id": userId,
}
err = db.C("SysUser").Find(query).One(&sysUser)
if err != nil {
panic(err)
}
sysUserMaster := sysUser["A"].(map[string]interface{})
srcBo := map[string]interface{}{}
srcQuery := map[string]interface{}{
"_id": (*bo)["id"],
"A.createUnit": sysUserMaster["createUnit"],
}
// log
modelTemplateFactory := ModelTemplateFactory{}
collectionName := modelTemplateFactory.GetCollectionName(dataSource)
srcQueryByte, err := json.Marshal(&srcQuery)
if err != nil {
panic(err)
}
log.Println("RSetModifyFixFieldValue,collectionName:" + collectionName + ", query:" + string(srcQueryByte))
db.C(collectionName).Find(srcQuery).One(&srcBo)
modelIterator := ModelIterator{}
modelIterator.IterateDiffBo(dataSource, bo, srcBo, &result, func(fieldGroupLi []FieldGroup, destData *map[string]interface{}, srcData map[string]interface{}, result *interface{}) {
if destData != nil && srcData == nil {
(*destData)["createBy"] = userId
(*destData)["createTime"] = modifyTime
(*destData)["createUnit"] = sysUserMaster["createUnit"]
} else if destData == nil && srcData != nil {
// 删除,不处理
} else if destData != nil && srcData != nil {
isMasterData := fieldGroupLi[0].IsMasterField()
isDetailDataDiff := (!fieldGroupLi[0].IsMasterField()) && modelTemplateFactory.IsDataDifferent(fieldGroupLi, *destData, srcData)
if isMasterData || isDetailDataDiff {
(*destData)["createBy"] = srcData["createBy"]
(*destData)["createTime"] = srcData["createTime"]
(*destData)["createUnit"] = srcData["createUnit"]
(*destData)["modifyBy"] = userId
(*destData)["modifyTime"] = modifyTime
(*destData)["modifyUnit"] = sysUserMaster["createUnit"]
}
}
})
}
示例11: GetAccountingPeriodYearSequenceNo
func (o AccountInOutService) GetAccountingPeriodYearSequenceNo(sessionId int, ymd 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{}{
"B.startDate": map[string]interface{}{
"$lte": ymd,
},
"B.endDate": map[string]interface{}{
"$gte": ymd,
},
"A.createUnit": qb.GetCreateUnitByUserId(session, userId),
}
accountingPeriod, found := qb.FindByMapWithSession(session, collectionName, queryMap)
if !found {
billDate, err := time.Parse("20060102", fmt.Sprint(ymd))
if err != nil {
panic(err)
}
// log.Println("单据日期" + billDate.Format("2006-01-02") + "未找到对应会计期")
// return 0,0
panic(BusinessError{Message: "单据日期" + billDate.Format("2006-01-02") + "未找到对应会计期"})
}
masterData := accountingPeriod["A"].(map[string]interface{})
year, err := strconv.Atoi(fmt.Sprint(masterData["accountingYear"]))
if err != nil {
panic(err)
}
var sequenceNo int
bDataSetLi := accountingPeriod["B"].([]interface{})
for _, item := range bDataSetLi {
line := item.(map[string]interface{})
if fmt.Sprint(line["startDate"]) <= fmt.Sprint(ymd) && fmt.Sprint(ymd) <= fmt.Sprint(line["endDate"]) {
sequenceNo, err = strconv.Atoi(fmt.Sprint(line["sequenceNo"]))
if err != nil {
panic(err)
}
break
}
}
// if sequenceNo == 0 {
// billDate, err := time.Parse("20060102", fmt.Sprint(ymd))
// if err != nil {
// panic(err)
// }
// panic(BusinessError{Message: "单据日期" + billDate.Format("2006-01-02") + "找到年度" + fmt.Sprint(year) + ",未找到会计期"})
// }
return year, sequenceNo
}
示例12: CheckBankAccountLimitControl
/**
* 银行帐户赤字检查
* @param sessionId
* @param accountId
* @param currencyTypeId
* @return {code: int, message: string}
* code AccountLimitControlStatus.SUCCESS:检查通过
* code AccountLimitControlStatus.FORBID:赤字字段为禁止,保存时金额 < 0,需要调用方抛出异常通知客户端
* code AccountLimitControlStatus.WARN:赤字字段为警告,保存时金额 < 0,需要调用方提供警告信息通知客户端
*/
func (o AccountInOutService) CheckBankAccountLimitControl(sessionId int, accountId int, currencyTypeId int) map[string]interface{} {
session, _ := global.GetConnection(sessionId)
userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
if err != nil {
panic(err)
}
qb := QuerySupport{}
queryMap := map[string]interface{}{
"_id": accountId,
"A.createUnit": qb.GetCreateUnitByUserId(session, userId),
}
collectionName := "BankAccount"
bankAccountBo, found := qb.FindByMapWithSession(session, collectionName, queryMap)
if !found {
queryMapByte, err := json.Marshal(&queryMap)
if err != nil {
panic(err)
}
panic(BusinessError{Message: "银行账户没找到,查询条件为:" + string(queryMapByte)})
}
bankAccountMaster := bankAccountBo["A"].(map[string]interface{})
bDetailDataLi := bankAccountBo["B"].([]interface{})
commonUtil := CommonUtil{}
for _, item := range bDetailDataLi {
bankAccountCurrencyType := item.(map[string]interface{})
if fmt.Sprint(bankAccountCurrencyType["currencyTypeId"]) == fmt.Sprint(currencyTypeId) {
limitsControl := fmt.Sprint(bankAccountCurrencyType["limitsControl"])
amtOriginalCurrencyBalanceStr := fmt.Sprint(bankAccountCurrencyType["amtOriginalCurrencyBalance"])
amtOriginalCurrencyBalance := commonUtil.GetFloat64FromString(amtOriginalCurrencyBalanceStr)
if limitsControl == "1" { // 禁止
if amtOriginalCurrencyBalance < 0 {
result := map[string]interface{}{
"code": LIMIT_CONTROL_FORBID,
"message": "帐户:" + fmt.Sprint(bankAccountMaster["name"]) + "出现赤字!",
}
return result
}
} else if limitsControl == "2" { // 警告
if amtOriginalCurrencyBalance < 0 {
result := map[string]interface{}{
"code": LIMIT_CONTROL_WARN,
"message": "帐户:" + fmt.Sprint(bankAccountMaster["name"]) + "出现赤字!",
}
return result
}
}
break
}
}
return map[string]interface{}{
"code": LIMIT_CONTROL_SUCCESS,
}
}
示例13: RRollbackTxn
func (c BaseDataAction) RRollbackTxn(sessionId int) {
txnId := global.GetGlobalAttr(sessionId, "txnId")
if txnId != nil {
if x := recover(); x != nil {
_, db := global.GetConnection(sessionId)
txnManager := TxnManager{db}
txnManager.Rollback(txnId.(int))
panic(x)
}
}
}
示例14: GetAccountingPeriodStartProgramDictionary
func (o ProgramDictionaryManager) GetAccountingPeriodStartProgramDictionary(sessionId int, db *mgo.Database, code string) map[string]interface{} {
userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
if err != nil {
panic(err)
}
collection := "AccountingPeriod"
c := db.C(collection)
session, _ := global.GetConnection(sessionId)
queryMap := map[string]interface{}{
"A.createUnit": o.GetCreateUnitByUserId(session, userId),
}
itemResult := []map[string]interface{}{}
err = c.Find(queryMap).All(&itemResult)
if err != nil {
panic(err)
}
result := map[string]interface{}{}
result["code"] = code
items := []interface{}{}
for _, item := range itemResult {
detailLi := item["B"].([]interface{})
for _, detail := range detailLi {
detailMap := detail.(map[string]interface{})
isIn := false
for _, dictItem := range items {
dictItemMap := dictItem.(map[string]interface{})
if fmt.Sprint(dictItemMap["code"]) == fmt.Sprint(detailMap["sequenceNo"]) {
isIn = true
break
}
}
if !isIn {
items = append(items, map[string]interface{}{
"code": detailMap["sequenceNo"],
"name": detailMap["sequenceNo"],
"order": detailMap["sequenceNo"],
})
}
}
}
result["items"] = items
// 排序
o.sortProgramDictionary(&result)
return result
}
示例15: LogCashAccountInOut
/**
* 现金帐户过帐,
* @param depositLogParam 过帐参数对象
*/
func (o AccountInOutService) LogCashAccountInOut(sessionId int, accountInOutParam AccountInOutParam) {
session, db := global.GetConnection(sessionId)
userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
if err != nil {
panic(err)
}
collectionName := "CashAccount"
querySupport := QuerySupport{}
queryMap := map[string]interface{}{
"_id": accountInOutParam.AccountId,
"A.createUnit": querySupport.GetCreateUnitByUserId(session, userId),
}
cashAccountBo, found := querySupport.FindByMapWithSession(session, collectionName, queryMap)
if !found {
queryMapByte, err := json.Marshal(&queryMap)
if err != nil {
panic(err)
}
panic(BusinessError{Message: "现金账户没找到,查询条件为:" + string(queryMapByte)})
}
mathUtil := MathUtil{}
cashAccount := cashAccountBo["A"].(map[string]interface{})
if fmt.Sprint(cashAccount["currencyTypeId"]) != fmt.Sprint(accountInOutParam.CurrencyTypeId) {
panic(BusinessError{Message: "过账现金账户:" + fmt.Sprint(cashAccount["name"]) + "未找到对应币别"})
}
amtOriginalCurrencyBalance := fmt.Sprint(cashAccount["amtOriginalCurrencyBalance"])
amtIncrease := accountInOutParam.AmtIncrease
amtReduce := accountInOutParam.AmtReduce
if accountInOutParam.DiffDataType == ADD || accountInOutParam.DiffDataType == AFTER_UPDATE { // 正过账
amtOriginalCurrencyBalance = mathUtil.Add(amtOriginalCurrencyBalance, amtIncrease)
amtOriginalCurrencyBalance = mathUtil.Sub(amtOriginalCurrencyBalance, amtReduce)
} else if accountInOutParam.DiffDataType == BEFORE_UPDATE || accountInOutParam.DiffDataType == DELETE { // 反过账
amtOriginalCurrencyBalance = mathUtil.Sub(amtOriginalCurrencyBalance, amtIncrease)
amtOriginalCurrencyBalance = mathUtil.Add(amtOriginalCurrencyBalance, amtReduce)
}
commonUtil := CommonUtil{}
cashAccount["amtOriginalCurrencyBalance"] = commonUtil.GetFloatFormat(amtOriginalCurrencyBalance)
cashAccountBo["A"] = cashAccount
txnManager := TxnManager{db}
txnId := global.GetTxnId(sessionId)
_, found = txnManager.Update(txnId, collectionName, cashAccountBo)
if !found {
panic(BusinessError{Message: "现金账户更新失败"})
}
}