scrm-go

article_controller.go 43KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494
  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)+"?vframe/jpg/offset/1/w/300/h/200"
  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. articles, total, err := article_service.GetAllComment(page, limit, userOrgID)
  994. fmt.Println("文章内容",articles)
  995. if err !=nil{
  996. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
  997. return
  998. }
  999. this.ServeSuccessJSON(map[string]interface{}{
  1000. "total":total,
  1001. "articles":articles,
  1002. })
  1003. }
  1004. func (this * ArticleManage) GetArticleCommentDetail(){
  1005. id, _ := this.GetInt64("id")
  1006. fmt.Println("id是多少",id)
  1007. page, _ := this.GetInt64("page", 1)
  1008. fmt.Println("页面",page)
  1009. limit, _ := this.GetInt64("limit", 10)
  1010. fmt.Println("限制",limit)
  1011. if page <= 0 {
  1012. page = 1
  1013. }
  1014. if limit <= 0 {
  1015. limit = 10
  1016. }
  1017. adminUserInfo := this.GetAdminUserInfo()
  1018. userOrgID := adminUserInfo.CurrentOrgId
  1019. articles, err := article_service.GetArticleCommentDetail(id, userOrgID)
  1020. comment, total, err := article_service.FindAllComments(page, limit, 20142)
  1021. org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
  1022. fmt.Println("err是什么",err)
  1023. fmt.Println("total",total)
  1024. if err !=nil{
  1025. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
  1026. return
  1027. }
  1028. this.ServeSuccessJSON(map[string]interface{}{
  1029. "articles":articles,
  1030. "comment":comment,
  1031. "total":total,
  1032. "orgName":org.OrgName,
  1033. "orgID":userOrgID,
  1034. })
  1035. }
  1036. func (this * ArticleManage) SendReplycontent() {
  1037. replycontent := this.GetString("replycontent")
  1038. actilcid, _ := this.GetInt64("acticlid")
  1039. parentid, _ := this.GetInt64("parentid")
  1040. fmt.Println("回复的内容",replycontent)
  1041. fmt.Println("文章ID",actilcid)
  1042. fmt.Println("父类ID",parentid)
  1043. adminUserInfo := this.GetAdminUserInfo()
  1044. userOrgID := adminUserInfo.CurrentOrgId
  1045. org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
  1046. orgName := org.OrgName
  1047. orgLogo := org.OrgLogo
  1048. fmt.Println("logo",orgLogo)
  1049. comment := models.Comment{
  1050. Content: replycontent,
  1051. ParentId: parentid,
  1052. ArticleId: actilcid,
  1053. Ctime: time.Now().Unix(),
  1054. CommentUserId:userOrgID,
  1055. Status:1,
  1056. CommentUserAvater: orgLogo,
  1057. CommentUserName:orgName,
  1058. }
  1059. err := article_service.AddComment(&comment)
  1060. fmt.Println("错误是什么",err)
  1061. if err !=nil{
  1062. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加回复内容失败")
  1063. return
  1064. }
  1065. this.ServeSuccessJSON(map[string]interface{}{
  1066. "comment":comment,
  1067. })
  1068. }
  1069. func (this * ArticleManage) GetReplyAllComents() {
  1070. page, _ := this.GetInt64("page", 1)
  1071. fmt.Println("页面",page)
  1072. limit, _ := this.GetInt64("limit", 10)
  1073. fmt.Println("限制",limit)
  1074. if page <= 0 {
  1075. page = 1
  1076. }
  1077. if limit <= 0 {
  1078. limit = 10
  1079. }
  1080. adminUserInfo := this.GetAdminUserInfo()
  1081. userOrgID := adminUserInfo.CurrentOrgId
  1082. fmt.Println("机构ID",userOrgID)
  1083. comment, total, err := article_service.GetReplyAllComents(page, limit)
  1084. if err !=nil{
  1085. this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取评论列表失败")
  1086. return
  1087. }
  1088. this.ServeSuccessJSON(map[string]interface{}{
  1089. "comments":comment,
  1090. "total":total,
  1091. })
  1092. }
  1093. func (this * ArticleManage) GetSendInformation() {
  1094. artilcid, _ := this.GetInt64("artilcid")
  1095. fmt.Println("文章id",artilcid)
  1096. parentid, _ := this.GetInt64("parentid")
  1097. fmt.Println("父类id",parentid)
  1098. content := this.GetString("content")
  1099. fmt.Println("文章内容",content)
  1100. adminUserInfo := this.GetAdminUserInfo()
  1101. userOrgID := adminUserInfo.CurrentOrgId
  1102. org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
  1103. orgName := org.OrgName
  1104. orgLogo := org.OrgLogo
  1105. fmt.Println("logo",orgLogo)
  1106. comment := models.Comment{
  1107. Content: content,
  1108. ParentId: parentid,
  1109. ArticleId: artilcid,
  1110. Ctime: time.Now().Unix(),
  1111. CommentUserId:userOrgID,
  1112. Status:1,
  1113. CommentUserAvater: orgLogo,
  1114. CommentUserName:orgName,
  1115. }
  1116. err := article_service.AddComment(&comment)
  1117. fmt.Println("错误是什么",err)
  1118. if err !=nil{
  1119. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加回复内容失败")
  1120. return
  1121. }
  1122. this.ServeSuccessJSON(map[string]interface{}{
  1123. "comment":comment,
  1124. })
  1125. }
  1126. func (this * ArticleManage) GetSpreadReplay() {
  1127. artilcid, _ := this.GetInt64("artilcid")
  1128. fmt.Println("文章id",artilcid)
  1129. parentid, _ := this.GetInt64("parentid")
  1130. fmt.Println("父类id",parentid)
  1131. comments, err := article_service.GetAllReplyFormId(artilcid, parentid)
  1132. if err !=nil{
  1133. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
  1134. return
  1135. }
  1136. this.ServeSuccessJSON(map[string]interface{}{
  1137. "comments":comments,
  1138. })
  1139. }
  1140. func (this * ArticleManage) ClearReplyInfo() {
  1141. id, _ := this.GetInt64("id")
  1142. fmt.Println("id为",id)
  1143. err := article_service.ClearReplyInfo(id)
  1144. fmt.Println("错误为",err)
  1145. if err !=nil{
  1146. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1147. return
  1148. }
  1149. returnData := make(map[string]interface{}, 0)
  1150. returnData["msg"] = "ok"
  1151. this.ServeSuccessJSON(returnData)
  1152. return
  1153. }
  1154. func (this * ArticleManage) DeleteReply() {
  1155. id, _ := this.GetInt64("id")
  1156. fmt.Println("id为",id)
  1157. err := article_service.DeleteReply(id)
  1158. if err !=nil{
  1159. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1160. return
  1161. }
  1162. returnData := make(map[string]interface{}, 0)
  1163. returnData["msg"] = "ok"
  1164. this.ServeSuccessJSON(returnData)
  1165. return
  1166. }
  1167. func (this * ArticleManage) GetSpreadInfo() {
  1168. parentid, _ := this.GetInt64("parentid")
  1169. acticlid, _ := this.GetInt64("acticlid")
  1170. fmt.Println("父类id",parentid)
  1171. fmt.Println("文章id",acticlid)
  1172. comments, err := article_service.GetQueryReplyInfo(parentid, acticlid)
  1173. if err !=nil{
  1174. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
  1175. return
  1176. }
  1177. this.ServeSuccessJSON(map[string]interface{}{
  1178. "comments":comments,
  1179. })
  1180. }
  1181. func (this * ArticleManage) ClearReply() {
  1182. id, _ := this.GetInt64("id")
  1183. fmt.Println("id是多少?",id)
  1184. err :=article_service.DeleteReply(id)
  1185. if err !=nil{
  1186. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1187. return
  1188. }
  1189. returnData := make(map[string]interface{}, 0)
  1190. returnData["msg"] = "ok"
  1191. this.ServeSuccessJSON(returnData)
  1192. return
  1193. }
  1194. func (this * ArticleManage) DeleteComments() {
  1195. id, _ := this.GetInt64("id")
  1196. fmt.Println("id事多少",id);
  1197. err := article_service.DeleteReply(id)
  1198. if err !=nil{
  1199. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
  1200. return
  1201. }
  1202. returnData := make(map[string]interface{}, 0)
  1203. returnData["msg"] = "ok"
  1204. this.ServeSuccessJSON(returnData)
  1205. return
  1206. }
  1207. func (this * ArticleManage) SaveVidoDraft() {
  1208. adminUserInfo := this.GetAdminUserInfo()
  1209. userOrgID := adminUserInfo.CurrentOrgId
  1210. id, _ := this.GetInt64("id")
  1211. fmt.Println("id是多少",id)
  1212. dataBody := make(map[string]interface{}, 0)
  1213. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1214. fmt.Println("视频发布是什么呢",err)
  1215. if err != nil {
  1216. utils.ErrorLog(err.Error())
  1217. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1218. return
  1219. }
  1220. vidname := dataBody["vid_name"].(string)
  1221. fmt.Println("视频名称",vidname)
  1222. if len(vidname) == 0 {
  1223. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  1224. return
  1225. }
  1226. vidpic := dataBody["vid_pic"].(string)+"?vframe/jpg/offset/1/w/300/h/200"
  1227. fmt.Println("视频封面",vidpic)
  1228. if len(vidpic) == 0 {
  1229. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  1230. return
  1231. }
  1232. vidtype := int64( dataBody["vid_type"].(float64))
  1233. fmt.Println("视频类型",vidtype)
  1234. if vidtype <= 0 {
  1235. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
  1236. return
  1237. }
  1238. articles := models.Articles{
  1239. Title: vidname,
  1240. Imgs: vidpic,
  1241. ClassId: vidtype,
  1242. Status: 1,
  1243. Mtime: time.Now().Unix(),
  1244. ArticleStatus:2,
  1245. }
  1246. article_service.SaveVidoDraft(&articles,userOrgID,id)
  1247. this.ServeSuccessJSON(map[string]interface{}{
  1248. "articls":articles,
  1249. })
  1250. }
  1251. func (this *ArticleManage) DeleteAllReply() {
  1252. dataBody := make(map[string]interface{}, 0)
  1253. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1254. if err != nil {
  1255. utils.ErrorLog(err.Error())
  1256. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1257. return
  1258. }
  1259. idsInters := dataBody["ids"].([]interface{})
  1260. if len(idsInters) == 0 {
  1261. if err != nil {
  1262. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除评论失败:(没有选择评论)")
  1263. return
  1264. }
  1265. }
  1266. ids := make([]int64, 0)
  1267. for _, idsInter := range idsInters {
  1268. id := int64(idsInter.(float64))
  1269. ids = append(ids, id)
  1270. }
  1271. fmt.Println("ids是什么",ids)
  1272. err = article_service.DeleteAllReply(ids)
  1273. if err !=nil{
  1274. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
  1275. return
  1276. }
  1277. returnData := make(map[string]interface{}, 0)
  1278. returnData["msg"] = "ok"
  1279. this.ServeSuccessJSON(returnData)
  1280. return
  1281. }
  1282. func (this *ArticleManage) DeleteAllArticles() {
  1283. dataBody := make(map[string]interface{}, 0)
  1284. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1285. if err != nil {
  1286. utils.ErrorLog(err.Error())
  1287. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1288. return
  1289. }
  1290. idsInters := dataBody["ids"].([]interface{})
  1291. if len(idsInters) == 0 {
  1292. if err != nil {
  1293. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除评论失败:(没有选择评论)")
  1294. return
  1295. }
  1296. }
  1297. ids := make([]int64, 0)
  1298. for _, idsInter := range idsInters {
  1299. id := int64(idsInter.(float64))
  1300. ids = append(ids, id)
  1301. }
  1302. fmt.Println("ids是什么",ids)
  1303. err = article_service.DeleteAllArticles(ids)
  1304. if err !=nil{
  1305. this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
  1306. return
  1307. }
  1308. returnData := make(map[string]interface{}, 0)
  1309. returnData["msg"] = "ok"
  1310. this.ServeSuccessJSON(returnData)
  1311. return
  1312. }
  1313. func (this *ArticleManage) GetAllCategory() {
  1314. adminUserInfo := this.GetAdminUserInfo()
  1315. userOrgID := adminUserInfo.CurrentOrgId
  1316. categorys, err := article_service.GetMenus(userOrgID)
  1317. if err !=nil{
  1318. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
  1319. return
  1320. }
  1321. this.ServeSuccessJSON(map[string]interface{}{
  1322. "categorys":categorys,
  1323. })
  1324. }
  1325. func (this *ArticleManage) GetArticleDetail() {
  1326. adminUserInfo := this.GetAdminUserInfo()
  1327. userOrgID := adminUserInfo.CurrentOrgId
  1328. id, _:= this.GetInt64("id")
  1329. fmt.Println("机构id",userOrgID)
  1330. fmt.Println("id",id)
  1331. articles, err := article_service.GetArticleDetailById(id, userOrgID)
  1332. if err !=nil{
  1333. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
  1334. return
  1335. }
  1336. this.ServeSuccessJSON(map[string]interface{}{
  1337. "articles":articles,
  1338. })
  1339. }
  1340. func (this *ArticleManage) GetVidoDetail() {
  1341. adminUserInfo := this.GetAdminUserInfo()
  1342. userOrgID := adminUserInfo.CurrentOrgId
  1343. id, _:= this.GetInt64("id")
  1344. fmt.Println("机构id",userOrgID)
  1345. fmt.Println("id",id)
  1346. articles, err := article_service.GetArticleDetailById(id, userOrgID)
  1347. if err !=nil{
  1348. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
  1349. return
  1350. }
  1351. this.ServeSuccessJSON(map[string]interface{}{
  1352. "articles":articles,
  1353. })
  1354. }
  1355. func (this *ArticleManage) GetEditArticleContent() {
  1356. adminUserInfo := this.GetAdminUserInfo()
  1357. userOrgID := adminUserInfo.CurrentOrgId
  1358. id, _:= this.GetInt64("id")
  1359. fmt.Println("机构id",userOrgID)
  1360. fmt.Println("预览返回id",id)
  1361. articles, err := article_service.GetArticleDetailById(id, userOrgID)
  1362. if err !=nil{
  1363. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
  1364. return
  1365. }
  1366. this.ServeSuccessJSON(map[string]interface{}{
  1367. "articles":articles,
  1368. })
  1369. }