Commit 5eb4784d by zhangjiec

1

parent 5e84e218
......@@ -37,19 +37,6 @@ func CreateArea(c *gin.Context) {
return
}
// v,ok := c.Get("adminID")
// adminID := v.(uint32)
//if ok!=true || adminID == 0{
// c.JSON(http.StatusOK, gin.H{
// "code": api.ErrorSystemErr,
// "data": api.CodeMsg[api.ErrorSystemErr],
// })
// logger.Log.Error("strconv.Atoi(c.Param(\"userID\")",
// zap.String("c.Param(\"userID\")",c.Param("userID")),
// zap.Error(err))
// return
//}
insertRes := dbcurd.InsertBaseArea(&reqData) //插入数据库
if insertRes == 1 {
c.JSON(http.StatusOK, gin.H{
......
......@@ -10,7 +10,7 @@ package api_cache
//// @Router /base/city/{provinceID} [GET]
//// @Security ApiKeyAuth
//func GetCacheBDistrictMap(c *gin.Context) {
// para, _ := strconv.Atoi(c.Param("id"))
// para, _ := strconv.ParseUint(c.Param("id"),10,32)
// v, _ := cache.CityMap.Load(uint32(para)) // 如果查不到就直接返回空data
// // data, _ := v.([]cache.DistrictStruct)
// c.JSON(http.StatusOK, gin.H{
......
......@@ -10,7 +10,7 @@ package api_cache
//// @Router /base/city/{provinceID} [GET]
//// @Security ApiKeyAuth
//func GetCacheBDistrictMap(c *gin.Context) {
// para, _ := strconv.Atoi(c.Param("id"))
// para, _ := strconv.ParseUint(c.Param("id"),10,32)
// v, _ := cache.CityMap.Load(uint32(para)) // 如果查不到就直接返回空data
// // data, _ := v.([]cache.DistrictStruct)
// c.JSON(http.StatusOK, gin.H{
......
......@@ -10,7 +10,7 @@ package api_cache
//// @Router /base/city/{provinceID} [GET]
//// @Security ApiKeyAuth
//func GetCountyAreaMap(c *gin.Context) {
// para, _ := strconv.Atoi(c.Param("id"))
// para, _ := strconv.ParseUint(c.Param("id"),10,32)
// v, _ := cache.CityMap.Load(uint32(para)) // 如果查不到就直接返回空data
// // data, _ := v.([]cache.DistrictStruct)
// c.JSON(http.StatusOK, gin.H{
......
......@@ -36,7 +36,7 @@ func GetProvinceList(c *gin.Context) {
// @Router /base/city/{provinceID} [GET]
// @Security ApiKeyAuth
func GetCityList(c *gin.Context) {
para, _ := strconv.Atoi(c.Param("id"))
para, _ := strconv.ParseUint(c.Param("id"), 10, 32)
v, _ := cache.CityMap.Load(uint32(para)) // 如果查不到就直接返回空data
// data, _ := v.([]model.CacheBDistrictStruct)
c.JSON(http.StatusOK, gin.H{
......@@ -55,7 +55,7 @@ func GetCityList(c *gin.Context) {
// @Router /base/county/{cityID} [GET]
// @Security ApiKeyAuth
func GetCountyList(c *gin.Context) {
para, _ := strconv.Atoi(c.Param("id"))
para, _ := strconv.ParseUint(c.Param("id"), 10, 32)
v, _ := cache.CountyMap.Load(uint32(para)) // 如果查不到就直接返回空data
// data, _ := v.([]model.CacheBDistrictStruct)
c.JSON(http.StatusOK, gin.H{
......@@ -79,7 +79,7 @@ type countyAreaRes struct {
// @Router /base/countyarea/{countyID} [GET]
// @Security ApiKeyAuth
func GetAreaByCounty(c *gin.Context) {
countyID, err := strconv.Atoi(c.Param("id"))
countyID, err := strconv.ParseUint(c.Param("id"), 10, 32)
if err != nil {
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorReqParaFormat,
......@@ -91,7 +91,7 @@ func GetAreaByCounty(c *gin.Context) {
if ok == false {
logger.Log.Error("userID在Context里面居然没填对,遇到鬼了",
zap.String("Src", "GetAreaByCounty"),
zap.Int("countyID", countyID))
zap.Uint64("countyID", countyID))
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorSystemErr,
"message": api.CodeMsg[api.ErrorSystemErr],
......@@ -181,6 +181,8 @@ func GetAreaByLocation(c *gin.Context) {
"温江区",
14,
})
} else {
cache.AreaMap.Delete(uint32(14))
}
c.JSON(http.StatusOK, gin.H{
......
......@@ -23,7 +23,7 @@ import (
// @Router /we/cardbind/{id} [PUT]
// @Security ApiKeyAuth
func CardBind(c *gin.Context) {
cardUserIDInt, _ := strconv.Atoi(c.Param("id"))
cardUserIDInt, _ := strconv.ParseUint(c.Param("id"), 10, 32)
cardUserID := uint32(cardUserIDInt)
if cardUserID == 0 {
c.JSON(http.StatusOK, gin.H{
......@@ -56,8 +56,7 @@ func CardBind(c *gin.Context) {
return
}
pType, _ := strconv.Atoi(c.Query("type"))
if pType != 1 {
if c.Query("type") != "1" {
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorReqPara,
"message": api.CodeMsg[api.ErrorReqPara] + " type暂时只支持1",
......
......@@ -23,7 +23,7 @@ import (
// @Router /we/cardloss/{id} [PUT]
// @Security ApiKeyAuth
func CardLoss(c *gin.Context) {
cardUserIDInt, _ := strconv.Atoi(c.Param("id"))
cardUserIDInt, _ := strconv.ParseUint(c.Param("id"), 10, 32)
cardUserID := uint32(cardUserIDInt)
if cardUserID == 0 {
c.JSON(http.StatusOK, gin.H{
......@@ -35,8 +35,8 @@ func CardLoss(c *gin.Context) {
// 取微信用户
v, ok := c.Get("userID")
masterWeUserID := v.(uint32)
if ok != true || masterWeUserID == 0 {
weUserID := v.(uint32)
if ok != true || weUserID == 0 {
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorSystemErr,
"data": api.CodeMsg[api.ErrorSystemErr],
......@@ -46,17 +46,7 @@ func CardLoss(c *gin.Context) {
return
}
// 校验weUserID是否有cardUserID权限
if cache.CheckCardUserMaserAndSlaveWeID(cardUserID, masterWeUserID) < 2 { //todo 从userinfo查
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorUserRole,
"data": api.CodeMsg[api.ErrorUserRole],
})
return
}
pType, _ := strconv.Atoi(c.Query("type"))
if pType != 1 {
if c.Query("type") != "1" {
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorReqPara,
"message": api.CodeMsg[api.ErrorReqPara] + " type暂时只支持1",
......@@ -64,7 +54,7 @@ func CardLoss(c *gin.Context) {
return
}
status, _ := strconv.Atoi(c.Query("loss"))
status, _ := strconv.ParseUint(c.Query("loss"), 10, 8)
if status == 0 || status > 2 {
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorReqPara,
......@@ -73,14 +63,21 @@ func CardLoss(c *gin.Context) {
return
}
userInfo := cache.GetCardUserInfo(cardUserID)
if userInfo == nil { //查不到用户信息
userInfo, r := cache.GetCardUserInfoAndCheckCardUserMaserAndSlaveWeID(cardUserID, weUserID)
if r < 2 { // 校验weUserID是否有cardUserID权限
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorSystemErr,
"data": api.CodeMsg[api.ErrorSystemErr],
"code": api.ErrorUserRole,
"data": api.CodeMsg[api.ErrorUserRole],
})
return
}
//if userInfo == nil { //查不到用户信息 只要r>0,肯定不为nil
// c.JSON(http.StatusOK, gin.H{
// "code": api.ErrorSystemErr,
// "data": api.CodeMsg[api.ErrorSystemErr],
// })
// return
//}
if len(userInfo.SimCardID) == 0 { //用户没绑卡
c.JSON(http.StatusOK, gin.H{
......
......@@ -43,7 +43,7 @@ func CreateCardUser(c *gin.Context) {
"code": api.ErrorSystemErr,
"data": api.CodeMsg[api.ErrorSystemErr],
})
logger.Log.Error("strconv.Atoi(c.Param(\"userID\")",
logger.Log.Error("CreateCardUser",
zap.Reflect("c.Get(\"userID\")", v))
return
}
......
......@@ -22,7 +22,7 @@ import (
// @Router /we/cardbind/{id} [DELETE]
// @Security ApiKeyAuth
func DeleteCardBind(c *gin.Context) {
cardUserIDInt, _ := strconv.Atoi(c.Param("id"))
cardUserIDInt, _ := strconv.ParseUint(c.Param("id"), 10, 32)
cardUserID := uint32(cardUserIDInt)
if cardUserID == 0 {
c.JSON(http.StatusOK, gin.H{
......@@ -55,8 +55,7 @@ func DeleteCardBind(c *gin.Context) {
return
}
pType, _ := strconv.Atoi(c.Query("type"))
if pType != 1 {
if c.Query("type") != "1" {
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorReqPara,
"message": api.CodeMsg[api.ErrorReqPara] + " type暂时只支持1",
......
......@@ -21,7 +21,7 @@ import (
// @Router /we/carduser/{id} [DELETE]
// @Security ApiKeyAuth
func DeleteCardUser(c *gin.Context) {
cardUserIDInt, _ := strconv.Atoi(c.Param("id"))
cardUserIDInt, _ := strconv.ParseUint(c.Param("id"), 10, 32)
cardUserID := uint32(cardUserIDInt)
if cardUserID == 0 {
c.JSON(http.StatusOK, gin.H{
......
......@@ -21,7 +21,7 @@ import (
// @Router /we/bindcarduser/{id} [DELETE]
// @Security ApiKeyAuth
func DeleteSlaveBindCardUser(c *gin.Context) {
cardUserIDInt, _ := strconv.Atoi(c.Param("id"))
cardUserIDInt, _ := strconv.ParseUint(c.Param("id"), 10, 32)
cardUserID := uint32(cardUserIDInt)
if cardUserID == 0 {
c.JSON(http.StatusOK, gin.H{
......@@ -70,7 +70,7 @@ func DeleteSlaveBindCardUser(c *gin.Context) {
// @Router /we/slaveweuser/{id} [DELETE]
// @Security ApiKeyAuth
func MasterDeleteSlaveWeUser(c *gin.Context) {
cardUserIDInt, _ := strconv.Atoi(c.Param("id"))
cardUserIDInt, _ := strconv.ParseUint(c.Param("id"), 10, 32)
cardUserID := uint32(cardUserIDInt)
if cardUserID == 0 {
c.JSON(http.StatusOK, gin.H{
......@@ -102,7 +102,7 @@ func MasterDeleteSlaveWeUser(c *gin.Context) {
return
}
weUserIDInt, _ := strconv.Atoi(c.Query("id"))
weUserIDInt, _ := strconv.ParseUint(c.Query("weUserID"), 10, 32)
weUserID := uint32(weUserIDInt)
if weUserID == 0 {
c.JSON(http.StatusOK, gin.H{
......
......@@ -26,7 +26,7 @@ import (
// @Router /we/callrecord/{id} [GET]
// @Security ApiKeyAuth
func GetCallRecord(c *gin.Context) {
cardUserIDInt, _ := strconv.Atoi(c.Param("id"))
cardUserIDInt, _ := strconv.ParseUint(c.Param("id"), 10, 32)
cardUserID := uint32(cardUserIDInt)
if cardUserID == 0 {
c.JSON(http.StatusOK, gin.H{
......@@ -58,8 +58,8 @@ func GetCallRecord(c *gin.Context) {
return
}
pNum, _ := strconv.Atoi(c.Query("pnum"))
pSize, _ := strconv.Atoi(c.Query("psize"))
pNum, _ := strconv.ParseUint(c.Query("pnum"), 10, 32)
pSize, _ := strconv.ParseUint(c.Query("psize"), 10, 32)
startTime := c.Query("start")
endTime := c.Query("end")
desc := "desc"
......
......@@ -27,7 +27,7 @@ type GetCardUserAndTrendRes struct {
// @Router /we/cardusertrend/{id} [GET]
// @Security ApiKeyAuth
func GetCardUserAndTrend(c *gin.Context) {
cardUserIDInt, _ := strconv.Atoi(c.Param("id"))
cardUserIDInt, _ := strconv.ParseUint(c.Param("id"), 10, 32)
cardUserID := uint32(cardUserIDInt)
if cardUserID == 0 {
c.JSON(http.StatusOK, gin.H{
......
......@@ -25,7 +25,7 @@ type GetCardUserInfoRes struct {
// @Router /we/carduser/{id} [GET]
// @Security ApiKeyAuth
func GetCardUser(c *gin.Context) {
cardUserIDInt, _ := strconv.Atoi(c.Param("id"))
cardUserIDInt, _ := strconv.ParseUint(c.Param("id"), 10, 32)
cardUserID := uint32(cardUserIDInt)
if cardUserID == 0 {
c.JSON(http.StatusOK, gin.H{
......
......@@ -25,7 +25,7 @@ import (
// @Router /we/sharestring/{id} [GET]
// @Security ApiKeyAuth
func GetCardUserShareCode(c *gin.Context) {
cardUserIDInt, _ := strconv.Atoi(c.Param("id"))
cardUserIDInt, _ := strconv.ParseUint(c.Param("id"), 10, 32)
cardUserID := uint32(cardUserIDInt)
if cardUserID == 0 {
c.JSON(http.StatusOK, gin.H{
......@@ -63,7 +63,7 @@ func GetCardUserShareCode(c *gin.Context) {
return
}
timeMin, err := strconv.Atoi(c.Query("time"))
timeMin, err := strconv.ParseUint(c.Query("time"), 10, 8)
if err != nil {
timeMin = 30
}
......@@ -75,7 +75,7 @@ func GetCardUserShareCode(c *gin.Context) {
return
}
eTime := uint32(time.Now().Second() + timeMin*60)
eTime := uint32(time.Now().Second()) + uint32(timeMin)*60
r := rand.New(rand.NewSource(time.Now().UnixNano()))
var clear = make([]byte, 11)
......
......@@ -20,7 +20,7 @@ import (
// @Router /we/trend/{id} [GET]
// @Security ApiKeyAuth
func GetCardUserTrend(c *gin.Context) {
cardUserID, _ := strconv.Atoi(c.Param("id"))
cardUserID, _ := strconv.ParseUint(c.Param("id"), 10, 32)
if cardUserID == 0 {
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorReqPara,
......@@ -53,6 +53,6 @@ func GetCardUserTrend(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"code": api.Success,
"data": cache.GetCardUserTrendMapByCardUserID(uint32(cardUserID)), // todo 改成从缓存取
"data": cache.GetCardUserTrendMapByCardUserID(uint32(cardUserID)),
})
}
......@@ -36,7 +36,7 @@ type getPhoneCardStatusRes struct {
// @Router /we/phonecardstatus/{id} [GET]
// @Security ApiKeyAuth
func GetPhoneCardStatus(c *gin.Context) {
cardUserIDInt, _ := strconv.Atoi(c.Param("id"))
cardUserIDInt, _ := strconv.ParseUint(c.Param("id"), 10, 32)
cardUserID := uint32(cardUserIDInt)
if cardUserID == 0 {
c.JSON(http.StatusOK, gin.H{
......
......@@ -40,7 +40,7 @@ type slaveWeUserRes struct {
// @Router /we/bindcarduser/{id} [GET]
// @Security ApiKeyAuth
func GetSlaveBindCardUser(c *gin.Context) {
cardUserIDInt, _ := strconv.Atoi(c.Param("id"))
cardUserIDInt, _ := strconv.ParseUint(c.Param("id"), 10, 32)
cardUserID := uint32(cardUserIDInt)
if cardUserID == 0 {
c.JSON(http.StatusOK, gin.H{
......
......@@ -208,8 +208,8 @@ func GetStudentList(c *gin.Context) {
"code": api.ErrorSystemErr,
"data": api.CodeMsg[api.ErrorSystemErr],
})
logger.Log.Error("strconv.Atoi(c.Param(\"userID\")",
zap.String("c.Param(\"userID\")", c.Param("userID")))
logger.Log.Error("GetStudentList",
zap.Reflect("c.Get(\"userID\")", v))
return
}
......
......@@ -24,7 +24,7 @@ import (
// @Router /we/carduser/{id} [PUT]
// @Security ApiKeyAuth
func PutCardUser(c *gin.Context) {
cardUserIDInt, _ := strconv.Atoi(c.Param("id"))
cardUserIDInt, _ := strconv.ParseUint(c.Param("id"), 10, 32)
cardUserID := uint32(cardUserIDInt)
if cardUserID == 0 {
c.JSON(http.StatusOK, gin.H{
......
......@@ -243,7 +243,7 @@ func JeffWTWechat() gin.HandlerFunc {
// c.Abort()
// return
// }
// cardUserID, _ := strconv.Atoi(c.Param("id"))
// cardUserID, _ := strconv.ParseUint(c.Param("id"),10,32)
// if cardUserID == 0 {
// c.JSON(http.StatusOK, gin.H{
// "status": ErrorReqPara,
......
......@@ -88,7 +88,7 @@ func GetAreaServiceInfo(areaServiceID uint32) *model.CacheAreaServiceStruct {
zap.String("src", "GetAreaServiceInfo"))
return &areaServiceInfo
}
logger.Log.Error("GetAreaServiceInfo SELECT service_type,area_id,operator_id,status FROM b_area_service WHERE id=$1", //todo
logger.Log.Error("GetAreaServiceInfo SELECT service_type,area_id,operator_id,status FROM b_area_service WHERE id=$1",
zap.Uint32("areaServiceID", areaServiceID),
zap.Error(err),
zap.String("src", "GetAreaServiceInfo"))
......
......@@ -38,8 +38,8 @@ func InsertCardUserTrendMap(cardUserID uint32, temp *model.CacheCardUserTrendStr
CardUserTrendMap.Store(cardUserID, trends)
return
} else { // 类型断言错误
fmt.Println("InsertCardUserTrendMap CardUserTrendMap 类型断言错误")
CardUserTrendMap.Delete(cardUserID)
fmt.Println("InsertCardUserTrendMap CardUserTrendMap 类型断言错误")
}
}
......@@ -53,8 +53,8 @@ func GetCardUserTrendMapByCardUserID(cardUserID uint32) (trends []model.CacheCar
if trends, ok = v.([]model.CacheCardUserTrendStruct); ok {
return trends
} else { // 类型断言错误
fmt.Println("InsertCardUserTrendMap CardUserTrendMap 类型断言错误")
CardUserTrendMap.Delete(cardUserID)
fmt.Println("InsertCardUserTrendMap CardUserTrendMap 类型断言错误")
}
} /*else {
logger.Log.Error("CardUserTrendMap 有问题,没数据",
......
......@@ -106,6 +106,7 @@ func GetWechatCustomerTokenCreatTime(weUserID uint32) int64 {
if data, ok = v.(model.CacheWeCustomerStruct); ok {
return data.TokenCreatTime //正常情况
} else {
WechatCustomerMap.Delete(weUserID)
logger.Log.Error("WechatCustomerMap 类型断言错误",
zap.String("Src", "GetWechatCustomerTokenCreatTime"),
zap.Uint32("userID", weUserID))
......@@ -230,6 +231,7 @@ func DeleteAStudentIDInWechatCustomerMap(weUserID uint32, cardUserID uint32, mas
WechatCustomerMap.Store(weUserID, data)
return true //正常的话就该这里
} else {
WechatCustomerMap.Delete(weUserID)
logger.Log.Error("WechatCustomerMap 类型断言错误",
zap.String("Src", "DeleteAStudentIDInWechatCustomerMap"),
zap.Uint32("weUserID", weUserID))
......
......@@ -125,16 +125,16 @@ func SelectCardUserTrendsLimit20FromUCallRecordByCardUserID(cardUserID uint32) (
//CallStartAt time.Time `json:"startAt"` // 通话开始时间
//TalkTime uint8 `json:"time"` // 通话时长,单位(分钟)
func SelectWeGetCallRecord(cardUserID uint32, startTime, endTime, desc string, pNum, pSize int) (callRecord []model.SelectWeGetCallRecordStruct) {
func SelectWeGetCallRecord(cardUserID uint32, startTime, endTime, desc string, pNum, pSize uint64) (callRecord []model.SelectWeGetCallRecordStruct) {
sql := "SELECT call_start_at,called_number,called_nickname,(talk_time+59)/60,place_user FROM public.u_call_record WHERE card_user_id=$1" // 后面分表后看情况优化,现在第一筛选条件为card_user_id我认为更好
if len(startTime) > 0 && len(endTime) > 0 {
sql += " AND call_start_at BETWEEN'" + startTime + "'AND'" + endTime + "'"
}
sql += " ORDER BY call_start_at " + desc
if pSize > 0 {
sql += " LIMIT " + strconv.Itoa(pSize)
sql += " LIMIT " + strconv.FormatUint(pSize, 10)
if pNum > 0 {
sql += " OFFSET " + strconv.Itoa(pNum*pSize)
sql += " OFFSET " + strconv.FormatUint(pNum*pSize, 10)
}
}
// fmt.Println("sql:",sql)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment