作者 tangxuhui

修复 缓存未命中,导致重复查询

... ... @@ -55,10 +55,12 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user
soureData[i]["reserve_type"] = reserveType.Name
} else {
reserveTypeId, _ := strconv.Atoi(reserveTypeIdS)
reserveType, err := models.GetChanceReserveTypeById(reserveTypeId)
if err == nil {
reserveTypeCache[reserveTypeIdS] = reserveType
soureData[i]["reserve_type"] = reserveType.Name
if reserveTypeId > 0 {
reserveType, err := models.GetChanceReserveTypeById(reserveTypeId)
if err == nil {
reserveTypeCache[reserveTypeIdS] = reserveType
soureData[i]["reserve_type"] = reserveType.Name
}
}
}
chanceTypeIdS := fmt.Sprint(soureData[i]["chance_type_id"])
... ... @@ -67,10 +69,12 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user
soureData[i]["chance_type"] = chanceType.Name
} else {
chanceTypeId, _ := strconv.Atoi(chanceTypeIdS)
chanceType, err := models.GetChanceTypeById(chanceTypeId)
if err == nil {
chanceTypeCache[chanceTypeIdS] = chanceType
soureData[i]["chance_type"] = chanceType.Name
if chanceTypeId > 0 {
chanceType, err := models.GetChanceTypeById(chanceTypeId)
if err == nil {
chanceTypeCache[chanceTypeIdS] = chanceType
soureData[i]["chance_type"] = chanceType.Name
}
}
}
auditTemplateIdS := fmt.Sprint(soureData[i]["audit_template_id"])
... ... @@ -79,10 +83,12 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user
soureData[i]["audit_template"] = auditTempalte.Name
} else {
auditTemplateId, _ := strconv.ParseInt(auditTemplateIdS, 10, 64)
auditTempalte, err := models.GetAuditTemplateById(auditTemplateId)
if err == nil {
auditTemplateCache[auditTemplateIdS] = auditTempalte
soureData[i]["audit_template"] = auditTempalte.Name
if auditTemplateId > 0 {
auditTempalte, err := models.GetAuditTemplateById(auditTemplateId)
if err == nil {
auditTemplateCache[auditTemplateIdS] = auditTempalte
soureData[i]["audit_template"] = auditTempalte.Name
}
}
}
departmentIdS := fmt.Sprint(soureData[i]["department_id"])
... ... @@ -90,10 +96,12 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user
soureData[i]["department"] = department.Name
} else {
departmentId, _ := strconv.ParseInt(departmentIdS, 10, 64)
department, err := models.GetDepartmentById(departmentId)
if err == nil {
departmentCache[departmentIdS] = department
soureData[i]["department"] = department.Name
if departmentId > 0 {
department, err := models.GetDepartmentById(departmentId)
if err == nil {
departmentCache[departmentIdS] = department
soureData[i]["department"] = department.Name
}
}
}
reviewStatusS := fmt.Sprint(soureData[i]["review_status"])
... ...