作者 yangfu

重构 去掉repository

@@ -5,19 +5,19 @@ import "sync" @@ -5,19 +5,19 @@ import "sync"
5 //全局 5 //全局
6 var ( 6 var (
7 once sync.Once 7 once sync.Once
8 - User IUserRepository  
9 - UserAuth IUserAuthRepository  
10 - Commend ICommendRepository  
11 - Company ICompanyRepository  
12 - Department IDepartmentRepository  
13 - Position IPositionRepository  
14 - Chance IChanceRepository  
15 - ChanceFavorite IChanceFavoriteRepository  
16 - Comment ICommentRepository  
17 - Message IMessageRepository  
18 - UserCompany IUserCompanyRepository  
19 - UserPosition IUserPositionRepository  
20 - UserDepartment IUserDepartmentRepository 8 + //User IUserRepository
  9 + //UserAuth IUserAuthRepository
  10 + //Commend ICommendRepository
  11 + //Company ICompanyRepository
  12 + //Department IDepartmentRepository
  13 + //Position IPositionRepository
  14 + //Chance IChanceRepository
  15 + //ChanceFavorite IChanceFavoriteRepository
  16 + //Comment ICommentRepository
  17 + //Message IMessageRepository
  18 + //UserCompany IUserCompanyRepository
  19 + //UserPosition IUserPositionRepository
  20 + //UserDepartment IUserDepartmentRepository
21 ) 21 )
22 22
23 func init() { 23 func init() {
@@ -25,24 +25,24 @@ func init() { @@ -25,24 +25,24 @@ func init() {
25 } 25 }
26 26
27 func InitRepository() { 27 func InitRepository() {
28 - User = &UserRepository{}  
29 - UserAuth = &UserAuthRepository{}  
30 - Commend = &CommendRepository{}  
31 - Company = &CompanyRepository{}  
32 - Department = &DepartmentRepository{}  
33 - Position = &PositionRepository{}  
34 - Chance = &ChanceRepository{}  
35 - Comment = &CommentRepository{}  
36 - Message = &MessageRepository{}  
37 - ChanceFavorite = &ChanceFavoriteRepository{}  
38 - UserCompany = &UserCompanyRepository{}  
39 - UserPosition = &UserPositionRepository{}  
40 - UserDepartment = &UserDepartmentRepository{} 28 + //User = &UserRepository{}
  29 + //UserAuth = &UserAuthRepository{}
  30 + //Commend = &CommendRepository{}
  31 + //Company = &CompanyRepository{}
  32 + //Department = &DepartmentRepository{}
  33 + //Position = &PositionRepository{}
  34 + //Chance = &ChanceRepository{}
  35 + //Comment = &CommentRepository{}
  36 + //Message = &MessageRepository{}
  37 + //ChanceFavorite = &ChanceFavoriteRepository{}
  38 + //UserCompany = &UserCompanyRepository{}
  39 + //UserPosition = &UserPositionRepository{}
  40 + //UserDepartment = &UserDepartmentRepository{}
41 } 41 }
42 42
43 func InitRepositoryMock() { 43 func InitRepositoryMock() {
44 once.Do(func() { 44 once.Do(func() {
45 - User = &UserMockRepository{}  
46 - UserAuth = &UserAuthMockRepository{} 45 + //User = &UserMockRepository{}
  46 + //UserAuth = &UserAuthMockRepository{}
47 }) 47 })
48 } 48 }
@@ -2,36 +2,41 @@ package protocol @@ -2,36 +2,41 @@ package protocol
2 2
3 import "opp/models" 3 import "opp/models"
4 4
  5 +//机会审核
  6 +//审核对象
5 const ( 7 const (
6 - MarkFlag_Zan = 1  
7 - MarkFlag_Collect = 2 8 + AuditByDepartmentor = iota + 1 //部门长
  9 + AuditByUser //指定用户
  10 + AuditByRole //指定角色
  11 + AuditBySpecailUser //特殊人员
8 ) 12 )
9 13
  14 +//审核类型
10 const ( 15 const (
11 - UnMarkFlag = 0  
12 - MarkFlag = 1 //是否标记 /点赞 /收藏 16 + FlowTypeNormal = iota + 1 //正常审核流程
  17 + FlowTypeSpecail //特殊审核流程
13 ) 18 )
14 19
  20 +//审核人为空
15 const ( 21 const (
16 - AuditFlowType_Departmentor = iota + 1 //部门长  
17 - AuditFlowType_User //指定用户  
18 - AuditFlowType_Role //指定角色  
19 - AuditFlowType_SpecailUser //特殊人员 22 + NoApproverPass = 1 //自动通过
  23 + NoApproverToAdmin = 2 //转交给公司管理员
20 ) 24 )
21 25
  26 +//机会
  27 +//审核状态
22 const ( 28 const (
23 - FlowType_Normal = iota + 1  
24 - FlowType_Specail 29 + ReviewStatusWait = 0 //待处理
  30 + ReviewStatusAuditging = 1 //待审核
  31 + ReviewStatusReturn = 2 //退回
  32 + ReviewStatusPass = 3 //通过
25 ) 33 )
26 34
  35 +//公开状态
27 const ( 36 const (
28 - NoApprover_Pass = 1  
29 - NoApprover_ToAdmin = 2  
30 -)  
31 -  
32 -const (  
33 - StaticType_Question = 1 << iota  
34 - StaticType_Question2 37 + NoPublic = 0 //未公开
  38 + PublicToDepartment = 1 //部门公开
  39 + PublicToCompany = 2 //公司公开
35 ) 40 )
36 41
37 /*Favorite */ 42 /*Favorite */
  1 +package protocol
  2 +
  3 +/*
  4 + 全局变量声明
  5 +*/
  6 +
  7 +//机会点赞收藏
  8 +const (
  9 + MarkFlagZan = 1 //点赞标记
  10 + MarkFlagCollect = 2 //收藏标记
  11 +)
  12 +
  13 +//标记状态
  14 +const (
  15 + UnMarkFlag = 0 //取消标记
  16 + MarkFlag = 1 //标记 /点赞 /收藏
  17 +)
  18 +
  19 +//有效状态
  20 +const (
  21 + InValid = 0 //无效
  22 + Valid = 1 //有效
  23 +)
@@ -29,7 +29,7 @@ func init() { @@ -29,7 +29,7 @@ func init() {
29 beego.AddNamespace(nsH5) 29 beego.AddNamespace(nsH5)
30 30
31 beego.SetStaticPath("/file/opp", beego.AppConfig.String("source_path")) 31 beego.SetStaticPath("/file/opp", beego.AppConfig.String("source_path"))
32 - beego.SetStaticPath("/log/opp", beego.AppConfig.String("aliyun_logs_access")) 32 + beego.SetStaticPath("/log", beego.AppConfig.String("aliyun_logs_access"))
33 beego.Handler("/metrics", promhttp.Handler()) 33 beego.Handler("/metrics", promhttp.Handler())
34 beego.Handler("/upgrage", http.HandlerFunc(websocket.Upgrage)) 34 beego.Handler("/upgrage", http.HandlerFunc(websocket.Upgrage))
35 } 35 }
@@ -4,7 +4,6 @@ import ( @@ -4,7 +4,6 @@ import (
4 "bytes" 4 "bytes"
5 "fmt" 5 "fmt"
6 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" 6 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
7 - "opp/internal/repository"  
8 "opp/internal/utils" 7 "opp/internal/utils"
9 "opp/models" 8 "opp/models"
10 "opp/protocol" 9 "opp/protocol"
@@ -139,7 +138,7 @@ func GetChance(chanceId int64, companyId int64) (v *protocol.ChanceDetail, err e @@ -139,7 +138,7 @@ func GetChance(chanceId int64, companyId int64) (v *protocol.ChanceDetail, err e
139 baseUserInfo *protocol.BaseUserInfo 138 baseUserInfo *protocol.BaseUserInfo
140 ) 139 )
141 140
142 - if c, err = repository.Chance.GetChanceById(chanceId); err != nil { 141 + if c, err = models.GetChanceById(chanceId); err != nil {
143 return 142 return
144 } 143 }
145 if baseUserInfo, err = GetUserBaseInfo(c.UserId, companyId); err != nil { 144 if baseUserInfo, err = GetUserBaseInfo(c.UserId, companyId); err != nil {
@@ -13,7 +13,6 @@ import ( @@ -13,7 +13,6 @@ import (
13 13
14 "gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/uid" 14 "gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/uid"
15 15
16 - "opp/internal/repository"  
17 "opp/models" 16 "opp/models"
18 "opp/protocol" 17 "opp/protocol"
19 s_sms "opp/services/sms" 18 s_sms "opp/services/sms"
@@ -89,14 +88,14 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp @@ -89,14 +88,14 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp
89 88
90 Success: 89 Success:
91 { 90 {
92 - userAuth, err = repository.UserAuth.GetUserAuthByUserId(user.Id, 1) 91 + userAuth, err = models.GetUserAuthByUserId(user.Id, 1)
93 if err != nil { 92 if err != nil {
94 if err == orm.ErrNoRows { 93 if err == orm.ErrNoRows {
95 userAuth = &models.UserAuth{ 94 userAuth = &models.UserAuth{
96 UserId: user.Id, 95 UserId: user.Id,
97 DeviceType: 1, //int8(header.DeviceType), 96 DeviceType: 1, //int8(header.DeviceType),
98 } 97 }
99 - repository.UserAuth.AddUserAuth(userAuth) 98 + models.AddUserAuth(userAuth)
100 } else { 99 } else {
101 log.Error(err) 100 log.Error(err)
102 return 101 return
@@ -111,12 +110,12 @@ Success: @@ -111,12 +110,12 @@ Success:
111 user.NickName = getUserResponse.NickName 110 user.NickName = getUserResponse.NickName
112 user.Accid = getUserResponse.Accid 111 user.Accid = getUserResponse.Accid
113 user.UserCenterId = getUserResponse.Id 112 user.UserCenterId = getUserResponse.Id
114 - if err = repository.User.UpdateUserInfo(user); err != nil { 113 + if err = models.UpdateUsersById(user); err != nil {
115 log.Error(err) 114 log.Error(err)
116 return 115 return
117 } 116 }
118 userAuth.AuthCodeExp = time.Now().Add(time.Second * protocol.TokenExpire) 117 userAuth.AuthCodeExp = time.Now().Add(time.Second * protocol.TokenExpire)
119 - if err = repository.UserAuth.UpdateUserAuthById(userAuth); err != nil { 118 + if err = models.UpdateUserAuthById(userAuth); err != nil {
120 return 119 return
121 } 120 }
122 rsp = &protocol.LoginResponse{AuthCode: userAuth.AuthCode} 121 rsp = &protocol.LoginResponse{AuthCode: userAuth.AuthCode}
@@ -179,7 +178,7 @@ func UpdateDevice(header *protocol.RequestHeader, request *protocol.UpdateDevice @@ -179,7 +178,7 @@ func UpdateDevice(header *protocol.RequestHeader, request *protocol.UpdateDevice
179 userAuth *models.UserAuth 178 userAuth *models.UserAuth
180 updateMap = make(map[string]interface{}) 179 updateMap = make(map[string]interface{})
181 ) 180 )
182 - if userAuth, err = repository.UserAuth.GetUserAuthByUserId(header.Uid, header.DeviceType); err != nil { 181 + if userAuth, err = models.GetUserAuthByUserId(header.Uid, header.DeviceType); err != nil {
183 log.Error(err) 182 log.Error(err)
184 return 183 return
185 } 184 }
@@ -204,7 +203,7 @@ func AccessToken(request *protocol.AccessTokenRequest) (rsp *protocol.AccessToke @@ -204,7 +203,7 @@ func AccessToken(request *protocol.AccessTokenRequest) (rsp *protocol.AccessToke
204 // err = protocol.NewErrWithMessage(101, err) 203 // err = protocol.NewErrWithMessage(101, err)
205 // return 204 // return
206 //} 205 //}
207 - userAuth, err = repository.UserAuth.GetUserAuthByAuthCode(request.AuthCode) 206 + userAuth, err = models.GetUserByAuthCode(request.AuthCode)
208 if err != nil { 207 if err != nil {
209 log.Error(err) 208 log.Error(err)
210 err = protocol.NewErrWithMessage(4139, err) 209 err = protocol.NewErrWithMessage(4139, err)
@@ -214,7 +213,7 @@ func AccessToken(request *protocol.AccessTokenRequest) (rsp *protocol.AccessToke @@ -214,7 +213,7 @@ func AccessToken(request *protocol.AccessTokenRequest) (rsp *protocol.AccessToke
214 userAuth.RefreshToken = uid.NewV1().StringNoDash() 213 userAuth.RefreshToken = uid.NewV1().StringNoDash()
215 userAuth.AccessTokenExp = time.Now().Add(protocol.TokenExpire * time.Second) 214 userAuth.AccessTokenExp = time.Now().Add(protocol.TokenExpire * time.Second)
216 userAuth.RefreshTokenExp = time.Now().Add(protocol.TokenExpire * time.Second) 215 userAuth.RefreshTokenExp = time.Now().Add(protocol.TokenExpire * time.Second)
217 - if err = repository.UserAuth.UpdateUserAuthById(userAuth); err != nil { 216 + if err = models.UpdateUserAuthById(userAuth); err != nil {
218 log.Error(err) 217 log.Error(err)
219 return 218 return
220 } 219 }
@@ -237,13 +236,13 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT @@ -237,13 +236,13 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT
237 // protocol.NewErrWithMessage(101, err) 236 // protocol.NewErrWithMessage(101, err)
238 // return 237 // return
239 //} 238 //}
240 - userAuth, err = repository.UserAuth.GetUserAuthByRefreshToken(request.RefreshToken) 239 + userAuth, err = models.GetUserAuthByRefreshToken(request.RefreshToken)
241 if err != nil { 240 if err != nil {
242 protocol.NewErrWithMessage(4139, err) 241 protocol.NewErrWithMessage(4139, err)
243 return 242 return
244 } 243 }
245 userAuth.AccessToken = uid.NewV1().StringNoDash() 244 userAuth.AccessToken = uid.NewV1().StringNoDash()
246 - if err = repository.UserAuth.UpdateUserAuthById(userAuth); err != nil { 245 + if err = models.UpdateUserAuthById(userAuth); err != nil {
247 return 246 return
248 } 247 }
249 rsp = &protocol.RefreshTokenResponse{ 248 rsp = &protocol.RefreshTokenResponse{
@@ -263,7 +262,7 @@ func CheckToken(request *protocol.CheckTokenRequest) (rsp *protocol.CheckTokenRe @@ -263,7 +262,7 @@ func CheckToken(request *protocol.CheckTokenRequest) (rsp *protocol.CheckTokenRe
263 err = common.NewErrorWithMsg(4141, "token not empty") 262 err = common.NewErrorWithMsg(4141, "token not empty")
264 return 263 return
265 } 264 }
266 - userAuth, err = repository.UserAuth.GetUserAuthByToken(request.Token) 265 + userAuth, err = models.GetUserAuthByToken(request.Token)
267 if err != nil { 266 if err != nil {
268 log.Error("查询失败: token:", request.Token, err) 267 log.Error("查询失败: token:", request.Token, err)
269 err = protocol.NewErrWithMessage(4141, err) 268 err = protocol.NewErrWithMessage(4141, err)
@@ -433,7 +432,7 @@ func Revoke(header *protocol.RequestHeader, request *protocol.RevokeRequest) (rs @@ -433,7 +432,7 @@ func Revoke(header *protocol.RequestHeader, request *protocol.RevokeRequest) (rs
433 updateMap = make(map[string]interface{}) 432 updateMap = make(map[string]interface{})
434 ) 433 )
435 //rsp =&protocol.RevokeResponse{} 434 //rsp =&protocol.RevokeResponse{}
436 - if userAuth, err = repository.UserAuth.GetUserAuthByUserId(header.Uid, header.DeviceType); err != nil { 435 + if userAuth, err = models.GetUserAuthByUserId(header.Uid, header.DeviceType); err != nil {
437 log.Error(err) 436 log.Error(err)
438 return 437 return
439 } 438 }
1 package auth 1 package auth
2 2
3 import ( 3 import (
4 - "opp/internal/repository"  
5 "testing" 4 "testing"
6 5
7 "opp/protocol" 6 "opp/protocol"
@@ -10,7 +9,7 @@ import ( @@ -10,7 +9,7 @@ import (
10 9
11 func init() { 10 func init() {
12 tests.Init() 11 tests.Init()
13 - repository.InitRepositoryMock() 12 + //repository.InitRepositoryMock()
14 } 13 }
15 14
16 func Test_SmsCode(t *testing.T) { 15 func Test_SmsCode(t *testing.T) {
@@ -7,7 +7,6 @@ import ( @@ -7,7 +7,6 @@ import (
7 "gitlab.fjmaimaimai.com/mmm-go/gocomm/common" 7 "gitlab.fjmaimaimai.com/mmm-go/gocomm/common"
8 "gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen" 8 "gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen"
9 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" 9 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
10 - "opp/internal/repository"  
11 "opp/internal/utils" 10 "opp/internal/utils"
12 "opp/models" 11 "opp/models"
13 "opp/protocol" 12 "opp/protocol"
@@ -22,7 +21,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) @@ -22,7 +21,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest)
22 chance *protocol.ChanceDetail 21 chance *protocol.ChanceDetail
23 ) 22 )
24 rsp = &protocol.FavoriteResponse{} 23 rsp = &protocol.FavoriteResponse{}
25 - favorites, rsp.Total, err = repository.ChanceFavorite.GetChanceFavorites( 24 + favorites, rsp.Total, err = models.GetChanceFavorites(
26 header.Uid, 25 header.Uid,
27 header.CompanyId, 26 header.CompanyId,
28 request.ObjectType, 27 request.ObjectType,
@@ -46,8 +45,8 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) @@ -46,8 +45,8 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest)
46 log.Error(err) 45 log.Error(err)
47 return 46 return
48 } 47 }
49 - chance.IsZan = (f.MarkFlag & protocol.MarkFlag_Zan) == protocol.MarkFlag_Zan  
50 - chance.IsCollect = (f.MarkFlag & protocol.MarkFlag_Collect) == protocol.MarkFlag_Collect 48 + chance.IsZan = (f.MarkFlag & protocol.MarkFlagZan) == protocol.MarkFlagZan
  49 + chance.IsCollect = (f.MarkFlag & protocol.MarkFlagCollect) == protocol.MarkFlagCollect
51 item.Favorite = chance 50 item.Favorite = chance
52 case protocol.SourceTypeComment: 51 case protocol.SourceTypeComment:
53 } 52 }
@@ -67,12 +66,12 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc @@ -67,12 +66,12 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
67 table string = "comment" 66 table string = "comment"
68 ) 67 )
69 rsp = &protocol.SympathyActionResponse{} 68 rsp = &protocol.SympathyActionResponse{}
70 - if chanceFavoirte, err = repository.ChanceFavorite.GetChanceFavorite(header.Uid, header.CompanyId, request.Id, request.SourceType); err != nil && err != orm.ErrNoRows { 69 + if chanceFavoirte, err = models.GetChanceFavorite(header.Uid, header.CompanyId, request.Id, request.SourceType); err != nil && err != orm.ErrNoRows {
71 log.Error(err) 70 log.Error(err)
72 return 71 return
73 } 72 }
74 if request.SourceType == protocol.SourceTypeChance { 73 if request.SourceType == protocol.SourceTypeChance {
75 - if chance, err = repository.Chance.GetChanceById(request.Id); err != nil { 74 + if chance, err = models.GetChanceById(request.Id); err != nil {
76 log.Error("机会不存在", err) 75 log.Error("机会不存在", err)
77 return 76 return
78 } 77 }
@@ -81,28 +80,28 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc @@ -81,28 +80,28 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
81 } 80 }
82 if chanceFavoirte != nil { 81 if chanceFavoirte != nil {
83 exists = true 82 exists = true
84 - if request.MarkType == protocol.MarkFlag_Zan {  
85 - if request.SympathyType == protocol.UnMarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlag_Zan) == 0 { 83 + if request.MarkType == protocol.MarkFlagZan {
  84 + if request.SympathyType == protocol.UnMarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlagZan) == 0 {
86 err = protocol.NewSuccessWithMessage("已经取消赞,不能重复取消赞") 85 err = protocol.NewSuccessWithMessage("已经取消赞,不能重复取消赞")
87 return 86 return
88 } 87 }
89 - if request.SympathyType == protocol.MarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlag_Zan) > 0 { 88 + if request.SympathyType == protocol.MarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlagZan) > 0 {
90 err = protocol.NewSuccessWithMessage("已经赞,不能重复点赞") 89 err = protocol.NewSuccessWithMessage("已经赞,不能重复点赞")
91 return 90 return
92 } 91 }
93 - } else if request.MarkType == protocol.MarkFlag_Collect {  
94 - if request.SympathyType == protocol.UnMarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlag_Collect) == 0 { 92 + } else if request.MarkType == protocol.MarkFlagCollect {
  93 + if request.SympathyType == protocol.UnMarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlagCollect) == 0 {
95 err = protocol.NewSuccessWithMessage("已经取消收藏,不能重复取消收藏") 94 err = protocol.NewSuccessWithMessage("已经取消收藏,不能重复取消收藏")
96 return 95 return
97 } 96 }
98 - if request.SympathyType == protocol.MarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlag_Collect) > 0 { 97 + if request.SympathyType == protocol.MarkFlag && (chanceFavoirte.MarkFlag&protocol.MarkFlagCollect) > 0 {
99 err = protocol.NewSuccessWithMessage("已经收藏,不能重复收藏") 98 err = protocol.NewSuccessWithMessage("已经收藏,不能重复收藏")
100 return 99 return
101 } 100 }
102 } 101 }
103 } 102 }
104 if exists { 103 if exists {
105 - if err = repository.ChanceFavorite.UpdateChanceFavorite(header.Uid, header.CompanyId, request.Id, 1<<(uint(request.MarkType-1))); err != nil { 104 + if err = models.UpdateChanceFavorite(header.Uid, header.CompanyId, request.Id, 1<<(uint(request.MarkType-1))); err != nil {
106 log.Error(request.MarkType, err) 105 log.Error(request.MarkType, err)
107 return 106 return
108 } 107 }
@@ -120,7 +119,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc @@ -120,7 +119,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
120 CreateAt: time.Now(), 119 CreateAt: time.Now(),
121 EnableStatus: 1, 120 EnableStatus: 1,
122 } 121 }
123 - if _, err = repository.ChanceFavorite.AddChanceFavorite(chanceFavoirte); err != nil { 122 + if _, err = models.AddChanceFavorite(chanceFavoirte); err != nil {
124 log.Error(err) 123 log.Error(err)
125 return 124 return
126 } else { 125 } else {
@@ -129,7 +128,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc @@ -129,7 +128,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
129 } 128 }
130 END: 129 END:
131 { 130 {
132 - if request.MarkType != protocol.MarkFlag_Zan { 131 + if request.MarkType != protocol.MarkFlagZan {
133 return 132 return
134 } 133 }
135 if request.SympathyType == protocol.UnMarkFlag { 134 if request.SympathyType == protocol.UnMarkFlag {
@@ -394,7 +393,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat @@ -394,7 +393,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat
394 //1.检查是否是特殊审核人 393 //1.检查是否是特殊审核人
395 for i := range configs { 394 for i := range configs {
396 config := configs[i] 395 config := configs[i]
397 - if groupId == 0 && config.FlowType == protocol.FlowType_Normal { 396 + if groupId == 0 && config.FlowType == protocol.FlowTypeNormal {
398 groupId = config.AuditGroupId 397 groupId = config.AuditGroupId
399 continue 398 continue
400 } 399 }
@@ -428,7 +427,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat @@ -428,7 +427,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat
428 return 427 return
429 } 428 }
430 429
431 - if company, err = repository.Company.GetCompanyById(header.CompanyId); err != nil { 430 + if company, err = models.GetCompanyById(header.CompanyId); err != nil {
432 log.Error(err) 431 log.Error(err)
433 return 432 return
434 } 433 }
@@ -443,17 +442,17 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat @@ -443,17 +442,17 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat
443 config := configs[i] 442 config := configs[i]
444 var userIds []int64 443 var userIds []int64
445 switch config.AuditFlowType { 444 switch config.AuditFlowType {
446 - case protocol.AuditFlowType_Departmentor: 445 + case protocol.AuditByDepartmentor:
447 if userIds, err = getDepartmentors(header); err != nil { 446 if userIds, err = getDepartmentors(header); err != nil {
448 log.Error(err) 447 log.Error(err)
449 return 448 return
450 } 449 }
451 - case protocol.AuditFlowType_User: 450 + case protocol.AuditByUser:
452 if err = json.Unmarshal([]byte(config.ToUser), &userIds); err != nil { 451 if err = json.Unmarshal([]byte(config.ToUser), &userIds); err != nil {
453 log.Error(err) 452 log.Error(err)
454 return 453 return
455 } 454 }
456 - case protocol.AuditFlowType_Role: 455 + case protocol.AuditByRole:
457 456
458 } 457 }
459 if len(userIds) == 0 { //当前步骤没有用户 默认一个空审核人 458 if len(userIds) == 0 { //当前步骤没有用户 默认一个空审核人
@@ -461,7 +460,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat @@ -461,7 +460,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat
461 } 460 }
462 for j := 0; j < len(userIds); j++ { 461 for j := 0; j < len(userIds); j++ {
463 uid := userIds[j] 462 uid := userIds[j]
464 - if uid == 0 && auditConfig.NoApprover == protocol.NoApprover_ToAdmin { //审批人为空 转交给管理员 463 + if uid == 0 && auditConfig.NoApprover == protocol.NoApproverToAdmin { //审批人为空 转交给管理员
465 uid = company.AdminId 464 uid = company.AdminId
466 } 465 }
467 if uid == header.Uid { //审核人自己 转交给管理员 466 if uid == header.Uid { //审核人自己 转交给管理员
@@ -508,7 +507,7 @@ func getDepartmentors(header *protocol.RequestHeader) (ids []int64, err error) { @@ -508,7 +507,7 @@ func getDepartmentors(header *protocol.RequestHeader) (ids []int64, err error) {
508 var ( 507 var (
509 departments []*protocol.Department 508 departments []*protocol.Department
510 ) 509 )
511 - if err = repository.UserDepartment.GetUserDepartment(header.Uid, header.CompanyId, &departments); err != nil { 510 + if err = models.GetUserDepartments(header.Uid, header.CompanyId, &departments); err != nil {
512 log.Error(err) 511 log.Error(err)
513 return 512 return
514 } 513 }
@@ -543,7 +542,7 @@ func getParentDepartmentors(pid int) (ids []int64) { @@ -543,7 +542,7 @@ func getParentDepartmentors(pid int) (ids []int64) {
543 if department.ParentId == 0 { 542 if department.ParentId == 0 {
544 return 543 return
545 } 544 }
546 - if department, err = repository.Department.GetDepartmentById(pid); err != nil { 545 + if department, err = models.GetDepartmentById(pid); err != nil {
547 log.Error(err) 546 log.Error(err)
548 return 547 return
549 } 548 }
@@ -4,7 +4,6 @@ import ( @@ -4,7 +4,6 @@ import (
4 "fmt" 4 "fmt"
5 "gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen" 5 "gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen"
6 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" 6 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
7 - "opp/internal/repository"  
8 "opp/internal/utils" 7 "opp/internal/utils"
9 "opp/models" 8 "opp/models"
10 "opp/protocol" 9 "opp/protocol"
@@ -23,14 +22,14 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest) @@ -23,14 +22,14 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest)
23 ) 22 )
24 switch request.SourceType { 23 switch request.SourceType {
25 case protocol.SourceTypeChance: 24 case protocol.SourceTypeChance:
26 - if chance, err = repository.Chance.GetChanceById(request.Id); err != nil { 25 + if chance, err = models.GetChanceById(request.Id); err != nil {
27 log.Error(err) 26 log.Error(err)
28 return 27 return
29 } 28 }
30 updateTable = chance 29 updateTable = chance
31 updateMap["CommentTotal"] = chance.CommentTotal + 1 30 updateMap["CommentTotal"] = chance.CommentTotal + 1
32 case protocol.SourceTypeComment: 31 case protocol.SourceTypeComment:
33 - if comment, err = repository.Comment.GetCommentById(request.Id); err != nil { 32 + if comment, err = models.GetCommentById(request.Id); err != nil {
34 log.Error(err) 33 log.Error(err)
35 return 34 return
36 } 35 }
@@ -47,7 +46,7 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest) @@ -47,7 +46,7 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest)
47 CreateAt: time.Now(), 46 CreateAt: time.Now(),
48 SourceId: request.Id, 47 SourceId: request.Id,
49 } 48 }
50 - if _, err = repository.Comment.AddComment(newComment); err != nil { 49 + if _, err = models.AddComment(newComment); err != nil {
51 log.Error(err) 50 log.Error(err)
52 return 51 return
53 } 52 }
@@ -74,7 +73,7 @@ func IComments(header *protocol.RequestHeader, request *protocol.ICommentsReques @@ -74,7 +73,7 @@ func IComments(header *protocol.RequestHeader, request *protocol.ICommentsReques
74 baseUserInfo *protocol.BaseUserInfo 73 baseUserInfo *protocol.BaseUserInfo
75 total int 74 total int
76 ) 75 )
77 - if comments, total, err = repository.Comment.GetComments(header.UserId, protocol.SourceTypeChance, 0, request.LastId, request.PageSize); err != nil { 76 + if comments, total, err = models.GetComments(header.UserId, protocol.SourceTypeChance, 0, request.LastId, request.PageSize); err != nil {
78 log.Error(err) 77 log.Error(err)
79 return 78 return
80 } 79 }
@@ -112,7 +111,7 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest) @@ -112,7 +111,7 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest)
112 total int 111 total int
113 exists bool 112 exists bool
114 ) 113 )
115 - if comments, total, err = repository.Comment.GetComments(header.UserId, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil { 114 + if comments, total, err = models.GetComments(header.UserId, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil {
116 log.Error(err) 115 log.Error(err)
117 return 116 return
118 } 117 }
@@ -134,7 +133,7 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest) @@ -134,7 +133,7 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest)
134 ZanTotal: comment.ZanTotal, 133 ZanTotal: comment.ZanTotal,
135 CommentTotal: comment.CommentTotal, 134 CommentTotal: comment.CommentTotal,
136 } 135 }
137 - if exists, _ = repository.ChanceFavorite.ExitsChanceFavorite(header.UserId, header.CompanyId, comment.Id, protocol.MarkFlag_Zan); exists { 136 + if exists, _ = models.ExitsChanceFavorite(header.UserId, header.CompanyId, comment.Id, protocol.MarkFlagZan); exists {
138 item.IsZan = 1 137 item.IsZan = 1
139 } 138 }
140 rsp.Comments = append(rsp.Comments, item) 139 rsp.Comments = append(rsp.Comments, item)
@@ -150,7 +149,7 @@ func CommentDetailsSingle(header *protocol.RequestHeader, request *protocol.Comm @@ -150,7 +149,7 @@ func CommentDetailsSingle(header *protocol.RequestHeader, request *protocol.Comm
150 exists bool 149 exists bool
151 ) 150 )
152 rsp = &protocol.CommentDetailsSingleResponse{} 151 rsp = &protocol.CommentDetailsSingleResponse{}
153 - if comment, err = repository.Comment.GetCommentById(request.Id); err != nil { 152 + if comment, err = models.GetCommentById(request.Id); err != nil {
154 log.Error(err) 153 log.Error(err)
155 return 154 return
156 } 155 }
@@ -167,7 +166,7 @@ func CommentDetailsSingle(header *protocol.RequestHeader, request *protocol.Comm @@ -167,7 +166,7 @@ func CommentDetailsSingle(header *protocol.RequestHeader, request *protocol.Comm
167 ZanTotal: comment.ZanTotal, 166 ZanTotal: comment.ZanTotal,
168 CommentTotal: comment.CommentTotal, 167 CommentTotal: comment.CommentTotal,
169 } 168 }
170 - if exists, _ = repository.ChanceFavorite.ExitsChanceFavorite(header.UserId, header.CompanyId, comment.Id, protocol.MarkFlag_Zan); exists { 169 + if exists, _ = models.ExitsChanceFavorite(header.UserId, header.CompanyId, comment.Id, protocol.MarkFlagZan); exists {
171 rsp.Comment.IsZan = 1 170 rsp.Comment.IsZan = 1
172 } 171 }
173 return 172 return
@@ -2,7 +2,6 @@ package commend @@ -2,7 +2,6 @@ package commend
2 2
3 import ( 3 import (
4 "gitlab.fjmaimaimai.com/mmm-go/gocomm/time" 4 "gitlab.fjmaimaimai.com/mmm-go/gocomm/time"
5 - "opp/internal/repository"  
6 "opp/models" 5 "opp/models"
7 "opp/protocol" 6 "opp/protocol"
8 "opp/services/agg" 7 "opp/services/agg"
@@ -15,11 +14,11 @@ func Commend(header *protocol.RequestHeader, request *protocol.CommendRequest) ( @@ -15,11 +14,11 @@ func Commend(header *protocol.RequestHeader, request *protocol.CommendRequest) (
15 commends []*models.Commend 14 commends []*models.Commend
16 ) 15 )
17 rsp = &protocol.CommendResponse{} 16 rsp = &protocol.CommendResponse{}
18 - user, err = repository.User.GetUsersById(header.Uid) 17 + user, err = models.GetUsersById(header.Uid)
19 if err != nil { 18 if err != nil {
20 return 19 return
21 } 20 }
22 - if commends, rsp.Total, err = repository.Commend.GetCommends(header.CompanyId, request.LastId, request.PageSize); err != nil { 21 + if commends, rsp.Total, err = models.GetCommends(header.CompanyId, request.LastId, request.PageSize); err != nil {
23 return 22 return
24 } 23 }
25 for i := 0; i < len(commends); i++ { 24 for i := 0; i < len(commends); i++ {
@@ -3,7 +3,6 @@ package department @@ -3,7 +3,6 @@ package department
3 import ( 3 import (
4 "encoding/json" 4 "encoding/json"
5 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" 5 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
6 - "opp/internal/repository"  
7 "opp/models" 6 "opp/models"
8 "opp/protocol" 7 "opp/protocol"
9 ) 8 )
@@ -16,7 +15,7 @@ func Departments(header *protocol.RequestHeader, request *protocol.DepartmentsRe @@ -16,7 +15,7 @@ func Departments(header *protocol.RequestHeader, request *protocol.DepartmentsRe
16 rsp = &protocol.DepartmentsResponse{} 15 rsp = &protocol.DepartmentsResponse{}
17 switch request.Type { 16 switch request.Type {
18 case protocol.DepartmentAll: 17 case protocol.DepartmentAll:
19 - if departments, err = repository.Department.GetDepartmentByCompanyId(header.CompanyId); err != nil { 18 + if departments, err = models.GetDepartmentByCompanyId(header.CompanyId); err != nil {
20 log.Error(err) 19 log.Error(err)
21 return 20 return
22 } 21 }
@@ -7,7 +7,6 @@ import ( @@ -7,7 +7,6 @@ import (
7 "github.com/astaxie/beego/orm" 7 "github.com/astaxie/beego/orm"
8 "gitlab.fjmaimaimai.com/mmm-go/gocomm/common" 8 "gitlab.fjmaimaimai.com/mmm-go/gocomm/common"
9 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" 9 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
10 - "opp/internal/repository"  
11 "opp/internal/utils" 10 "opp/internal/utils"
12 "opp/models" 11 "opp/models"
13 "opp/protocol" 12 "opp/protocol"
@@ -17,7 +16,7 @@ import ( @@ -17,7 +16,7 @@ import (
17 func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCenterRequest) (rsp *protocol.MessageCenterResponse, err error) { 16 func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCenterRequest) (rsp *protocol.MessageCenterResponse, err error) {
18 var () 17 var ()
19 rsp = &protocol.MessageCenterResponse{} 18 rsp = &protocol.MessageCenterResponse{}
20 - err = repository.Message.GetUserMsgTotals(header.Uid, header.CompanyId, request.MsgType, &rsp.Totals) 19 + err = models.GetUserMsgTotals(header.Uid, header.CompanyId, request.MsgType, &rsp.Totals)
21 return 20 return
22 } 21 }
23 22
@@ -25,7 +24,7 @@ func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCent @@ -25,7 +24,7 @@ func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCent
25 func MsgCenterRead(header *protocol.RequestHeader, request *protocol.MsgCenterReadRequest) (rsp *protocol.MsgCenterReadResponse, err error) { 24 func MsgCenterRead(header *protocol.RequestHeader, request *protocol.MsgCenterReadRequest) (rsp *protocol.MsgCenterReadResponse, err error) {
26 var () 25 var ()
27 //rsp =&protocol.MsgCenterReadResponse{} 26 //rsp =&protocol.MsgCenterReadResponse{}
28 - err = repository.Message.UpdateUserMsgSetRead(header.Uid, header.CompanyId, request.MsgType, request.MsgId) 27 + err = models.UpdateUserMsgSetRead(header.Uid, header.CompanyId, request.MsgType, request.MsgId)
29 if err != nil { 28 if err != nil {
30 log.Error(err) 29 log.Error(err)
31 } 30 }
@@ -35,7 +34,7 @@ func MsgCenterRead(header *protocol.RequestHeader, request *protocol.MsgCenterRe @@ -35,7 +34,7 @@ func MsgCenterRead(header *protocol.RequestHeader, request *protocol.MsgCenterRe
35 //标记全部已读 34 //标记全部已读
36 func MsgCenterAllRead(header *protocol.RequestHeader, request *protocol.MsgCenterAllReadRequest) (rsp *protocol.MsgCenterAllReadResponse, err error) { 35 func MsgCenterAllRead(header *protocol.RequestHeader, request *protocol.MsgCenterAllReadRequest) (rsp *protocol.MsgCenterAllReadResponse, err error) {
37 var () 36 var ()
38 - err = repository.Message.UpdateUserMsgSetRead(header.Uid, header.CompanyId, request.MsgType, 0) 37 + err = models.UpdateUserMsgSetRead(header.Uid, header.CompanyId, request.MsgType, 0)
39 if err != nil { 38 if err != nil {
40 log.Error(err) 39 log.Error(err)
41 } 40 }
@@ -48,7 +47,7 @@ func MsgInteractive(header *protocol.RequestHeader, request *protocol.MsgInterac @@ -48,7 +47,7 @@ func MsgInteractive(header *protocol.RequestHeader, request *protocol.MsgInterac
48 userMsgs []*models.UserMsg 47 userMsgs []*models.UserMsg
49 ) 48 )
50 rsp = &protocol.MsgInteractiveResponse{} 49 rsp = &protocol.MsgInteractiveResponse{}
51 - userMsgs, rsp.Total, err = repository.Message.GetUserMsgs(header.Uid, header.CompanyId, request.MsgType, request.SourceType, request.LastId, request.PageSize) 50 + userMsgs, rsp.Total, err = models.GetUserMsgs(header.Uid, header.CompanyId, request.MsgType, request.SourceType, request.LastId, request.PageSize)
52 if err != nil { 51 if err != nil {
53 log.Error(err) 52 log.Error(err)
54 return 53 return
@@ -5,7 +5,6 @@ import ( @@ -5,7 +5,6 @@ import (
5 "github.com/astaxie/beego/orm" 5 "github.com/astaxie/beego/orm"
6 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" 6 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
7 "net/http" 7 "net/http"
8 - "opp/internal/repository"  
9 "opp/internal/utils" 8 "opp/internal/utils"
10 "opp/models" 9 "opp/models"
11 "opp/protocol" 10 "opp/protocol"
@@ -22,7 +21,7 @@ func CheckSmsCode(header *protocol.RequestHeader, request *protocol.CheckSmsCode @@ -22,7 +21,7 @@ func CheckSmsCode(header *protocol.RequestHeader, request *protocol.CheckSmsCode
22 ) 21 )
23 //rsp =&protocol.CheckSmsCodeResponse{} 22 //rsp =&protocol.CheckSmsCodeResponse{}
24 23
25 - if user, err = repository.User.GetUsersById(header.Uid); err != nil { 24 + if user, err = models.GetUsersById(header.Uid); err != nil {
26 log.Error(err) 25 log.Error(err)
27 return 26 return
28 } 27 }
@@ -42,7 +41,7 @@ func ChangePhone(header *protocol.RequestHeader, request *protocol.ChangePhoneRe @@ -42,7 +41,7 @@ func ChangePhone(header *protocol.RequestHeader, request *protocol.ChangePhoneRe
42 user *models.User 41 user *models.User
43 result bool 42 result bool
44 ) 43 )
45 - if user, err = repository.User.GetUsersById(header.Uid); err != nil { 44 + if user, err = models.GetUsersById(header.Uid); err != nil {
46 log.Error(err) 45 log.Error(err)
47 return 46 return
48 } 47 }
@@ -93,7 +92,7 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo @@ -93,7 +92,7 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo
93 err = protocol.NewErrWithMessage(2027) 92 err = protocol.NewErrWithMessage(2027)
94 return 93 return
95 } 94 }
96 - if user, err = repository.User.GetUsersById(header.Uid); err != nil { 95 + if user, err = models.GetUsersById(header.Uid); err != nil {
97 log.Error(err) 96 log.Error(err)
98 return 97 return
99 } 98 }
@@ -144,7 +143,7 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass @@ -144,7 +143,7 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass
144 err = protocol.NewErrWithMessage(2027) 143 err = protocol.NewErrWithMessage(2027)
145 return 144 return
146 } 145 }
147 - if user, err = repository.User.GetUsersById(header.Uid); err != nil { 146 + if user, err = models.GetUsersById(header.Uid); err != nil {
148 log.Error(err) 147 log.Error(err)
149 return 148 return
150 } 149 }
@@ -203,12 +202,12 @@ func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompa @@ -203,12 +202,12 @@ func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompa
203 userCompany *models.UserCompany 202 userCompany *models.UserCompany
204 auth *models.UserAuth 203 auth *models.UserAuth
205 ) 204 )
206 - if userCompany, err = repository.UserCompany.GetUserCompanyByUserId(header.Uid, int64(request.CompanyId)); err != nil { 205 + if userCompany, err = models.GetUserCompanyByUserId(header.Uid, int64(request.CompanyId)); err != nil {
207 log.Error(err) 206 log.Error(err)
208 err = protocol.NewErrWithMessage(4201) //找不到这家公司 207 err = protocol.NewErrWithMessage(4201) //找不到这家公司
209 return 208 return
210 } 209 }
211 - if auth, err = repository.UserAuth.GetUserAuthByUserId(header.Uid, protocol.DeviceType); err != nil { 210 + if auth, err = models.GetUserAuthByUserId(header.Uid, protocol.DeviceType); err != nil {
212 log.Error(err) 211 log.Error(err)
213 return 212 return
214 } 213 }
@@ -233,17 +232,35 @@ func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompa @@ -233,17 +232,35 @@ func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompa
233 //用户信息 232 //用户信息
234 func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) (rsp *protocol.UserInfoResponse, err error) { 233 func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) (rsp *protocol.UserInfoResponse, err error) {
235 var ( 234 var (
236 - companyId = header.CompanyId 235 + companyId int64
237 userCompany *models.UserCompany 236 userCompany *models.UserCompany
238 userAuth *models.UserAuth 237 userAuth *models.UserAuth
239 userBaseAgg *protocol.UserBaseInfoAggregation 238 userBaseAgg *protocol.UserBaseInfoAggregation
240 companys []*models.Company 239 companys []*models.Company
241 ) 240 )
242 - if userCompany, err = models.GetUserCompanys(header.Uid); err != nil { 241 + if companys, err = models.GetCompanyByPermission(header.Uid); err != nil {
243 log.Error(err) 242 log.Error(err)
244 return 243 return
245 } 244 }
  245 +
  246 + //保证用户登录期间公司有权限
  247 + if len(companys) == 0 {
  248 + //无权限
  249 + err = protocol.NewErrWithMessage(2002)
  250 + return
  251 + }
  252 + for i := range companys {
  253 + if companys[i].Id == header.CompanyId {
  254 + companyId = header.CompanyId
  255 + break
  256 + }
  257 + }
  258 +
246 if companyId == 0 { 259 if companyId == 0 {
  260 + if userCompany, err = models.GetUserCompanys(header.Uid); err != nil {
  261 + log.Error(err)
  262 + return
  263 + }
247 if userAuth, err = models.GetUserAuthByUserId(header.Uid, protocol.DeviceType); err != nil { 264 if userAuth, err = models.GetUserAuthByUserId(header.Uid, protocol.DeviceType); err != nil {
248 log.Error(err) 265 log.Error(err)
249 return 266 return
@@ -256,10 +273,6 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) @@ -256,10 +273,6 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest)
256 companyId = int64(userCompany.CompanyId) 273 companyId = int64(userCompany.CompanyId)
257 header.UserId = userCompany.Id 274 header.UserId = userCompany.Id
258 } 275 }
259 - if companys, err = models.GetCompanyByPermission(header.Uid); err != nil {  
260 - log.Error(err)  
261 - return  
262 - }  
263 if userBaseAgg, err = agg.GetUserBaseInfoAggregation(header.UserId, companyId); err != nil { 276 if userBaseAgg, err = agg.GetUserBaseInfoAggregation(header.UserId, companyId); err != nil {
264 return 277 return
265 } 278 }