正在显示
6 个修改的文件
包含
105 行增加
和
6 行删除
@@ -11,6 +11,8 @@ | @@ -11,6 +11,8 @@ | ||
11 | |修改手机号|完成|2019.11.20|/v1/user/changePhone| | 11 | |修改手机号|完成|2019.11.20|/v1/user/changePhone| |
12 | |修改密码|完成|2019.11.20|v1/user/changePassword| | 12 | |修改密码|完成|2019.11.20|v1/user/changePassword| |
13 | |忘记密码|完成|2019.11.20|v1/user/resetPassword| | 13 | |忘记密码|完成|2019.11.20|v1/user/resetPassword| |
14 | +|切换企业| | |v1/user/switchCompany| | ||
15 | +|用户公司列表| | |v1/user/companys| | ||
14 | |机会评论列表|完成|2019.11.21|/v1/chance/comments| | 16 | |机会评论列表|完成|2019.11.21|/v1/chance/comments| |
15 | |我来评论|完成|2019.11.21|/v1/chance/iComment| | 17 | |我来评论|完成|2019.11.21|/v1/chance/iComment| |
16 | |我的评论|完成|2019.11.21|/v1/chance/iComments| | 18 | |我的评论|完成|2019.11.21|/v1/chance/iComments| |
@@ -33,7 +35,6 @@ | @@ -33,7 +35,6 @@ | ||
33 | |模板列表|进行中| |v1/chance/templates| | 35 | |模板列表|进行中| |v1/chance/templates| |
34 | |提交机会|进行中| |v1/chance/submit| | 36 | |提交机会|进行中| |v1/chance/submit| |
35 | |部门列表|完成|2019.12.3|v1/department/departments| | 37 | |部门列表|完成|2019.12.3|v1/department/departments| |
36 | -|配置-机会类型| | |v1/config/chanceType| | ||
37 | |配置-评分| | |v1/config/score| | 38 | |配置-评分| | |v1/config/score| |
38 | |机会审核| | |v1/chance/audit| | 39 | |机会审核| | |v1/chance/audit| |
39 | |机会修改评分| | |v1/chance/editScore| | 40 | |机会修改评分| | |v1/chance/editScore| |
@@ -95,3 +95,45 @@ func (this *UserController) ChangePassword() { | @@ -95,3 +95,45 @@ func (this *UserController) ChangePassword() { | ||
95 | header := controllers.GetRequestHeader(this.Ctx) | 95 | header := controllers.GetRequestHeader(this.Ctx) |
96 | msg = protocol.NewReturnResponse(user.ChangePassword(header, request)) | 96 | msg = protocol.NewReturnResponse(user.ChangePassword(header, request)) |
97 | } | 97 | } |
98 | + | ||
99 | +//UserCompanys | ||
100 | +//@router /userCompanys [post] | ||
101 | +func (this *UserController) UserCompanys() { | ||
102 | + var msg *protocol.ResponseMessage | ||
103 | + defer func() { | ||
104 | + this.Resp(msg) | ||
105 | + }() | ||
106 | + var request *protocol.UserCompanysRequest | ||
107 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
108 | + log.Error(err) | ||
109 | + msg = protocol.BadRequestParam(1) | ||
110 | + return | ||
111 | + } | ||
112 | + if b, m := this.Valid(request); !b { | ||
113 | + msg = m | ||
114 | + return | ||
115 | + } | ||
116 | + header := controllers.GetRequestHeader(this.Ctx) | ||
117 | + msg = protocol.NewReturnResponse(user.UserCompanys(header, request)) | ||
118 | +} | ||
119 | + | ||
120 | +//SwitchCompany | ||
121 | +//@router /switchCompany [post] | ||
122 | +func (this *UserController) SwitchCompany() { | ||
123 | + var msg *protocol.ResponseMessage | ||
124 | + defer func() { | ||
125 | + this.Resp(msg) | ||
126 | + }() | ||
127 | + var request *protocol.SwitchCompanyRequest | ||
128 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
129 | + log.Error(err) | ||
130 | + msg = protocol.BadRequestParam(1) | ||
131 | + return | ||
132 | + } | ||
133 | + if b, m := this.Valid(request); !b { | ||
134 | + msg = m | ||
135 | + return | ||
136 | + } | ||
137 | + header := controllers.GetRequestHeader(this.Ctx) | ||
138 | + msg = protocol.NewReturnResponse(user.SwitchCompany(header, request)) | ||
139 | +} |
@@ -3,7 +3,6 @@ package utils | @@ -3,7 +3,6 @@ package utils | ||
3 | import ( | 3 | import ( |
4 | "errors" | 4 | "errors" |
5 | "fmt" | 5 | "fmt" |
6 | - "github.com/astaxie/beego" | ||
7 | "github.com/astaxie/beego/orm" | 6 | "github.com/astaxie/beego/orm" |
8 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 7 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
9 | "reflect" | 8 | "reflect" |
@@ -13,11 +12,11 @@ import ( | @@ -13,11 +12,11 @@ import ( | ||
13 | func UpdateTableByMap(tabeleStruct interface{}, changeMap map[string]interface{}) error { | 12 | func UpdateTableByMap(tabeleStruct interface{}, changeMap map[string]interface{}) error { |
14 | if reflect.TypeOf(tabeleStruct).Kind() != reflect.Ptr { | 13 | if reflect.TypeOf(tabeleStruct).Kind() != reflect.Ptr { |
15 | err := errors.New("UpdateTableByMap: tableStruct must ptr") | 14 | err := errors.New("UpdateTableByMap: tableStruct must ptr") |
16 | - beego.Error(err) | 15 | + log.Error(err) |
17 | return err | 16 | return err |
18 | } | 17 | } |
19 | if len(changeMap) < 1 { | 18 | if len(changeMap) < 1 { |
20 | - beego.Info("changeMap is nil") | 19 | + log.Info("changeMap is nil") |
21 | return nil | 20 | return nil |
22 | } | 21 | } |
23 | o := orm.NewOrm() | 22 | o := orm.NewOrm() |
@@ -25,13 +24,13 @@ func UpdateTableByMap(tabeleStruct interface{}, changeMap map[string]interface{} | @@ -25,13 +24,13 @@ func UpdateTableByMap(tabeleStruct interface{}, changeMap map[string]interface{} | ||
25 | for i, v := range changeMap { | 24 | for i, v := range changeMap { |
26 | changeColumn = append(changeColumn, i) | 25 | changeColumn = append(changeColumn, i) |
27 | if err := SetStructValueByType(tabeleStruct, i, v); err != nil { | 26 | if err := SetStructValueByType(tabeleStruct, i, v); err != nil { |
28 | - beego.Error(err, i, v) | 27 | + log.Error(err, i, v) |
29 | return err | 28 | return err |
30 | } | 29 | } |
31 | } | 30 | } |
32 | num, err := o.Update(tabeleStruct, changeColumn...) | 31 | num, err := o.Update(tabeleStruct, changeColumn...) |
33 | if err != nil { | 32 | if err != nil { |
34 | - beego.Error(err) | 33 | + log.Error(err) |
35 | return err | 34 | return err |
36 | } | 35 | } |
37 | log.Info(fmt.Sprintf("UpdateTableByMap: table:%s effect records:%d column:%v", GetTableName(tabeleStruct), num, changeColumn)) | 36 | log.Info(fmt.Sprintf("UpdateTableByMap: table:%s effect records:%d column:%v", GetTableName(tabeleStruct), num, changeColumn)) |
@@ -31,3 +31,16 @@ type ChangePasswordRequest struct { | @@ -31,3 +31,16 @@ type ChangePasswordRequest struct { | ||
31 | } | 31 | } |
32 | type ChangePasswordResponse struct { | 32 | type ChangePasswordResponse struct { |
33 | } | 33 | } |
34 | + | ||
35 | +/*UserCompanys */ | ||
36 | +type UserCompanysRequest struct { | ||
37 | +} | ||
38 | +type UserCompanysResponse struct { | ||
39 | +} | ||
40 | + | ||
41 | +/*SwitchCompany */ | ||
42 | +type SwitchCompanyRequest struct { | ||
43 | + CompanyId int64 `json:"company_id" valid:"Required"` | ||
44 | +} | ||
45 | +type SwitchCompanyResponse struct { | ||
46 | +} |
@@ -239,4 +239,20 @@ func init() { | @@ -239,4 +239,20 @@ func init() { | ||
239 | MethodParams: param.Make(), | 239 | MethodParams: param.Make(), |
240 | Params: nil}) | 240 | Params: nil}) |
241 | 241 | ||
242 | + beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"], | ||
243 | + beego.ControllerComments{ | ||
244 | + Method: "SwitchCompany", | ||
245 | + Router: `/switchCompany`, | ||
246 | + AllowHTTPMethods: []string{"post"}, | ||
247 | + MethodParams: param.Make(), | ||
248 | + Params: nil}) | ||
249 | + | ||
250 | + beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"], | ||
251 | + beego.ControllerComments{ | ||
252 | + Method: "UserCompanys", | ||
253 | + Router: `/userCompanys`, | ||
254 | + AllowHTTPMethods: []string{"post"}, | ||
255 | + MethodParams: param.Make(), | ||
256 | + Params: nil}) | ||
257 | + | ||
242 | } | 258 | } |
@@ -108,3 +108,31 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass | @@ -108,3 +108,31 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass | ||
108 | err = utils.UpdateTableByMap(&models.User{Id: user.Id}, map[string]interface{}{"Passwd": request.NewPwd}) | 108 | err = utils.UpdateTableByMap(&models.User{Id: user.Id}, map[string]interface{}{"Passwd": request.NewPwd}) |
109 | return | 109 | return |
110 | } | 110 | } |
111 | + | ||
112 | +func UserCompanys(header *protocol.RequestHeader, request *protocol.UserCompanysRequest) (rsp *protocol.UserCompanysResponse, err error) { | ||
113 | + var () | ||
114 | + rsp = &protocol.UserCompanysResponse{} | ||
115 | + return | ||
116 | +} | ||
117 | + | ||
118 | +//切换公司 | ||
119 | +func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompanyRequest) (rsp *protocol.SwitchCompanyResponse, err error) { | ||
120 | + var ( | ||
121 | + company *models.UserCompany | ||
122 | + auth *models.UserAuth | ||
123 | + ) | ||
124 | + rsp = &protocol.SwitchCompanyResponse{} | ||
125 | + if company, err = repository.UserCompany.GetUserCompanyByUserId(header.Uid, int64(request.CompanyId)); err != nil { | ||
126 | + log.Error(err) | ||
127 | + return | ||
128 | + } | ||
129 | + if auth, err = repository.UserAuth.GetUserAuthByUserId(header.Uid, header.DeviceType); err != nil { | ||
130 | + log.Error(err) | ||
131 | + return | ||
132 | + } | ||
133 | + if err = utils.UpdateTableByMap(&models.UserAuth{Id: auth.Id}, map[string]interface{}{"CurrentCompanyId": company.CompanyId}); err != nil { | ||
134 | + log.Error(err) | ||
135 | + return | ||
136 | + } | ||
137 | + return | ||
138 | +} |
-
请 注册 或 登录 后发表评论