本文整理匯總了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: "現金賬戶更新失敗"})
}
}