// Package service /** * @ File: hrRedis.go * @ Date: 2021/6/9 15:07 * @ Author: JYQ * @ Description: 心率相关Redis操作 */ package service import ( "sportfitness/base/assembly/heartRate/model" "sportfitness/base/assembly/heartRate/repository/postgre" "sportfitness/base/assembly/heartRate/repository/redis" "sportfitness/base/errors" ) type HrRedis struct { base } // ClassStartR1AndOnClassByUUStdID 确认上课时创建R1与OnClass func (h HrRedis) ClassStartR1AndOnClassByUUStdID(token string, objectShopId int64, uuid string) string { optId := h.checkPermission(token, objectShopId) rst, err := postgre.PGHr{}.GetStdInfoAndCrIdByUUStdID(optId, objectShopId, uuid) if err != nil { panic(errors.PGError) } rsMap, b := h.JSONToMap(rst) if !b { return rst } sn := rsMap["rs"].(map[string]interface{})["sn_info"].([]interface{}) eqSn := rsMap["rs"].(map[string]interface{})["eqsn_list"].([]interface{}) var snInfo []model.HrVerifyDetail // 心率带信息sn_info for _, v := range sn { one := model.HrVerifyDetail{} one.Sn = v.(map[string]interface{})["sn"].(string) one.Age = int(v.(map[string]interface{})["age"].(float64)) one.Sex = int(v.(map[string]interface{})["sex"].(float64)) one.Name = v.(map[string]interface{})["name"].(string) one.CrId = int64(v.(map[string]interface{})["cr_id"].(float64)) one.Height = int(v.(map[string]interface{})["height"].(float64)) one.Weight = int(v.(map[string]interface{})["weight"].(float64)) one.HeadImg = v.(map[string]interface{})["headurl"].(string) one.GroupNo = int(v.(map[string]interface{})["group_no"].(float64)) one.IsPrivate = int(v.(map[string]interface{})["is_private"].(float64)) one.IsBirthday = int(v.(map[string]interface{})["is_birthday"].(float64)) one.PowerPercent = int(v.(map[string]interface{})["power_percent"].(float64)) snInfo = append(snInfo, one) } // eqSn信息eqsn_list var eqSnInfo []model.ClassStartDetail //var onClass []model.CrIdList for _, k := range eqSn { one := model.ClassStartDetail{} //class := model.CrIdList{} one.EqSn = k.(map[string]interface{})["eqsn"].(string) //class.EqSn = k.(map[string]interface{})["eqsn"].(string) classInfo := k.(map[string]interface{})["std_info"].(map[string]interface{})["classinfo"].([]interface{}) for _, c := range classInfo { // 循环遍历classInfo info := model.ClassInfo{} info.Coach = c.(map[string]interface{})["coach"].(string) info.ClassName = c.(map[string]interface{})["class_name"].(string) info.ClassType = int(c.(map[string]interface{})["class_type"].(float64)) info.MemberCount = int(c.(map[string]interface{})["member_count"].(float64)) one.StdInfo.ClassInfoList = append(one.StdInfo.ClassInfoList, info) } crId := k.(map[string]interface{})["crid_list"].([]interface{}) for _, c := range crId { id := int64(c.(float64)) one.CrIdLIst = append(one.CrIdLIst, id) } eqSnInfo = append(eqSnInfo, one) //onClass = append(onClass, class) } redis.OnClassRedis(eqSnInfo) redis.HrVerifyR1(snInfo) //redis return rst }