Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into dev
正在显示
6 个修改的文件
包含
48 行增加
和
32 行删除
1 | ### 接口完成进度 | 1 | ### 接口完成进度 |
2 | 2 | ||
3 | | 功能 | 完成状态 | 时间 | 接口路径 | 请求方式 | | 3 | | 功能 | 完成状态 | 时间 | 接口路径 | 请求方式 | |
4 | -| -------------- | ------------------ | --------------- | --------------------------------- | -------- | | 4 | +| ---------------- | ------------------ | --------------- | ------------------------------- | -------- | |
5 | | 登录获取 token | 完成 | 2018/12/11 | /auth/login | post | | 5 | | 登录获取 token | 完成 | 2018/12/11 | /auth/login | post | |
6 | | 短信验证码 | 未开始 | | | | 6 | | 短信验证码 | 未开始 | | | |
7 | | 刷新 token | 完成 | 2018/12/11 | /v1/auth/refresh_token | get | | 7 | | 刷新 token | 完成 | 2018/12/11 | /v1/auth/refresh_token | get | |
8 | | 切换公司 | 完成 | 2018/12/11 | /v1/auth/change_company | post | | 8 | | 切换公司 | 完成 | 2018/12/11 | /v1/auth/change_company | post | |
9 | +| 获取个人基础数据 | 未开始 | | /v1/auth/me | get | | ||
9 | | 获取角色列表 | 完成 | | /v1/rbac/:companyid/role | get | | 10 | | 获取角色列表 | 完成 | | /v1/rbac/:companyid/role | get | |
10 | | 添加角色 | 完成 | 2019.11.26 | /v1/rbac/role | post | | 11 | | 添加角色 | 完成 | 2019.11.26 | /v1/rbac/role | post | |
11 | | 编辑角色 | 完成 | 2019.11.26 | /v1/rbac/role | put | | 12 | | 编辑角色 | 完成 | 2019.11.26 | /v1/rbac/role | put | |
@@ -14,7 +15,7 @@ | @@ -14,7 +15,7 @@ | ||
14 | | 添加角色组 | 完成 | 2019.12.04 | /v1/rbac/role_group | post | | 15 | | 添加角色组 | 完成 | 2019.12.04 | /v1/rbac/role_group | post | |
15 | | 编辑角色组 | 完成 | 2019.12.04 | /v1/rbac/role_group | put | | 16 | | 编辑角色组 | 完成 | 2019.12.04 | /v1/rbac/role_group | put | |
16 | | 删除角色组 | 完成 | 2019.12.04 | /v1/rbac/role_group | delete | | 17 | | 删除角色组 | 完成 | 2019.12.04 | /v1/rbac/role_group | delete | |
17 | -| 获取部门列表 | 完成 | 2019.12.5 | /v1/company/:companyid/department | get | | 18 | +| 获取部门列表 | 完成 | 2019.12.5 | /v1/company/department | get | |
18 | | 添加部门 | 完成 | 2019.11.28 | /v1/company/department | post | | 19 | | 添加部门 | 完成 | 2019.11.28 | /v1/company/department | post | |
19 | | 编辑部门 | 完成 | 2019.11.29 | /v1/company/department | put | | 20 | | 编辑部门 | 完成 | 2019.11.29 | /v1/company/department | put | |
20 | | ~~删除部门~~ | ~~完成(待变更)~~ | ~~2019.11.29~~ | ~~/v1/company/department~~ | delete | | 21 | | ~~删除部门~~ | ~~完成(待变更)~~ | ~~2019.11.29~~ | ~~/v1/company/department~~ | delete | |
@@ -54,12 +54,6 @@ func (c *AuthController) Login() { | @@ -54,12 +54,6 @@ func (c *AuthController) Login() { | ||
54 | msg = protocol.BadRequestParam("10021") | 54 | msg = protocol.BadRequestParam("10021") |
55 | return | 55 | return |
56 | } | 56 | } |
57 | - // logintoken, err := serveauth.LoginAuthByPassword(param.Account, param.Password) | ||
58 | - // if err != nil { | ||
59 | - // msg = protocol.NewReturnResponse(nil, err) | ||
60 | - // return | ||
61 | - // } | ||
62 | - // err = serveauth.ResetLoginToken(logintoken) | ||
63 | logintoken, err := serveauth.LoginAuthByUCenter(param.Account, param.Password) | 57 | logintoken, err := serveauth.LoginAuthByUCenter(param.Account, param.Password) |
64 | if err != nil { | 58 | if err != nil { |
65 | msg = protocol.NewReturnResponse(nil, err) | 59 | msg = protocol.NewReturnResponse(nil, err) |
@@ -17,26 +17,14 @@ func (c *CompanyController) URLMapping() { | @@ -17,26 +17,14 @@ func (c *CompanyController) URLMapping() { | ||
17 | //c.Mapping("AccessToken", c.AccessToken) | 17 | //c.Mapping("AccessToken", c.AccessToken) |
18 | } | 18 | } |
19 | 19 | ||
20 | -// DepartmentAdd 部门列表 | ||
21 | -// @router /:companyid/department [get] | 20 | +// DepartmentList 部门列表 |
21 | +// @router /department [get] | ||
22 | func (c *CompanyController) DepartmentList() { | 22 | func (c *CompanyController) DepartmentList() { |
23 | - log.Debug("DepartmentList param:%v", c.Ctx.Input.Param(":companyid")) | ||
24 | - | ||
25 | var msg *protocol.ResponseMessage | 23 | var msg *protocol.ResponseMessage |
26 | defer func() { | 24 | defer func() { |
27 | c.ResposeJson(msg) | 25 | c.ResposeJson(msg) |
28 | }() | 26 | }() |
29 | - var ( | ||
30 | - param string | ||
31 | - companyid int64 | ||
32 | - err error | ||
33 | - ) | ||
34 | - param = c.Ctx.Input.Param(":companyid") | ||
35 | - companyid, err = strconv.ParseInt(param, 10, 64) | ||
36 | - if err != nil { | ||
37 | - msg = protocol.BadRequestParam("1") | ||
38 | - return | ||
39 | - } | 27 | + companyid := c.GetCompanyId() |
40 | if companyid <= 0 { | 28 | if companyid <= 0 { |
41 | msg = protocol.BadRequestParam("1") | 29 | msg = protocol.BadRequestParam("1") |
42 | return | 30 | return |
@@ -48,7 +36,7 @@ func (c *CompanyController) DepartmentList() { | @@ -48,7 +36,7 @@ func (c *CompanyController) DepartmentList() { | ||
48 | msg = protocol.NewReturnResponse(listdata, err) | 36 | msg = protocol.NewReturnResponse(listdata, err) |
49 | } | 37 | } |
50 | 38 | ||
51 | -// DepartmentAdd 部门列表 | 39 | +// DepartmentOne 部门信息 |
52 | // @router /department/:id [get] | 40 | // @router /department/:id [get] |
53 | func (c *CompanyController) DepartmentOne() { | 41 | func (c *CompanyController) DepartmentOne() { |
54 | log.Debug("DepartmentOne param:%v", c.Ctx.Input.Param(":id")) | 42 | log.Debug("DepartmentOne param:%v", c.Ctx.Input.Param(":id")) |
@@ -87,12 +75,12 @@ func (c *CompanyController) DepartmentAdd() { | @@ -87,12 +75,12 @@ func (c *CompanyController) DepartmentAdd() { | ||
87 | msg = protocol.BadRequestParam("1") | 75 | msg = protocol.BadRequestParam("1") |
88 | return | 76 | return |
89 | } | 77 | } |
78 | + param.CompanyID = c.GetCompanyId() | ||
90 | if param.CompanyID <= 0 { | 79 | if param.CompanyID <= 0 { |
91 | log.Error("param.CompanyID <= 0") | 80 | log.Error("param.CompanyID <= 0") |
92 | msg = protocol.BadRequestParam("1") | 81 | msg = protocol.BadRequestParam("1") |
93 | return | 82 | return |
94 | } | 83 | } |
95 | - //err := protocol.NewErrWithMessage("101", nil) | ||
96 | err := servecompany.DepartmentAdd(param) | 84 | err := servecompany.DepartmentAdd(param) |
97 | msg = protocol.NewReturnResponse(nil, err) | 85 | msg = protocol.NewReturnResponse(nil, err) |
98 | return | 86 | return |
@@ -112,6 +100,7 @@ func (c *CompanyController) DepartmentUpdate() { | @@ -112,6 +100,7 @@ func (c *CompanyController) DepartmentUpdate() { | ||
112 | msg = protocol.BadRequestParam("1") | 100 | msg = protocol.BadRequestParam("1") |
113 | return | 101 | return |
114 | } | 102 | } |
103 | + param.CompanyID = c.GetCompanyId() | ||
115 | if param.ID <= 0 { | 104 | if param.ID <= 0 { |
116 | log.Error(" param.ID <= 0 ") | 105 | log.Error(" param.ID <= 0 ") |
117 | msg = protocol.BadRequestParam("1") | 106 | msg = protocol.BadRequestParam("1") |
@@ -136,7 +125,7 @@ func (c *CompanyController) DepartmentDelete() { | @@ -136,7 +125,7 @@ func (c *CompanyController) DepartmentDelete() { | ||
136 | msg = protocol.BadRequestParam("1") | 125 | msg = protocol.BadRequestParam("1") |
137 | return | 126 | return |
138 | } | 127 | } |
139 | - | 128 | + param.CompanyID = c.GetCompanyId() |
140 | err := servecompany.DepartmentDelete(param) | 129 | err := servecompany.DepartmentDelete(param) |
141 | msg = protocol.NewReturnResponse(nil, err) | 130 | msg = protocol.NewReturnResponse(nil, err) |
142 | return | 131 | return |
@@ -155,6 +144,8 @@ func (c *CompanyController) PositionAdd() { | @@ -155,6 +144,8 @@ func (c *CompanyController) PositionAdd() { | ||
155 | msg = protocol.BadRequestParam("1") | 144 | msg = protocol.BadRequestParam("1") |
156 | return | 145 | return |
157 | } | 146 | } |
147 | + | ||
148 | + param.CompanyID = c.GetCompanyId() | ||
158 | positioninfo, err := servecompany.PositionAdd(param) | 149 | positioninfo, err := servecompany.PositionAdd(param) |
159 | msg = protocol.NewReturnResponse(positioninfo, err) | 150 | msg = protocol.NewReturnResponse(positioninfo, err) |
160 | return | 151 | return |
@@ -173,6 +164,7 @@ func (c *CompanyController) PositionEdit() { | @@ -173,6 +164,7 @@ func (c *CompanyController) PositionEdit() { | ||
173 | msg = protocol.BadRequestParam("1") | 164 | msg = protocol.BadRequestParam("1") |
174 | return | 165 | return |
175 | } | 166 | } |
167 | + param.CompanyID = c.GetCompanyId() | ||
176 | positioninfo, err := servecompany.PositionEdit(param) | 168 | positioninfo, err := servecompany.PositionEdit(param) |
177 | msg = protocol.NewReturnResponse(positioninfo, err) | 169 | msg = protocol.NewReturnResponse(positioninfo, err) |
178 | return | 170 | return |
@@ -191,13 +183,14 @@ func (c *CompanyController) PositionDelete() { | @@ -191,13 +183,14 @@ func (c *CompanyController) PositionDelete() { | ||
191 | msg = protocol.BadRequestParam("1") | 183 | msg = protocol.BadRequestParam("1") |
192 | return | 184 | return |
193 | } | 185 | } |
186 | + param.CompanyID = c.GetCompanyId() | ||
194 | err := servecompany.PositionDelete(param) | 187 | err := servecompany.PositionDelete(param) |
195 | msg = protocol.NewReturnResponse(nil, err) | 188 | msg = protocol.NewReturnResponse(nil, err) |
196 | return | 189 | return |
197 | } | 190 | } |
198 | 191 | ||
199 | // PositionList 获取职位列表 | 192 | // PositionList 获取职位列表 |
200 | -// @router /:companyid/position [get] | 193 | +// @router /position [get] |
201 | func (c *CompanyController) PositionList() { | 194 | func (c *CompanyController) PositionList() { |
202 | var msg *protocol.ResponseMessage | 195 | var msg *protocol.ResponseMessage |
203 | defer func() { | 196 | defer func() { |
@@ -209,8 +202,8 @@ func (c *CompanyController) PositionList() { | @@ -209,8 +202,8 @@ func (c *CompanyController) PositionList() { | ||
209 | list []protocol.ResponsePositionInfo | 202 | list []protocol.ResponsePositionInfo |
210 | companyid int64 | 203 | companyid int64 |
211 | ) | 204 | ) |
212 | - param := c.Ctx.Input.Param(":companyid") | ||
213 | - companyid, _ = strconv.ParseInt(param, 10, 64) | 205 | + |
206 | + companyid = c.GetCompanyId() | ||
214 | if companyid <= 0 { | 207 | if companyid <= 0 { |
215 | msg = protocol.BadRequestParam("1") | 208 | msg = protocol.BadRequestParam("1") |
216 | return | 209 | return |
@@ -219,3 +212,8 @@ func (c *CompanyController) PositionList() { | @@ -219,3 +212,8 @@ func (c *CompanyController) PositionList() { | ||
219 | msg = protocol.NewReturnResponse(list, err) | 212 | msg = protocol.NewReturnResponse(list, err) |
220 | return | 213 | return |
221 | } | 214 | } |
215 | + | ||
216 | +//获取公司的基本信息 | ||
217 | +func (c *CompanyController) BaseInfo() { | ||
218 | + | ||
219 | +} |
@@ -14,12 +14,12 @@ func init() { | @@ -14,12 +14,12 @@ func init() { | ||
14 | beego.NSBefore(middleware.LogRequestData), | 14 | beego.NSBefore(middleware.LogRequestData), |
15 | beego.NSBefore(middleware.AuthToken), | 15 | beego.NSBefore(middleware.AuthToken), |
16 | beego.NSNamespace("/company", | 16 | beego.NSNamespace("/company", |
17 | - beego.NSRouter("/:companyid([0-9]+)/department", &controllers.CompanyController{}, "get:DepartmentList"), | 17 | + beego.NSRouter("/department", &controllers.CompanyController{}, "get:DepartmentList"), |
18 | beego.NSRouter("/department/:id([0-9]+)", &controllers.CompanyController{}, "get:DepartmentOne"), | 18 | beego.NSRouter("/department/:id([0-9]+)", &controllers.CompanyController{}, "get:DepartmentOne"), |
19 | beego.NSRouter("/department", &controllers.CompanyController{}, "post:DepartmentAdd"), | 19 | beego.NSRouter("/department", &controllers.CompanyController{}, "post:DepartmentAdd"), |
20 | beego.NSRouter("/department", &controllers.CompanyController{}, "put:DepartmentUpdate"), | 20 | beego.NSRouter("/department", &controllers.CompanyController{}, "put:DepartmentUpdate"), |
21 | beego.NSRouter("/department", &controllers.CompanyController{}, "delete:DepartmentDelete"), | 21 | beego.NSRouter("/department", &controllers.CompanyController{}, "delete:DepartmentDelete"), |
22 | - beego.NSRouter("/:companyid([0-9]+)/position", &controllers.CompanyController{}, "get:PositionList"), | 22 | + beego.NSRouter("/position", &controllers.CompanyController{}, "get:PositionList"), |
23 | beego.NSRouter("/position", &controllers.CompanyController{}, "post:PositionAdd"), | 23 | beego.NSRouter("/position", &controllers.CompanyController{}, "post:PositionAdd"), |
24 | beego.NSRouter("/position", &controllers.CompanyController{}, "put:PositionEdit"), | 24 | beego.NSRouter("/position", &controllers.CompanyController{}, "put:PositionEdit"), |
25 | beego.NSRouter("/position", &controllers.CompanyController{}, "delete:PositionDelete"), | 25 | beego.NSRouter("/position", &controllers.CompanyController{}, "delete:PositionDelete"), |
@@ -11,6 +11,7 @@ type CommResponse struct { | @@ -11,6 +11,7 @@ type CommResponse struct { | ||
11 | Msg string `json:"msg"` | 11 | Msg string `json:"msg"` |
12 | } | 12 | } |
13 | 13 | ||
14 | +//RequesLogin 用户登录 | ||
14 | type RequesLogin struct { | 15 | type RequesLogin struct { |
15 | Password string `json:"password"` | 16 | Password string `json:"password"` |
16 | Phone string `json:"phone"` | 17 | Phone string `json:"phone"` |
1 | -# 机会导向管理后台接口 | 1 | +# 机会导向管理后台接口(非正式版) |
2 | 2 | ||
3 | ## 全局统一设定 | 3 | ## 全局统一设定 |
4 | 4 | ||
@@ -13,6 +13,28 @@ | @@ -13,6 +13,28 @@ | ||
13 | 13 | ||
14 | --- | 14 | --- |
15 | 15 | ||
16 | +### token 机制描述 | ||
17 | + | ||
18 | +token 的响应内容 | ||
19 | + | ||
20 | +```json | ||
21 | +{ | ||
22 | + "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzYwNTM2OTAsImlhdCI6MTU3NjA1MTg4OCwiaXNzIjoibW1tX29wcG1nIiwibmJmIjoxNTc2MDUxODg4LCJ1aWQiOjEwLCJjb21wYW55X2lkIjoyfQ.R056B306_vO4UKfMRalncFULE5Z0phN4WOhS9PMwydc", | ||
23 | + "expires_in": 1576053688, | ||
24 | + "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzYwNTU0OTAsImlhdCI6MTU3NjA1MTg4OCwiaXNzIjoibW1tX29wcG1nIiwibmJmIjoxNTc2MDUxODg4LCJ1aWQiOjEwLCJjb21wYW55X2lkIjoyfQ.OY54QdDwAq2B1NPnAmHkSxy_KvhktmZA2boSlcSSfoU", | ||
25 | + "refresh_expires": 1576055488 | ||
26 | +} | ||
27 | +``` | ||
28 | + | ||
29 | +客户端可本地存储该内容数据。 | ||
30 | + | ||
31 | +- access_token 对应请求头的 x-mmm-accesstoken。expires_in 指的是 access_token 的到期时间(时间戳),客户端可以依此判断 access_token 到期时间,然后决定是否调用接口刷新 token。 | ||
32 | +- refresh_token 对应请求头的 x-mmm-refreshtoken。refresh_expires 指的是 refresh_token 的到期时间(时间戳),客户端可以依此判断 refresh_token 到期时间,然后决定是否退出重新登录。 | ||
33 | +- 刷新 toke 的依据是 refresh_token,如果 refresh_token 过期失效则只能退出系统重新登录。 | ||
34 | +- 为应对客户端未主动刷新 token 的情况。当服务端发现 access_token 过期且 refresh_token 未过期时返回错误码【10026】,并附带刷新后的 token,影响的内容格式同上,客户端可依此刷新请求头。当服务端发现 refresh_token 过期时返回错误码【10024】,客户需要退出重新登录。 | ||
35 | + | ||
36 | +--- | ||
37 | + | ||
16 | ### 通用响应结构 | 38 | ### 通用响应结构 |
17 | 39 | ||
18 | ```json | 40 | ```json |
-
请 注册 或 登录 后发表评论