Commit 5eb4784d by zhangjiec

1

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