|
@@ -15,12 +15,15 @@ import (
|
15
|
15
|
|
16
|
16
|
func ArticleRouters() {
|
17
|
17
|
|
18
|
|
- beego.Router("/api/acticle/createacticle",&ArticleManage{},"Get:CreateArticle")
|
|
18
|
+ beego.Router("/api/acticle/createacticle",&ArticleManage{},"Post:CreateArticle")
|
19
|
19
|
beego.Router("/api/acticle/getArticleType",&ArticleManage{},"Get:GetArticleType")
|
20
|
20
|
beego.Router("/api/acticle/getAllArticles",&ArticleManage{},"Get:GetAllArticles")
|
21
|
21
|
beego.Router("/api/article/addCategory",&ArticleManage{},"Post:AddCategory")
|
22
|
22
|
beego.Router("/api/acticle/getCategorys",&ArticleManage{},"Get:GetCategorys")
|
23
|
|
- beego.Router("/api/acticle/edit",&ArticleManage{},"Put:EditCategorys")
|
|
23
|
+ beego.Router("/api/acticle/edit",&ArticleManage{},"Post:EditCategorys")
|
|
24
|
+ beego.Router("/api/acticle/delete",&ArticleManage{},"Delete:DeleteCategorys")
|
|
25
|
+ beego.Router("/api/acticle/addvido",&ArticleManage{},"Post:Addvido")
|
|
26
|
+ beego.Router("/api/acticle/savedraft",&ArticleManage{},"Post:SaveDraft")
|
24
|
27
|
}
|
25
|
28
|
|
26
|
29
|
type ArticleManage struct {
|
|
@@ -31,10 +34,40 @@ type ArticleManage struct {
|
31
|
34
|
func (this *ArticleManage) CreateArticle(){
|
32
|
35
|
adminUserInfo := this.GetAdminUserInfo()
|
33
|
36
|
userOrgID := int64(adminUserInfo.CurrentOrgId)
|
34
|
|
- actname := this.GetString("act_name")
|
35
|
|
- actcontent := this.GetString("act_content")
|
36
|
|
- orglogo := this.GetString("org_logo")
|
37
|
|
- acttype, _ := this.GetInt64("act_type")
|
|
37
|
+ dataBody := make(map[string]interface{}, 0)
|
|
38
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
39
|
+ fmt.Println("视频发布是什么呢",err)
|
|
40
|
+
|
|
41
|
+ if err != nil {
|
|
42
|
+ utils.ErrorLog(err.Error())
|
|
43
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
|
|
44
|
+ return
|
|
45
|
+ }
|
|
46
|
+
|
|
47
|
+ actname := dataBody["act_name"].(string)
|
|
48
|
+ if len(actname) == 0 {
|
|
49
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
|
|
50
|
+ return
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+ actcontent := dataBody["act_content"].(string)
|
|
54
|
+ if len(actcontent) == 0 {
|
|
55
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章内容不能为空")
|
|
56
|
+ return
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ orglogo := dataBody["org_logo"].(string)
|
|
60
|
+ if len(orglogo) == 0 {
|
|
61
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "封面图片不能为空")
|
|
62
|
+ return
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+ acttype := int64(dataBody["act_type"].(float64))
|
|
66
|
+ if acttype <= 0 {
|
|
67
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
|
|
68
|
+ return
|
|
69
|
+ }
|
|
70
|
+
|
38
|
71
|
timenow := time.Now().Unix()
|
39
|
72
|
fmt.Println("姓名:",actname,"文章内容",actcontent,"图片",orglogo,"文章类型",acttype,userOrgID)
|
40
|
73
|
articles := models.Articles{
|
|
@@ -45,12 +78,17 @@ func (this *ArticleManage) CreateArticle(){
|
45
|
78
|
UserOrgId:userOrgID,
|
46
|
79
|
Ctime:timenow,
|
47
|
80
|
Status:1,
|
|
81
|
+ Type:1,
|
|
82
|
+ ArticleStatus:1,
|
48
|
83
|
}
|
49
|
|
- err := article_service.AddAritcle(articles)
|
|
84
|
+ err = article_service.AddAritcle(articles)
|
50
|
85
|
if err !=nil{
|
51
|
86
|
this.ServeFailJsonSend(enums.ErrorCodeDataException, "插入文章失败")
|
52
|
87
|
return
|
53
|
88
|
}
|
|
89
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
90
|
+ "articles":articles,
|
|
91
|
+ })
|
54
|
92
|
}
|
55
|
93
|
|
56
|
94
|
func (this *ArticleManage) GetArticleType(){
|
|
@@ -124,14 +162,14 @@ func (this *ArticleManage) AddCategory(){
|
124
|
162
|
return
|
125
|
163
|
}
|
126
|
164
|
|
127
|
|
- content := dataBody["content"].(string)
|
|
165
|
+ content := dataBody["summary"].(string)
|
128
|
166
|
fmt.Println("content是谁?",content)
|
129
|
167
|
if len(content) == 0 {
|
130
|
168
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong,"内容不能为空")
|
131
|
169
|
return
|
132
|
170
|
}
|
133
|
171
|
|
134
|
|
- sort := dataBody["sort"].(string)
|
|
172
|
+ sort := dataBody["order"].(string)
|
135
|
173
|
sors, _ := strconv.ParseInt(sort, 10, 64)
|
136
|
174
|
if sors <=0 {
|
137
|
175
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序不能为空")
|
|
@@ -189,7 +227,7 @@ func (this *ArticleManage) GetCategorys() {
|
189
|
227
|
}
|
190
|
228
|
|
191
|
229
|
func (this *ArticleManage) EditCategorys() {
|
192
|
|
- id, _ := this.GetInt64("MenuId", 0)
|
|
230
|
+ id, _ := this.GetInt64("id", 0)
|
193
|
231
|
fmt.Println("ID是多少",id)
|
194
|
232
|
if id <= 0 {
|
195
|
233
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误:id")
|
|
@@ -198,18 +236,18 @@ func (this *ArticleManage) EditCategorys() {
|
198
|
236
|
adminUserInfo := this.GetAdminUserInfo()
|
199
|
237
|
userOrgID := adminUserInfo.CurrentOrgId
|
200
|
238
|
categorys, err := article_service.GetCategorysByID(userOrgID, id)
|
201
|
|
- fmt.Println("err是设么",err)
|
|
239
|
+ fmt.Println("categorys是?",categorys,err)
|
202
|
240
|
if err != nil {
|
203
|
|
- this.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑类别失败:("+err.Error()+")")
|
|
241
|
+ this.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑会员失败:("+err.Error()+")")
|
204
|
242
|
return
|
205
|
243
|
}
|
206
|
244
|
if categorys == nil {
|
207
|
|
- this.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑类别失败:(会员记录不存在)")
|
|
245
|
+ this.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑会员失败:(会员记录不存在)")
|
208
|
246
|
return
|
209
|
247
|
}
|
210
|
|
-
|
211
|
248
|
timenow := time.Now().Unix()
|
212
|
249
|
|
|
250
|
+
|
213
|
251
|
dataBody := make(map[string]interface{}, 0)
|
214
|
252
|
err = json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
215
|
253
|
if err != nil {
|
|
@@ -218,28 +256,25 @@ func (this *ArticleManage) EditCategorys() {
|
218
|
256
|
return
|
219
|
257
|
}
|
220
|
258
|
|
221
|
|
- name:= dataBody["Name"].(string)
|
|
259
|
+ name:= dataBody["name"].(string)
|
222
|
260
|
fmt.Println("name是谁?",name)
|
223
|
|
- if len(name) == 0 {
|
224
|
|
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "姓名不能为空")
|
225
|
|
- return
|
226
|
|
- }
|
227
|
261
|
|
228
|
|
- content := dataBody["Summary"].(string)
|
|
262
|
+ content := dataBody["summary"].(string)
|
229
|
263
|
fmt.Println("content是谁?",content)
|
230
|
264
|
if len(content) == 0 {
|
231
|
265
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong,"内容不能为空")
|
232
|
266
|
return
|
233
|
267
|
}
|
234
|
268
|
|
235
|
|
- sort := dataBody["Order"].(string)
|
236
|
|
- sors, _ := strconv.ParseInt(sort, 10, 64)
|
237
|
|
- if sors <=0 {
|
|
269
|
+ sors :=int64(dataBody["order"].(float64))
|
|
270
|
+ //sors, _ := strconv.ParseInt(sort, 10, 64)
|
|
271
|
+ fmt.Println("sort0",sors)
|
|
272
|
+ if sors <= 0 {
|
238
|
273
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序不能为空")
|
239
|
274
|
return
|
240
|
275
|
}
|
241
|
|
- fmt.Println("soert是谁?",sort)
|
242
|
|
- fmt.Println("姓名:",name,"内容",content,"排序",sort)
|
|
276
|
+ fmt.Println("soert是谁?",sors)
|
|
277
|
+ fmt.Println("姓名:",name,"内容",content,"排序",sors)
|
243
|
278
|
|
244
|
279
|
category := models.ArticleCategory{
|
245
|
280
|
Name: name,
|
|
@@ -249,14 +284,173 @@ func (this *ArticleManage) EditCategorys() {
|
249
|
284
|
Status: 1,
|
250
|
285
|
Mtime: timenow,
|
251
|
286
|
}
|
252
|
|
- err = article_service.EditCategory(category)
|
253
|
|
- fmt.Println("err错误",err)
|
|
287
|
+ fmt.Println("category是?",category)
|
|
288
|
+ article_service.EditCategory(&category,userOrgID,id)
|
|
289
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
290
|
+ "category":category,
|
|
291
|
+ })
|
|
292
|
+}
|
|
293
|
+
|
|
294
|
+func (this *ArticleManage) DeleteCategorys() {
|
|
295
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
296
|
+
|
|
297
|
+ dataBody := make(map[string]interface{}, 0)
|
|
298
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
299
|
+ if err != nil {
|
|
300
|
+ utils.ErrorLog(err.Error())
|
|
301
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
|
|
302
|
+ return
|
|
303
|
+ }
|
|
304
|
+
|
|
305
|
+ idsInters := dataBody["ids"].([]interface{})
|
|
306
|
+ if len(idsInters) == 0 {
|
|
307
|
+ if err != nil {
|
|
308
|
+ this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
|
|
309
|
+ return
|
|
310
|
+ }
|
|
311
|
+ }
|
|
312
|
+
|
|
313
|
+ ids := make([]int64, 0)
|
|
314
|
+ for _, idsInter := range idsInters {
|
|
315
|
+ id := int64(idsInter.(float64))
|
|
316
|
+ ids = append(ids, id)
|
|
317
|
+ }
|
|
318
|
+
|
|
319
|
+ err = article_service.DeleteCategorys(adminUserInfo.CurrentOrgId, ids)
|
254
|
320
|
if err != nil {
|
255
|
|
- this.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑类别失败:("+err.Error()+")")
|
|
321
|
+ this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除分类失败:("+err.Error()+")")
|
256
|
322
|
return
|
257
|
323
|
}
|
258
|
|
- fmt.Println(category)
|
|
324
|
+ returnData := make(map[string]interface{}, 0)
|
|
325
|
+ returnData["msg"] = "ok"
|
|
326
|
+ this.ServeSuccessJSON(returnData)
|
|
327
|
+ return
|
|
328
|
+}
|
|
329
|
+
|
|
330
|
+func (this *ArticleManage) Addvido(){
|
|
331
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
332
|
+ userOrgID := adminUserInfo.CurrentOrgId
|
|
333
|
+ dataBody := make(map[string]interface{}, 0)
|
|
334
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
335
|
+ fmt.Println("视频发布是什么呢",err)
|
|
336
|
+
|
|
337
|
+ if err != nil {
|
|
338
|
+ utils.ErrorLog(err.Error())
|
|
339
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
|
|
340
|
+ return
|
|
341
|
+ }
|
|
342
|
+
|
|
343
|
+ vidupload := dataBody["vio_upload"].(string)
|
|
344
|
+ if len(vidupload) == 0 {
|
|
345
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频不能为空")
|
|
346
|
+ return
|
|
347
|
+ }
|
|
348
|
+ fmt.Println("视频",vidupload)
|
|
349
|
+ vidname := dataBody["vid_name"].(string)
|
|
350
|
+ if len(vidname)==0{
|
|
351
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频标题不能为空")
|
|
352
|
+ return
|
|
353
|
+ }
|
|
354
|
+ fmt.Println("视频名称",vidname)
|
|
355
|
+ vidpic := dataBody["vid_pic"].(string)
|
|
356
|
+ if(vidpic == ""){
|
|
357
|
+ vidpic = vidupload + "?vframe/jpg/offset/1/w/300/h/200"
|
|
358
|
+ }
|
|
359
|
+ if len(vidpic)==0{
|
|
360
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频封面不能为空")
|
|
361
|
+ return
|
|
362
|
+ }
|
|
363
|
+ fmt.Println("视频图片",vidpic)
|
|
364
|
+ vidtype := int64(dataBody["vid_type"].(float64))
|
|
365
|
+ if vidtype <= 0 {
|
|
366
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "所属分类不能为空")
|
|
367
|
+ return
|
|
368
|
+ }
|
|
369
|
+ fmt.Println("视频类型",vidtype)
|
|
370
|
+ fmt.Println("视频",vidupload,"视频标题",vidname,"视频封面",vidpic,"视频类型",vidtype)
|
|
371
|
+ timenow := time.Now().Unix()
|
|
372
|
+ articles := models.Articles{
|
|
373
|
+ UserOrgId:userOrgID,
|
|
374
|
+ Ctime:timenow,
|
|
375
|
+ Type:2,
|
|
376
|
+ VideoUrl:vidupload,
|
|
377
|
+ Title:vidname,
|
|
378
|
+ Imgs:vidpic,
|
|
379
|
+ ClassId:vidtype,
|
|
380
|
+ ArticleStatus:1,
|
|
381
|
+ }
|
|
382
|
+
|
|
383
|
+ err = article_service.AddVido(articles)
|
|
384
|
+ if err !=nil{
|
|
385
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加分类失败")
|
|
386
|
+ return
|
|
387
|
+ }
|
|
388
|
+
|
259
|
389
|
this.ServeSuccessJSON(map[string]interface{}{
|
260
|
|
- "category":categorys,
|
|
390
|
+ "vido":articles,
|
|
391
|
+ })
|
|
392
|
+}
|
|
393
|
+
|
|
394
|
+func (this *ArticleManage) SaveDraft() {
|
|
395
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
396
|
+ userOrgID := adminUserInfo.CurrentOrgId
|
|
397
|
+ dataBody := make(map[string]interface{}, 0)
|
|
398
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
399
|
+ fmt.Println("视频发布是什么呢",err)
|
|
400
|
+
|
|
401
|
+ if err != nil {
|
|
402
|
+ utils.ErrorLog(err.Error())
|
|
403
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
|
|
404
|
+ return
|
|
405
|
+ }
|
|
406
|
+
|
|
407
|
+ vidupload := dataBody["vio_upload"].(string)
|
|
408
|
+ if len(vidupload) == 0 {
|
|
409
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频不能为空")
|
|
410
|
+ return
|
|
411
|
+ }
|
|
412
|
+ fmt.Println("视频",vidupload)
|
|
413
|
+ vidname := dataBody["vid_name"].(string)
|
|
414
|
+ if len(vidname)==0{
|
|
415
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频标题不能为空")
|
|
416
|
+ return
|
|
417
|
+ }
|
|
418
|
+ fmt.Println("视频名称",vidname)
|
|
419
|
+ vidpic := dataBody["vid_pic"].(string)
|
|
420
|
+ if(vidpic == ""){
|
|
421
|
+ vidpic = vidupload + "?vframe/jpg/offset/1/w/300/h/200"
|
|
422
|
+ }
|
|
423
|
+ if len(vidpic)==0{
|
|
424
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频封面不能为空")
|
|
425
|
+ return
|
|
426
|
+ }
|
|
427
|
+ fmt.Println("视频图片",vidpic)
|
|
428
|
+ vidtype := int64(dataBody["vid_type"].(float64))
|
|
429
|
+ if vidtype <= 0 {
|
|
430
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "所属分类不能为空")
|
|
431
|
+ return
|
|
432
|
+ }
|
|
433
|
+ fmt.Println("视频类型",vidtype)
|
|
434
|
+ fmt.Println("视频",vidupload,"视频标题",vidname,"视频封面",vidpic,"视频类型",vidtype)
|
|
435
|
+ timenow := time.Now().Unix()
|
|
436
|
+ articles := models.Articles{
|
|
437
|
+ UserOrgId:userOrgID,
|
|
438
|
+ Ctime:timenow,
|
|
439
|
+ Type:2,
|
|
440
|
+ VideoUrl:vidupload,
|
|
441
|
+ Title:vidname,
|
|
442
|
+ Imgs:vidpic,
|
|
443
|
+ ClassId:vidtype,
|
|
444
|
+ ArticleStatus:2,
|
|
445
|
+ }
|
|
446
|
+
|
|
447
|
+ err = article_service.AddVido(articles)
|
|
448
|
+ if err !=nil{
|
|
449
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加分类失败")
|
|
450
|
+ return
|
|
451
|
+ }
|
|
452
|
+
|
|
453
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
454
|
+ "savedraft":articles,
|
261
|
455
|
})
|
262
|
456
|
}
|