Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into dev
正在显示
10 个修改的文件
包含
305 行增加
和
31 行删除
@@ -48,12 +48,20 @@ func (this *BaseController) ResposeJson(msg *protocol.ResponseMessage) { | @@ -48,12 +48,20 @@ func (this *BaseController) ResposeJson(msg *protocol.ResponseMessage) { | ||
48 | func (this *BaseController) GetCompanyId() int64 { | 48 | func (this *BaseController) GetCompanyId() int64 { |
49 | v := this.Ctx.Input.GetData(protocol.HeaderCompanyid) | 49 | v := this.Ctx.Input.GetData(protocol.HeaderCompanyid) |
50 | companyid, _ := strconv.ParseInt(fmt.Sprint(v), 10, 64) | 50 | companyid, _ := strconv.ParseInt(fmt.Sprint(v), 10, 64) |
51 | + | ||
52 | + if beego.BConfig.RunMode != "prod" && companyid == 0 { | ||
53 | + companyid, _ = strconv.ParseInt(this.Ctx.Input.Header("x-mmm-cid"), 10, 64) | ||
54 | + } | ||
51 | return companyid | 55 | return companyid |
52 | } | 56 | } |
53 | 57 | ||
54 | func (this *BaseController) GetUserId() int64 { | 58 | func (this *BaseController) GetUserId() int64 { |
55 | v := this.Ctx.Input.GetData(protocol.HeaderUserid) | 59 | v := this.Ctx.Input.GetData(protocol.HeaderUserid) |
56 | userid, _ := strconv.ParseInt(fmt.Sprint(v), 10, 64) | 60 | userid, _ := strconv.ParseInt(fmt.Sprint(v), 10, 64) |
61 | + | ||
62 | + if beego.BConfig.RunMode != "prod" && userid == 0 { | ||
63 | + userid, _ = strconv.ParseInt(this.Ctx.Input.Header("x-mmm-uid"), 10, 64) | ||
64 | + } | ||
57 | return userid | 65 | return userid |
58 | } | 66 | } |
59 | 67 |
@@ -31,9 +31,9 @@ func (this *BulletinController) BulletinRelease() { | @@ -31,9 +31,9 @@ func (this *BulletinController) BulletinRelease() { | ||
31 | msg = protocol.BadRequestParam("1") | 31 | msg = protocol.BadRequestParam("1") |
32 | return | 32 | return |
33 | } | 33 | } |
34 | - if request.Type != 1 || request.Type != 2 { | 34 | + if !(request.Type == 1 || request.Type == 2) { |
35 | msg = protocol.BadRequestParam("1") | 35 | msg = protocol.BadRequestParam("1") |
36 | - log.Error("type error :", request.Type) | 36 | + log.Error("type error :%v", request.Type) |
37 | return | 37 | return |
38 | } | 38 | } |
39 | if b, m := this.Valid(request); !b { | 39 | if b, m := this.Valid(request); !b { |
@@ -79,15 +79,15 @@ func (this *BulletinController) GetBulletin() { | @@ -79,15 +79,15 @@ func (this *BulletinController) GetBulletin() { | ||
79 | this.ResposeJson(msg) | 79 | this.ResposeJson(msg) |
80 | }() | 80 | }() |
81 | var request *protocol.GetBulletinRequest | 81 | var request *protocol.GetBulletinRequest |
82 | - if err := json.Unmarshal(this.Ctx.Input.RequestBody, &request); err != nil { | ||
83 | - log.Error("json 解析失败", err) | ||
84 | - msg = protocol.BadRequestParam("1") | ||
85 | - return | ||
86 | - } | ||
87 | - if b, m := this.Valid(request); !b { | ||
88 | - msg = m | ||
89 | - return | ||
90 | - } | 82 | + //if err := json.Unmarshal(this.Ctx.Input.RequestBody, &request); err != nil { |
83 | + // log.Error("json 解析失败", err) | ||
84 | + // msg = protocol.BadRequestParam("1") | ||
85 | + // return | ||
86 | + //} | ||
87 | + //if b, m := this.Valid(request); !b { | ||
88 | + // msg = m | ||
89 | + // return | ||
90 | + //} | ||
91 | param := this.Ctx.Input.Param(":id") | 91 | param := this.Ctx.Input.Param(":id") |
92 | id, _ := strconv.ParseInt(param, 10, 64) | 92 | id, _ := strconv.ParseInt(param, 10, 64) |
93 | if id == 0 { | 93 | if id == 0 { |
@@ -2,6 +2,7 @@ package middleware | @@ -2,6 +2,7 @@ package middleware | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "github.com/astaxie/beego" | ||
5 | "oppmg/common/log" | 6 | "oppmg/common/log" |
6 | "oppmg/protocol" | 7 | "oppmg/protocol" |
7 | serveauth "oppmg/services/auth" | 8 | serveauth "oppmg/services/auth" |
@@ -55,6 +56,9 @@ var LogRequestData = func(ctx *context.Context) { | @@ -55,6 +56,9 @@ var LogRequestData = func(ctx *context.Context) { | ||
55 | //AuthToken Before Router | 56 | //AuthToken Before Router |
56 | var AuthToken = func(ctx *context.Context) { | 57 | var AuthToken = func(ctx *context.Context) { |
57 | log.Debug("执行中间件AuthToken") | 58 | log.Debug("执行中间件AuthToken") |
59 | + if beego.BConfig.RunMode != "prod" { | ||
60 | + return | ||
61 | + } | ||
58 | var ( | 62 | var ( |
59 | storetoken redisdata.RedisLoginToken | 63 | storetoken redisdata.RedisLoginToken |
60 | msg *protocol.ResponseMessage | 64 | msg *protocol.ResponseMessage |
@@ -83,14 +83,14 @@ func DeleteBulletin(id int) (err error) { | @@ -83,14 +83,14 @@ func DeleteBulletin(id int) (err error) { | ||
83 | } | 83 | } |
84 | 84 | ||
85 | func GetBulletins(companyId int64, status int8, page, pageSize int) (v []*Bulletin, total int, err error) { | 85 | func GetBulletins(companyId int64, status int8, page, pageSize int) (v []*Bulletin, total int, err error) { |
86 | - sql := "select * from bulletin where (status=? or ?==0) and company_id =? order by create_at desc limit ?,?" | 86 | + sql := "select * from bulletin where (status=? or ?=0) and company_id =? order by create_at desc limit ?,?" |
87 | o := orm.NewOrm() | 87 | o := orm.NewOrm() |
88 | - if _, err = o.Raw(sql, status, companyId, page-1, pageSize).QueryRows(&v); err != nil { | 88 | + if _, err = o.Raw(sql, status, status, companyId, page-1, pageSize).QueryRows(&v); err != nil { |
89 | return | 89 | return |
90 | } | 90 | } |
91 | 91 | ||
92 | - sqlTotal := "select count(1) from bulletin where (status=? or ?==0) and company_id =?" | ||
93 | - if _, err = o.Raw(sqlTotal, status, companyId).QueryRows(&total); err != nil { | 92 | + sqlTotal := "select count(1) from bulletin where (status=? or ?=0) and company_id =?" |
93 | + if err = o.Raw(sqlTotal, status, status, companyId).QueryRow(&total); err != nil { | ||
94 | return | 94 | return |
95 | } | 95 | } |
96 | return | 96 | return |
@@ -15,8 +15,6 @@ type BulletinQuestion struct { | @@ -15,8 +15,6 @@ type BulletinQuestion struct { | ||
15 | Content string `orm:"column(content);size(2000);null" description:"内容"` | 15 | Content string `orm:"column(content);size(2000);null" description:"内容"` |
16 | CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"` | 16 | CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"` |
17 | UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间"` | 17 | UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间"` |
18 | - MustRead int8 `orm:"column(must_read);null" description:"公告内容看完才可以关闭 1:是 0:否"` | ||
19 | - MustAnswer int8 `orm:"column(must_answer);null" description:"回答完问题才可以关闭 1:是 0:否"` | ||
20 | } | 18 | } |
21 | 19 | ||
22 | func (t *BulletinQuestion) TableName() string { | 20 | func (t *BulletinQuestion) TableName() string { |
@@ -110,7 +110,7 @@ func getUserNameByIds(ids []int64) ([]User, error) { | @@ -110,7 +110,7 @@ func getUserNameByIds(ids []int64) ([]User, error) { | ||
110 | o := orm.NewOrm() | 110 | o := orm.NewOrm() |
111 | _, err = o.QueryTable(&User{}). | 111 | _, err = o.QueryTable(&User{}). |
112 | Filter("id__in", ids). | 112 | Filter("id__in", ids). |
113 | - Filter("delete_at", time.Unix(0, 0)).All(&users) | 113 | + Filter("delete_at", 0).All(&users) |
114 | 114 | ||
115 | if err == orm.ErrNoRows { | 115 | if err == orm.ErrNoRows { |
116 | return users, nil | 116 | return users, nil |
1 | package protocol | 1 | package protocol |
2 | 2 | ||
3 | +const ( | ||
4 | + BulletinUnRelease = 1 //下架 | ||
5 | + BulletinRelease = 2 //上架 | ||
6 | +) | ||
7 | + | ||
8 | +const ( | ||
9 | + QuestionSingleSelect = 0 //单选 | ||
10 | + QuestionMultiSelect = 1 //多选 | ||
11 | +) | ||
12 | + | ||
3 | /*BulletinRelease */ | 13 | /*BulletinRelease */ |
4 | type BulletinReleaseRequest struct { | 14 | type BulletinReleaseRequest struct { |
5 | Id int `json:"id"` | 15 | Id int `json:"id"` |
@@ -20,11 +30,11 @@ type Question struct { | @@ -20,11 +30,11 @@ type Question struct { | ||
20 | Content []QuestionContent `json:"content" valid:"Required"` | 30 | Content []QuestionContent `json:"content" valid:"Required"` |
21 | } | 31 | } |
22 | type QuestionContent struct { | 32 | type QuestionContent struct { |
23 | - Id int | ||
24 | - Content string | 33 | + Id int `json:"id" valid:"Required"` |
34 | + Content string `json:"content" valid:"Required"` | ||
25 | } | 35 | } |
26 | type Cover struct { | 36 | type Cover struct { |
27 | - Path string `json:"path"` | 37 | + Path string `json:"path" valid:"Required"` |
28 | H int `json:"h"` | 38 | H int `json:"h"` |
29 | W int `json:"w"` | 39 | W int `json:"w"` |
30 | } | 40 | } |
@@ -47,7 +57,7 @@ type BulletinItem struct { | @@ -47,7 +57,7 @@ type BulletinItem struct { | ||
47 | Type int8 `json:"type"` | 57 | Type int8 `json:"type"` |
48 | Title string `json:"title"` | 58 | Title string `json:"title"` |
49 | Status int8 `json:"status"` | 59 | Status int8 `json:"status"` |
50 | - Receiver []string `json:"receiver" valid:"Required"` | 60 | + Receiver []Receiver `json:"receiver" valid:"Required"` |
51 | CreateAt string `json:"time"` | 61 | CreateAt string `json:"time"` |
52 | } | 62 | } |
53 | 63 | ||
@@ -62,11 +72,16 @@ type GetBulletinResponse struct { | @@ -62,11 +72,16 @@ type GetBulletinResponse struct { | ||
62 | AllowClose int `json:"allow_close"` | 72 | AllowClose int `json:"allow_close"` |
63 | AllowCondition int `json:"allow_condition"` | 73 | AllowCondition int `json:"allow_condition"` |
64 | QuestionSwitch int `json:"question_switch"` | 74 | QuestionSwitch int `json:"question_switch"` |
65 | - Receiver []string `json:"receiver" valid:"Required"` | 75 | + Receiver []Receiver `json:"receiver" valid:"Required"` |
66 | Question Question `json:"question"` | 76 | Question Question `json:"question"` |
67 | Cover Cover `json:"cover" valid:"Required"` | 77 | Cover Cover `json:"cover" valid:"Required"` |
68 | } | 78 | } |
69 | 79 | ||
80 | +type Receiver struct { | ||
81 | + Id int64 `json:"id"` | ||
82 | + NickName string `json:"name"` | ||
83 | +} | ||
84 | + | ||
70 | /*UpdateBulletin */ | 85 | /*UpdateBulletin */ |
71 | type UpdateBulletinRequest struct { | 86 | type UpdateBulletinRequest struct { |
72 | Id int `json:"id" valid:"Required"` | 87 | Id int `json:"id" valid:"Required"` |
@@ -38,10 +38,10 @@ func init() { | @@ -38,10 +38,10 @@ func init() { | ||
38 | beego.NSRouter("/refresh_token", &controllers.AuthController{}, "get:RefreshToken"), | 38 | beego.NSRouter("/refresh_token", &controllers.AuthController{}, "get:RefreshToken"), |
39 | ), | 39 | ), |
40 | beego.NSNamespace("/bulletin", | 40 | beego.NSNamespace("/bulletin", |
41 | - beego.NSRouter("/release", &controllers.BulletinController{}, "post:BulletinRelease"), | 41 | + beego.NSRouter("/add", &controllers.BulletinController{}, "post:BulletinRelease"), |
42 | beego.NSRouter("/list", &controllers.BulletinController{}, "post:BulletinList"), | 42 | beego.NSRouter("/list", &controllers.BulletinController{}, "post:BulletinList"), |
43 | beego.NSRouter("/:id([0-9]+)", &controllers.BulletinController{}, "get:GetBulletin"), | 43 | beego.NSRouter("/:id([0-9]+)", &controllers.BulletinController{}, "get:GetBulletin"), |
44 | - beego.NSRouter("/update", &controllers.BulletinController{}, "get:UpdateBulletin"), | 44 | + beego.NSRouter("/update", &controllers.BulletinController{}, "post:UpdateBulletin"), |
45 | ), | 45 | ), |
46 | ) | 46 | ) |
47 | 47 |
@@ -37,6 +37,7 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ | @@ -37,6 +37,7 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ | ||
37 | CompanyId: companyId, | 37 | CompanyId: companyId, |
38 | CreateAt: time.Now(), | 38 | CreateAt: time.Now(), |
39 | UpdateAt: time.Now(), | 39 | UpdateAt: time.Now(), |
40 | + Status: protocol.BulletinUnRelease, | ||
40 | } | 41 | } |
41 | 42 | ||
42 | orm := orm2.NewOrm() | 43 | orm := orm2.NewOrm() |
@@ -55,6 +56,11 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ | @@ -55,6 +56,11 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ | ||
55 | log.Error(err.Error()) | 56 | log.Error(err.Error()) |
56 | return | 57 | return |
57 | } | 58 | } |
59 | + if !(request.Question.Type == protocol.QuestionSingleSelect || request.Question.Type == protocol.QuestionMultiSelect) { | ||
60 | + err = protocol.NewErrWithMessage("1") | ||
61 | + log.Error("BulletinRelease:Question.Type error:%v", request.Question.Type) | ||
62 | + return | ||
63 | + } | ||
58 | bulletinQuestion = &models.BulletinQuestion{ | 64 | bulletinQuestion = &models.BulletinQuestion{ |
59 | BulletinId: int(id), | 65 | BulletinId: int(id), |
60 | Type: int8(request.Question.Type), | 66 | Type: int8(request.Question.Type), |
@@ -86,6 +92,7 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( | @@ -86,6 +92,7 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( | ||
86 | if request.PageSize == 0 { | 92 | if request.PageSize == 0 { |
87 | request.PageSize = 20 | 93 | request.PageSize = 20 |
88 | } | 94 | } |
95 | + rsp = &protocol.BulletinListResponse{} | ||
89 | if list, total, err = models.GetBulletins(companyId, request.Status, request.Page, request.PageSize); err != nil { | 96 | if list, total, err = models.GetBulletins(companyId, request.Status, request.Page, request.PageSize); err != nil { |
90 | log.Error(err.Error()) | 97 | log.Error(err.Error()) |
91 | return | 98 | return |
@@ -93,7 +100,7 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( | @@ -93,7 +100,7 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( | ||
93 | if len(list) == 0 { | 100 | if len(list) == 0 { |
94 | return | 101 | return |
95 | } | 102 | } |
96 | - rsp = &protocol.BulletinListResponse{} | 103 | + rsp.Total = total |
97 | for i := range list { | 104 | for i := range list { |
98 | bulletin := list[i] | 105 | bulletin := list[i] |
99 | item := &protocol.BulletinItem{ | 106 | item := &protocol.BulletinItem{ |
@@ -101,8 +108,6 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( | @@ -101,8 +108,6 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( | ||
101 | Type: bulletin.Type, | 108 | Type: bulletin.Type, |
102 | Title: bulletin.Title, | 109 | Title: bulletin.Title, |
103 | Status: int8(bulletin.Status), | 110 | Status: int8(bulletin.Status), |
104 | - //TODO:user | ||
105 | - Receiver: []string{}, | ||
106 | CreateAt: bulletin.CreateAt.Format("2006-01-02 15:04:05"), | 111 | CreateAt: bulletin.CreateAt.Format("2006-01-02 15:04:05"), |
107 | } | 112 | } |
108 | if item.Receiver, err = getUsersName(bulletin.Receiver); err != nil { | 113 | if item.Receiver, err = getUsersName(bulletin.Receiver); err != nil { |
@@ -111,7 +116,7 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( | @@ -111,7 +116,7 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( | ||
111 | } | 116 | } |
112 | rsp.List = append(rsp.List, item) | 117 | rsp.List = append(rsp.List, item) |
113 | } | 118 | } |
114 | - rsp.Total = total | 119 | + |
115 | return | 120 | return |
116 | } | 121 | } |
117 | 122 | ||
@@ -131,13 +136,16 @@ func getUsers(idsstr string) (v []models.User, err error) { | @@ -131,13 +136,16 @@ func getUsers(idsstr string) (v []models.User, err error) { | ||
131 | return models.GetUserNameByIds(ids) | 136 | return models.GetUserNameByIds(ids) |
132 | } | 137 | } |
133 | 138 | ||
134 | -func getUsersName(idsStr string) (v []string, err error) { | 139 | +func getUsersName(idsStr string) (v []protocol.Receiver, err error) { |
135 | var users []models.User | 140 | var users []models.User |
136 | if users, err = getUsers(idsStr); err != nil { | 141 | if users, err = getUsers(idsStr); err != nil { |
137 | return | 142 | return |
138 | } | 143 | } |
139 | for i := range users { | 144 | for i := range users { |
140 | - v = append(v, users[i].NickName) | 145 | + v = append(v, protocol.Receiver{ |
146 | + Id: users[i].Id, | ||
147 | + NickName: users[i].NickName, | ||
148 | + }) | ||
141 | } | 149 | } |
142 | return | 150 | return |
143 | } | 151 | } |
@@ -178,6 +186,7 @@ func GetBulletin(id int, companyId int64, request *protocol.GetBulletinRequest) | @@ -178,6 +186,7 @@ func GetBulletin(id int, companyId int64, request *protocol.GetBulletinRequest) | ||
178 | } | 186 | } |
179 | rsp.QuestionSwitch = int(bulletin.QuestionSwitch) | 187 | rsp.QuestionSwitch = int(bulletin.QuestionSwitch) |
180 | rsp.Question = protocol.Question{ | 188 | rsp.Question = protocol.Question{ |
189 | + Id: question.Id, | ||
181 | Type: int(question.Type), | 190 | Type: int(question.Type), |
182 | Title: question.Title, | 191 | Title: question.Title, |
183 | } | 192 | } |
@@ -238,12 +247,18 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r | @@ -238,12 +247,18 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r | ||
238 | log.Error(err.Error()) | 247 | log.Error(err.Error()) |
239 | return | 248 | return |
240 | } | 249 | } |
250 | + if bulletinQuestion.BulletinId != bulletin.Id { | ||
251 | + err = protocol.NewErrWithMessage("1") | ||
252 | + log.Error("UpdateBulletin:BulletinId not equal:(%v!=%v)", bulletinQuestion.BulletinId, bulletin.Id) | ||
253 | + return | ||
254 | + } | ||
241 | if questionContent, err = json.Marshal(request.Question.Content); err != nil { | 255 | if questionContent, err = json.Marshal(request.Question.Content); err != nil { |
242 | log.Error(err.Error()) | 256 | log.Error(err.Error()) |
243 | return | 257 | return |
244 | } | 258 | } |
245 | bulletinQuestion.Content = string(questionContent) | 259 | bulletinQuestion.Content = string(questionContent) |
246 | bulletinQuestion.Type = int8(request.Question.Type) | 260 | bulletinQuestion.Type = int8(request.Question.Type) |
261 | + bulletinQuestion.UpdateAt = time.Now() | ||
247 | if err = models.UpdateBulletinQuestionById(bulletinQuestion); err != nil { | 262 | if err = models.UpdateBulletinQuestionById(bulletinQuestion); err != nil { |
248 | log.Error(err.Error()) | 263 | log.Error(err.Error()) |
249 | return | 264 | return |
@@ -144,3 +144,237 @@ token 的响应内容 | @@ -144,3 +144,237 @@ token 的响应内容 | ||
144 | - 备注:切换公司实际是变更 token 信息 | 144 | - 备注:切换公司实际是变更 token 信息 |
145 | 145 | ||
146 | --- | 146 | --- |
147 | + | ||
148 | + | ||
149 | +## 公告 | ||
150 | + | ||
151 | +### 添加公告 | ||
152 | + | ||
153 | +- 请求路径 :/v1/bulletin/add | ||
154 | +- 请求方式 :post | ||
155 | +- 请求 json: | ||
156 | + | ||
157 | +```json | ||
158 | +{ | ||
159 | + "type":2, | ||
160 | + "title":"标题", | ||
161 | + "content":"公告内容", | ||
162 | + "allow_close":0, | ||
163 | + "allow_condition":3, | ||
164 | + "question_switch":1, | ||
165 | + "receiver":["1","2"], | ||
166 | + "question": | ||
167 | + { | ||
168 | + "id":1, | ||
169 | + "type":1, | ||
170 | + "title":"今天星期几?", | ||
171 | + "content":[ | ||
172 | + { | ||
173 | + "id":1, | ||
174 | + "content":"星期1" | ||
175 | + }, | ||
176 | + { | ||
177 | + "id":2, | ||
178 | + "content":"星期2" | ||
179 | + } | ||
180 | + ] | ||
181 | + }, | ||
182 | + "cover":{ | ||
183 | + "path":"/xx/xx.img", | ||
184 | + "w":50, | ||
185 | + "h":70 | ||
186 | + } | ||
187 | +} | ||
188 | +``` | ||
189 | + | ||
190 | +``` | ||
191 | +obj.type 公告类型(1图+跳转链接、2纯文本) | ||
192 | +obj.title 标题 | ||
193 | +obj.content 公告内容 | ||
194 | +obj.allow_close 允许关闭公告(0允许,1禁止) | ||
195 | +obj.allow_condition 关闭条件 (1(bit 0):公告内容查看完 2(bit 1):回答完问题) | ||
196 | +obj.question_switch 设置问题开关 (是否有问题) 1:是 0:否 | ||
197 | +obj.receiver 接收者 | ||
198 | +obj.question.type 类型:0-单选,1-多选 | ||
199 | +obj.question.title 标题 | ||
200 | +obj.question.content 问题选项 | ||
201 | +obj.cover 封面 | ||
202 | +``` | ||
203 | + | ||
204 | +- 响应 json | ||
205 | + | ||
206 | +```json | ||
207 | +{ | ||
208 | + "code": "00000", | ||
209 | + "msg": "成功", | ||
210 | + "data": {} | ||
211 | +} | ||
212 | +``` | ||
213 | + | ||
214 | +--- | ||
215 | + | ||
216 | + | ||
217 | +### 公告列表 | ||
218 | + | ||
219 | +- 请求路径 :/v1/bulletin/list | ||
220 | +- 请求方式 :post | ||
221 | +- 请求 json: | ||
222 | + | ||
223 | +```json | ||
224 | +{ | ||
225 | + "page":1, | ||
226 | + "page_size":20, | ||
227 | + "status":0 | ||
228 | +} | ||
229 | +``` | ||
230 | + | ||
231 | +``` | ||
232 | +obj.status 状态 0-所有 1-下架 2-上架 | ||
233 | +``` | ||
234 | + | ||
235 | +- 响应 json | ||
236 | + | ||
237 | +```json | ||
238 | +{ | ||
239 | + "code": "00000", | ||
240 | + "msg": "成功", | ||
241 | + "data": { | ||
242 | + "list": [ | ||
243 | + { | ||
244 | + "id": 5, | ||
245 | + "type": 2, | ||
246 | + "title": "测试公告", | ||
247 | + "status": 1, | ||
248 | + "receiver": [ | ||
249 | + { | ||
250 | + "id": 1, | ||
251 | + "name": "Jennifer Clark" | ||
252 | + }, | ||
253 | + { | ||
254 | + "id": 2, | ||
255 | + "name": "邓娱婷1208" | ||
256 | + } | ||
257 | + ], | ||
258 | + "time": "2019-12-11 17:11:43" | ||
259 | + } | ||
260 | + ], | ||
261 | + "Total": 2 | ||
262 | + } | ||
263 | +} | ||
264 | +``` | ||
265 | + | ||
266 | + | ||
267 | +### 公告详情 | ||
268 | + | ||
269 | +- 请求路径 :/v1/bulletin/:id | ||
270 | +- 请求方式 :get | ||
271 | +- 请求 json: | ||
272 | + | ||
273 | +```json | ||
274 | +{ | ||
275 | +} | ||
276 | +``` | ||
277 | + | ||
278 | +``` | ||
279 | +obj.status 状态 0-所有 1-下架 2-上架 | ||
280 | +``` | ||
281 | + | ||
282 | +- 响应 json | ||
283 | + | ||
284 | +```json | ||
285 | +{ | ||
286 | + "code": "00000", | ||
287 | + "msg": "成功", | ||
288 | + "data": { | ||
289 | + "id": 5, | ||
290 | + "type": 2, | ||
291 | + "title": "测试公告", | ||
292 | + "content": "今天发布了一则公告", | ||
293 | + "allow_close": 0, | ||
294 | + "allow_condition": 3, | ||
295 | + "question_switch": 1, | ||
296 | + "receiver": [ | ||
297 | + { | ||
298 | + "id": 1, | ||
299 | + "name": "Jennifer Clark" | ||
300 | + }, | ||
301 | + { | ||
302 | + "id": 2, | ||
303 | + "name": "邓娱婷1208" | ||
304 | + } | ||
305 | + ], | ||
306 | + "question": { | ||
307 | + "id": 4, | ||
308 | + "type": 1, | ||
309 | + "title": "今天星期几?", | ||
310 | + "content": [ | ||
311 | + { | ||
312 | + "id": 1, | ||
313 | + "content": "星期1" | ||
314 | + }, | ||
315 | + { | ||
316 | + "id": 2, | ||
317 | + "content": "星期2" | ||
318 | + } | ||
319 | + ] | ||
320 | + }, | ||
321 | + "cover": { | ||
322 | + "path": "/xx/xx.img", | ||
323 | + "h": 70, | ||
324 | + "w": 50 | ||
325 | + } | ||
326 | + } | ||
327 | +} | ||
328 | +``` | ||
329 | + | ||
330 | + | ||
331 | +### 公告更新 | ||
332 | + | ||
333 | +- 请求路径 :/v1/bulletin/update | ||
334 | +- 请求方式 :post | ||
335 | +- 请求 json: | ||
336 | + | ||
337 | +```json | ||
338 | +{ | ||
339 | + "id":3, | ||
340 | + "type":2, | ||
341 | + "title":"测试公告3", | ||
342 | + "content":"今天发布了一则公告3", | ||
343 | + "allow_close":0, | ||
344 | + "allow_condition":2, | ||
345 | + "question_switch":1, | ||
346 | + "receiver":["1","2","3"], | ||
347 | + "question": | ||
348 | + { | ||
349 | + "id":2, | ||
350 | + "type":1, | ||
351 | + "title":"今天星期几?", | ||
352 | + "content":[ | ||
353 | + { | ||
354 | + "id":1, | ||
355 | + "content":"星期2" | ||
356 | + }, | ||
357 | + { | ||
358 | + "id":2, | ||
359 | + "content":"星期3" | ||
360 | + } | ||
361 | + ] | ||
362 | + }, | ||
363 | + "cover":{ | ||
364 | + "path":"/xx/xx.img", | ||
365 | + "w":50, | ||
366 | + "h":70 | ||
367 | + } | ||
368 | +} | ||
369 | +``` | ||
370 | + | ||
371 | +- 响应 json | ||
372 | + | ||
373 | +```json | ||
374 | +{ | ||
375 | + "code": "00000", | ||
376 | + "msg": "成功", | ||
377 | + "data": null | ||
378 | +} | ||
379 | +``` | ||
380 | + |
-
请 注册 或 登录 后发表评论