作者 tangxvhui

。。

... ... @@ -36,6 +36,7 @@ ucenter_secret = "cykbjnfqgctn"
file_save_path = "/var/www/opp/file"
file_host = "http://mmm-oppmg-dev.fjmaimaimai.com"
file_host_path = "/file/opp"
# 审批流程修改 消息发布
message_publish = "audit_change"
#---自定义配置 结束----
\ No newline at end of file
... ...
... ... @@ -13,6 +13,7 @@ import (
"github.com/GeeTeam/gt3-golang-sdk/geetest"
)
//AuthController 授权认证相关
type AuthController struct {
BaseController
}
... ... @@ -83,7 +84,7 @@ func (c *AuthController) Login() {
}
// LoginSms 登录
// @router /login [post]
// @router /login_sms [post]
func (c *AuthController) LoginSms() {
var msg *protocol.ResponseMessage
defer func() {
... ...
... ... @@ -7,6 +7,7 @@ import (
"oppmg/services/bulletin"
)
//BulletinController 公告
type BulletinController struct {
BaseController
}
... ...
... ... @@ -2,6 +2,7 @@ package controllers
import (
"encoding/json"
"oppmg/common/config"
"oppmg/common/log"
"oppmg/protocol"
servecommon "oppmg/services/common"
... ... @@ -97,6 +98,8 @@ func (c *CommonController) SelectorPosition() {
return
}
//SelectorUserAndDepart 下拉列表 -用户部门混合
//@router /user_and_department [post]
func (c *CommonController) SelectorUserAndDepart() {
var msg *protocol.ResponseMessage
defer func() {
... ... @@ -116,3 +119,40 @@ func (c *CommonController) SelectorUserAndDepart() {
msg = protocol.NewReturnResponse(departs, err)
return
}
//DefaultImage 获取默认图片
//@router /default_image
func (c *CommonController) DefaultImage() {
var msg *protocol.ResponseMessage
defer func() {
c.ResposeJson(msg)
}()
type Parameter struct {
CmdType int64 `json:"cmd_type"`
}
var param Parameter
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &param); err != nil {
log.Error("json 解析失败 err:%s", err)
msg = protocol.BadRequestParam("1")
return
}
imgehost := config.MConfig.FileHost + "/static/chance_template"
imageNames := []string{}
switch param.CmdType {
case 1:
//返回机会分类的图标
imageNames = []string{
imgehost + "/图片1.jpg",
}
case 2:
//返回机会模板的图标
imageNames = []string{
imgehost + "/图片1.jpg",
}
}
data := map[string][]string{
"urls": imageNames,
}
msg = protocol.NewReturnResponse(data, nil)
return
}
... ...
... ... @@ -9,6 +9,7 @@ import (
"strings"
)
// CompanyController 公司基础数据设置
type CompanyController struct {
BaseController
}
... ... @@ -518,8 +519,10 @@ func (c *CompanyController) DepartmentUser() {
msg = protocol.BadRequestParam("1")
return
}
companyid := c.GetCompanyId()
resultdata, err := servecompany.GetDepartmentUser(companyid, param.DepartmentId)
msg = protocol.NewReturnResponse(resultdata, err)
return
}
... ...
... ... @@ -8,6 +8,7 @@ import (
serverbac "oppmg/services/rbac"
)
// RbacController 角色权限
type RbacController struct {
BaseController
}
... ...
... ... @@ -7,6 +7,7 @@ import (
"oppmg/services/audit"
)
//TemplateController 机会模板
type TemplateController struct {
BaseController
}
... ...
... ... @@ -41,7 +41,6 @@ var AuthToken = func(ctx *context.Context) {
accesstoken := ctx.Input.Header(protocol.HeaderAccessToken)
//解出需要的jwt串 例:头【Authorization】:Bearer 123token456
s := strings.Split(accesstoken, "\u0020")
// strings.TrimSpace()
if len(s) > 0 {
accesstoken = s[len(s)-1]
}
... ... @@ -66,8 +65,10 @@ var AuthToken = func(ctx *context.Context) {
return
}
}
redisdata.RefreshLoginTokenExpires(mtoken.UID, mtoken.CompanyID)
ctx.Input.SetData(protocol.HeaderCompanyid, mtoken.CompanyID)
ctx.Input.SetData(protocol.HeaderUserid, mtoken.UID)
return
}
if ok := serveauth.IsJwtErrorExpired(err); ok {
... ... @@ -91,7 +92,7 @@ var AllowOption = func(ctx *context.Context) {
AllowHeaders: []string{"Origin", "Accept", "Content-Type", "Authorization",
"x-mmm-cid", "x-mmm-uid", "x-mmm-accesstoken", "x-mmm-refreshtoken", "x-requested-with"}, //允许的头部信息
ExposeHeaders: []string{"Content-Length"}, //允许暴露的头信息
AllowCredentials: true, //不允许共享AuthTuffic证书
AllowCredentials: true, //不允许共享AuthTuffic证书
AllowAllOrigins: true, //允许的请求来源
})
f(ctx)
... ...
... ... @@ -32,10 +32,10 @@ type ResponseLogin struct {
}
type LoginAuthToken struct {
AccessToken string `json:"access_token"`
ExpiresIn int64 `json:"expires_in"`
RefreshToken string `json:"refresh_token"`
RefreshExpires int64 `json:"refresh_expires"`
AccessToken string `json:"access_token"`
ExpiresIn int64 `json:"expires_in"`
// RefreshToken string `json:"refresh_token"`
// RefreshExpires int64 `json:"refresh_expires"`
}
//RequestSwapCompany 切换公司
... ...
... ... @@ -71,6 +71,7 @@ func init() {
beego.NSRouter("/role", &controllers.CommonController{}, "post:SelectorRole"),
beego.NSRouter("/position", &controllers.CommonController{}, "post:SelectorPosition"),
beego.NSRouter("/user_and_department", &controllers.CommonController{}, "post:SelectorUserAndDepart"),
beego.NSRouter("/default_image", &controllers.CommonController{}, "post:DefaultImage"),
),
beego.NSNamespace("/template",
beego.NSRouter("/add", &controllers.TemplateController{}, "post:TemplateAdd"),
... ...
... ... @@ -60,8 +60,6 @@ func ResetLoginToken(loginToken protocol.LoginAuthToken) error {
CurrentCompanyId: companyid,
AccessToken: loginToken.AccessToken,
AccessTokenExp: time.Unix(loginToken.ExpiresIn, 0), //,
RefreshToken: loginToken.RefreshToken,
RefreshTokenExp: time.Unix(loginToken.RefreshExpires, 0),
CreateAt: nowTime,
UpdateAt: nowTime,
DeviceType: models.DEVICE_TYPE_WEB,
... ... @@ -77,10 +75,8 @@ func ResetLoginToken(loginToken protocol.LoginAuthToken) error {
uAuth.CurrentCompanyId = companyid
uAuth.AccessToken = loginToken.AccessToken
uAuth.AccessTokenExp = time.Unix(loginToken.ExpiresIn, 0)
uAuth.RefreshToken = loginToken.RefreshToken
uAuth.RefreshTokenExp = time.Unix(loginToken.RefreshExpires, 0)
uAuth.UpdateAt = nowTime
upCol := []string{"CurrentCompanyId", "AccessTokenExp", "RefreshTokenExp", "AccessToken", "RefreshToken", "RefreshTokenExp", "UpdateAt"}
upCol := []string{"CurrentCompanyId", "AccessTokenExp", "RefreshTokenExp", "AccessToken", "UpdateAt"}
if err = models.UpdateUserAuthById(uAuth, upCol); err != nil {
e := fmt.Errorf("UpdateUserAuthById err:%s", err)
log.Error(e.Error())
... ...
... ... @@ -66,25 +66,25 @@ func IsJwtErrorExpired(err error) bool {
func GenerateAuthToken(uid int64, companyid int64) (protocol.LoginAuthToken, error) {
var (
authToken protocol.LoginAuthToken
accesstoken string //主token,请求用
expiresIn int64 = 60 * 60 * 2 //主token过期时间,30分钟
refreshtoken string //副token,刷新主token用
refreshExpires int64 = 60 * 60 * 2 //副token 过期时间 ,60分钟
err error
nowtime = time.Now()
authToken protocol.LoginAuthToken
accesstoken string //主token,请求用
expiresIn int64 = 60 * 60 * 6 //主token过期时间,6小时
// refreshtoken string //副token,刷新主token用
// refreshExpires int64 = 60 * 60 * 2 //副token 过期时间 ,60分钟
err error
nowtime = time.Now()
)
accesstoken, err = CreateJWTToken(uid, companyid, nowtime.Unix()+expiresIn+2)
if err != nil {
return authToken, err
}
refreshtoken, err = CreateJWTToken(uid, companyid, nowtime.Unix()+refreshExpires+2)
if err != nil {
return authToken, err
}
// refreshtoken, err = CreateJWTToken(uid, companyid, nowtime.Unix()+refreshExpires+2)
// if err != nil {
// return authToken, err
// }
authToken.AccessToken = accesstoken
authToken.ExpiresIn = nowtime.Unix() + expiresIn
authToken.RefreshToken = refreshtoken
authToken.RefreshExpires = nowtime.Unix() + refreshExpires
// authToken.RefreshToken = refreshtoken
// authToken.RefreshExpires = nowtime.Unix() + refreshExpires
return authToken, err
}
... ...
... ... @@ -337,7 +337,7 @@ func DepartmentDelete(param protocol.RequestDepartmentDelete) error {
//DepartmentListAll 获取公司的部门
func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, error) {
var (
departs []protocol.ResponseDepartmentInfo
departs = make([]protocol.ResponseDepartmentInfo, 0)
departmodels []*models.Department
err error
)
... ... @@ -349,7 +349,7 @@ func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, erro
if err != nil {
e := fmt.Errorf("EXECUTE SQL err:%s", err)
log.Error(e.Error())
return nil, protocol.NewErrWithMessage("1", err)
return departs, protocol.NewErrWithMessage("1", err)
}
for _, v := range departmodels {
cnt, err := models.CountUserDepartByDepart(v.Id)
... ... @@ -378,7 +378,7 @@ func GetDepartmentUser(companyid int64, departmentid int64) ([]protocol.DepartUs
err error
)
var (
returnData []protocol.DepartUserBase
returnData = make([]protocol.DepartUserBase, 0)
)
department, err = models.GetDepartmentById(departmentid)
if err != nil {
... ...
... ... @@ -278,7 +278,7 @@ func GetPositionList(companyid int64) ([]protocol.ResponsePositionInfo, error) {
)
var (
err error
list []protocol.ResponsePositionInfo
list = make([]protocol.ResponsePositionInfo, 0)
)
err = utils.ExecuteQueryAll(&list, dataSql, companyid)
if err != nil {
... ...
... ... @@ -15,7 +15,7 @@ func GetMenuAll() ([]protocol.PermissionItem, error) {
const datasql string = `SELECT id,name,icon,parent_id,senior_status,sort,code
FROM menu WHERE enabled=1 ORDER BY sort `
var (
list []protocol.PermissionItem
list = make([]protocol.PermissionItem, 0)
err error
)
err = utils.ExecuteQueryAll(&list, datasql)
... ... @@ -26,7 +26,6 @@ func GetMenuAll() ([]protocol.PermissionItem, error) {
return list, nil
}
//
func GetRoleHasMenu(roleid int64, companyid int64) (*protocol.ResponseRoleMenus, error) {
var (
roleData *models.Role
... ... @@ -48,7 +47,7 @@ func GetRoleHasMenu(roleid int64, companyid int64) (*protocol.ResponseRoleMenus,
}
var (
rolemenu []models.RoleMenu
ids []int64
ids = make([]int64, 0)
)
rolemenu, err = models.GetRoleMenuByRole(roleid)
if err != nil {
... ...
... ... @@ -7,6 +7,7 @@ import (
"oppmg/protocol"
)
//RequestUCenterLogin 调用用户中心进行账号密码登录
func RequestUCenterLogin(account, password string) (*ResponseLogin, error) {
var uclientReturn *ResponseLogin
param := RequesLogin{
... ... @@ -32,6 +33,7 @@ func RequestUCenterLogin(account, password string) (*ResponseLogin, error) {
return uclientReturn, nil
}
//RequestUCenterAddUser 调用用户中心进行注册用户
func RequestUCenterAddUser(phone string, nickname string, avatar string) (*ResponseAddUser, error) {
if len(avatar) <= 0 {
... ...
... ... @@ -3,7 +3,6 @@ package ucenter
import (
"encoding/json"
"errors"
"fmt"
)
//CommResponse 公共响应结构
... ... @@ -42,6 +41,7 @@ func (r RequesLogin) Valid() error {
return nil
}
//ResponseLogin 登录响应返回
type ResponseLogin struct {
CommResponse
Data struct {
... ... @@ -55,6 +55,7 @@ type ResponseLogin struct {
} `json:"data"`
}
//RequestAddUser 注册用户
type RequestAddUser struct {
Phone string `json:"phone"`
RegIm int8 `json:"regIm"`
... ... @@ -99,34 +100,34 @@ type ResponseAddUser struct {
} `json:"data"`
}
type RequestCheckCompany struct {
CompanyId int64 `json:"company_id"`
}
//Format 实现IUCenterParam接口
func (r RequestCheckCompany) Format() []byte {
return nil
}
//Format 实现IUCenterParam接口
func (r RequestCheckCompany) GetPath() (string, string) {
return fmt.Sprintf("/company/%d", r.CompanyId), "GET"
}
//Format 实现IUCenterParam接口
func (r RequestCheckCompany) Valid() error {
if r.CompanyId == 0 {
return errors.New("r.CompanyId == 0")
}
return nil
}
type ResponseCheckCompany struct {
CommResponse
Data struct {
CompanyId int64 `json:"id"` //公司的id
CompanyName string `json:"name"` //公司的名称
AdminAccount string `json:"admin_account"` //主管账号
AdminName string `json:"admin_name"` //主管名称
} `json:"data"`
}
// type RequestCheckCompany struct {
// CompanyId int64 `json:"company_id"`
// }
// //Format 实现IUCenterParam接口
// func (r RequestCheckCompany) Format() []byte {
// return nil
// }
// //Format 实现IUCenterParam接口
// func (r RequestCheckCompany) GetPath() (string, string) {
// return fmt.Sprintf("/company/%d", r.CompanyId), "GET"
// }
// //Format 实现IUCenterParam接口
// func (r RequestCheckCompany) Valid() error {
// if r.CompanyId == 0 {
// return errors.New("r.CompanyId == 0")
// }
// return nil
// }
// type ResponseCheckCompany struct {
// CommResponse
// Data struct {
// CompanyId int64 `json:"id"` //公司的id
// CompanyName string `json:"name"` //公司的名称
// AdminAccount string `json:"admin_account"` //主管账号
// AdminName string `json:"admin_name"` //主管名称
// } `json:"data"`
// }
... ...
# 用来存放业务需要并且长期使用的静态文件
# 文件
* avatar_default.png 用户默认头像
# 文件夹
* chance_template 存放机会模板默认的图标
\ No newline at end of file
... ...
package redisdata
import "fmt"
import (
"fmt"
"time"
)
const (
KEY_PREFIX string = "oppmg_" //统一前缀
KEY_USER_TOKEN string = "token" //登录token存储
)
const (
LOGIN_TOKEN_EXP = 1800 * time.Second //token 过期时间30分钟
)
type RedisLoginToken struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
... ...
... ... @@ -6,27 +6,23 @@ import (
"oppmg/common/redis"
"oppmg/protocol"
"strings"
"time"
)
func SetLoginToken(param protocol.LoginAuthToken, userid int64, companyid int64) error {
client := redis.GetRedis()
var (
key string
value []byte
err error
exp int64
nowTime = time.Now().Unix()
key string
value []byte
err error
)
data := RedisLoginToken{
AccessToken: param.AccessToken,
RefreshToken: param.RefreshToken,
CurrentCompany: companyid,
}
value, _ = json.Marshal(data)
exp = param.RefreshExpires - nowTime
key = GetKeyLoginToken(userid, companyid)
err = client.Set(key, string(value), time.Duration(exp)*time.Second).Err()
err = client.Set(key, string(value), LOGIN_TOKEN_EXP).Err()
return err
}
... ... @@ -80,7 +76,7 @@ func RefreshLoginTokenExpires(userid int64, companyid int64) error {
if result == 0 {
return nil
}
_, err = client.Expire(key, 30*time.Minute).Result()
_, err = client.Expire(key, LOGIN_TOKEN_EXP).Result()
if err != nil {
return err
}
... ...
# 机会导向管理后台接口(非正式版)
## 全局统一设定
### 请求头指定要求的字段
| 字段 | 说明 |
| ------------------ | ---------------------------- |
| x-mmm-accesstoken | 发起请求时使用时校验用 token |
| x-mmm-refreshtoken | 刷新 token 时使用的 token |
- 备注 :token 使用 jwt 进行处理.其中包含有 user_id、company_id 的数据,登录时获取
---
### token 机制描述
token 的响应内容
```json
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzYwNTM2OTAsImlhdCI6MTU3NjA1MTg4OCwiaXNzIjoibW1tX29wcG1nIiwibmJmIjoxNTc2MDUxODg4LCJ1aWQiOjEwLCJjb21wYW55X2lkIjoyfQ.R056B306_vO4UKfMRalncFULE5Z0phN4WOhS9PMwydc",
"expires_in": 1576053688,
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzYwNTU0OTAsImlhdCI6MTU3NjA1MTg4OCwiaXNzIjoibW1tX29wcG1nIiwibmJmIjoxNTc2MDUxODg4LCJ1aWQiOjEwLCJjb21wYW55X2lkIjoyfQ.OY54QdDwAq2B1NPnAmHkSxy_KvhktmZA2boSlcSSfoU",
"refresh_expires": 1576055488
}
```
客户端可本地存储该内容数据。
- 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 未过期时返回错误码【2】,并附带刷新后的 token,影响的内容格式同上,客户端可依此刷新请求头。当服务端发现 refresh_token 过期时返回错误码【3】,客户需要退出重新登录。
---
### 通用响应结构
```json
{
"code": "错误码数字",
"msg": "错误描述字符串",
"data": {
"xxx": "any"
}
}
```
- 备注:data 中的内容根据各接口实际情况确定
---
## 认证相关
### 登录
- 请求路径 :/auth/login
- 请求方式 :POST
- 请求 json:
```json
{
"account": "账号",
"password": "密码"
}
```
- 正常响应 json
```json
{
"token":""
"code": 0,
"msg": "成功",
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzYwNTM2OTAsImlhdCI6MTU3NjA1MTg4OCwiaXNzIjoibW1tX29wcG1nIiwibmJmIjoxNTc2MDUxODg4LCJ1aWQiOjEwLCJjb21wYW55X2lkIjoyfQ.R056B306_vO4UKfMRalncFULE5Z0phN4WOhS9PMwydc",
"expires_in": 1576053688,
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzYwNTU0OTAsImlhdCI6MTU3NjA1MTg4OCwiaXNzIjoibW1tX29wcG1nIiwibmJmIjoxNTc2MDUxODg4LCJ1aWQiOjEwLCJjb21wYW55X2lkIjoyfQ.OY54QdDwAq2B1NPnAmHkSxy_KvhktmZA2boSlcSSfoU",
"refresh_expires": 1576055488
}
}
```
- 备注:该请求无需指定请求头
---
### 刷新 token
- 请求路径 :/v1/auth/refresh_token
- 请求方式 :get
- 请求 json:
```json
```
- 正常响应 json
```json
{
"code": 0,
"msg": "成功",
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzYwNTM2OTAsImlhdCI6MTU3NjA1MTg4OCwiaXNzIjoibW1tX29wcG1nIiwibmJmIjoxNTc2MDUxODg4LCJ1aWQiOjEwLCJjb21wYW55X2lkIjoyfQ.R056B306_vO4UKfMRalncFULE5Z0phN4WOhS9PMwydc",
"expires_in": 1576053688,
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzYwNTU0OTAsImlhdCI6MTU3NjA1MTg4OCwiaXNzIjoibW1tX29wcG1nIiwibmJmIjoxNTc2MDUxODg4LCJ1aWQiOjEwLCJjb21wYW55X2lkIjoyfQ.OY54QdDwAq2B1NPnAmHkSxy_KvhktmZA2boSlcSSfoU",
"refresh_expires": 1576055488
}
}
```
- 备注:无
---
### 切换公司
- 请求路径 :/v1/auth/change_company
- 请求方式 :post
- 请求 json:
```json
{
"company_id": 2
}
```
- 正常响应 json
```json
{
"code": 0,
"msg": "成功",
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzYwNTM2OTAsImlhdCI6MTU3NjA1MTg4OCwiaXNzIjoibW1tX29wcG1nIiwibmJmIjoxNTc2MDUxODg4LCJ1aWQiOjEwLCJjb21wYW55X2lkIjoyfQ.R056B306_vO4UKfMRalncFULE5Z0phN4WOhS9PMwydc",
"expires_in": 1576053688,
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzYwNTU0OTAsImlhdCI6MTU3NjA1MTg4OCwiaXNzIjoibW1tX29wcG1nIiwibmJmIjoxNTc2MDUxODg4LCJ1aWQiOjEwLCJjb21wYW55X2lkIjoyfQ.OY54QdDwAq2B1NPnAmHkSxy_KvhktmZA2boSlcSSfoU",
"refresh_expires": 1576055488
}
}
```
- 备注:切换公司实际是变更 token 信息
---
## 公司部门管理
### 部门列表
- 请求路径:/v1/department/list
- 请求方式:post
- 请求 json:
```json
{}
```
- 正常响应 json
```json
{
"code": 0,
"msg": "成功",
"data": {
"lists": [
{
"id": 1,
"company_id": 1,
"name": "部门1",
"parant_id": 0,
"manages": [
{
"id": 1,
"name": "主管"
}
],
"member": 1
},
{
"id": 2,
"company_id": 1,
"name": "部门1-2",
"parant_id": 1,
"manages": [
{
"id": 1,
"name": "主管"
}
],
"member": 1
}
]
}
}
```
- 备注;无
---
### 添加部门
- 请求路径:/v1/department/add
- 请求方式:post
- 请求 json:
```json
{
"name": "部门8",
"parent_id": 13,
"manages": [1, 2, 3] //部门主管id列表
}
```
- 正常响应 json
```json
{
"code": 0,
"msg": "成功",
"data": {
"id": 12 //部门id
}
}
```
- 备注;无
---
### 编辑部门
- 请求路径:/v1/department/edit
- 请求方式:post
- 请求 json:
```json
{
"id": 1,
"name": "部门8",
"parent_id": 13,
"manages": [1, 2, 3] //部门主管id列表
}
```
- 响应 json
```json
{
"code": 0,
"msg": "成功",
"data": null
}
```
- 备注;无
---
### 删除部门
- 请求路径:/v1/department/delete
- 请求方式:post
- 请求 json:
```json
{
"ids": [1, 2]
}
```
- 响应 json
```json
{
"code": 0,
"msg": "成功",
"data": null
}
```
- 备注;无
---
## 公司职位管理
### 职位列表
- 请求路径:/v1/position/list
- 请求方式:post
- 请求 json:
```json
{}
```
- 响应 json
```json
{
"code": 0,
"msg": "成功",
"data": [
{
"id": 1,
"name": "董事长",
"parent_id": 0
},
{
"id": 2,
"name": "总经理",
"parent_id": 1
},
{
"id": 3,
"name": "副总经理",
"parent_id": 2
},
{
"id": 4,
"name": "技术总监",
"parent_id": 2
},
{
"id": 5,
"name": "职位a",
"parent_id": 0
},
{
"id": 6,
"name": "职位b-1",
"parent_id": 9
},
{
"id": 7,
"name": "职位a-2",
"parent_id": 5
},
{
"id": 8,
"name": "职位a-1-1",
"parent_id": 6
},
{
"id": 9,
"name": "职位b-1",
"parent_id": 0
}
]
}
```
- 备注;无
---
### 添加职位
- 请求路径:/v1/position/add
- 请求方式:post
- 请求 json:
```json
{
"name": "职位b-1",
"parent_id": 8
}
```
- 响应 json
```json
{
"code": 0,
"msg": "成功",
"data": {
"id": 2
}
}
```
- 备注;无
---
### 编辑职位
- 请求路径:/v1/position/edit
- 请求方式:post
- 请求 json:
```json
{
"id": 2,
"name": "职位b-1",
"parent_id": 8
}
```
- 响应 json
```json
{
"code": 0,
"msg": "成功",
"data": {
"id": 2
}
}
```
- 备注;无
---
### 删除职位
- 请求路径:/v1/position/delete
- 请求方式:post
- 请求 json:
```json
{
"ids": [1, 2, 3]
}
```
- 响应 json
```json
{
"code": 0,
"msg": "成功",
"data": null
}
```
- 备注;无
---
## 公司员工角色
### 角色列表
- 请求路径:/v1/rbac/role/list
- 请求方式:post
- 请求 json:
```json
{}
```
- 响应 json
```json
{
"code": 0,
"msg": "成功",
"data": {
"list": [
{
"id": 1,
"company_id": 1,
"name": "部门1",
"parant_id": 0,
"manages": [],
"members": [
{
"id": 1,
"name": "Jennifer Clark"
}
],
"member": 1
},
{
"id": 2,
"company_id": 1,
"name": "部门1-2",
"parant_id": 1,
"manages": [],
"members": [],
"member": 1
},
{
"id": 3,
"company_id": 1,
"name": "部门1-2-3",
"parant_id": 2,
"manages": [],
"members": [],
"member": 0
},
{
"id": 4,
"company_id": 1,
"name": "部门1-2-4",
"parant_id": 2,
"manages": [],
"members": [],
"member": 0
},
{
"id": 5,
"company_id": 1,
"name": "部门1-2-5",
"parant_id": 3,
"manages": [],
"members": [],
"member": 0
},
{
"id": 7,
"company_id": 1,
"name": "部门1-2-5-7",
"parant_id": 5,
"manages": [],
"members": [],
"member": 0
},
{
"id": 10,
"company_id": 1,
"name": "部门2",
"parant_id": 0,
"manages": [],
"members": [],
"member": 0
},
{
"id": 26,
"company_id": 1,
"name": "部门名称1",
"parant_id": 1,
"manages": [
{
"id": 1,
"name": "Jennifer Clark"
}
],
"members": [],
"member": 0
},
{
"id": 27,
"company_id": 1,
"name": "部门名称1",
"parant_id": 1,
"manages": [],
"members": [],
"member": 0
}
]
}
}
```
- 备注;无
---
### 添加角色
- 请求路径:/v1/rbac/role/add
- 请求方式:post
- 请求 json:
```json
{
"pid": 8,
"name": "角色7"
}
```
- 响应 json
```json
{
"code": 0,
"msg": "成功",
"data": {
"id": 2
}
}
```
- 备注;无
---
### 编辑角色
- 请求路径:/v1/rbac/role/edit
- 请求方式:post
- 请求 json:
```json
{
"id": 7,
"pid": 8,
"name": "角色7"
}
```
- 响应 json
```json
{
"code": 0,
"msg": "成功",
"data": {
"id": 2
}
}
```
### 删除角色
- 请求路径:/v1/rbac/role/delete
- 请求方式:post
- 请求 json:
```json
{
"id": 1
}
```
- 响应 json
```json
{
"code": 0,
"msg": "成功",
"data": null
}
```
- 备注;无
---
- 备注;无
---
## 公告
### 添加公告
- 请求路径 :/v1/bulletin/add
- 请求方式 :post
- 请求 json:
```json
{
"type": 2,
"title": "标题",
"content": "公告内容",
"allow_close": 0,
"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 公告内容
obj.allow_close 允许关闭公告(0允许关闭窗口,1阅读完才能关闭,2选项打勾后才能关闭)
obj.question_switch 设置问题开关 (是否有问题) 1:是 0:否
obj.receiver 接收者
obj.question.type 类型:0-单选,1-多选
obj.question.title 标题
obj.question.content 问题选项
obj.cover 封面
```
- 响应 json
```json
{
"code": "00000",
"msg": "成功",
"data": {}
}
```
---
### 公告列表
- 请求路径 :/v1/bulletin/list
- 请求方式 :post
- 请求 json:
```json
{
"page": 1,
"page_size": 20,
"status": 0
}
```
```
obj.status 状态 0-所有 1-下架 2-上架
```
- 响应 json
```json
{
"code": "00000",
"msg": "成功",
"data": {
"list": [
{
"id": 5,
"type": 2,
"title": "测试公告",
"status": 1,
"receiver": [
{
"id": 1,
"name": "Jennifer Clark"
},
{
"id": 2,
"name": "邓娱婷1208"
}
],
"time": "2019-12-11 17:11:43"
}
],
"Total": 2
}
}
```
### 公告详情
- 请求路径 :/v1/bulletin/get
- 请求方式 :post
- 请求 json:
```json
{
"id": 5
}
```
```
obj.status 状态 0-所有 1-下架 2-上架
```
- 响应 json
```json
{
"code": "00000",
"msg": "成功",
"data": {
"id": 5,
"type": 2,
"title": "测试公告",
"content": "今天发布了一则公告",
"allow_close": 0,
"question_switch": 1,
"receiver": [
{
"id": 1,
"name": "Jennifer Clark"
},
{
"id": 2,
"name": "邓娱婷1208"
}
],
"question": {
"id": 4,
"type": 1,
"title": "今天星期几?",
"content": [
{
"id": 1,
"content": "星期1"
},
{
"id": 2,
"content": "星期2"
}
]
},
"cover": {
"path": "/xx/xx.img",
"h": 70,
"w": 50
}
}
}
```
### 公告更新
- 请求路径 :/v1/bulletin/update
- 请求方式 :post
- 请求 json:
```json
{
"id": 3,
"type": 2,
"title": "测试公告3",
"content": "今天发布了一则公告3",
"allow_close": 0,
"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
}
}
```
- 响应 json
```json
{
"code": "00000",
"msg": "成功",
"data": null
}
```