diff --git a/.gitignore b/.gitignore index 45a581b..8a2913e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ cache log dist *.log -blacklist.txt \ No newline at end of file +blacklist.txt +frontend.* diff --git a/app/assistant.go b/app/assistant.go index b1c12a6..849a742 100644 --- a/app/assistant.go +++ b/app/assistant.go @@ -2,6 +2,9 @@ package app import ( "github.com/gin-gonic/gin" + "go-wechat/common/response" + "go-wechat/config" + "go-wechat/service" ) // SaveAssistant @@ -12,3 +15,22 @@ func SaveAssistant(ctx *gin.Context) { //ctx.String(http.StatusOK, "操作成功") ctx.Redirect(302, "/assistant.html") } + +// GetAssistants +// @description: 获取AI助手列表 +// @param ctx +func GetAssistants(ctx *gin.Context) { + records, err := service.GetAllAiAssistant() + if err != nil { + response.New(ctx).SetMsg("系统错误").SetError(err).Fail() + return + } + response.New(ctx).SetData(records).Success() +} + +// GetAiModels +// @description: 获取AI模型列表 +// @param ctx +func GetAiModels(ctx *gin.Context) { + response.New(ctx).SetData(config.Conf.Ai.Models).Success() +} diff --git a/app/contact.go b/app/contact.go new file mode 100644 index 0000000..f083ba7 --- /dev/null +++ b/app/contact.go @@ -0,0 +1,33 @@ +package app + +import ( + "github.com/gin-gonic/gin" + "go-wechat/common/response" + "go-wechat/service" +) + +// GetFriends +// @description: 获取好友列表 +// @param ctx +func GetFriends(ctx *gin.Context) { + // 取出所有好友列表 + friends, _, err := service.GetAllFriend() + if err != nil { + response.New(ctx).SetMsg("系统错误").SetError(err).Fail() + } + + response.New(ctx).SetData(friends).Success() +} + +// GetGroups +// @description: 获取群列表 +// @param ctx +func GetGroups(ctx *gin.Context) { + // 取出所有好友列表 + _, groups, err := service.GetAllFriend() + if err != nil { + response.New(ctx).SetMsg("系统错误").SetError(err).Fail() + } + + response.New(ctx).SetData(groups).Success() +} diff --git a/app/friend.go b/app/friend.go index 71a4212..2d4cd84 100644 --- a/app/friend.go +++ b/app/friend.go @@ -3,7 +3,7 @@ package app import ( "github.com/gin-gonic/gin" "go-wechat/client" - "go-wechat/entity" + "go-wechat/model/entity" "gorm.io/gorm" "log" "net/http" diff --git a/common/current/robot.go b/common/current/robot.go index dae5fa6..55a33e9 100644 --- a/common/current/robot.go +++ b/common/current/robot.go @@ -1,7 +1,7 @@ package current import ( - "go-wechat/model" + "go-wechat/model/model" plugin "go-wechat/plugin" ) diff --git a/common/response/fail.go b/common/response/fail.go new file mode 100644 index 0000000..6bf45d7 --- /dev/null +++ b/common/response/fail.go @@ -0,0 +1,16 @@ +package response + +// Fail +// @description: 失败响应 +// @receiver r +// @param data +// @return err +func (r *Response) Fail() { + if r.msg == "" { + r.msg = "系统错误" + } + if r.code == 0 { + r.code = fail + } + r.Result() +} diff --git a/common/response/page.go b/common/response/page.go new file mode 100644 index 0000000..3db7794 --- /dev/null +++ b/common/response/page.go @@ -0,0 +1,43 @@ +package response + +// PageData +// @description: 分页数据通用结构体 +type PageData[T any] struct { + Current int `json:"current"` // 当前页码 + Size int `json:"size"` // 每页数量 + Total int64 `json:"total"` // 总数 + TotalPage int `json:"totalPage"` // 总页数 + Records T `json:"records"` // 返回数据 +} + +// NewPageData +// @description: 创建分页数据 +// @param records any 数据列表 +// @param total int64 总数 +// @param current int 页码 +// @param size int 页数量 +// @return data PageData[any] 分页数据 +func NewPageData(records any, total int64, current, size int) (data PageData[any]) { + // 处理一下页码、页数量 + if current == -1 { + current = 1 + size = int(total) + } + // 计算总页码 + totalPage := 0 + if total > 0 { + upPage := 0 + if int(total)%size > 0 { + upPage = 1 + } + totalPage = (int(total) / size) + upPage + } + data = PageData[any]{ + Current: current, + Size: size, + Total: total, + TotalPage: totalPage, + Records: records, + } + return +} diff --git a/common/response/response.go b/common/response/response.go new file mode 100644 index 0000000..602772d --- /dev/null +++ b/common/response/response.go @@ -0,0 +1,81 @@ +package response + +import ( + "github.com/gin-gonic/gin" + "go-wechat/common/validator" + "net/http" +) + +// 定义状态码 +const ( + fail = http.StatusInternalServerError + success = http.StatusOK +) + +// Response +// @description: 返回结果 +type Response struct { + ctx *gin.Context + code int + data any + msg string + errMsg string +} + +// New +// @description: 返回结果实现 +// @param ctx +// @return Response +func New(ctx *gin.Context) *Response { + var r Response + r.ctx = ctx + + return &r +} + +// SetCode +// @description: 设置状态码 +// @receiver r +// @param code +// @return *Response +func (r *Response) SetCode(code int) *Response { + r.code = code + return r +} + +// SetData +// @description: 设置返回数据 +// @receiver r +// @param data +// @return *Response +func (r *Response) SetData(data any) *Response { + r.data = data + return r +} + +// SetMsg +// @description: 设置返回消息 +// @receiver r +// @param msg +// @return *Response +func (r *Response) SetMsg(msg string) *Response { + r.msg = msg + return r +} + +// SetError +// @description: 设置错误信息 +// @receiver r +// @param err +// @return *Response +func (r *Response) SetError(err error) *Response { + if err != nil { + ne := validator.Translate(err) + if ne != nil { + r.errMsg = ne.Error() + } else { + r.errMsg = err.Error() + } + } + return r +} diff --git a/common/response/result.go b/common/response/result.go new file mode 100644 index 0000000..fc0fca9 --- /dev/null +++ b/common/response/result.go @@ -0,0 +1,27 @@ +package response + +// Result +// @description: 响应 +// @receiver r +// @param code int 状态码 +// @param data any 数据 +// @param msg string 消息 +// @param err string 错误信息 +// @return err error 返回数据错误 +func (r *Response) Result() { + type resp struct { + Code int `json:"code"` + Data any `json:"data"` + Msg string `json:"message"` + ErrMsg string `json:"errMsg,omitempty"` + } + + rd := resp{ + r.code, + r.data, + r.msg, + r.errMsg, + } + // 返回数据 + r.ctx.JSON(r.code, rd) +} diff --git a/common/response/success.go b/common/response/success.go new file mode 100644 index 0000000..b7267ec --- /dev/null +++ b/common/response/success.go @@ -0,0 +1,16 @@ +package response + +// Success +// @description: 成功响应 +// @receiver r +// @param data +// @return err +func (r *Response) Success() { + if r.msg == "" { + r.msg = "success" + } + if r.code == 0 { + r.code = success + } + r.Result() +} diff --git a/common/validator/validator.go b/common/validator/validator.go new file mode 100644 index 0000000..b16ae99 --- /dev/null +++ b/common/validator/validator.go @@ -0,0 +1,56 @@ +package validator + +import ( + "errors" + "github.com/gin-gonic/gin/binding" + "github.com/go-playground/locales/zh" + ut "github.com/go-playground/universal-translator" + "github.com/go-playground/validator/v10" + zhTranslations "github.com/go-playground/validator/v10/translations/zh" + "log" + "strings" +) + +var ( + uni *ut.UniversalTranslator + validate *validator.Validate + trans ut.Translator +) + +// Init +// @description: 初始化验证器 +func Init() { + //注册翻译器 + zhTranslator := zh.New() + uni = ut.New(zhTranslator, zhTranslator) + + trans, _ = uni.GetTranslator("zh") + + //获取gin的校验器 + validate = binding.Validator.Engine().(*validator.Validate) + //注册翻译器 + err := zhTranslations.RegisterDefaultTranslations(validate, trans) + if err != nil { + log.Panicf("注册翻译器失败:%v", err) + } +} + +// Translate +// @description: 翻译错误信息 +// @param err +// @return error +func Translate(err error) error { + errorMsg := make([]string, 0) + + var ves validator.ValidationErrors + ok := errors.As(err, &ves) + if !ok { + return err + } + + for _, e := range ves { + errorMsg = append(errorMsg, e.Translate(trans)) + } + + return errors.New(strings.Join(errorMsg, ";")) +} diff --git a/config.yaml b/config.yaml index 7c73209..122c82e 100644 --- a/config.yaml +++ b/config.yaml @@ -20,7 +20,7 @@ system: # 微信HOOK配置 wechat: # 微信HOOK接口地址 - host: 10.0.0.73:19088 + host: 10.0.0.79:19088 # 微信容器映射出来的vnc页面地址,没有就不填 # vncUrl: http://192.168.1.175:19087/vnc_lite.html # 是否在启动的时候自动设置hook服务的回调 diff --git a/initialization/plugin.go b/initialization/plugin.go index 515fd51..debf3c7 100644 --- a/initialization/plugin.go +++ b/initialization/plugin.go @@ -2,7 +2,7 @@ package initialization import ( "go-wechat/common/current" - "go-wechat/model" + "go-wechat/model/model" plugin "go-wechat/plugin" "go-wechat/plugin/plugins" "go-wechat/service" diff --git a/initialization/wechat.go b/initialization/wechat.go index 08f99b5..9e9a246 100644 --- a/initialization/wechat.go +++ b/initialization/wechat.go @@ -4,7 +4,7 @@ import ( "github.com/go-resty/resty/v2" "go-wechat/common/current" "go-wechat/config" - "go-wechat/model" + model2 "go-wechat/model/model" "log" ) @@ -12,7 +12,7 @@ import ( // @description: 初始化微信机器人信息 func InitWechatRobotInfo() { // 获取数据 - var base model.Response[model.RobotUserInfo] + var base model2.Response[model2.RobotUserInfo] _, err := resty.New().R(). SetHeader("Content-Type", "application/json;chartset=utf-8"). SetResult(&base). diff --git a/entity/aiassistant.go b/model/entity/aiassistant.go similarity index 100% rename from entity/aiassistant.go rename to model/entity/aiassistant.go diff --git a/entity/friend.go b/model/entity/friend.go similarity index 100% rename from entity/friend.go rename to model/entity/friend.go diff --git a/entity/message.go b/model/entity/message.go similarity index 100% rename from entity/message.go rename to model/entity/message.go diff --git a/entity/plugindata.go b/model/entity/plugindata.go similarity index 100% rename from entity/plugindata.go rename to model/entity/plugindata.go diff --git a/model/friend.go b/model/model/friend.go similarity index 100% rename from model/friend.go rename to model/model/friend.go diff --git a/model/leigod.go b/model/model/leigod.go similarity index 100% rename from model/leigod.go rename to model/model/leigod.go diff --git a/model/message.go b/model/model/message.go similarity index 95% rename from model/message.go rename to model/model/message.go index 951ee0f..8202245 100644 --- a/model/message.go +++ b/model/model/message.go @@ -163,3 +163,15 @@ func (m Message) CleanContentStartWith(prefix string) bool { return strings.HasPrefix(content, prefix) } + +// IsInvitationJoinGroup +// @description: 是否是邀请入群消息 +// @receiver m +// @return bool +func (m Message) IsInvitationJoinGroup() bool { + if m.Type == types.MsgTypeApp { + // 解析xml + + } + return false +} diff --git a/model/news.go b/model/model/news.go similarity index 100% rename from model/news.go rename to model/model/news.go diff --git a/model/response.go b/model/model/response.go similarity index 100% rename from model/response.go rename to model/model/response.go diff --git a/model/userinfo.go b/model/model/userinfo.go similarity index 100% rename from model/userinfo.go rename to model/model/userinfo.go diff --git a/vo/friend.go b/model/vo/friend.go similarity index 100% rename from vo/friend.go rename to model/vo/friend.go diff --git a/vo/leigod.go b/model/vo/leigod.go similarity index 100% rename from vo/leigod.go rename to model/vo/leigod.go diff --git a/vo/message.go b/model/vo/message.go similarity index 100% rename from vo/message.go rename to model/vo/message.go diff --git a/mq/handler.go b/mq/handler.go index 3350a87..1eac7c3 100644 --- a/mq/handler.go +++ b/mq/handler.go @@ -3,7 +3,7 @@ package mq import ( "encoding/json" "go-wechat/common/current" - "go-wechat/model" + "go-wechat/model/model" "go-wechat/types" "log" "strings" diff --git a/plugin/plugin.go b/plugin/plugin.go index 1ae565d..f5572dc 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -1,7 +1,7 @@ package plugin import ( - "go-wechat/model" + "go-wechat/model/model" ) // MessageHandler 消息处理函数 diff --git a/plugin/plugins/ai.go b/plugin/plugins/ai.go index 2619c11..b409e25 100644 --- a/plugin/plugins/ai.go +++ b/plugin/plugins/ai.go @@ -8,7 +8,7 @@ import ( "go-wechat/client" "go-wechat/common/current" "go-wechat/config" - "go-wechat/entity" + "go-wechat/model/entity" "go-wechat/plugin" "go-wechat/service" "go-wechat/types" diff --git a/plugin/plugins/command/ai.go b/plugin/plugins/command/ai.go index db1aa92..4e7115c 100644 --- a/plugin/plugins/command/ai.go +++ b/plugin/plugins/command/ai.go @@ -3,7 +3,7 @@ package command import ( "fmt" "go-wechat/client" - "go-wechat/entity" + "go-wechat/model/entity" "go-wechat/utils" "log" "strings" diff --git a/plugin/plugins/command/leigod.go b/plugin/plugins/command/leigod.go index db5e66d..fb830e3 100644 --- a/plugin/plugins/command/leigod.go +++ b/plugin/plugins/command/leigod.go @@ -5,10 +5,10 @@ import ( "errors" "fmt" "go-wechat/client" - "go-wechat/entity" - "go-wechat/model" + "go-wechat/model/entity" + "go-wechat/model/model" + "go-wechat/model/vo" "go-wechat/utils" - "go-wechat/vo" "gorm.io/gorm" "log" "strings" diff --git a/plugin/plugins/save2db.go b/plugin/plugins/save2db.go index 18d294b..555cd41 100644 --- a/plugin/plugins/save2db.go +++ b/plugin/plugins/save2db.go @@ -1,7 +1,7 @@ package plugins import ( - "go-wechat/entity" + "go-wechat/model/entity" "go-wechat/plugin" "go-wechat/service" "time" diff --git a/plugin/plugins/welconenew.go b/plugin/plugins/welconenew.go index 2a89d1c..d5f80a6 100644 --- a/plugin/plugins/welconenew.go +++ b/plugin/plugins/welconenew.go @@ -3,7 +3,7 @@ package plugins import ( "go-wechat/client" "go-wechat/config" - "go-wechat/entity" + "go-wechat/model/entity" "go-wechat/plugin" "go-wechat/utils" ) diff --git a/router/router.go b/router/router.go index d216360..c1b9203 100644 --- a/router/router.go +++ b/router/router.go @@ -9,31 +9,49 @@ import ( // @description: 初始化路由 // @param g func Init(g *gin.Engine) { - g.GET("/", func(ctx *gin.Context) { - // 重定向到index.html - ctx.Redirect(302, "/index.html") - }) + //g.GET("/", func(ctx *gin.Context) { + // // 重定向到index.html + // ctx.Redirect(302, "/index.html") + //}) g.GET("/index.html", app.Index) // 首页 g.GET("/friend.html", app.Friend) // 好友列表 g.GET("/group.html", app.Group) // 群组列表 g.GET("/assistant.html", app.Assistant) // AI角色 - g.GET("/404.html", app.PageNotFound) // 群组列表 + //g.GET("/404.html", app.PageNotFound) // 群组列表 // 接口 api := g.Group("/api") - api.PUT("/ai/status", app.ChangeEnableAiStatus) // 修改是否开启AI状态 - api.POST("/ai/model", app.ChangeUseAiModel) // 修改使用的AI模型 - api.POST("/ai/assistant", app.ChangeUseAiAssistant) // 修改使用的AI助手 - api.PUT("/welcome/status", app.ChangeEnableWelcomeStatus) // 修改是否开启迎新状态 - api.PUT("/command/status", app.ChangeEnableCommandStatus) // 修改是否开启指令状态 - api.PUT("/news/status", app.ChangeEnableNewsStatus) // 修改是否开启早报状态 - api.PUT("/grouprank/status", app.ChangeEnableGroupRankStatus) // 修改是否开启水群排行榜状态 - api.PUT("/grouprank/skip", app.ChangeSkipGroupRankStatus) // 修改是否跳过水群排行榜状态 - api.GET("/group/users", app.GetGroupUsers) // 获取群成员列表 - api.PUT("/summary/status", app.ChangeEnableSummaryStatus) // 修改是否开启群聊总结状态 - api.PUT("/clearmembers", app.AutoClearMembers) // 自动清理群成员 - api.POST("/assistant", app.SaveAssistant) // 保存AI助手 + contact := api.Group("/contact") // 通讯录 + { + contact.GET("/friend", app.GetFriends) // 获取好友列表 + contact.GET("/group", app.GetGroups) // 获取群组列表 + profile := contact.Group("/profile") // 配置 + { + profile.PUT("/ai/status", app.ChangeEnableAiStatus) // 修改是否开启AI状态 + profile.POST("/ai/model", app.ChangeUseAiModel) // 修改使用的AI模型 + profile.POST("/ai/assistant", app.ChangeUseAiAssistant) // 修改使用的AI助手 + profile.PUT("/welcome/status", app.ChangeEnableWelcomeStatus) // 修改是否开启迎新 + profile.PUT("/command/status", app.ChangeEnableCommandStatus) // 修改是否开启指令 + profile.PUT("/news/status", app.ChangeEnableNewsStatus) // 修改是否开启早报 + profile.PUT("/grouprank/status", app.ChangeEnableGroupRankStatus) // 修改是否开启水群排行榜 + profile.PUT("/summary/status", app.ChangeEnableSummaryStatus) // 修改是否开启群聊总结 + profile.PUT("/clearmembers", app.AutoClearMembers) // 自动清理群成员 + } + + group := contact.Group("/group") // 群组 + { + group.GET("/users", app.GetGroupUsers) // 获取群成员列表 + group.PUT("/grouprank/skip", app.ChangeSkipGroupRankStatus) // 修改是否跳过水群排行榜状态 + } + } + + system := api.Group("/system") // 系统设置 + { + system.GET("/assistant", app.GetAssistants) // 获取AI助手列表 + system.POST("/assistant", app.SaveAssistant) // 保存AI助手 + system.GET("/models", app.GetAiModels) // 获取AI模型列表 + } } diff --git a/service/aiassistant.go b/service/aiassistant.go index f5608fe..2d1ba52 100644 --- a/service/aiassistant.go +++ b/service/aiassistant.go @@ -2,7 +2,7 @@ package service import ( "go-wechat/client" - "go-wechat/entity" + "go-wechat/model/entity" ) // GetAllAiAssistant diff --git a/service/friend.go b/service/friend.go index 0a40f95..1729f34 100644 --- a/service/friend.go +++ b/service/friend.go @@ -2,8 +2,8 @@ package service import ( "go-wechat/client" - "go-wechat/entity" - "go-wechat/vo" + "go-wechat/model/entity" + "go-wechat/model/vo" "log" "strings" ) diff --git a/service/group.go b/service/group.go index 1475497..b25ff6a 100644 --- a/service/group.go +++ b/service/group.go @@ -2,7 +2,7 @@ package service import ( "go-wechat/client" - "go-wechat/vo" + "go-wechat/model/vo" ) // GetGroupUsersByGroupId diff --git a/service/message.go b/service/message.go index 7708aa2..c3171bb 100644 --- a/service/message.go +++ b/service/message.go @@ -2,8 +2,8 @@ package service import ( "go-wechat/client" - "go-wechat/entity" - "go-wechat/vo" + "go-wechat/model/entity" + "go-wechat/model/vo" "log" "os" "strconv" diff --git a/tasks/cleargroupuser/cleargroupuser.go b/tasks/cleargroupuser/cleargroupuser.go index a415533..6223502 100644 --- a/tasks/cleargroupuser/cleargroupuser.go +++ b/tasks/cleargroupuser/cleargroupuser.go @@ -3,7 +3,7 @@ package cleargroupuser import ( "fmt" "go-wechat/client" - "go-wechat/entity" + "go-wechat/model/entity" "go-wechat/service" "go-wechat/utils" "log" diff --git a/tasks/friends/friends.go b/tasks/friends/friends.go index b423839..96d0fad 100644 --- a/tasks/friends/friends.go +++ b/tasks/friends/friends.go @@ -6,8 +6,8 @@ import ( "go-wechat/client" "go-wechat/common/constant" "go-wechat/config" - "go-wechat/entity" - "go-wechat/model" + "go-wechat/model/entity" + model2 "go-wechat/model/model" "go-wechat/utils" "gorm.io/gorm" "log" @@ -24,7 +24,7 @@ var hc = resty.New() // Sync // @description: 同步好友列表 func Sync() { - var base model.Response[[]model.FriendItem] + var base model2.Response[[]model2.FriendItem] resp, err := hc.R(). SetHeader("Content-Type", "application/json;chartset=utf-8"). @@ -155,7 +155,7 @@ func Sync() { // @description: 同步群成员 // @param gid func syncGroupUsers(tx *gorm.DB, gid string) { - var baseResp model.Response[model.GroupUser] + var baseResp model2.Response[model2.GroupUser] // 组装参数 param := map[string]any{ @@ -242,8 +242,8 @@ func syncGroupUsers(tx *gorm.DB, gid string) { // @param wxid // @return ent // @return err -func getContactProfile(wxid string) (ent model.ContactProfile, err error) { - var baseResp model.Response[model.ContactProfile] +func getContactProfile(wxid string) (ent model2.ContactProfile, err error) { + var baseResp model2.Response[model2.ContactProfile] // 组装参数 param := map[string]any{ diff --git a/tasks/summary/summary.go b/tasks/summary/summary.go index 94c3aa1..1316b31 100644 --- a/tasks/summary/summary.go +++ b/tasks/summary/summary.go @@ -5,9 +5,9 @@ import ( "fmt" "github.com/sashabaranov/go-openai" "go-wechat/config" + "go-wechat/model/vo" "go-wechat/service" "go-wechat/utils" - "go-wechat/vo" "log" "strings" ) diff --git a/tasks/watergroup/month.go b/tasks/watergroup/month.go index f3b8c81..09a9035 100644 --- a/tasks/watergroup/month.go +++ b/tasks/watergroup/month.go @@ -4,7 +4,7 @@ import ( "fmt" "go-wechat/client" "go-wechat/config" - "go-wechat/entity" + "go-wechat/model/entity" "go-wechat/service" "go-wechat/utils" "log" diff --git a/tasks/watergroup/week.go b/tasks/watergroup/week.go index b4902c0..084c21e 100644 --- a/tasks/watergroup/week.go +++ b/tasks/watergroup/week.go @@ -4,7 +4,7 @@ import ( "fmt" "go-wechat/client" "go-wechat/config" - "go-wechat/entity" + "go-wechat/model/entity" "go-wechat/service" "go-wechat/utils" "log" diff --git a/tasks/watergroup/year.go b/tasks/watergroup/year.go index 8ea50ba..130a6ca 100644 --- a/tasks/watergroup/year.go +++ b/tasks/watergroup/year.go @@ -4,7 +4,7 @@ import ( "fmt" "go-wechat/client" "go-wechat/config" - "go-wechat/entity" + "go-wechat/model/entity" "go-wechat/service" "go-wechat/utils" "log" diff --git a/tasks/watergroup/yesterday.go b/tasks/watergroup/yesterday.go index e6b3863..0142baf 100644 --- a/tasks/watergroup/yesterday.go +++ b/tasks/watergroup/yesterday.go @@ -4,7 +4,7 @@ import ( "fmt" "go-wechat/client" "go-wechat/config" - "go-wechat/entity" + "go-wechat/model/entity" "go-wechat/service" "go-wechat/utils" "log" diff --git a/tcpserver/parse.go b/tcpserver/parse.go index 981d543..576a0ab 100644 --- a/tcpserver/parse.go +++ b/tcpserver/parse.go @@ -3,7 +3,7 @@ package tcpserver import ( "encoding/json" "go-wechat/common/current" - "go-wechat/model" + "go-wechat/model/model" "go-wechat/types" "log" "net" diff --git a/utils/leigod.go b/utils/leigod.go index c20f628..ec5af7b 100644 --- a/utils/leigod.go +++ b/utils/leigod.go @@ -6,16 +6,16 @@ import ( "errors" "fmt" "github.com/go-resty/resty/v2" - "go-wechat/model" + model2 "go-wechat/model/model" "log" ) // LeiGod // @description: 雷神加速器相关接口 type LeiGod interface { - Login() error // 登录 - Info() (model.LeiGodUserInfoResp, error) // 获取用户信息 - Pause() error // 暂停加速 + Login() error // 登录 + Info() (model2.LeiGodUserInfoResp, error) // 获取用户信息 + Pause() error // 暂停加速 } type leiGod struct { @@ -59,7 +59,7 @@ func (l *leiGod) Login() (err error) { } pbs, _ := json.Marshal(param) - var loginResp model.Response[any] + var loginResp model2.Response[any] var resp *resty.Response res := resty.New() @@ -84,7 +84,7 @@ func (l *leiGod) Login() (err error) { return } - var loginInfo model.LeiGodLoginResp + var loginInfo model2.LeiGodLoginResp if err = json.Unmarshal(bs, &loginInfo); err != nil { return } @@ -100,7 +100,7 @@ func (l *leiGod) Login() (err error) { // @description: 获取用户信息 // @receiver l // @return string -func (l *leiGod) Info() (ui model.LeiGodUserInfoResp, err error) { +func (l *leiGod) Info() (ui model2.LeiGodUserInfoResp, err error) { // 组装参数 param := map[string]any{ "account_token": l.token, @@ -109,7 +109,7 @@ func (l *leiGod) Info() (ui model.LeiGodUserInfoResp, err error) { } pbs, _ := json.Marshal(param) - var userInfoResp model.Response[model.LeiGodUserInfoResp] + var userInfoResp model2.Response[model2.LeiGodUserInfoResp] var resp *resty.Response res := resty.New() @@ -145,7 +145,7 @@ func (l *leiGod) Pause() (err error) { } pbs, _ := json.Marshal(param) - var pauseResp model.Response[any] + var pauseResp model2.Response[any] var resp *resty.Response res := resty.New() diff --git a/utils/news.go b/utils/news.go index 6d6c60b..aeaeb21 100644 --- a/utils/news.go +++ b/utils/news.go @@ -2,7 +2,7 @@ package utils import ( "github.com/go-resty/resty/v2" - "go-wechat/model" + "go-wechat/model/model" "log" )