作者 唐旭辉

请求路由修改

### 接口完成进度
| 功能 | 完成状态 | 时间 | 接口路径 | 请求方式 |
| ---------------- | ------------------ | --------------- | ------------------------------- | -------- |
| 登录获取 token | 完成 | 2018/12/11 | /auth/login | post |
| 短信验证码 | 未开始 | | |
| 刷新 token | 完成 | 2018/12/11 | /v1/auth/refresh_token | get |
| 切换公司 | 完成 | 2018/12/11 | /v1/auth/change_company | post |
| 获取个人基础数据 | 未开始 | | /v1/auth/me | get |
| 获取角色列表 | 完成 | | /v1/rbac/:companyid/role | get |
| 添加角色 | 完成 | 2019.11.26 | /v1/rbac/role | post |
| 编辑角色 | 完成 | 2019.11.26 | /v1/rbac/role | put |
| ~~删除角色~~ | ~~完成(待变更)~~ | ~~ 2019.11.26~~ | /v1/rbac/role | delete |
| 删除角色 | 完成 | 2019.12.04 | /v1/rbac/role | delete |
| 添加角色组 | 完成 | 2019.12.04 | /v1/rbac/role_group | post |
| 编辑角色组 | 完成 | 2019.12.04 | /v1/rbac/role_group | put |
| 删除角色组 | 完成 | 2019.12.04 | /v1/rbac/role_group | delete |
| 获取部门列表 | 完成 | 2019.12.5 | /v1/company/department | get |
| 添加部门 | 完成 | 2019.11.28 | /v1/company/department | post |
| 编辑部门 | 完成 | 2019.11.29 | /v1/company/department | put |
| ~~删除部门~~ | ~~完成(待变更)~~ | ~~2019.11.29~~ | ~~/v1/company/department~~ | delete |
| 删除部门 | 完成 | 2019.12.2 | /v1/company/department | delete |
| 获取职位列表 | 进行中 | | /v1/company/:companyid/position | get |
| 添加职位 | 完成 | 2019.12.2 | /v1/company/position | post |
| 编辑职位 | 完成 | 2019.12.2 | /v1/company/position | put |
| 删除职位 | 完成 | 2019.12.2 | /v1/company/position | delete |
| 添加员工 | 未开始 | | /v1/company/user | post |
| 编辑员工 | 未开始 | | /v1/company/user | put |
| 删除员工 | 未开始 | | /v1/company/user | delete |
| 公告管理 | 未开始 | | | |
| 公告管理 | 未开始 | | | |
| 公告管理 | 未开始 | | | |
| 机会&审批 模板 | 未开始 | | | |
| 机会&审批 模板 | 未开始 | | | |
| 机会&审批 模板 | 未开始 | | | |
| 机会&审批 模板 | 未开始 | | | |
| 功能 | 完成状态 | 时间 | 接口路径 | 请求方式 |
| ---------------- | ------------------ | --------------- | -------------------------- | -------- |
| 登录获取 token | 完成 | 2018/12/11 | /auth/login | post |
| 短信验证码 | 未开始 | | |
| 刷新 token | 完成 | 2018/12/11 | /v1/auth/refresh_token | get |
| 切换公司 | 完成 | 2018/12/11 | /v1/auth/change_company | post |
| 获取个人基础数据 | 未开始 | | /v1/auth/me | get |
| 获取角色列表 | 完成 | | /v1/rbac/role | get |
| 添加角色 | 完成 | 2019.11.26 | /v1/rbac/role/add | post |
| 编辑角色 | 完成 | 2019.11.26 | /v1/rbac/role/edit | post |
| ~~删除角色~~ | ~~完成(待变更)~~ | ~~ 2019.11.26~~ | /v1/rbac/role/delete | post |
| 删除角色 | 完成 | 2019.12.04 | /v1/rbac/role/delete | post |
| 添加角色组 | 完成 | 2019.12.04 | /v1/rbac/role_group/add | post |
| 编辑角色组 | 完成 | 2019.12.04 | /v1/rbac/role_group/edit | post |
| 删除角色组 | 完成 | 2019.12.04 | /v1/rbac/role_group/delete | post |
| 获取部门列表 | 完成 | 2019.12.5 | /v1/department | get |
| 添加部门 | 完成 | 2019.11.28 | /v1/department/add | post |
| 编辑部门 | 完成 | 2019.11.29 | /v1/department/edit | post |
| ~~删除部门~~ | ~~完成(待变更)~~ | ~~2019.11.29~~ | ~~/v1/department~~ | post |
| 删除部门 | 完成 | 2019.12.2 | /v1/department/delete | post |
| 获取职位列表 | 进行中 | | /v1/position | get |
| 添加职位 | 完成 | 2019.12.2 | /v1/position/add | post |
| 编辑职位 | 完成 | 2019.12.2 | /v1/position/edit | post |
| 删除职位 | 完成 | 2019.12.2 | /v1/position/delete | post |
| 添加员工 | 未开始 | | /v1/company/user | post |
| 编辑员工 | 未开始 | | /v1/company/user | post |
| 删除员工 | 未开始 | | /v1/company/user | post |
| 公告管理 | 未开始 | | | |
| 公告管理 | 未开始 | | | |
| 公告管理 | 未开始 | | | |
| 机会&审批 模板 | 未开始 | | | |
| 机会&审批 模板 | 未开始 | | | |
| 机会&审批 模板 | 未开始 | | | |
| 机会&审批 模板 | 未开始 | | | |
... ...
... ... @@ -6,7 +6,6 @@ import (
"oppmg/models"
"oppmg/protocol"
serverbac "oppmg/services/rbac"
"strconv"
)
type RbacController struct {
... ... @@ -31,6 +30,7 @@ func (c *RbacController) RoleAdd() {
msg = protocol.BadRequestParam("1")
return
}
param.CompanyID = c.GetCompanyId()
if param.CompanyID <= 0 {
log.Error("param.CompanyID <= 0")
msg = protocol.BadRequestParam("1")
... ... @@ -55,6 +55,7 @@ func (c *RbacController) RoleUpdate() {
msg = protocol.BadRequestParam("1")
return
}
param.CompanyID = c.GetCompanyId()
if param.CompanyID <= 0 {
log.Error("param.CompanyID <= 0")
msg = protocol.BadRequestParam("1")
... ... @@ -79,6 +80,7 @@ func (c *RbacController) RoleDelete() {
msg = protocol.BadRequestParam("1")
return
}
param.CompanyID = c.GetCompanyId()
if param.CompanyID <= 0 {
log.Error("param.CompanyID <= 0")
msg = protocol.BadRequestParam("1")
... ... @@ -104,6 +106,7 @@ func (c *RbacController) RoleGroupAdd() {
msg = protocol.BadRequestParam("1")
return
}
param.CompanyID = c.GetCompanyId()
if param.CompanyID <= 0 {
log.Error("param.CompanyID <= 0")
msg = protocol.BadRequestParam("1")
... ... @@ -129,6 +132,7 @@ func (c *RbacController) RoleGroupUpdate() {
msg = protocol.BadRequestParam("1")
return
}
param.CompanyID = c.GetCompanyId()
if param.CompanyID <= 0 {
log.Error("param.CompanyID <= 0")
msg = protocol.BadRequestParam("1")
... ... @@ -154,6 +158,7 @@ func (c *RbacController) RoleGroupDelete() {
msg = protocol.BadRequestParam("1")
return
}
param.CompanyID = c.GetCompanyId()
if param.CompanyID <= 0 {
log.Error("param.CompanyID <= 0")
msg = protocol.BadRequestParam("1")
... ... @@ -166,15 +171,14 @@ func (c *RbacController) RoleGroupDelete() {
}
// RoleList
// @router /:companyid/role [get]
// @router /role [get]
func (c *RbacController) RoleList() {
var msg *protocol.ResponseMessage
defer func() {
c.ResposeJson(msg)
}()
var companyid int64
param := c.Ctx.Input.Param(":companyid")
companyid, _ = strconv.ParseInt(param, 10, 64)
companyid = c.GetCompanyId()
if companyid <= 0 {
msg = protocol.BadRequestParam("1")
return
... ...
... ... @@ -2,7 +2,6 @@ package middleware
import (
"fmt"
"github.com/astaxie/beego"
"oppmg/common/log"
"oppmg/protocol"
serveauth "oppmg/services/auth"
... ...
... ... @@ -10,4 +10,5 @@ type RequestPageInfo struct {
type ResponsePageInfo struct {
TotalPage int `json:"totalRow"`
CurrentPage int `json:"pageNumber"`
// ListData interface{} `json:"list"`
}
... ...
... ... @@ -90,6 +90,7 @@ func SearchErr(code string) ErrorCode {
return errmessge.Search(code)
}
//NewReturnResponse 控制层响应返回
func NewReturnResponse(data interface{}, eRR error) (msg *ResponseMessage) {
// var msg *ResponseMessage
if eRR == nil {
... ... @@ -104,6 +105,22 @@ func NewReturnResponse(data interface{}, eRR error) (msg *ResponseMessage) {
return NewMesage("1")
}
//BadRequestParam 控制层响应返回
func BadRequestParam(code string) *ResponseMessage {
return NewMesage(code)
}
//NewPageDataResponse 控制层分页数据响应返回
func NewPageDataResponse(data interface{}, eRR error) (msg *ResponseMessage) {
if eRR != nil {
if x, ok := eRR.(CustomErrParse); ok {
return x.ParseToMessage()
}
return NewMesage("1")
}
msg = NewMesage("0")
msg.Data = map[string]interface{}{
"gridResult": data,
}
return msg
}
... ...
... ... @@ -13,25 +13,26 @@ func init() {
beego.NSBefore(middleware.AllowOption),
beego.NSBefore(middleware.LogRequestData),
beego.NSBefore(middleware.AuthToken),
beego.NSNamespace("/company",
beego.NSRouter("/department", &controllers.CompanyController{}, "get:DepartmentList"),
beego.NSRouter("/department/:id([0-9]+)", &controllers.CompanyController{}, "get:DepartmentOne"),
beego.NSRouter("/department", &controllers.CompanyController{}, "post:DepartmentAdd"),
beego.NSRouter("/department", &controllers.CompanyController{}, "put:DepartmentUpdate"),
beego.NSRouter("/department", &controllers.CompanyController{}, "delete:DepartmentDelete"),
beego.NSRouter("/position", &controllers.CompanyController{}, "get:PositionList"),
beego.NSRouter("/position", &controllers.CompanyController{}, "post:PositionAdd"),
beego.NSRouter("/position", &controllers.CompanyController{}, "put:PositionEdit"),
beego.NSRouter("/position", &controllers.CompanyController{}, "delete:PositionDelete"),
beego.NSNamespace("/department",
beego.NSRouter("/list", &controllers.CompanyController{}, "get:DepartmentList"),
beego.NSRouter("/add", &controllers.CompanyController{}, "post:DepartmentAdd"),
beego.NSRouter("/edit", &controllers.CompanyController{}, "post:DepartmentUpdate"),
beego.NSRouter("/delete", &controllers.CompanyController{}, "post:DepartmentDelete"),
),
beego.NSNamespace("position",
beego.NSRouter("/list", &controllers.CompanyController{}, "get:PositionList"),
beego.NSRouter("/add", &controllers.CompanyController{}, "post:PositionAdd"),
beego.NSRouter("/edit", &controllers.CompanyController{}, "post:PositionEdit"),
beego.NSRouter("/delete", &controllers.CompanyController{}, "post:PositionDelete"),
),
beego.NSNamespace("/rbac",
beego.NSRouter("/role", &controllers.RbacController{}, "post:RoleAdd"),
beego.NSRouter("/role", &controllers.RbacController{}, "put:RoleUpdate"),
beego.NSRouter("/role", &controllers.RbacController{}, "delete:RoleDelete"),
beego.NSRouter("/role_group", &controllers.RbacController{}, "post:RoleGroupAdd"),
beego.NSRouter("/role_group", &controllers.RbacController{}, "put:RoleGroupUpdate"),
beego.NSRouter("/role_group", &controllers.RbacController{}, "delete:RoleGroupDelete"),
beego.NSRouter("/:companyid([0-9]+)/role", &controllers.RbacController{}, "get:RoleList"),
beego.NSRouter("/role/add", &controllers.RbacController{}, "post:RoleAdd"),
beego.NSRouter("/role/edit", &controllers.RbacController{}, "post:RoleUpdate"),
beego.NSRouter("/role/delete", &controllers.RbacController{}, "post:RoleDelete"),
beego.NSRouter("/role_group/add", &controllers.RbacController{}, "post:RoleGroupAdd"),
beego.NSRouter("/role_group/edit", &controllers.RbacController{}, "post:RoleGroupUpdate"),
beego.NSRouter("/role_group/delete", &controllers.RbacController{}, "post:RoleGroupDelete"),
beego.NSRouter("/role", &controllers.RbacController{}, "get:RoleList"),
),
beego.NSNamespace("/auth",
beego.NSRouter("/change_company", &controllers.AuthController{}, "post:ChangeCompany"),
... ...
... ... @@ -31,7 +31,7 @@ token 的响应内容
- access_token 对应请求头的 x-mmm-accesstoken。expires_in 指的是 access_token 的到期时间(时间戳),客户端可以依此判断 access_token 到期时间,然后决定是否调用接口刷新 token。
- refresh_token 对应请求头的 x-mmm-refreshtoken。refresh_expires 指的是 refresh_token 的到期时间(时间戳),客户端可以依此判断 refresh_token 到期时间,然后决定是否退出重新登录。
- 刷新 toke 的依据是 refresh_token,如果 refresh_token 过期失效则只能退出系统重新登录。
- 为应对客户端未主动刷新 token 的情况。当服务端发现 access_token 过期且 refresh_token 未过期时返回错误码【10026】,并附带刷新后的 token,影响的内容格式同上,客户端可依此刷新请求头。当服务端发现 refresh_token 过期时返回错误码【10024】,客户需要退出重新登录。
- 为应对客户端未主动刷新 token 的情况。当服务端发现 access_token 过期且 refresh_token 未过期时返回错误码【2】,并附带刷新后的 token,影响的内容格式同上,客户端可依此刷新请求头。当服务端发现 refresh_token 过期时返回错误码【3】,客户需要退出重新登录。
---
... ... @@ -39,7 +39,7 @@ token 的响应内容
```json
{
"code": "错误码字符串",
"code": "错误码数字",
"msg": "错误描述字符串",
"data": {
"xxx": "any"
... ... @@ -70,7 +70,7 @@ token 的响应内容
```json
{
"code": "00000",
"code": 0,
"msg": "成功",
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzYwNTM2OTAsImlhdCI6MTU3NjA1MTg4OCwiaXNzIjoibW1tX29wcG1nIiwibmJmIjoxNTc2MDUxODg4LCJ1aWQiOjEwLCJjb21wYW55X2lkIjoyfQ.R056B306_vO4UKfMRalncFULE5Z0phN4WOhS9PMwydc",
... ... @@ -99,7 +99,7 @@ token 的响应内容
```json
{
"code": "00000",
"code": 0,
"msg": "成功",
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzYwNTM2OTAsImlhdCI6MTU3NjA1MTg4OCwiaXNzIjoibW1tX29wcG1nIiwibmJmIjoxNTc2MDUxODg4LCJ1aWQiOjEwLCJjb21wYW55X2lkIjoyfQ.R056B306_vO4UKfMRalncFULE5Z0phN4WOhS9PMwydc",
... ... @@ -130,7 +130,7 @@ token 的响应内容
```json
{
"code": "00000",
"code": 0,
"msg": "成功",
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzYwNTM2OTAsImlhdCI6MTU3NjA1MTg4OCwiaXNzIjoibW1tX29wcG1nIiwibmJmIjoxNTc2MDUxODg4LCJ1aWQiOjEwLCJjb21wYW55X2lkIjoyfQ.R056B306_vO4UKfMRalncFULE5Z0phN4WOhS9PMwydc",
... ... @@ -145,7 +145,6 @@ token 的响应内容
---
## 公告
### 添加公告
... ... @@ -156,38 +155,37 @@ token 的响应内容
```json
{
"type":2,
"title":"标题",
"content":"公告内容",
"allow_close":0,
"allow_condition":3,
"question_switch":1,
"receiver":["1","2"],
"question":
{
"id":1,
"type":1,
"title":"今天星期几?",
"content":[
{
"id":1,
"content":"星期1"
},
{
"id":2,
"content":"星期2"
}
]
},
"cover":{
"path":"/xx/xx.img",
"w":50,
"h":70
}
"type": 2,
"title": "标题",
"content": "公告内容",
"allow_close": 0,
"allow_condition": 3,
"question_switch": 1,
"receiver": ["1", "2"],
"question": {
"id": 1,
"type": 1,
"title": "今天星期几?",
"content": [
{
"id": 1,
"content": "星期1"
},
{
"id": 2,
"content": "星期2"
}
]
},
"cover": {
"path": "/xx/xx.img",
"w": 50,
"h": 70
}
}
```
```
```
obj.type 公告类型(1图+跳转链接、2纯文本)
obj.title 标题
obj.content 公告内容
... ... @@ -197,7 +195,7 @@ obj.question_switch 设置问题开关 (是否有问题) 1:是 0:否
obj.receiver 接收者
obj.question.type 类型:0-单选,1-多选
obj.question.title 标题
obj.question.content 问题选项
obj.question.content 问题选项
obj.cover 封面
```
... ... @@ -213,8 +211,7 @@ obj.cover 封面
---
### 公告列表
### 公告列表
- 请求路径 :/v1/bulletin/list
- 请求方式 :post
... ... @@ -222,14 +219,14 @@ obj.cover 封面
```json
{
"page":1,
"page_size":20,
"status":0
"page": 1,
"page_size": 20,
"status": 0
}
```
```
obj.status 状态 0-所有 1-下架 2-上架
obj.status 状态 0-所有 1-下架 2-上架
```
- 响应 json
... ... @@ -263,20 +260,18 @@ obj.status 状态 0-所有 1-下架 2-上架
}
```
### 公告详情
### 公告详情
- 请求路径 :/v1/bulletin/:id
- 请求方式 :get
- 请求 json:
```json
{
}
{}
```
```
obj.status 状态 0-所有 1-下架 2-上架
obj.status 状态 0-所有 1-下架 2-上架
```
- 响应 json
... ... @@ -327,8 +322,7 @@ obj.status 状态 0-所有 1-下架 2-上架
}
```
### 公告更新
### 公告更新
- 请求路径 :/v1/bulletin/update
- 请求方式 :post
... ... @@ -336,35 +330,34 @@ obj.status 状态 0-所有 1-下架 2-上架
```json
{
"id":3,
"type":2,
"title":"测试公告3",
"content":"今天发布了一则公告3",
"allow_close":0,
"allow_condition":2,
"question_switch":1,
"receiver":["1","2","3"],
"question":
{
"id":2,
"type":1,
"title":"今天星期几?",
"content":[
{
"id":1,
"content":"星期2"
},
{
"id":2,
"content":"星期3"
}
]
},
"cover":{
"path":"/xx/xx.img",
"w":50,
"h":70
}
"id": 3,
"type": 2,
"title": "测试公告3",
"content": "今天发布了一则公告3",
"allow_close": 0,
"allow_condition": 2,
"question_switch": 1,
"receiver": ["1", "2", "3"],
"question": {
"id": 2,
"type": 1,
"title": "今天星期几?",
"content": [
{
"id": 1,
"content": "星期2"
},
{
"id": 2,
"content": "星期3"
}
]
},
"cover": {
"path": "/xx/xx.img",
"w": 50,
"h": 70
}
}
```
... ... @@ -377,4 +370,3 @@ obj.status 状态 0-所有 1-下架 2-上架
"data": null
}
```
... ...