作者 唐旭辉

日常提交

... ... @@ -31,6 +31,9 @@ func (c *CompanyController) DepartmentList() {
return
}
departs, err := servecompany.DepartmentListAll(companyid)
if len(departs) == 0 {
departs = make([]protocol.ResponseDepartmentInfo, 0)
}
listdata := protocol.ResponseDepartmentList{
List: departs,
}
... ...
... ... @@ -139,3 +139,10 @@ func ExistUserByPhone(phone string) bool {
ok := o.QueryTable(&User{}).Filter("phone", phone).Exist()
return ok
}
func GetUserByUCenter(ucenterId int64) (v *User, err error) {
v = &User{}
o := orm.NewOrm()
err = o.QueryTable(&User{}).Filter("user_center_id", ucenterId).One(v)
return nil, nil
}
... ...
package protocol
var (
NullData = struct{}{}
NullSlice = []interface{}{}
NullData = struct{}{}
// NullSlice = []interface{}{}
)
//CustomErrParse 解析自定义错误结构体
... ... @@ -93,7 +93,7 @@ func SearchErr(code string) ErrorCode {
//NewReturnResponse 控制层响应返回
func NewReturnResponse(data interface{}, eRR error) (msg *ResponseMessage) {
// var msg *ResponseMessage
if data == nil {
data = NullData
}
... ...
... ... @@ -179,7 +179,12 @@ func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, erro
companyid int64
userdata *models.User
)
userdata, err = models.GetUserByPhone(account)
var uclientReturn *ucenter.ResponseLogin
uclientReturn, err = ucenter.RequestUCenterLogin(account, password)
if err != nil {
return logintoken, protocol.NewErrWithMessage("10021")
}
userdata, err = models.GetUserByUCenter(uclientReturn.Data.Id)
if err != nil {
log.Debug("GetUserByPhone(%s) err:%s", account, err)
return logintoken, protocol.NewErrWithMessage("10021")
... ... @@ -207,11 +212,7 @@ func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, erro
} else {
companyid = companys[0].Id
}
var uclientReturn *ucenter.ResponseLogin
uclientReturn, err = ucenter.RequestUCenterLogin(account, password)
if err != nil {
return logintoken, protocol.NewErrWithMessage("10021")
}
//更新用户数据
userdata.Accid = uclientReturn.Data.Accid
userdata.Icon = uclientReturn.Data.Avatar
... ...