scrm-go

article_controller.go 43KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498
  1. package article
  2. import (
  3. "github.com/astaxie/beego"
  4. "fmt"
  5. "SCRM/controllers"
  6. "SCRM/service/article_service"
  7. "SCRM/enums"
  8. "SCRM/models"
  9. "time"
  10. "SCRM/utils"
  11. "encoding/json"
  12. "strconv"
  13. "github.com/jinzhu/gorm"
  14. )
  15. func ArticleRouters() {
  16. beego.Router("/api/acticle/createacticle",&ArticleManage{},"Post:CreateArticle")
  17. beego.Router("/api/acticle/getArticleType",&ArticleManage{},"Get:GetArticleType")
  18. beego.Router("/api/acticle/getAllArticles",&ArticleManage{},"Get:GetAllArticles")
  19. beego.Router("/api/article/addCategory",&ArticleManage{},"Post:AddCategory")
  20. beego.Router("/api/article/getAritcleCount",&ArticleManage{},"Post:GetArticleCount")
  21. beego.Router("/api/acticle/getCategorys",&ArticleManage{},"Get:GetCategorys")
  22. beego.Router("/api/acticle/edit",&ArticleManage{},"Post:EditCategorys")
  23. beego.Router("/api/acticle/delete",&ArticleManage{},"Delete:DeleteCategorys")
  24. beego.Router("/api/acticle/addvido",&ArticleManage{},"Post:Addvido")
  25. beego.Router("/api/acticle/savedraft",&ArticleManage{},"Post:SaveDraft")
  26. beego.Router("/api/acticle/prviewArticle",&ArticleManage{},"Post:PrviewArticle")
  27. beego.Router("/api/acticle/getarticlePreview",&ArticleManage{},"Get:GetArtilcePreview")
  28. beego.Router("/api/acticle/save",&ArticleManage{},"Post:AddDraft")
  29. beego.Router("/api/acticle/getEditArticle",&ArticleManage{},"Post:GetArticleInfo")
  30. beego.Router("/api/article/Delete",&ArticleManage{},"Delete:DeleteArticle")
  31. beego.Router("/api/acticle/getMenus",&ArticleManage{},"Get:GetMenus")
  32. beego.Router("/api/acticle/updateArticlesInfo",&ArticleManage{},"Post:UpdataArticleInfo")
  33. beego.Router("/api/acticle/saveArticleDraft",&ArticleManage{},"Post:SaveArticleDraft")
  34. beego.Router("/api/acticle/updateVidoInfo",&ArticleManage{},"Post:UpdateVidoInfo")
  35. beego.Router("/api/acticle/previewEditArticle",&ArticleManage{},"Post:PreviewEditArticle")
  36. beego.Router("/api/acticle/getPreviewInfo",&ArticleManage{},"Get:GetPreviewInfoTwo")
  37. beego.Router("/api/acticle/getAllComment",&ArticleManage{},"Get:GetAllComment")
  38. beego.Router("/api/acticle/getArticleCommentDetail",&ArticleManage{},"Get:GetArticleCommentDetail")
  39. beego.Router("/api/article/deleteArticle",&ArticleManage{},"Get:DeleteArticles")
  40. beego.Router("/api/acticle/send",&ArticleManage{},"Get:SendReplycontent")
  41. beego.Router("/api/acticle/getReplyAllComents",&ArticleManage{},"Get:GetReplyAllComents")
  42. beego.Router("/api/article/sendInformation",&ArticleManage{},"Get:GetSendInformation")
  43. beego.Router("/api/article/spreadReplay",&ArticleManage{},"Get:GetSpreadReplay")
  44. beego.Router("/api/article/clearRelyInfo",&ArticleManage{},"Delete:ClearReplyInfo")
  45. beego.Router("/api/article/deleteReply",&ArticleManage{},"Delete:DeleteReply")
  46. beego.Router("/api/article/spread",&ArticleManage{},"Get:GetSpreadInfo")
  47. beego.Router("/api/article/clear",&ArticleManage{},"Delete:ClearReply")
  48. beego.Router("/api/article/deleteComments",&ArticleManage{},"Delete:DeleteComments")
  49. beego.Router("/api/acticle/getEditVidoInfo",&ArticleManage{},"Get:GetVidoInfo")
  50. beego.Router("/api/acticle/savevidodraft",&ArticleManage{},"Post:SaveVidoDraft")
  51. beego.Router("/api/article/openDeleteReply",&ArticleManage{},"Delete:DeleteAllReply")
  52. beego.Router("/api/article/deleteAllArticles",&ArticleManage{},"Delete:DeleteAllArticles")
  53. beego.Router("/api/aritcle/getallcategory",&ArticleManage{},"Get:GetAllCategory")
  54. beego.Router("/api/article/getarticledetail",&ArticleManage{},"Get:GetArticleDetail")
  55. beego.Router("/api/article/getvidodetail",&ArticleManage{},"Get:GetVidoDetail")
  56. beego.Router("/api/article/geteditarticlecontent",&ArticleManage{},"Get:GetEditArticleContent")
  57. }
  58. type ArticleManage struct {
  59. controllers.BaseAuthAPIController
  60. }
  61. func (this *ArticleManage) CreateArticle(){
  62. adminUserInfo := this.GetAdminUserInfo()
  63. userOrgID := int64(adminUserInfo.CurrentOrgId)
  64. dataBody := make(map[string]interface{}, 0)
  65. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  66. fmt.Println("视频发布是什么呢",err)
  67. if err != nil {
  68. utils.ErrorLog(err.Error())
  69. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  70. return
  71. }
  72. actname := dataBody["act_name"].(string)
  73. fmt.Println("文章标题",actname)
  74. if len(actname) == 0 {
  75. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  76. return
  77. }
  78. actcontent := dataBody["act_content"].(string)
  79. fmt.Println("文章内容",actcontent)
  80. if len(actcontent) == 0 {
  81. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章内容不能为空")
  82. return
  83. }
  84. orglogo := dataBody["org_logo"].(string)
  85. fmt.Println("封面图片",orglogo)
  86. //if len(orglogo) == 0 {
  87. // this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "封面图片不能为空")
  88. // return
  89. //}
  90. acttype := int64(dataBody["act_type"].(float64))
  91. fmt.Println("文章分类",acttype)
  92. if acttype <= 0 {
  93. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
  94. return
  95. }
  96. timenow := time.Now().Unix()
  97. fmt.Println("姓名:",actname,"文章内容",actcontent,"图片",orglogo,"文章类型",acttype,userOrgID)
  98. articles := models.Articles{
  99. Title: actname,
  100. Content: actcontent,
  101. Imgs: orglogo,
  102. ClassId: acttype,
  103. UserOrgId:userOrgID,
  104. Ctime:timenow,
  105. Status:1,
  106. Type:1,
  107. ArticleStatus:1,
  108. }
  109. err = article_service.AddAritcle(articles)
  110. fmt.Println("错误是什么",err)
  111. if err !=nil{
  112. this.ServeFailJsonSend(enums.ErrorCodeDataException, "插入文章失败")
  113. return
  114. }
  115. this.ServeSuccessJSON(map[string]interface{}{
  116. "articles":articles,
  117. })
  118. }
  119. func (this *ArticleManage) GetArticleType(){
  120. adminUserInfo := this.GetAdminUserInfo()
  121. userOrgID := adminUserInfo.CurrentOrgId
  122. category, err := article_service.FindArticleCategoryType(userOrgID)
  123. fmt.Println("文章分类列表",category,err)
  124. if err !=nil{
  125. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
  126. return
  127. }
  128. this.ServeSuccessJSON(map[string]interface{}{
  129. "category":category,
  130. })
  131. return
  132. }
  133. func (this *ArticleManage) GetAllArticles() {
  134. page, _ := this.GetInt64("page", 1)
  135. fmt.Println("页面",page)
  136. limit, _ := this.GetInt64("limit", 10)
  137. fmt.Println("限制",limit)
  138. searchKey := this.GetString("keyword", "")
  139. fmt.Println("搜索字",searchKey)
  140. classId,_ := this.GetInt64("id",0)
  141. status, _ := this.GetInt64("status")
  142. fmt.Println("页面",page,"限制",limit,"关键字",searchKey,"分类号",classId,"状态值:",status)
  143. if page <= 0 {
  144. page = 1
  145. }
  146. if limit <= 0 {
  147. limit = 10
  148. }
  149. adminUserInfo := this.GetAdminUserInfo()
  150. userOrgID := adminUserInfo.CurrentOrgId
  151. //org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
  152. //OrgName := org.OrgName
  153. //fmt.Println("机构姓名:",OrgName)
  154. if(status == 1){
  155. articles, total, err := article_service.GetPublished(userOrgID, page, limit, searchKey)
  156. category, err := article_service.FindCategoryList(userOrgID)
  157. fmt.Println("分类号",category)
  158. if err !=nil{
  159. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
  160. return
  161. }
  162. this.ServeSuccessJSON(map[string]interface{}{
  163. "articles":articles,
  164. "total":total,
  165. "category":category,
  166. })
  167. }
  168. if(status == 2){
  169. articles, total, err := article_service.GetDraftbox(userOrgID, page, limit, searchKey)
  170. category, err := article_service.FindCategoryList(userOrgID)
  171. if err !=nil{
  172. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
  173. return
  174. }
  175. this.ServeSuccessJSON(map[string]interface{}{
  176. "articles":articles,
  177. "total":total,
  178. "category":category,
  179. })
  180. }
  181. if(status == 3){
  182. articles, total, err := article_service.GetNoPass(userOrgID, page, limit, searchKey)
  183. category, err := article_service.FindCategoryList(userOrgID)
  184. if err !=nil{
  185. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
  186. return
  187. }
  188. this.ServeSuccessJSON(map[string]interface{}{
  189. "articles":articles,
  190. "total":total,
  191. "category":category,
  192. })
  193. }
  194. articles, total, err := article_service.FindAllArticle(userOrgID, page,limit, searchKey,classId)
  195. fmt.Println("文章内容是是么",articles)
  196. fmt.Println("total",total)
  197. fmt.Println("err",err)
  198. if err !=nil{
  199. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章列表失败")
  200. return
  201. }
  202. category, err := article_service.FindCategoryList(userOrgID)
  203. fmt.Println("category是傻",category,err)
  204. if err !=nil{
  205. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
  206. return
  207. }
  208. this.ServeSuccessJSON(map[string]interface{}{
  209. "articles":articles,
  210. "total":total,
  211. "category":category,
  212. })
  213. return
  214. }
  215. //func (this *ArticleManage) GetAllartic() {
  216. // page, _ := this.GetInt64("page", 1)
  217. // fmt.Println("页面2",page)
  218. // limit, _ := this.GetInt64("limit", 10)
  219. // fmt.Println("限制3",limit)
  220. // adminUserInfo := this.GetAdminUserInfo()
  221. // userOrgID := adminUserInfo.CurrentOrgId
  222. // if page <= 0 {
  223. // page = 1
  224. // }
  225. // if limit <= 0 {
  226. // limit = 10
  227. // }
  228. // articles, total, err := article_service.GetAllartic(page, limit, userOrgID)
  229. // fmt.Println("articles",articles)
  230. // fmt.Println("total",total)
  231. // fmt.Println("err",err)
  232. // if err !=nil{
  233. // this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
  234. // return
  235. // }
  236. // //org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
  237. // //OrgName := org.OrgName
  238. // //fmt.Println("OrgName",OrgName)
  239. // this.ServeSuccessJSON(map[string]interface{}{
  240. // "articles":articles,
  241. // "total":total,
  242. // })
  243. //}
  244. func (this *ArticleManage) AddCategory(){
  245. dataBody := make(map[string]interface{}, 0)
  246. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  247. fmt.Println("err是什么呢",err)
  248. if err != nil {
  249. utils.ErrorLog(err.Error())
  250. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  251. return
  252. }
  253. name:= dataBody["name"].(string)
  254. fmt.Println("name是谁?",name)
  255. if len(name) == 0 {
  256. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "姓名不能为空")
  257. return
  258. }
  259. content := dataBody["summary"].(string)
  260. fmt.Println("content是谁?",content)
  261. if len(content) == 0 {
  262. this.ServeFailJsonSend(enums.ErrorCodeParamWrong,"内容不能为空")
  263. return
  264. }
  265. sort := dataBody["order"].(string)
  266. sors, _ := strconv.ParseInt(sort, 10, 64)
  267. if sors <=0 {
  268. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序不能为空")
  269. return
  270. }
  271. fmt.Println("soert是谁?",sort)
  272. fmt.Println("姓名:",name,"内容",content,"排序",sort)
  273. timenow := time.Now().Unix()
  274. adminUserInfo := this.GetAdminUserInfo()
  275. userOrgID := adminUserInfo.CurrentOrgId
  276. category := models.ArticleCategory{
  277. Name: name,
  278. Summary: content,
  279. Order: sors,
  280. UserOrgId:userOrgID,
  281. Status: 1,
  282. Ctime: timenow,
  283. }
  284. fmt.Println(category)
  285. articleCategory, errcod := article_service.AddCategory(name)
  286. fmt.Println(articleCategory);
  287. fmt.Println("errecod是什么",errcod)
  288. if errcod == gorm.ErrRecordNotFound{
  289. fmt.Println("aaaaa");
  290. err := article_service.SaveCategory(category)
  291. fmt.Println("报错",err)
  292. this.ServeSuccessJSON(map[string]interface{}{
  293. "category":category,
  294. })
  295. fmt.Println(err)
  296. }else if errcod == nil {
  297. fmt.Println("bbbbbbb")
  298. this.ServeFailJsonSend(enums.ErrorCodeDBCreate, "添加标签失败:(已经存在同名的标签)")
  299. return
  300. }else {
  301. this.ServeSuccessJSON(map[string]interface{}{
  302. "category":category,
  303. })
  304. }
  305. return
  306. }
  307. func (this *ArticleManage) GetArticleCount() {
  308. dataBody := make(map[string]interface{}, 0)
  309. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  310. fmt.Println("err是什么呢",err)
  311. if err != nil {
  312. utils.ErrorLog(err.Error())
  313. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  314. return
  315. }
  316. name:= dataBody["name"].(string)
  317. fmt.Println("name是什么?",name)
  318. if len(name) == 0 {
  319. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "姓名不能为空")
  320. return
  321. }
  322. }
  323. func (this *ArticleManage) GetCategorys() {
  324. adminUserInfo := this.GetAdminUserInfo()
  325. userOrgID := adminUserInfo.CurrentOrgId
  326. page, _ := this.GetInt64("page", 1)
  327. fmt.Println("页面",page)
  328. limit, _ := this.GetInt64("limit", 10)
  329. fmt.Println("限制",limit)
  330. if page <= 0 {
  331. page = 1
  332. }
  333. if limit <= 0 {
  334. limit = 10
  335. }
  336. fmt.Println("机构ID",userOrgID)
  337. categorys, total, err := article_service.GetCategorys(page, limit, userOrgID)
  338. fmt.Println("hhe",categorys,total,err)
  339. if err !=nil{
  340. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
  341. return
  342. }
  343. this.ServeSuccessJSON(map[string]interface{}{
  344. "category":categorys,
  345. "total":total,
  346. })
  347. return
  348. }
  349. func (this *ArticleManage) EditCategorys() {
  350. id, _ := this.GetInt64("id", 0)
  351. fmt.Println("ID是多少",id)
  352. if id <= 0 {
  353. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误:id")
  354. return
  355. }
  356. adminUserInfo := this.GetAdminUserInfo()
  357. userOrgID := adminUserInfo.CurrentOrgId
  358. categorys, err := article_service.GetCategorysByID(userOrgID, id)
  359. fmt.Println("categorys是?",categorys,err)
  360. if err != nil {
  361. this.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑会员失败:("+err.Error()+")")
  362. return
  363. }
  364. if categorys == nil {
  365. this.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑会员失败:(会员记录不存在)")
  366. return
  367. }
  368. timenow := time.Now().Unix()
  369. dataBody := make(map[string]interface{}, 0)
  370. err = json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  371. if err != nil {
  372. utils.ErrorLog(err.Error())
  373. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  374. return
  375. }
  376. name:= dataBody["name"].(string)
  377. fmt.Println("name是谁?",name)
  378. content := dataBody["summary"].(string)
  379. fmt.Println("content是谁?",content)
  380. if len(content) == 0 {
  381. this.ServeFailJsonSend(enums.ErrorCodeParamWrong,"内容不能为空")
  382. return
  383. }
  384. sors :=int64(dataBody["order"].(float64))
  385. fmt.Println("sort0",sors)
  386. if sors <= 0 {
  387. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序不能为空")
  388. return
  389. }
  390. fmt.Println("soert是谁?",sors)
  391. fmt.Println("姓名:",name,"内容",content,"排序",sors)
  392. category := models.ArticleCategory{
  393. Name: name,
  394. Summary: content,
  395. Order: sors,
  396. UserOrgId:userOrgID,
  397. Status: 1,
  398. Mtime: timenow,
  399. }
  400. fmt.Println("category是?",category)
  401. article_service.EditCategory(&category,userOrgID,id)
  402. this.ServeSuccessJSON(map[string]interface{}{
  403. "category":category,
  404. })
  405. }
  406. func (this *ArticleManage) DeleteCategorys() {
  407. adminUserInfo := this.GetAdminUserInfo()
  408. dataBody := make(map[string]interface{}, 0)
  409. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  410. if err != nil {
  411. utils.ErrorLog(err.Error())
  412. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  413. return
  414. }
  415. idsInters := dataBody["ids"].([]interface{})
  416. if len(idsInters) == 0 {
  417. if err != nil {
  418. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
  419. return
  420. }
  421. }
  422. ids := make([]int64, 0)
  423. for _, idsInter := range idsInters {
  424. id := int64(idsInter.(float64))
  425. ids = append(ids, id)
  426. }
  427. err = article_service.DeleteCategorys(adminUserInfo.CurrentOrgId, ids)
  428. if err != nil {
  429. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除分类失败:("+err.Error()+")")
  430. return
  431. }
  432. returnData := make(map[string]interface{}, 0)
  433. returnData["msg"] = "ok"
  434. this.ServeSuccessJSON(returnData)
  435. return
  436. }
  437. func (this *ArticleManage) Addvido(){
  438. adminUserInfo := this.GetAdminUserInfo()
  439. userOrgID := adminUserInfo.CurrentOrgId
  440. dataBody := make(map[string]interface{}, 0)
  441. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  442. fmt.Println("视频发布是什么呢",err)
  443. if err != nil {
  444. utils.ErrorLog(err.Error())
  445. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  446. return
  447. }
  448. vidupload := dataBody["vio_upload"].(string)
  449. if len(vidupload) == 0 {
  450. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频不能为空")
  451. return
  452. }
  453. fmt.Println("视频",vidupload)
  454. vidname := dataBody["vid_name"].(string)
  455. if len(vidname)==0{
  456. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频标题不能为空")
  457. return
  458. }
  459. fmt.Println("视频名称",vidname)
  460. vidpic := dataBody["vid_pic"].(string)
  461. if(vidpic == ""){
  462. vidpic = vidupload + "?vframe/jpg/offset/1/w/300/h/200"
  463. }
  464. if len(vidpic)==0{
  465. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频封面不能为空")
  466. return
  467. }
  468. fmt.Println("视频图片",vidpic)
  469. vidtype := int64(dataBody["vid_type"].(float64))
  470. if vidtype <= 0 {
  471. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "所属分类不能为空")
  472. return
  473. }
  474. fmt.Println("视频类型",vidtype)
  475. fmt.Println("视频",vidupload,"视频标题",vidname,"视频封面",vidpic,"视频类型",vidtype)
  476. timenow := time.Now().Unix()
  477. articles := models.Articles{
  478. UserOrgId:userOrgID,
  479. Ctime:timenow,
  480. Type:2,
  481. VideoUrl:vidupload,
  482. Title:vidname,
  483. Imgs:vidpic,
  484. ClassId:vidtype,
  485. ArticleStatus:1,
  486. Status:1,
  487. }
  488. err = article_service.AddVido(articles)
  489. if err !=nil{
  490. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加分类失败")
  491. return
  492. }
  493. this.ServeSuccessJSON(map[string]interface{}{
  494. "vido":articles,
  495. })
  496. }
  497. func (this *ArticleManage) SaveDraft() {
  498. adminUserInfo := this.GetAdminUserInfo()
  499. userOrgID := adminUserInfo.CurrentOrgId
  500. dataBody := make(map[string]interface{}, 0)
  501. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  502. fmt.Println("视频发布是什么呢",err)
  503. if err != nil {
  504. utils.ErrorLog(err.Error())
  505. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  506. return
  507. }
  508. vidupload := dataBody["vio_upload"].(string)
  509. if len(vidupload) == 0 {
  510. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频不能为空")
  511. return
  512. }
  513. fmt.Println("视频",vidupload)
  514. vidname := dataBody["vid_name"].(string)
  515. if len(vidname)==0{
  516. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频标题不能为空")
  517. return
  518. }
  519. fmt.Println("视频名称",vidname)
  520. vidpic := dataBody["vid_pic"].(string)
  521. if(vidpic == ""){
  522. vidpic = vidupload + "?vframe/jpg/offset/1/w/300/h/200"
  523. }
  524. if len(vidpic)==0{
  525. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频封面不能为空")
  526. return
  527. }
  528. fmt.Println("视频图片",vidpic)
  529. vidtype := int64(dataBody["vid_type"].(float64))
  530. if vidtype <= 0 {
  531. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "所属分类不能为空")
  532. return
  533. }
  534. fmt.Println("视频类型",vidtype)
  535. fmt.Println("视频",vidupload,"视频标题",vidname,"视频封面",vidpic,"视频类型",vidtype)
  536. timenow := time.Now().Unix()
  537. articles := models.Articles{
  538. UserOrgId:userOrgID,
  539. Ctime:timenow,
  540. Type:2,
  541. VideoUrl:vidupload,
  542. Title:vidname,
  543. Imgs:vidpic,
  544. ClassId:vidtype,
  545. ArticleStatus:2,
  546. Status:1,
  547. }
  548. err = article_service.AddVido(articles)
  549. if err !=nil{
  550. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加分类失败")
  551. return
  552. }
  553. this.ServeSuccessJSON(map[string]interface{}{
  554. "savedraft":articles,
  555. })
  556. }
  557. func (this *ArticleManage) PrviewArticle() {
  558. adminUserInfo := this.GetAdminUserInfo()
  559. userOrgID := adminUserInfo.CurrentOrgId
  560. dataBody := make(map[string]interface{}, 0)
  561. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  562. fmt.Println("视频发布是什么呢",err)
  563. if err != nil {
  564. utils.ErrorLog(err.Error())
  565. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  566. return
  567. }
  568. actname := dataBody["act_name"].(string)
  569. if len(actname) == 0 {
  570. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  571. return
  572. }
  573. actcontent := dataBody["act_content"].(string)
  574. if len(actcontent) == 0 {
  575. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章内容不能为空")
  576. return
  577. }
  578. orglogo := dataBody["org_logo"].(string)
  579. if len(orglogo) == 0 {
  580. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "封面图片不能为空")
  581. return
  582. }
  583. acttype := int64(dataBody["act_type"].(float64))
  584. if acttype <= 0 {
  585. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
  586. return
  587. }
  588. timenow := time.Now().Unix()
  589. fmt.Println("姓名:",actname,"文章内容",actcontent,"图片",orglogo,"文章类型",acttype,userOrgID)
  590. articles := models.Articles{
  591. Title: actname,
  592. Content: actcontent,
  593. Imgs: orglogo,
  594. ClassId: acttype,
  595. UserOrgId:userOrgID,
  596. Ctime:timenow,
  597. Status:1,
  598. Type:1,
  599. ArticleStatus:3,
  600. }
  601. err = article_service.AddPrviewArticle(articles)
  602. if err !=nil{
  603. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加预览失败")
  604. return
  605. }
  606. this.ServeSuccessJSON(map[string]interface{}{
  607. "art":articles,
  608. })
  609. fmt.Println("art是谁",articles)
  610. }
  611. func (this *ArticleManage) GetArtilcePreview() {
  612. adminUserInfo := this.GetAdminUserInfo()
  613. userOrgID := adminUserInfo.CurrentOrgId
  614. articles, err := article_service.GetArtilcePreview(userOrgID)
  615. if err !=nil{
  616. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
  617. return
  618. }
  619. fmt.Println("文章内容",articles)
  620. this.ServeSuccessJSON(map[string]interface{}{
  621. "articles":articles,
  622. })
  623. }
  624. func (this *ArticleManage) AddDraft() {
  625. adminUserInfo := this.GetAdminUserInfo()
  626. userOrgID := adminUserInfo.CurrentOrgId
  627. dataBody := make(map[string]interface{}, 0)
  628. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  629. fmt.Println("视频发布是什么呢", err)
  630. if err != nil {
  631. utils.ErrorLog(err.Error())
  632. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  633. return
  634. }
  635. actname := dataBody["act_name"].(string)
  636. if len(actname) == 0 {
  637. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  638. return
  639. }
  640. actcontent := dataBody["act_content"].(string)
  641. if len(actcontent) == 0 {
  642. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章内容不能为空")
  643. return
  644. }
  645. orglogo := dataBody["org_logo"].(string)
  646. if len(orglogo) == 0 {
  647. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "封面图片不能为空")
  648. return
  649. }
  650. acttype := int64(dataBody["act_type"].(float64))
  651. if acttype <= 0 {
  652. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
  653. return
  654. }
  655. timenow := time.Now().Unix()
  656. fmt.Println("姓名:", actname, "文章内容", actcontent, "图片", orglogo, "文章类型", acttype, userOrgID)
  657. articles := models.Articles{
  658. Title: actname,
  659. Content: actcontent,
  660. Imgs: orglogo,
  661. ClassId: acttype,
  662. UserOrgId: userOrgID,
  663. Ctime: timenow,
  664. Status: 1,
  665. Type: 1,
  666. ArticleStatus: 2,
  667. }
  668. err = article_service.AddDraft(articles)
  669. if err !=nil{
  670. this.ServeFailJsonSend(enums.ErrorCodeDataException, "保存草稿失败")
  671. return
  672. }
  673. fmt.Println("文章内容",articles)
  674. this.ServeSuccessJSON(map[string]interface{}{
  675. "articles":articles,
  676. })
  677. }
  678. func (this *ArticleManage) GetArticleInfo() {
  679. id, _ := this.GetInt64("id")
  680. fmt.Println("id是啥",id)
  681. adminUserInfo := this.GetAdminUserInfo()
  682. userOrgID := adminUserInfo.CurrentOrgId
  683. articles, err := article_service.GetArticleInfo(userOrgID, id)
  684. fmt.Println("错误是什么",err)
  685. if err !=nil{
  686. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询文章信息失败")
  687. return
  688. }
  689. fmt.Println("编辑文章内容是啥什么",articles)
  690. this.ServeSuccessJSON(map[string]interface{}{
  691. "articles":articles,
  692. })
  693. }
  694. func (this *ArticleManage) GetVidoInfo() {
  695. id, _ := this.GetInt64("id")
  696. fmt.Println("视频id是多少?",id)
  697. adminUserInfo := this.GetAdminUserInfo()
  698. userOrgID := adminUserInfo.CurrentOrgId
  699. vidos, err := article_service.GetArticleInfo(userOrgID, id)
  700. if err !=nil{
  701. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询文章信息失败")
  702. return
  703. }
  704. fmt.Println("内容是啥什么",vidos)
  705. this.ServeSuccessJSON(map[string]interface{}{
  706. "vidos":vidos,
  707. })
  708. }
  709. func (this *ArticleManage) DeleteArticle() {
  710. adminUserInfo := this.GetAdminUserInfo()
  711. userOrgID := adminUserInfo.CurrentOrgId
  712. dataBody := make(map[string]interface{}, 0)
  713. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  714. if err != nil {
  715. utils.ErrorLog(err.Error())
  716. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  717. return
  718. }
  719. idsInters := dataBody["ids"].([]interface{})
  720. if len(idsInters) == 0 {
  721. if err != nil {
  722. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
  723. return
  724. }
  725. }
  726. ids := make([]int64, 0)
  727. for _, idsInter := range idsInters {
  728. id := int64(idsInter.(float64))
  729. ids = append(ids, id)
  730. }
  731. err = article_service.DeleteArticle(ids, userOrgID)
  732. if err !=nil{
  733. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
  734. return
  735. }
  736. returnData := make(map[string]interface{}, 0)
  737. returnData["msg"] = "ok"
  738. this.ServeSuccessJSON(returnData)
  739. return
  740. }
  741. func (this *ArticleManage) DeleteArticles() {
  742. id, _:= this.GetInt64("id")
  743. fmt.Println("id是多少呢",id)
  744. adminUserInfo := this.GetAdminUserInfo()
  745. userOrgID := adminUserInfo.CurrentOrgId
  746. err := article_service.DeleteArticles(id, userOrgID)
  747. if err !=nil{
  748. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
  749. return
  750. }
  751. returnData := make(map[string]interface{}, 0)
  752. returnData["msg"] = "ok"
  753. this.ServeSuccessJSON(returnData)
  754. return
  755. }
  756. func (this *ArticleManage) GetMenus(){
  757. adminUserInfo := this.GetAdminUserInfo()
  758. userOrgID := adminUserInfo.CurrentOrgId
  759. categorys, err := article_service.GetMenus(userOrgID)
  760. if err !=nil{
  761. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询失败")
  762. return
  763. }
  764. this.ServeSuccessJSON(map[string]interface{}{
  765. "categorys":categorys,
  766. })
  767. }
  768. func (this * ArticleManage) UpdataArticleInfo(){
  769. adminUserInfo := this.GetAdminUserInfo()
  770. userOrgID := adminUserInfo.CurrentOrgId
  771. id, _ := this.GetInt64("id")
  772. fmt.Println("id是多少",id)
  773. dataBody := make(map[string]interface{}, 0)
  774. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  775. fmt.Println("视频发布是什么呢",err)
  776. if err != nil {
  777. utils.ErrorLog(err.Error())
  778. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  779. return
  780. }
  781. title := dataBody["title"].(string)
  782. if len(title) == 0 {
  783. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  784. return
  785. }
  786. fmt.Println("title",title)
  787. content := dataBody["content"].(string)
  788. if len(content) == 0 {
  789. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "内容不能为空")
  790. return
  791. }
  792. fmt.Println("content",content)
  793. images := dataBody["imgs"].(string)
  794. fmt.Println("images",images)
  795. classid :=int64( dataBody["class_id"].(float64))
  796. if classid <=0 {
  797. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
  798. return
  799. }
  800. //classid, _ := strconv.ParseInt(class_id, 10, 64)
  801. fmt.Println("分类号",classid)
  802. fmt.Println("标题",title,"内容",content,"图片",images,"分类号",classid,"机构ID",userOrgID)
  803. articles := models.Articles{
  804. Title: title,
  805. Content: content,
  806. Imgs: images,
  807. ClassId: classid,
  808. Status: 1,
  809. Mtime: time.Now().Unix(),
  810. ArticleStatus:1,
  811. }
  812. fmt.Println("为什么",articles)
  813. article_service.UpdataArticleInfo(&articles,userOrgID, id)
  814. this.ServeSuccessJSON(map[string]interface{}{
  815. "articls":articles,
  816. })
  817. }
  818. func (this * ArticleManage) SaveArticleDraft() {
  819. adminUserInfo := this.GetAdminUserInfo()
  820. userOrgID := adminUserInfo.CurrentOrgId
  821. id, _ := this.GetInt64("id")
  822. fmt.Println("id是多少",id)
  823. dataBody := make(map[string]interface{}, 0)
  824. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  825. fmt.Println("视频发布是什么呢",err)
  826. if err != nil {
  827. utils.ErrorLog(err.Error())
  828. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  829. return
  830. }
  831. title := dataBody["title"].(string)
  832. if len(title) == 0 {
  833. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  834. return
  835. }
  836. fmt.Println("title",title)
  837. content := dataBody["content"].(string)
  838. if len(content) == 0 {
  839. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "内容不能为空")
  840. return
  841. }
  842. fmt.Println("content",content)
  843. images := dataBody["imgs"].(string)
  844. fmt.Println("images",images)
  845. classid :=int64( dataBody["class_id"].(float64))
  846. if classid <=0 {
  847. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
  848. return
  849. }
  850. //classid, _ := strconv.ParseInt(class_id, 10, 64)
  851. fmt.Println("分类号",classid)
  852. fmt.Println("标题",title,"保存文章草稿内容",content,"图片",images,"分类号",classid,"机构ID",userOrgID)
  853. articles := models.Articles{
  854. Title: title,
  855. Content: content,
  856. Imgs: images,
  857. ClassId: classid,
  858. Status: 1,
  859. Mtime: time.Now().Unix(),
  860. ArticleStatus:2,
  861. }
  862. fmt.Println("为什么",articles)
  863. article_service.UpdataArticleInfo(&articles,userOrgID, id)
  864. this.ServeSuccessJSON(map[string]interface{}{
  865. "articls":articles,
  866. })
  867. }
  868. func (this * ArticleManage) UpdateVidoInfo() {
  869. adminUserInfo := this.GetAdminUserInfo()
  870. userOrgID := adminUserInfo.CurrentOrgId
  871. id, _ := this.GetInt64("id")
  872. fmt.Println("id是多少",id)
  873. dataBody := make(map[string]interface{}, 0)
  874. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  875. fmt.Println("视频发布是什么呢",err)
  876. if err != nil {
  877. utils.ErrorLog(err.Error())
  878. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  879. return
  880. }
  881. vidname := dataBody["vid_name"].(string)
  882. fmt.Println("视频名称",vidname)
  883. if len(vidname) == 0 {
  884. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  885. return
  886. }
  887. vioupload := dataBody["vio_upload"].(string)
  888. fmt.Println("视频上传路径",vioupload)
  889. vidpic := dataBody["vid_pic"].(string)
  890. fmt.Println("视频封面",vidpic)
  891. if len(vidpic) == 0 {
  892. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  893. return
  894. }
  895. vidtype := int64( dataBody["vid_type"].(float64))
  896. fmt.Println("视频封面",vidtype)
  897. if vidtype <= 0 {
  898. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  899. return
  900. }
  901. articles := models.Articles{
  902. Title: vidname,
  903. Imgs: vidpic,
  904. VideoUrl:vioupload,
  905. ClassId: vidtype,
  906. Status: 1,
  907. Mtime: time.Now().Unix(),
  908. ArticleStatus:1,
  909. }
  910. article_service.UpdataArticleInfo(&articles,userOrgID, id)
  911. this.ServeSuccessJSON(map[string]interface{}{
  912. "articls":articles,
  913. })
  914. }
  915. func (this * ArticleManage) PreviewEditArticle() {
  916. adminUserInfo := this.GetAdminUserInfo()
  917. userOrgID := adminUserInfo.CurrentOrgId
  918. id, _ := this.GetInt64("id")
  919. fmt.Println("id是多少",id)
  920. dataBody := make(map[string]interface{}, 0)
  921. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  922. fmt.Println("视频发布是什么呢",err)
  923. if err != nil {
  924. utils.ErrorLog(err.Error())
  925. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  926. return
  927. }
  928. title := dataBody["title"].(string)
  929. if len(title) == 0 {
  930. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  931. return
  932. }
  933. fmt.Println("title",title)
  934. content := dataBody["content"].(string)
  935. if len(content) == 0 {
  936. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "内容不能为空")
  937. return
  938. }
  939. fmt.Println("content",content)
  940. images := dataBody["imgs"].(string)
  941. fmt.Println("images",images)
  942. classid :=int64( dataBody["class_id"].(float64))
  943. if classid <=0 {
  944. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
  945. return
  946. }
  947. //classid, _ := strconv.ParseInt(class_id, 10, 64)
  948. fmt.Println("分类号",classid)
  949. fmt.Println("标题",title,"内容",content,"图片",images,"分类号",classid,"机构ID",userOrgID)
  950. articles := models.Articles{
  951. Title: title,
  952. Content: content,
  953. Imgs: images,
  954. ClassId: classid,
  955. Status: 1,
  956. Mtime: time.Now().Unix(),
  957. ArticleStatus:1,
  958. }
  959. article_service.PreviewEditArticle(articles,userOrgID,id)
  960. this.ServeSuccessJSON(map[string]interface{}{
  961. "articls":articles,
  962. })
  963. }
  964. func (this * ArticleManage) GetPreviewInfoTwo() {
  965. adminUserInfo := this.GetAdminUserInfo()
  966. userOrgID := adminUserInfo.CurrentOrgId
  967. fmt.Println("机构id",userOrgID)
  968. id, _:= this.GetInt64("id")
  969. articles, err := article_service.GetPreviewInfoById(id, userOrgID)
  970. if err !=nil{
  971. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
  972. return
  973. }
  974. fmt.Println("错误",err)
  975. fmt.Println("预览文章内容",articles)
  976. this.ServeSuccessJSON(map[string]interface{}{
  977. "articles":articles,
  978. })
  979. }
  980. func (this * ArticleManage) GetAllComment() {
  981. page, _ := this.GetInt64("page", 1)
  982. fmt.Println("页面",page)
  983. limit, _ := this.GetInt64("limit", 10)
  984. fmt.Println("限制",limit)
  985. if page <= 0 {
  986. page = 1
  987. }
  988. if limit <= 0 {
  989. limit = 10
  990. }
  991. adminUserInfo := this.GetAdminUserInfo()
  992. userOrgID := adminUserInfo.CurrentOrgId
  993. fmt.Println("文章评论机构id",userOrgID)
  994. articles, total, err := article_service.GetAllComment(page, limit, userOrgID)
  995. fmt.Println("文章内容",articles)
  996. if err !=nil{
  997. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
  998. return
  999. }
  1000. this.ServeSuccessJSON(map[string]interface{}{
  1001. "total":total,
  1002. "articles":articles,
  1003. })
  1004. }
  1005. func (this * ArticleManage) GetArticleCommentDetail(){
  1006. id, _ := this.GetInt64("id")
  1007. fmt.Println("id是多少",id)
  1008. page, _ := this.GetInt64("page", 1)
  1009. fmt.Println("页面",page)
  1010. limit, _ := this.GetInt64("limit", 10)
  1011. fmt.Println("限制",limit)
  1012. if page <= 0 {
  1013. page = 1
  1014. }
  1015. if limit <= 0 {
  1016. limit = 10
  1017. }
  1018. adminUserInfo := this.GetAdminUserInfo()
  1019. userOrgID := adminUserInfo.CurrentOrgId
  1020. articles, err := article_service.GetArticleCommentDetail(id, userOrgID)
  1021. comment, total, err := article_service.FindAllComments(page, limit, 20142)
  1022. org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
  1023. fmt.Println("err是什么",err)
  1024. fmt.Println("total",total)
  1025. if err !=nil{
  1026. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
  1027. return
  1028. }
  1029. this.ServeSuccessJSON(map[string]interface{}{
  1030. "articles":articles,
  1031. "comment":comment,
  1032. "total":total,
  1033. "orgName":org.OrgName,
  1034. "orgID":userOrgID,
  1035. })
  1036. }
  1037. func (this * ArticleManage) SendReplycontent() {
  1038. replycontent := this.GetString("replycontent")
  1039. actilcid, _ := this.GetInt64("acticlid")
  1040. parentid, _ := this.GetInt64("parentid")
  1041. fmt.Println("回复的内容",replycontent)
  1042. fmt.Println("文章ID",actilcid)
  1043. fmt.Println("父类ID",parentid)
  1044. adminUserInfo := this.GetAdminUserInfo()
  1045. userOrgID := adminUserInfo.CurrentOrgId
  1046. org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
  1047. orgName := org.OrgName
  1048. orgLogo := org.OrgLogo
  1049. fmt.Println("logo",orgLogo)
  1050. comment := models.Comment{
  1051. Content: replycontent,
  1052. ParentId: parentid,
  1053. ArticleId: actilcid,
  1054. Ctime: time.Now().Unix(),
  1055. CommentUserId:userOrgID,
  1056. Status:1,
  1057. CommentUserAvater: orgLogo,
  1058. CommentUserName:orgName,
  1059. }
  1060. err := article_service.AddComment(&comment)
  1061. fmt.Println("错误是什么",err)
  1062. if err !=nil{
  1063. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加回复内容失败")
  1064. return
  1065. }
  1066. this.ServeSuccessJSON(map[string]interface{}{
  1067. "comment":comment,
  1068. })
  1069. }
  1070. func (this * ArticleManage) GetReplyAllComents() {
  1071. page, _ := this.GetInt64("page", 1)
  1072. fmt.Println("页面",page)
  1073. limit, _ := this.GetInt64("limit", 10)
  1074. fmt.Println("限制",limit)
  1075. if page <= 0 {
  1076. page = 1
  1077. }
  1078. if limit <= 0 {
  1079. limit = 10
  1080. }
  1081. adminUserInfo := this.GetAdminUserInfo()
  1082. userOrgID := adminUserInfo.CurrentOrgId
  1083. fmt.Println("机构ID",userOrgID)
  1084. comment, total, err := article_service.GetReplyAllComents(userOrgID,page, limit)
  1085. fmt.Println("comment",comment)
  1086. fmt.Println("total",total)
  1087. fmt.Println("错误",err)
  1088. if err !=nil{
  1089. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取评论列表失败")
  1090. return
  1091. }
  1092. this.ServeSuccessJSON(map[string]interface{}{
  1093. "comments":comment,
  1094. "total":total,
  1095. })
  1096. }
  1097. func (this * ArticleManage) GetSendInformation() {
  1098. artilcid, _ := this.GetInt64("artilcid")
  1099. fmt.Println("文章id",artilcid)
  1100. parentid, _ := this.GetInt64("parentid")
  1101. fmt.Println("父类id",parentid)
  1102. content := this.GetString("content")
  1103. fmt.Println("文章内容",content)
  1104. adminUserInfo := this.GetAdminUserInfo()
  1105. userOrgID := adminUserInfo.CurrentOrgId
  1106. org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
  1107. orgName := org.OrgName
  1108. orgLogo := org.OrgLogo
  1109. fmt.Println("logo",orgLogo)
  1110. comment := models.Comment{
  1111. Content: content,
  1112. ParentId: parentid,
  1113. ArticleId: artilcid,
  1114. Ctime: time.Now().Unix(),
  1115. CommentUserId:userOrgID,
  1116. Status:1,
  1117. CommentUserAvater: orgLogo,
  1118. CommentUserName:orgName,
  1119. }
  1120. err := article_service.AddComment(&comment)
  1121. fmt.Println("错误是什么",err)
  1122. if err !=nil{
  1123. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加回复内容失败")
  1124. return
  1125. }
  1126. this.ServeSuccessJSON(map[string]interface{}{
  1127. "comment":comment,
  1128. })
  1129. }
  1130. func (this * ArticleManage) GetSpreadReplay() {
  1131. artilcid, _ := this.GetInt64("artilcid")
  1132. fmt.Println("文章id",artilcid)
  1133. parentid, _ := this.GetInt64("parentid")
  1134. fmt.Println("父类id",parentid)
  1135. comments, err := article_service.GetAllReplyFormId(artilcid, parentid)
  1136. if err !=nil{
  1137. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
  1138. return
  1139. }
  1140. this.ServeSuccessJSON(map[string]interface{}{
  1141. "comments":comments,
  1142. })
  1143. }
  1144. func (this * ArticleManage) ClearReplyInfo() {
  1145. id, _ := this.GetInt64("id")
  1146. fmt.Println("id为",id)
  1147. err := article_service.ClearReplyInfo(id)
  1148. fmt.Println("错误为",err)
  1149. if err !=nil{
  1150. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1151. return
  1152. }
  1153. returnData := make(map[string]interface{}, 0)
  1154. returnData["msg"] = "ok"
  1155. this.ServeSuccessJSON(returnData)
  1156. return
  1157. }
  1158. func (this * ArticleManage) DeleteReply() {
  1159. id, _ := this.GetInt64("id")
  1160. fmt.Println("id为",id)
  1161. err := article_service.DeleteReply(id)
  1162. if err !=nil{
  1163. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1164. return
  1165. }
  1166. returnData := make(map[string]interface{}, 0)
  1167. returnData["msg"] = "ok"
  1168. this.ServeSuccessJSON(returnData)
  1169. return
  1170. }
  1171. func (this * ArticleManage) GetSpreadInfo() {
  1172. parentid, _ := this.GetInt64("parentid")
  1173. acticlid, _ := this.GetInt64("acticlid")
  1174. fmt.Println("父类id",parentid)
  1175. fmt.Println("文章id",acticlid)
  1176. comments, err := article_service.GetQueryReplyInfo(parentid, acticlid)
  1177. if err !=nil{
  1178. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
  1179. return
  1180. }
  1181. this.ServeSuccessJSON(map[string]interface{}{
  1182. "comments":comments,
  1183. })
  1184. }
  1185. func (this * ArticleManage) ClearReply() {
  1186. id, _ := this.GetInt64("id")
  1187. fmt.Println("id是多少?",id)
  1188. err :=article_service.DeleteReply(id)
  1189. if err !=nil{
  1190. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1191. return
  1192. }
  1193. returnData := make(map[string]interface{}, 0)
  1194. returnData["msg"] = "ok"
  1195. this.ServeSuccessJSON(returnData)
  1196. return
  1197. }
  1198. func (this * ArticleManage) DeleteComments() {
  1199. id, _ := this.GetInt64("id")
  1200. fmt.Println("id事多少",id);
  1201. err := article_service.DeleteReply(id)
  1202. if err !=nil{
  1203. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1204. return
  1205. }
  1206. returnData := make(map[string]interface{}, 0)
  1207. returnData["msg"] = "ok"
  1208. this.ServeSuccessJSON(returnData)
  1209. return
  1210. }
  1211. func (this * ArticleManage) SaveVidoDraft() {
  1212. adminUserInfo := this.GetAdminUserInfo()
  1213. userOrgID := adminUserInfo.CurrentOrgId
  1214. id, _ := this.GetInt64("id")
  1215. fmt.Println("id是多少",id)
  1216. dataBody := make(map[string]interface{}, 0)
  1217. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1218. fmt.Println("视频发布是什么呢",err)
  1219. if err != nil {
  1220. utils.ErrorLog(err.Error())
  1221. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1222. return
  1223. }
  1224. vidname := dataBody["vid_name"].(string)
  1225. fmt.Println("视频名称",vidname)
  1226. if len(vidname) == 0 {
  1227. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  1228. return
  1229. }
  1230. vidpic := dataBody["vid_pic"].(string)+"?vframe/jpg/offset/1/w/300/h/200"
  1231. fmt.Println("视频封面",vidpic)
  1232. if len(vidpic) == 0 {
  1233. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  1234. return
  1235. }
  1236. vidtype := int64( dataBody["vid_type"].(float64))
  1237. fmt.Println("视频类型",vidtype)
  1238. if vidtype <= 0 {
  1239. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  1240. return
  1241. }
  1242. articles := models.Articles{
  1243. Title: vidname,
  1244. Imgs: vidpic,
  1245. ClassId: vidtype,
  1246. Status: 1,
  1247. Mtime: time.Now().Unix(),
  1248. ArticleStatus:2,
  1249. }
  1250. article_service.SaveVidoDraft(&articles,userOrgID,id)
  1251. this.ServeSuccessJSON(map[string]interface{}{
  1252. "articls":articles,
  1253. })
  1254. }
  1255. func (this *ArticleManage) DeleteAllReply() {
  1256. dataBody := make(map[string]interface{}, 0)
  1257. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1258. if err != nil {
  1259. utils.ErrorLog(err.Error())
  1260. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1261. return
  1262. }
  1263. idsInters := dataBody["ids"].([]interface{})
  1264. if len(idsInters) == 0 {
  1265. if err != nil {
  1266. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除评论失败:(没有选择评论)")
  1267. return
  1268. }
  1269. }
  1270. ids := make([]int64, 0)
  1271. for _, idsInter := range idsInters {
  1272. id := int64(idsInter.(float64))
  1273. ids = append(ids, id)
  1274. }
  1275. fmt.Println("ids是什么",ids)
  1276. err = article_service.DeleteAllReply(ids)
  1277. if err !=nil{
  1278. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
  1279. return
  1280. }
  1281. returnData := make(map[string]interface{}, 0)
  1282. returnData["msg"] = "ok"
  1283. this.ServeSuccessJSON(returnData)
  1284. return
  1285. }
  1286. func (this *ArticleManage) DeleteAllArticles() {
  1287. dataBody := make(map[string]interface{}, 0)
  1288. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1289. if err != nil {
  1290. utils.ErrorLog(err.Error())
  1291. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1292. return
  1293. }
  1294. idsInters := dataBody["ids"].([]interface{})
  1295. if len(idsInters) == 0 {
  1296. if err != nil {
  1297. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除评论失败:(没有选择评论)")
  1298. return
  1299. }
  1300. }
  1301. ids := make([]int64, 0)
  1302. for _, idsInter := range idsInters {
  1303. id := int64(idsInter.(float64))
  1304. ids = append(ids, id)
  1305. }
  1306. fmt.Println("ids是什么",ids)
  1307. err = article_service.DeleteAllArticles(ids)
  1308. if err !=nil{
  1309. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
  1310. return
  1311. }
  1312. returnData := make(map[string]interface{}, 0)
  1313. returnData["msg"] = "ok"
  1314. this.ServeSuccessJSON(returnData)
  1315. return
  1316. }
  1317. func (this *ArticleManage) GetAllCategory() {
  1318. adminUserInfo := this.GetAdminUserInfo()
  1319. userOrgID := adminUserInfo.CurrentOrgId
  1320. categorys, err := article_service.GetMenus(userOrgID)
  1321. if err !=nil{
  1322. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
  1323. return
  1324. }
  1325. this.ServeSuccessJSON(map[string]interface{}{
  1326. "categorys":categorys,
  1327. })
  1328. }
  1329. func (this *ArticleManage) GetArticleDetail() {
  1330. adminUserInfo := this.GetAdminUserInfo()
  1331. userOrgID := adminUserInfo.CurrentOrgId
  1332. id, _:= this.GetInt64("id")
  1333. fmt.Println("机构id",userOrgID)
  1334. fmt.Println("id",id)
  1335. articles, err := article_service.GetArticleDetailById(id, userOrgID)
  1336. if err !=nil{
  1337. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
  1338. return
  1339. }
  1340. this.ServeSuccessJSON(map[string]interface{}{
  1341. "articles":articles,
  1342. })
  1343. }
  1344. func (this *ArticleManage) GetVidoDetail() {
  1345. adminUserInfo := this.GetAdminUserInfo()
  1346. userOrgID := adminUserInfo.CurrentOrgId
  1347. id, _:= this.GetInt64("id")
  1348. fmt.Println("机构id",userOrgID)
  1349. fmt.Println("id",id)
  1350. articles, err := article_service.GetArticleDetailById(id, userOrgID)
  1351. if err !=nil{
  1352. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
  1353. return
  1354. }
  1355. this.ServeSuccessJSON(map[string]interface{}{
  1356. "articles":articles,
  1357. })
  1358. }
  1359. func (this *ArticleManage) GetEditArticleContent() {
  1360. adminUserInfo := this.GetAdminUserInfo()
  1361. userOrgID := adminUserInfo.CurrentOrgId
  1362. id, _:= this.GetInt64("id")
  1363. fmt.Println("机构id",userOrgID)
  1364. fmt.Println("预览返回id",id)
  1365. articles, err := article_service.GetArticleDetailById(id, userOrgID)
  1366. if err !=nil{
  1367. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
  1368. return
  1369. }
  1370. this.ServeSuccessJSON(map[string]interface{}{
  1371. "articles":articles,
  1372. })
  1373. }