修改小bug
This commit is contained in:
parent
3850c224c9
commit
07239a556b
|
@ -1,5 +1,7 @@
|
|||
package model
|
||||
|
||||
import "database/sql"
|
||||
|
||||
type WechatUser struct {
|
||||
OpenID string `json:"open_id"`
|
||||
Remark string `json:"remark"`
|
||||
|
@ -33,6 +35,9 @@ func FindWechatUser(openID string) (*WechatUser, error) {
|
|||
ping()
|
||||
w := new(WechatUser)
|
||||
err := db.QueryRow(`select * from wechat_user where open_id=?;`, openID).Scan(&w.OpenID, &w.Remark, &w.Status, &w.LastRequestTime)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, err
|
||||
}
|
||||
return w, err
|
||||
}
|
||||
|
||||
|
|
12
push/wx.go
12
push/wx.go
|
@ -1,6 +1,7 @@
|
|||
package push
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
@ -273,8 +274,9 @@ func handleTextPass(id, msg string) {
|
|||
* @param msg
|
||||
*/
|
||||
func handleEventUseRequest(id, msg string) {
|
||||
count := model.WechatUserCount(id)
|
||||
if count < 0 {
|
||||
user, err := model.FindWechatUser(id)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
err := model.AddWechatUser(&model.WechatUser{
|
||||
OpenID: id,
|
||||
Remark: "",
|
||||
|
@ -287,7 +289,11 @@ func handleEventUseRequest(id, msg string) {
|
|||
}
|
||||
sendMsg(conf.GetConfig().Wechat.SuperOpenID, fmt.Sprintf("用户%v申请使用测试号,通过则回复信息:\n通过 %v\n\n拒绝则回复:\n拒绝 %v", id, id, id))
|
||||
} else {
|
||||
user, err := model.FindWechatUser(id)
|
||||
log.Errorln("查询用户出现未知错误" + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
} else {
|
||||
if err != nil {
|
||||
log.Errorln("查询wechat用户错误" + err.Error())
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue