作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/opp into dev

... ... @@ -90,6 +90,7 @@ func GetRequestHeader(ctx *context.Context) *protocol.RequestHeader {
h.Uid, _ = strconv.ParseInt(ctx.Input.Header("x-mmm-uid"), 10, 64)
}
h.CompanyId, _ = strconv.ParseInt(ctx.Input.Header("x-mmm-cid"), 10, 64)
h.UserId, _ = strconv.ParseInt(ctx.Input.Header("x-mmm-id"), 10, 64)
log.Debug(common.AssertJson(h))
return h
}
... ... @@ -103,7 +104,7 @@ func FilterComm(ctx *context.Context) {
//统计
MetricCounter(ctx)
if beego.BConfig.RunMode == "dev" && (ctx.Input.Header("x-mmm-uid")!="" || ctx.Input.Header("uid")!=""){
if beego.BConfig.RunMode == "dev" && (ctx.Input.Header("x-mmm-uid") != "" || ctx.Input.Header("uid") != "") {
return
}
//1.检查签名
... ... @@ -160,10 +161,10 @@ func CheckToken(ctx *context.Context) (result bool) {
msg *protocol.ResponseMessage
)
token := ctx.Input.Header("x-mmm-accesstoken")
if token==""{
if token == "" {
if strings.HasSuffix(ctx.Request.RequestURI, "login") ||
strings.HasSuffix(ctx.Request.RequestURI, "accessToken") ||
strings.HasSuffix(ctx.Request.RequestURI, "refreshToken") {
strings.HasSuffix(ctx.Request.RequestURI, "accessToken") ||
strings.HasSuffix(ctx.Request.RequestURI, "refreshToken") {
return true
}
}
... ... @@ -183,6 +184,7 @@ func CheckToken(ctx *context.Context) (result bool) {
//设置附加数据
ctx.Request.Header.Add("x-mmm-uid", fmt.Sprintf("%v", rsp.UserInfo.UserId))
ctx.Request.Header.Add("x-mmm-cid", fmt.Sprintf("%v", rsp.UserInfo.CurrentCompanyId))
ctx.Request.Header.Add("x-mmm-id", fmt.Sprintf("%v", rsp.UserInfo.CurrentUserCompanyId))
}
}
return
... ...
... ... @@ -11,20 +11,21 @@ import (
)
type UserAuth struct {
Id int `orm:"column(id);auto" description:"唯一编号"`
UserId int64 `orm:"column(user_id)" description:"表user.id "`
RefreshToken string `orm:"column(refresh_token);size(64)" description:"refresh token "`
RefreshTokenExp time.Time `orm:"column(refresh_token_exp);type(timestamp)" description:"refresh token 过期时间"`
AccessToken string `orm:"column(access_token);size(64)" description:"access_token "`
AccessTokenExp time.Time `orm:"column(access_token_exp);type(timestamp)" description:"access token 过期时间"`
AuthCode string `orm:"column(auth_code);size(64)" description:"auth_code"`
AuthCodeExp time.Time `orm:"column(auth_code_exp);type(timestamp)" description:"auth_code过期时间"`
DeviceType int8 `orm:"column(device_type)" description:"设备类型 0:ios 1:安卓 2:web "`
ClientId string `orm:"column(client_id);size(100)" description:"设备识别码 推送标识"`
DeviceToken string `orm:"column(device_token);size(100)" description:"设备识别码 推送标识"`
CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
CurrentCompanyId int64 `orm:"column(current_company_id)" description:"当前登录的公司id "`
Id int `orm:"column(id);auto" description:"唯一编号"`
UserId int64 `orm:"column(user_id)" description:"表user.id "`
RefreshToken string `orm:"column(refresh_token);size(64)" description:"refresh token "`
RefreshTokenExp time.Time `orm:"column(refresh_token_exp);type(timestamp)" description:"refresh token 过期时间"`
AccessToken string `orm:"column(access_token);size(64)" description:"access_token "`
AccessTokenExp time.Time `orm:"column(access_token_exp);type(timestamp)" description:"access token 过期时间"`
AuthCode string `orm:"column(auth_code);size(64)" description:"auth_code"`
AuthCodeExp time.Time `orm:"column(auth_code_exp);type(timestamp)" description:"auth_code过期时间"`
DeviceType int8 `orm:"column(device_type)" description:"设备类型 0:ios 1:安卓 2:web "`
ClientId string `orm:"column(client_id);size(100)" description:"设备识别码 推送标识"`
DeviceToken string `orm:"column(device_token);size(100)" description:"设备识别码 推送标识"`
CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
CurrentCompanyId int64 `orm:"column(current_company_id)" description:"当前登录的公司id "`
CurrentUserCompanyId int64 `orm:"column(current_user_company_id)" description:"当前登录的公司 user_company.id "`
}
func (t *UserAuth) TableName() string {
... ... @@ -180,10 +181,10 @@ func GetUserAuthByRefreshToken(refreshToken string) (v *UserAuth, err error) {
return nil, err
}
func GetUserAuthByToken(refreshToken string) (v *UserAuth, err error) {
func GetUserAuthByToken(token string) (v *UserAuth, err error) {
o := orm.NewOrm()
sql := "select * from user_auth where access_token=? and access_token_exp >= Now()"
if err = o.Raw(sql, refreshToken).QueryRow(&v); err == nil {
if err = o.Raw(sql, token).QueryRow(&v); err == nil {
return v, nil
}
return nil, err
... ...
... ... @@ -8,7 +8,7 @@ import (
)
type UserCompany struct {
Id int `orm:"column(id);auto" description:"唯一标识"`
Id int64 `orm:"column(id)" description:"唯一标识"`
CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司编号"`
UserId int64 `orm:"column(user_id)" description:"表user.id 用户编号"`
DepartmentId int `orm:"column(department_id)" description:"部门id"`
... ... @@ -37,7 +37,7 @@ func AddUserCompany(m *UserCompany) (id int64, err error) {
// GetUserCompanyById retrieves UserCompany by Id. Returns error if
// Id doesn't exist
func GetUserCompanyById(id int) (v *UserCompany, err error) {
func GetUserCompanyById(id int64) (v *UserCompany, err error) {
o := orm.NewOrm()
v = &UserCompany{Id: id}
if err = o.Read(v); err == nil {
... ... @@ -63,7 +63,7 @@ func UpdateUserCompanyById(m *UserCompany) (err error) {
// DeleteUserCompany deletes UserCompany by Id and returns error if
// the record to be deleted doesn't exist
func DeleteUserCompany(id int) (err error) {
func DeleteUserCompany(id int64) (err error) {
o := orm.NewOrm()
v := UserCompany{Id: id}
// ascertain id exists in the database
... ... @@ -94,4 +94,4 @@ func GetUserCompanyFirst(uid int64) (v *UserCompany, err error) {
return v, nil
}
return nil, err
}
\ No newline at end of file
}
... ...
... ... @@ -7,8 +7,8 @@ const (
LoginTypeSmdcode = "signInCaptcha"
)
const(
DeviceType =1
const (
DeviceType = 1
)
const TokenExpire = 3600
... ... @@ -24,8 +24,9 @@ type RequestHeader struct {
DeviceType int
AppProject string
AccessToken string
Uid int64
Uid int64 //用户基本信息Id
CompanyId int64
UserId int64 //UserId 唯一标识,唯一关联所有用户信息(=user_company.id)
}
/*Login */
... ...
... ... @@ -9,266 +9,266 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
beego.ControllerComments{
Method: "AccessToken",
Router: `/accessToken`,
Method: "AccessToken",
Router: `/accessToken`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
beego.ControllerComments{
Method: "Login",
Router: `/login`,
Method: "Login",
Router: `/login`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
beego.ControllerComments{
Method: "RefreshToken",
Router: `/refreshToken`,
Method: "RefreshToken",
Router: `/refreshToken`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
beego.ControllerComments{
Method: "Revoke",
Router: `/revoke`,
Method: "Revoke",
Router: `/revoke`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
beego.ControllerComments{
Method: "SmsCode",
Router: `/smsCode`,
Method: "SmsCode",
Router: `/smsCode`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
beego.ControllerComments{
Method: "UpdateDevice",
Router: `/updateDevice`,
Method: "UpdateDevice",
Router: `/updateDevice`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "ChanceType",
Router: `/chanceType`,
Method: "ChanceType",
Router: `/chanceType`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "CommentDetailsMulti",
Router: `/commentDetailsMulti`,
Method: "CommentDetailsMulti",
Router: `/commentDetailsMulti`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "CommentDetailsSingle",
Router: `/commentDetailsSingle`,
Method: "CommentDetailsSingle",
Router: `/commentDetailsSingle`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "Comments",
Router: `/comments`,
Method: "Comments",
Router: `/comments`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "Favorite",
Router: `/favorite`,
Method: "Favorite",
Router: `/favorite`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "IComment",
Router: `/iComment`,
Method: "IComment",
Router: `/iComment`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "IComments",
Router: `/iComments`,
Method: "IComments",
Router: `/iComments`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "ChanceSubmit",
Router: `/submit`,
Method: "ChanceSubmit",
Router: `/submit`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "SympathyAction",
Router: `/sympathyAction`,
Method: "SympathyAction",
Router: `/sympathyAction`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "Templates",
Router: `/templates`,
Method: "Templates",
Router: `/templates`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:CommendController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:CommendController"],
beego.ControllerComments{
Method: "Company",
Router: `/company`,
Method: "Company",
Router: `/company`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"],
beego.ControllerComments{
Method: "Departments",
Router: `/departments`,
Method: "Departments",
Router: `/departments`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MessageCenter",
Router: `/messageCenter`,
Method: "MessageCenter",
Router: `/messageCenter`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MsgCenterAllRead",
Router: `/msgCenterAllRead`,
Method: "MsgCenterAllRead",
Router: `/msgCenterAllRead`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MsgCenterRead",
Router: `/msgCenterRead`,
Method: "MsgCenterRead",
Router: `/msgCenterRead`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MsgInteractive",
Router: `/msgInteractive`,
Method: "MsgInteractive",
Router: `/msgInteractive`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UcenterController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UcenterController"],
beego.ControllerComments{
Method: "UCenterLogin",
Router: `/login`,
Method: "UCenterLogin",
Router: `/login`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
beego.ControllerComments{
Method: "Image",
Router: `/image`,
Method: "Image",
Router: `/image`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
beego.ControllerComments{
Method: "Video",
Router: `/video`,
Method: "Video",
Router: `/video`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
beego.ControllerComments{
Method: "Voice",
Router: `/voice`,
Method: "Voice",
Router: `/voice`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
beego.ControllerComments{
Method: "ChangePassword",
Router: `/changePassword`,
Method: "ChangePassword",
Router: `/changePassword`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
beego.ControllerComments{
Method: "ChangePhone",
Router: `/changePhone`,
Method: "ChangePhone",
Router: `/changePhone`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
beego.ControllerComments{
Method: "CheckSmsCode",
Router: `/checkSmsCode`,
Method: "CheckSmsCode",
Router: `/checkSmsCode`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
beego.ControllerComments{
Method: "ResetPassword",
Router: `/resetPassword`,
Method: "ResetPassword",
Router: `/resetPassword`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
beego.ControllerComments{
Method: "SwitchCompany",
Router: `/switchCompany`,
Method: "SwitchCompany",
Router: `/switchCompany`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
beego.ControllerComments{
Method: "UserCompanys",
Router: `/userCompanys`,
Method: "UserCompanys",
Router: `/userCompanys`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
beego.ControllerComments{
Method: "UserInfo",
Router: `/userInfo`,
Method: "UserInfo",
Router: `/userInfo`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
}
... ...
... ... @@ -15,18 +15,18 @@ import (
func GetUserBaseInfoAggregation(uid int64, companyId int64) (v *protocol.UserBaseInfoAggregation, err error) {
v = &protocol.UserBaseInfoAggregation{}
var wg sync.WaitGroup
if v.User, err = repository.User.GetUsersById(uid); err != nil {
if v.UserCompany, err = models.GetUserCompanyByUserId(uid, companyId); err != nil {
log.Error(err)
return
}
if v.UserCompany, err = repository.UserCompany.GetUserCompanyByUserId(uid, companyId); err != nil {
if v.User, err = models.GetUsersById(v.UserCompany.UserId); err != nil {
log.Error(err)
return
}
wg.Add(3)
go func() {
defer wg.Done()
if v.Company, err = repository.Company.GetCompanyById(int64(v.UserCompany.CompanyId)); err != nil {
if v.Company, err = models.GetCompanyById(int64(v.UserCompany.CompanyId)); err != nil {
log.Error(err)
return
}
... ... @@ -34,7 +34,7 @@ func GetUserBaseInfoAggregation(uid int64, companyId int64) (v *protocol.UserBas
go func() {
defer wg.Done()
if err = repository.UserDepartment.GetUserDepartment(uid, companyId, &v.Department); err != nil {
if err = models.GetUserDepartments(uid, companyId, &v.Department); err != nil {
log.Error(err)
return
}
... ... @@ -42,7 +42,7 @@ func GetUserBaseInfoAggregation(uid int64, companyId int64) (v *protocol.UserBas
go func() {
defer wg.Done()
if err = repository.UserPosition.GetUserPositions(uid, companyId, &v.Position); err != nil {
if err = models.GetUserPositions(uid, companyId, &v.Position); err != nil {
log.Error(err)
return
}
... ...
... ... @@ -41,7 +41,7 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest)
}
newComment := &models.Comment{
Id: idgen.Next(),
UserId: header.Uid,
UserId: header.UserId,
SourceType: int8(request.SourceType),
Content: request.Content,
CreateAt: time.Now(),
... ... @@ -74,7 +74,7 @@ func IComments(header *protocol.RequestHeader, request *protocol.ICommentsReques
baseUserInfo *protocol.BaseUserInfo
total int
)
if comments, total, err = repository.Comment.GetComments(header.Uid, protocol.SourceTypeChance, 0, request.LastId, request.PageSize); err != nil {
if comments, total, err = repository.Comment.GetComments(header.UserId, protocol.SourceTypeChance, 0, request.LastId, request.PageSize); err != nil {
log.Error(err)
return
}
... ... @@ -112,7 +112,7 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest)
total int
exists bool
)
if comments, total, err = repository.Comment.GetComments(header.Uid, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil {
if comments, total, err = repository.Comment.GetComments(header.UserId, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil {
log.Error(err)
return
}
... ... @@ -134,7 +134,7 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest)
ZanTotal: comment.ZanTotal,
CommentTotal: comment.CommentTotal,
}
if exists, _ = repository.ChanceFavorite.ExitsChanceFavorite(header.Uid, header.CompanyId, comment.Id, protocol.MarkFlag_Zan); exists {
if exists, _ = repository.ChanceFavorite.ExitsChanceFavorite(header.UserId, header.CompanyId, comment.Id, protocol.MarkFlag_Zan); exists {
item.IsZan = 1
}
rsp.Comments = append(rsp.Comments, item)
... ... @@ -167,7 +167,7 @@ func CommentDetailsSingle(header *protocol.RequestHeader, request *protocol.Comm
ZanTotal: comment.ZanTotal,
CommentTotal: comment.CommentTotal,
}
if exists, _ = repository.ChanceFavorite.ExitsChanceFavorite(header.Uid, header.CompanyId, comment.Id, protocol.MarkFlag_Zan); exists {
if exists, _ = repository.ChanceFavorite.ExitsChanceFavorite(header.UserId, header.CompanyId, comment.Id, protocol.MarkFlag_Zan); exists {
rsp.Comment.IsZan = 1
}
return
... ...
... ... @@ -183,15 +183,15 @@ func UserCompanys(header *protocol.RequestHeader, request *protocol.UserCompanys
companys []*models.Company
)
rsp = &protocol.UserCompanysResponse{}
if companys,err =models.GetCompanyByPermission(header.Uid);err!=nil{
if companys, err = models.GetCompanyByPermission(header.Uid); err != nil {
log.Error(err)
err = protocol.NewErrWithMessage(4201) //找不到这家公司
return
}
for i:=range companys{
rsp.Companys =append(rsp.Companys,protocol.Company{
Id:companys[i].Id,
Name:companys[i].Name,
for i := range companys {
rsp.Companys = append(rsp.Companys, protocol.Company{
Id: companys[i].Id,
Name: companys[i].Name,
})
}
return
... ... @@ -213,11 +213,11 @@ func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompa
log.Error(err)
return
}
if auth.CurrentCompanyId == request.CompanyId{
log.Error(fmt.Sprintf("uid:%v 当前公司已经是:%v",header.Uid,request.CompanyId))
if auth.CurrentCompanyId == request.CompanyId {
log.Error(fmt.Sprintf("uid:%v 当前公司已经是:%v", header.Uid, request.CompanyId))
return
}
if err = utils.UpdateTableByMap(&models.UserAuth{Id: auth.Id}, map[string]interface{}{"CurrentCompanyId": company.CompanyId}); err != nil {
if err = utils.UpdateTableByMap(&models.UserAuth{Id: auth.Id}, map[string]interface{}{"CurrentCompanyId": company.CompanyId, "CurrentCompanyUserId": company.Id}); err != nil {
log.Error(err)
return
}
... ... @@ -227,15 +227,15 @@ func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompa
//用户信息
func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) (rsp *protocol.UserInfoResponse, err error) {
var (
companyId = header.CompanyId
company *models.UserCompany
baseInfo *protocol.BaseUserInfo
userAuth *models.UserAuth
user *models.User
companyId = header.CompanyId
userCompany *models.UserCompany
baseInfo *protocol.BaseUserInfo
userAuth *models.UserAuth
user *models.User
)
if companyId == 0 {
if company, err = models.GetUserCompanyFirst(header.Uid); err != nil {
if userCompany, err = models.GetUserCompanyFirst(header.Uid); err != nil {
log.Error(err)
return
}
... ... @@ -243,17 +243,17 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest)
log.Error(err)
return
}
if err = utils.UpdateTableByMap(&models.UserAuth{Id: userAuth.Id}, map[string]interface{}{"CurrentCompanyId": companyId}); err != nil {
if err = utils.UpdateTableByMap(&models.UserAuth{Id: userAuth.Id}, map[string]interface{}{"CurrentCompanyId": userCompany.CompanyId, "CurrentUserCompanyId": userCompany.Id}); err != nil {
log.Error(err)
return
}
companyId = int64(company.Id)
companyId = int64(userCompany.CompanyId)
}
if user, err = models.GetUsersById(header.Uid); err != nil {
log.Error(err)
return
}
if baseInfo, err = agg.GetUserBaseInfo(header.Uid, companyId); err != nil {
if baseInfo, err = agg.GetUserBaseInfo(header.UserId, companyId); err != nil {
log.Error(err)
return
}
... ...