作者 唐旭辉

日常提交

@@ -31,6 +31,9 @@ func (c *CompanyController) DepartmentList() { @@ -31,6 +31,9 @@ func (c *CompanyController) DepartmentList() {
31 return 31 return
32 } 32 }
33 departs, err := servecompany.DepartmentListAll(companyid) 33 departs, err := servecompany.DepartmentListAll(companyid)
  34 + if len(departs) == 0 {
  35 + departs = make([]protocol.ResponseDepartmentInfo, 0)
  36 + }
34 listdata := protocol.ResponseDepartmentList{ 37 listdata := protocol.ResponseDepartmentList{
35 List: departs, 38 List: departs,
36 } 39 }
@@ -139,3 +139,10 @@ func ExistUserByPhone(phone string) bool { @@ -139,3 +139,10 @@ func ExistUserByPhone(phone string) bool {
139 ok := o.QueryTable(&User{}).Filter("phone", phone).Exist() 139 ok := o.QueryTable(&User{}).Filter("phone", phone).Exist()
140 return ok 140 return ok
141 } 141 }
  142 +
  143 +func GetUserByUCenter(ucenterId int64) (v *User, err error) {
  144 + v = &User{}
  145 + o := orm.NewOrm()
  146 + err = o.QueryTable(&User{}).Filter("user_center_id", ucenterId).One(v)
  147 + return nil, nil
  148 +}
@@ -2,7 +2,7 @@ package protocol @@ -2,7 +2,7 @@ package protocol
2 2
3 var ( 3 var (
4 NullData = struct{}{} 4 NullData = struct{}{}
5 - NullSlice = []interface{}{} 5 + // NullSlice = []interface{}{}
6 ) 6 )
7 7
8 //CustomErrParse 解析自定义错误结构体 8 //CustomErrParse 解析自定义错误结构体
@@ -93,7 +93,7 @@ func SearchErr(code string) ErrorCode { @@ -93,7 +93,7 @@ func SearchErr(code string) ErrorCode {
93 93
94 //NewReturnResponse 控制层响应返回 94 //NewReturnResponse 控制层响应返回
95 func NewReturnResponse(data interface{}, eRR error) (msg *ResponseMessage) { 95 func NewReturnResponse(data interface{}, eRR error) (msg *ResponseMessage) {
96 - // var msg *ResponseMessage 96 +
97 if data == nil { 97 if data == nil {
98 data = NullData 98 data = NullData
99 } 99 }
@@ -179,7 +179,12 @@ func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, erro @@ -179,7 +179,12 @@ func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, erro
179 companyid int64 179 companyid int64
180 userdata *models.User 180 userdata *models.User
181 ) 181 )
182 - userdata, err = models.GetUserByPhone(account) 182 + var uclientReturn *ucenter.ResponseLogin
  183 + uclientReturn, err = ucenter.RequestUCenterLogin(account, password)
  184 + if err != nil {
  185 + return logintoken, protocol.NewErrWithMessage("10021")
  186 + }
  187 + userdata, err = models.GetUserByUCenter(uclientReturn.Data.Id)
183 if err != nil { 188 if err != nil {
184 log.Debug("GetUserByPhone(%s) err:%s", account, err) 189 log.Debug("GetUserByPhone(%s) err:%s", account, err)
185 return logintoken, protocol.NewErrWithMessage("10021") 190 return logintoken, protocol.NewErrWithMessage("10021")
@@ -207,11 +212,7 @@ func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, erro @@ -207,11 +212,7 @@ func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, erro
207 } else { 212 } else {
208 companyid = companys[0].Id 213 companyid = companys[0].Id
209 } 214 }
210 - var uclientReturn *ucenter.ResponseLogin  
211 - uclientReturn, err = ucenter.RequestUCenterLogin(account, password)  
212 - if err != nil {  
213 - return logintoken, protocol.NewErrWithMessage("10021")  
214 - } 215 +
215 //更新用户数据 216 //更新用户数据
216 userdata.Accid = uclientReturn.Data.Accid 217 userdata.Accid = uclientReturn.Data.Accid
217 userdata.Icon = uclientReturn.Data.Avatar 218 userdata.Icon = uclientReturn.Data.Avatar