|
@@ -3,21 +3,24 @@ package wechat
|
3
|
3
|
import (
|
4
|
4
|
"wechat-conf/models"
|
5
|
5
|
"wechat-conf/models/model"
|
|
6
|
+ "wechat-conf/models/sysorg"
|
6
|
7
|
"wechat-conf/models/wechat"
|
7
|
8
|
"wechat-conf/utils"
|
8
|
9
|
)
|
9
|
10
|
|
10
|
11
|
// WechatServ 用户
|
11
|
12
|
type WechatServ struct {
|
12
|
|
- ctx *utils.Context
|
13
|
|
- dao *wechat.WechatDAO
|
|
13
|
+ ctx *utils.Context
|
|
14
|
+ dao *wechat.WechatDAO
|
|
15
|
+ orgdao *sysorg.SysorgDAO
|
14
|
16
|
}
|
15
|
17
|
|
16
|
18
|
// NewWechatServ 初始化
|
17
|
19
|
func NewWechatServ(ctx *utils.Context) *WechatServ {
|
18
|
20
|
return &WechatServ{
|
19
|
|
- ctx: ctx,
|
20
|
|
- dao: wechat.NewWechatDAO(ctx),
|
|
21
|
+ ctx: ctx,
|
|
22
|
+ dao: wechat.NewWechatDAO(ctx),
|
|
23
|
+ orgdao: sysorg.NewSysorgDAO(ctx),
|
21
|
24
|
}
|
22
|
25
|
}
|
23
|
26
|
|
|
@@ -58,3 +61,32 @@ func (s *WechatServ) GetWechatConfByConfId(confid string) (*model.SysWechatConf,
|
58
|
61
|
conf, err := s.dao.GetWechatConfByConfId(confid)
|
59
|
62
|
return conf, err
|
60
|
63
|
}
|
|
64
|
+
|
|
65
|
+// UnAuthorized 取消授权
|
|
66
|
+func (s *WechatServ) UnAuthorized(appid string) error {
|
|
67
|
+ if appid == "" {
|
|
68
|
+ return nil
|
|
69
|
+ }
|
|
70
|
+ conf, err := s.dao.GetWechatConfByAppID(appid)
|
|
71
|
+ if err != nil {
|
|
72
|
+ utils.LogError("解绑获取微信信息失败:", err)
|
|
73
|
+ return err
|
|
74
|
+ }
|
|
75
|
+ if conf == nil || conf.ConfId == "" {
|
|
76
|
+ utils.LogError("解绑获取微信信息为空")
|
|
77
|
+ return nil
|
|
78
|
+ }
|
|
79
|
+ var wxConf = model.SysWechatConf{
|
|
80
|
+ ConfId: conf.ConfId,
|
|
81
|
+ Status: models.STATUS_DEL,
|
|
82
|
+ }
|
|
83
|
+ err = s.dao.UpdateWechatConf(wxConf, []string{
|
|
84
|
+ "status",
|
|
85
|
+ })
|
|
86
|
+ if err != nil {
|
|
87
|
+ return err
|
|
88
|
+ }
|
|
89
|
+ // 解绑org
|
|
90
|
+ err = s.orgdao.UnAutoOrg(conf.ConfId)
|
|
91
|
+ return err
|
|
92
|
+}
|