1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489 |
- package article
-
- import (
- "SCRM/controllers"
- "SCRM/enums"
- "SCRM/models"
- "SCRM/service/article_service"
- "SCRM/utils"
- "encoding/json"
- "fmt"
- "github.com/astaxie/beego"
- "github.com/jinzhu/gorm"
- "strconv"
- "time"
- )
-
- func ArticleRouters() {
-
- beego.Router("/api/acticle/createacticle", &ArticleManage{}, "Post:CreateArticle")
- beego.Router("/api/acticle/getArticleType", &ArticleManage{}, "Get:GetArticleType")
- beego.Router("/api/acticle/getAllArticles", &ArticleManage{}, "Get:GetAllArticles")
- beego.Router("/api/article/addCategory", &ArticleManage{}, "Post:AddCategory")
- beego.Router("/api/article/getAritcleCount", &ArticleManage{}, "Post:GetArticleCount")
- beego.Router("/api/acticle/getCategorys", &ArticleManage{}, "Get:GetCategorys")
- beego.Router("/api/acticle/edit", &ArticleManage{}, "Post:EditCategorys")
- beego.Router("/api/acticle/delete", &ArticleManage{}, "Delete:DeleteCategorys")
- beego.Router("/api/acticle/addvido", &ArticleManage{}, "Post:Addvido")
- beego.Router("/api/acticle/savedraft", &ArticleManage{}, "Post:SaveDraft")
- beego.Router("/api/acticle/prviewArticle", &ArticleManage{}, "Post:PrviewArticle")
- beego.Router("/api/acticle/getarticlePreview", &ArticleManage{}, "Get:GetArtilcePreview")
- beego.Router("/api/acticle/save", &ArticleManage{}, "Post:AddDraft")
- beego.Router("/api/acticle/getEditArticle", &ArticleManage{}, "Post:GetArticleInfo")
- beego.Router("/api/article/Delete", &ArticleManage{}, "Delete:DeleteArticle")
- beego.Router("/api/acticle/getMenus", &ArticleManage{}, "Get:GetMenus")
- beego.Router("/api/acticle/updateArticlesInfo", &ArticleManage{}, "Post:UpdataArticleInfo")
- beego.Router("/api/acticle/saveArticleDraft", &ArticleManage{}, "Post:SaveArticleDraft")
- beego.Router("/api/acticle/updateVidoInfo", &ArticleManage{}, "Post:UpdateVidoInfo")
- beego.Router("/api/acticle/previewEditArticle", &ArticleManage{}, "Post:PreviewEditArticle")
- beego.Router("/api/acticle/getPreviewInfo", &ArticleManage{}, "Get:GetPreviewInfoTwo")
- beego.Router("/api/acticle/getAllComment", &ArticleManage{}, "Get:GetAllComment")
- beego.Router("/api/acticle/getArticleCommentDetail", &ArticleManage{}, "Get:GetArticleCommentDetail")
- beego.Router("/api/article/deleteArticle", &ArticleManage{}, "Get:DeleteArticles")
- beego.Router("/api/acticle/send", &ArticleManage{}, "Get:SendReplycontent")
- beego.Router("/api/acticle/getReplyAllComents", &ArticleManage{}, "Get:GetReplyAllComents")
- beego.Router("/api/article/sendInformation", &ArticleManage{}, "Get:GetSendInformation")
- beego.Router("/api/article/spreadReplay", &ArticleManage{}, "Get:GetSpreadReplay")
- beego.Router("/api/article/clearRelyInfo", &ArticleManage{}, "Delete:ClearReplyInfo")
- beego.Router("/api/article/deleteReply", &ArticleManage{}, "Delete:DeleteReply")
- beego.Router("/api/article/spread", &ArticleManage{}, "Get:GetSpreadInfo")
- beego.Router("/api/article/clear", &ArticleManage{}, "Delete:ClearReply")
- beego.Router("/api/article/deleteComments", &ArticleManage{}, "Delete:DeleteComments")
- beego.Router("/api/acticle/getEditVidoInfo", &ArticleManage{}, "Get:GetVidoInfo")
- beego.Router("/api/acticle/savevidodraft", &ArticleManage{}, "Post:SaveVidoDraft")
- beego.Router("/api/article/openDeleteReply", &ArticleManage{}, "Delete:DeleteAllReply")
- beego.Router("/api/article/deleteAllArticles", &ArticleManage{}, "Delete:DeleteAllArticles")
- beego.Router("/api/aritcle/getallcategory", &ArticleManage{}, "Get:GetAllCategory")
- beego.Router("/api/article/getarticledetail", &ArticleManage{}, "Get:GetArticleDetail")
- beego.Router("/api/article/getvidodetail", &ArticleManage{}, "Get:GetVidoDetail")
- beego.Router("/api/article/geteditarticlecontent", &ArticleManage{}, "Get:GetEditArticleContent")
-
- }
-
- type ArticleManage struct {
- controllers.BaseAuthAPIController
- }
-
- func (this *ArticleManage) CreateArticle() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := int64(adminUserInfo.CurrentOrgId)
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println("视频发布是什么呢", err)
-
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- actname := dataBody["act_name"].(string)
- fmt.Println("文章标题", actname)
- if len(actname) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
- return
- }
-
- actcontent := dataBody["act_content"].(string)
- fmt.Println("文章内容", actcontent)
- if len(actcontent) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章内容不能为空")
- return
- }
- orglogo := dataBody["org_logo"].(string)
- fmt.Println("封面图片", orglogo)
- //if len(orglogo) == 0 {
- // this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "封面图片不能为空")
- // return
- //}
- acttype := int64(dataBody["act_type"].(float64))
- fmt.Println("文章分类", acttype)
- if acttype <= 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
- return
- }
-
- timenow := time.Now().Unix()
- fmt.Println("姓名:", actname, "文章内容", actcontent, "图片", orglogo, "文章类型", acttype, userOrgID)
- articles := models.Articles{
- Title: actname,
- Content: actcontent,
- Imgs: orglogo,
- ClassId: acttype,
- UserOrgId: userOrgID,
- Ctime: timenow,
- Status: 1,
- Type: 1,
- ArticleStatus: 1,
- }
- err = article_service.AddAritcle(articles)
- fmt.Println("错误是什么", err)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "插入文章失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "articles": articles,
- })
- }
-
- func (this *ArticleManage) GetArticleType() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- category, err := article_service.FindArticleCategoryType(userOrgID)
- fmt.Println("文章分类列表", category, err)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "category": category,
- })
- return
- }
-
- func (this *ArticleManage) GetAllArticles() {
- page, _ := this.GetInt64("page", 1)
- fmt.Println("页面", page)
- limit, _ := this.GetInt64("limit", 10)
- fmt.Println("限制", limit)
- searchKey := this.GetString("keyword", "")
- fmt.Println("搜索字", searchKey)
- classId, _ := this.GetInt64("id", 0)
- status, _ := this.GetInt64("status")
- fmt.Println("页面", page, "限制", limit, "关键字", searchKey, "分类号", classId, "状态值:", status)
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- //org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
- //OrgName := org.OrgName
- //fmt.Println("机构姓名:",OrgName)
- if status == 1 {
- articles, total, err := article_service.GetPublished(userOrgID, page, limit, searchKey)
- category, err := article_service.FindCategoryList(userOrgID)
- fmt.Println("分类号", category)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "articles": articles,
- "total": total,
- "category": category,
- })
- }
- if status == 2 {
- articles, total, err := article_service.GetDraftbox(userOrgID, page, limit, searchKey)
- category, err := article_service.FindCategoryList(userOrgID)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "articles": articles,
- "total": total,
- "category": category,
- })
- }
-
- if status == 3 {
- articles, total, err := article_service.GetNoPass(userOrgID, page, limit, searchKey)
- category, err := article_service.FindCategoryList(userOrgID)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "articles": articles,
- "total": total,
- "category": category,
- })
- }
-
- articles, total, err := article_service.FindAllArticle(userOrgID, page, limit, searchKey, classId)
- fmt.Println("文章内容是是么", articles)
- fmt.Println("total", total)
- fmt.Println("err", err)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章列表失败")
- return
- }
- category, err := article_service.FindCategoryList(userOrgID)
- fmt.Println("category是傻", category, err)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "articles": articles,
- "total": total,
- "category": category,
- })
- return
- }
-
- //func (this *ArticleManage) GetAllartic() {
- // page, _ := this.GetInt64("page", 1)
- // fmt.Println("页面2",page)
- // limit, _ := this.GetInt64("limit", 10)
- // fmt.Println("限制3",limit)
- // adminUserInfo := this.GetAdminUserInfo()
- // userOrgID := adminUserInfo.CurrentOrgId
- // if page <= 0 {
- // page = 1
- // }
- // if limit <= 0 {
- // limit = 10
- // }
- // articles, total, err := article_service.GetAllartic(page, limit, userOrgID)
- // fmt.Println("articles",articles)
- // fmt.Println("total",total)
- // fmt.Println("err",err)
- // if err !=nil{
- // this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
- // return
- // }
- // //org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
- // //OrgName := org.OrgName
- // //fmt.Println("OrgName",OrgName)
- // this.ServeSuccessJSON(map[string]interface{}{
- // "articles":articles,
- // "total":total,
- // })
- //}
-
- func (this *ArticleManage) AddCategory() {
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println("err是什么呢", err)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
- name := dataBody["name"].(string)
- fmt.Println("name是谁?", name)
- if len(name) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "姓名不能为空")
- return
- }
-
- content := dataBody["summary"].(string)
- fmt.Println("content是谁?", content)
- if len(content) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "内容不能为空")
- return
- }
-
- sort := dataBody["order"].(string)
- sors, _ := strconv.ParseInt(sort, 10, 64)
- if sors <= 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序不能为空")
- return
- }
- fmt.Println("soert是谁?", sort)
- fmt.Println("姓名:", name, "内容", content, "排序", sort)
- timenow := time.Now().Unix()
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
-
- category := models.ArticleCategory{
- Name: name,
- Summary: content,
- Order: sors,
- UserOrgId: userOrgID,
- Status: 1,
- Ctime: timenow,
- }
- fmt.Println(category)
- articleCategory, errcod := article_service.AddCategory(name)
- fmt.Println(articleCategory)
- fmt.Println("errecod是什么", errcod)
- if errcod == gorm.ErrRecordNotFound {
- fmt.Println("aaaaa")
- err := article_service.SaveCategory(category)
- fmt.Println("报错", err)
- this.ServeSuccessJSON(map[string]interface{}{
- "category": category,
- })
- fmt.Println(err)
- } else if errcod == nil {
- fmt.Println("bbbbbbb")
- this.ServeFailJsonSend(enums.ErrorCodeDBCreate, "添加标签失败:(已经存在同名的标签)")
- return
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "category": category,
- })
- }
-
- return
- }
-
- func (this *ArticleManage) GetArticleCount() {
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println("err是什么呢", err)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
- name := dataBody["name"].(string)
- fmt.Println("name是什么?", name)
- if len(name) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "姓名不能为空")
- return
- }
- }
-
- func (this *ArticleManage) GetCategorys() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- page, _ := this.GetInt64("page", 1)
- fmt.Println("页面", page)
- limit, _ := this.GetInt64("limit", 10)
- fmt.Println("限制", limit)
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- fmt.Println("机构ID", userOrgID)
- categorys, total, err := article_service.GetCategorys(page, limit, userOrgID)
- fmt.Println("hhe", categorys, total, err)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "category": categorys,
- "total": total,
- })
- return
- }
-
- func (this *ArticleManage) EditCategorys() {
- id, _ := this.GetInt64("id", 0)
- fmt.Println("ID是多少", id)
- if id <= 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误:id")
- return
- }
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- categorys, err := article_service.GetCategorysByID(userOrgID, id)
- fmt.Println("categorys是?", categorys, err)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑会员失败:("+err.Error()+")")
- return
- }
- if categorys == nil {
- this.ServeFailJsonSend(enums.ErrorCodeDBUpdate, "编辑会员失败:(会员记录不存在)")
- return
- }
- timenow := time.Now().Unix()
-
- dataBody := make(map[string]interface{}, 0)
- err = json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- name := dataBody["name"].(string)
- fmt.Println("name是谁?", name)
-
- content := dataBody["summary"].(string)
- fmt.Println("content是谁?", content)
- if len(content) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "内容不能为空")
- return
- }
-
- sors := int64(dataBody["order"].(float64))
- fmt.Println("sort0", sors)
- if sors <= 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序不能为空")
- return
- }
- fmt.Println("soert是谁?", sors)
- fmt.Println("姓名:", name, "内容", content, "排序", sors)
-
- category := models.ArticleCategory{
- Name: name,
- Summary: content,
- Order: sors,
- UserOrgId: userOrgID,
- Status: 1,
- Mtime: timenow,
- }
- fmt.Println("category是?", category)
- article_service.EditCategory(&category, userOrgID, id)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "category": category,
- })
- }
-
- func (this *ArticleManage) DeleteCategorys() {
- adminUserInfo := this.GetAdminUserInfo()
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- idsInters := dataBody["ids"].([]interface{})
- if len(idsInters) == 0 {
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
- return
- }
- }
-
- ids := make([]int64, 0)
- for _, idsInter := range idsInters {
- id := int64(idsInter.(float64))
- ids = append(ids, id)
- }
-
- err = article_service.DeleteCategorys(adminUserInfo.CurrentOrgId, ids)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除分类失败:("+err.Error()+")")
- return
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *ArticleManage) Addvido() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println("视频发布是什么呢", err)
-
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- vidupload := dataBody["vio_upload"].(string)
- if len(vidupload) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频不能为空")
- return
- }
- fmt.Println("视频", vidupload)
- vidname := dataBody["vid_name"].(string)
- if len(vidname) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频标题不能为空")
- return
- }
- fmt.Println("视频名称", vidname)
- vidpic := dataBody["vid_pic"].(string)
- if vidpic == "" {
- vidpic = vidupload + "?vframe/jpg/offset/1/w/300/h/200"
- }
- if len(vidpic) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频封面不能为空")
- return
- }
- fmt.Println("视频图片", vidpic)
- vidtype := int64(dataBody["vid_type"].(float64))
- if vidtype <= 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "所属分类不能为空")
- return
- }
- fmt.Println("视频类型", vidtype)
- fmt.Println("视频", vidupload, "视频标题", vidname, "视频封面", vidpic, "视频类型", vidtype)
- timenow := time.Now().Unix()
- articles := models.Articles{
- UserOrgId: userOrgID,
- Ctime: timenow,
- Type: 2,
- VideoUrl: vidupload,
- Title: vidname,
- Imgs: vidpic,
- ClassId: vidtype,
- ArticleStatus: 1,
- Status: 1,
- }
-
- err = article_service.AddVido(articles)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加分类失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "vido": articles,
- })
- }
-
- func (this *ArticleManage) SaveDraft() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println("视频发布是什么呢", err)
-
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- vidupload := dataBody["vio_upload"].(string)
- if len(vidupload) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频不能为空")
- return
- }
- fmt.Println("视频", vidupload)
- vidname := dataBody["vid_name"].(string)
- if len(vidname) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频标题不能为空")
- return
- }
- fmt.Println("视频名称", vidname)
- vidpic := dataBody["vid_pic"].(string)
- if vidpic == "" {
- vidpic = vidupload + "?vframe/jpg/offset/1/w/300/h/200"
- }
- if len(vidpic) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "视频封面不能为空")
- return
- }
- fmt.Println("视频图片", vidpic)
- vidtype := int64(dataBody["vid_type"].(float64))
- if vidtype <= 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "所属分类不能为空")
- return
- }
- fmt.Println("视频类型", vidtype)
- fmt.Println("视频", vidupload, "视频标题", vidname, "视频封面", vidpic, "视频类型", vidtype)
- timenow := time.Now().Unix()
- articles := models.Articles{
- UserOrgId: userOrgID,
- Ctime: timenow,
- Type: 2,
- VideoUrl: vidupload,
- Title: vidname,
- Imgs: vidpic,
- ClassId: vidtype,
- ArticleStatus: 2,
- Status: 1,
- }
-
- err = article_service.AddVido(articles)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加分类失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "savedraft": articles,
- })
- }
-
- func (this *ArticleManage) PrviewArticle() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println("视频发布是什么呢", err)
-
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- actname := dataBody["act_name"].(string)
- if len(actname) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
- return
- }
-
- actcontent := dataBody["act_content"].(string)
- if len(actcontent) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章内容不能为空")
- return
- }
-
- orglogo := dataBody["org_logo"].(string)
- if len(orglogo) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "封面图片不能为空")
- return
- }
-
- acttype := int64(dataBody["act_type"].(float64))
- if acttype <= 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
- return
- }
-
- timenow := time.Now().Unix()
- fmt.Println("姓名:", actname, "文章内容", actcontent, "图片", orglogo, "文章类型", acttype, userOrgID)
- articles := models.Articles{
- Title: actname,
- Content: actcontent,
- Imgs: orglogo,
- ClassId: acttype,
- UserOrgId: userOrgID,
- Ctime: timenow,
- Status: 1,
- Type: 1,
- ArticleStatus: 3,
- }
- err = article_service.AddPrviewArticle(articles)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加预览失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "art": articles,
- })
- fmt.Println("art是谁", articles)
- }
-
- func (this *ArticleManage) GetArtilcePreview() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- articles, err := article_service.GetArtilcePreview(userOrgID)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
- return
- }
- fmt.Println("文章内容", articles)
- this.ServeSuccessJSON(map[string]interface{}{
- "articles": articles,
- })
-
- }
-
- func (this *ArticleManage) AddDraft() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println("视频发布是什么呢", err)
-
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
- actname := dataBody["act_name"].(string)
- if len(actname) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
- return
- }
-
- actcontent := dataBody["act_content"].(string)
- if len(actcontent) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章内容不能为空")
- return
- }
-
- orglogo := dataBody["org_logo"].(string)
- if len(orglogo) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "封面图片不能为空")
- return
- }
-
- acttype := int64(dataBody["act_type"].(float64))
- if acttype <= 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
- return
- }
-
- timenow := time.Now().Unix()
- fmt.Println("姓名:", actname, "文章内容", actcontent, "图片", orglogo, "文章类型", acttype, userOrgID)
- articles := models.Articles{
- Title: actname,
- Content: actcontent,
- Imgs: orglogo,
- ClassId: acttype,
- UserOrgId: userOrgID,
- Ctime: timenow,
- Status: 1,
- Type: 1,
- ArticleStatus: 2,
- }
- err = article_service.AddDraft(articles)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "保存草稿失败")
- return
- }
- fmt.Println("文章内容", articles)
- this.ServeSuccessJSON(map[string]interface{}{
- "articles": articles,
- })
- }
-
- func (this *ArticleManage) GetArticleInfo() {
- id, _ := this.GetInt64("id")
- fmt.Println("id是啥", id)
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- articles, err := article_service.GetArticleInfo(userOrgID, id)
- fmt.Println("错误是什么", err)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询文章信息失败")
- return
- }
- fmt.Println("编辑文章内容是啥什么", articles)
- this.ServeSuccessJSON(map[string]interface{}{
- "articles": articles,
- })
- }
-
- func (this *ArticleManage) GetVidoInfo() {
- id, _ := this.GetInt64("id")
- fmt.Println("视频id是多少?", id)
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- vidos, err := article_service.GetArticleInfo(userOrgID, id)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询文章信息失败")
- return
- }
- fmt.Println("内容是啥什么", vidos)
- this.ServeSuccessJSON(map[string]interface{}{
- "vidos": vidos,
- })
- }
- func (this *ArticleManage) DeleteArticle() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- idsInters := dataBody["ids"].([]interface{})
- if len(idsInters) == 0 {
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
- return
- }
- }
-
- ids := make([]int64, 0)
- for _, idsInter := range idsInters {
- id := int64(idsInter.(float64))
- ids = append(ids, id)
- }
-
- err = article_service.DeleteArticle(ids, userOrgID)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
- return
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *ArticleManage) DeleteArticles() {
- id, _ := this.GetInt64("id")
- fmt.Println("id是多少呢", id)
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- err := article_service.DeleteArticles(id, userOrgID)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
- return
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *ArticleManage) GetMenus() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- categorys, err := article_service.GetMenus(userOrgID)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "categorys": categorys,
- })
- }
-
- func (this *ArticleManage) UpdataArticleInfo() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- id, _ := this.GetInt64("id")
- fmt.Println("id是多少", id)
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println("视频发布是什么呢", err)
-
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- title := dataBody["title"].(string)
- if len(title) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
- return
- }
- fmt.Println("title", title)
- content := dataBody["content"].(string)
- if len(content) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "内容不能为空")
- return
- }
- fmt.Println("content", content)
- images := dataBody["imgs"].(string)
- fmt.Println("images", images)
- classid := int64(dataBody["class_id"].(float64))
- if classid <= 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
- return
- }
- //classid, _ := strconv.ParseInt(class_id, 10, 64)
- fmt.Println("分类号", classid)
- fmt.Println("标题", title, "内容", content, "图片", images, "分类号", classid, "机构ID", userOrgID)
-
- articles := models.Articles{
- Title: title,
- Content: content,
- Imgs: images,
- ClassId: classid,
- Status: 1,
- Mtime: time.Now().Unix(),
- ArticleStatus: 1,
- }
- fmt.Println("为什么", articles)
- article_service.UpdataArticleInfo(&articles, userOrgID, id)
- this.ServeSuccessJSON(map[string]interface{}{
- "articls": articles,
- })
- }
-
- func (this *ArticleManage) SaveArticleDraft() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- id, _ := this.GetInt64("id")
- fmt.Println("id是多少", id)
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println("视频发布是什么呢", err)
-
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- title := dataBody["title"].(string)
- if len(title) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
- return
- }
- fmt.Println("title", title)
- content := dataBody["content"].(string)
- if len(content) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "内容不能为空")
- return
- }
- fmt.Println("content", content)
- images := dataBody["imgs"].(string)
- fmt.Println("images", images)
- classid := int64(dataBody["class_id"].(float64))
- if classid <= 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
- return
- }
- //classid, _ := strconv.ParseInt(class_id, 10, 64)
- fmt.Println("分类号", classid)
- fmt.Println("标题", title, "保存文章草稿内容", content, "图片", images, "分类号", classid, "机构ID", userOrgID)
-
- articles := models.Articles{
- Title: title,
- Content: content,
- Imgs: images,
- ClassId: classid,
- Status: 1,
- Mtime: time.Now().Unix(),
- ArticleStatus: 2,
- }
- fmt.Println("为什么", articles)
- article_service.UpdataArticleInfo(&articles, userOrgID, id)
- this.ServeSuccessJSON(map[string]interface{}{
- "articls": articles,
- })
- }
-
- func (this *ArticleManage) UpdateVidoInfo() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- id, _ := this.GetInt64("id")
- fmt.Println("id是多少", id)
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println("视频发布是什么呢", err)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- vidname := dataBody["vid_name"].(string)
- fmt.Println("视频名称", vidname)
- if len(vidname) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
- return
- }
- vioupload := dataBody["vio_upload"].(string)
- fmt.Println("视频上传路径", vioupload)
- vidpic := dataBody["vid_pic"].(string)
- fmt.Println("视频封面", vidpic)
- if len(vidpic) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
- return
- }
-
- vidtype := int64(dataBody["vid_type"].(float64))
- fmt.Println("视频封面", vidtype)
- if vidtype <= 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
- return
- }
- articles := models.Articles{
- Title: vidname,
- Imgs: vidpic,
- VideoUrl: vioupload,
- ClassId: vidtype,
- Status: 1,
- Mtime: time.Now().Unix(),
- ArticleStatus: 1,
- }
- article_service.UpdataArticleInfo(&articles, userOrgID, id)
- this.ServeSuccessJSON(map[string]interface{}{
- "articls": articles,
- })
- }
-
- func (this *ArticleManage) PreviewEditArticle() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- id, _ := this.GetInt64("id")
- fmt.Println("id是多少", id)
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println("视频发布是什么呢", err)
-
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- title := dataBody["title"].(string)
- if len(title) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
- return
- }
- fmt.Println("title", title)
- content := dataBody["content"].(string)
- if len(content) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "内容不能为空")
- return
- }
- fmt.Println("content", content)
- images := dataBody["imgs"].(string)
- fmt.Println("images", images)
- classid := int64(dataBody["class_id"].(float64))
- if classid <= 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
- return
- }
- //classid, _ := strconv.ParseInt(class_id, 10, 64)
- fmt.Println("分类号", classid)
- fmt.Println("标题", title, "内容", content, "图片", images, "分类号", classid, "机构ID", userOrgID)
-
- articles := models.Articles{
- Title: title,
- Content: content,
- Imgs: images,
- ClassId: classid,
- Status: 1,
- Mtime: time.Now().Unix(),
- ArticleStatus: 1,
- }
-
- article_service.PreviewEditArticle(articles, userOrgID, id)
- this.ServeSuccessJSON(map[string]interface{}{
- "articls": articles,
- })
- }
-
- func (this *ArticleManage) GetPreviewInfoTwo() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- fmt.Println("机构id", userOrgID)
- id, _ := this.GetInt64("id")
- articles, err := article_service.GetPreviewInfoById(id, userOrgID)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
- return
- }
- fmt.Println("错误", err)
- fmt.Println("预览文章内容", articles)
- this.ServeSuccessJSON(map[string]interface{}{
- "articles": articles,
- })
- }
-
- func (this *ArticleManage) GetAllComment() {
- page, _ := this.GetInt64("page", 1)
- fmt.Println("页面", page)
- limit, _ := this.GetInt64("limit", 10)
- fmt.Println("限制", limit)
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- fmt.Println("文章评论机构id", userOrgID)
- articles, total, err := article_service.GetAllComment(page, limit, userOrgID)
- fmt.Println("文章内容", articles)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "articles": articles,
- })
- }
-
- func (this *ArticleManage) GetArticleCommentDetail() {
- id, _ := this.GetInt64("id")
- fmt.Println("id是多少", id)
- page, _ := this.GetInt64("page", 1)
- fmt.Println("页面", page)
- limit, _ := this.GetInt64("limit", 10)
- fmt.Println("限制", limit)
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- articles, err := article_service.GetArticleCommentDetail(id, userOrgID)
- comment, total, err := article_service.FindAllComments(page, limit, 20142)
- org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
- fmt.Println("err是什么", err)
- fmt.Println("total", total)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "articles": articles,
- "comment": comment,
- "total": total,
- "orgName": org.OrgName,
- "orgID": userOrgID,
- })
- }
-
- func (this *ArticleManage) SendReplycontent() {
- replycontent := this.GetString("replycontent")
- actilcid, _ := this.GetInt64("acticlid")
- parentid, _ := this.GetInt64("parentid")
- fmt.Println("回复的内容", replycontent)
- fmt.Println("文章ID", actilcid)
- fmt.Println("父类ID", parentid)
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
- orgName := org.OrgName
- orgLogo := org.OrgLogo
- fmt.Println("logo", orgLogo)
- comment := models.Comment{
- Content: replycontent,
- ParentId: parentid,
- ArticleId: actilcid,
- Ctime: time.Now().Unix(),
- CommentUserId: userOrgID,
- Status: 1,
- CommentUserAvater: orgLogo,
- CommentUserName: orgName,
- }
- err := article_service.AddComment(&comment)
- fmt.Println("错误是什么", err)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加回复内容失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "comment": comment,
- })
- }
-
- func (this *ArticleManage) GetReplyAllComents() {
- page, _ := this.GetInt64("page", 1)
- fmt.Println("页面", page)
- limit, _ := this.GetInt64("limit", 10)
- fmt.Println("限制", limit)
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- fmt.Println("机构ID", userOrgID)
- comment, total, err := article_service.GetReplyAllComents(userOrgID, page, limit)
- fmt.Println("comment", comment)
- fmt.Println("total", total)
- fmt.Println("错误", err)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取评论列表失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "comments": comment,
- "total": total,
- })
- }
-
- func (this *ArticleManage) GetSendInformation() {
- artilcid, _ := this.GetInt64("artilcid")
- fmt.Println("文章id", artilcid)
- parentid, _ := this.GetInt64("parentid")
- fmt.Println("父类id", parentid)
- content := this.GetString("content")
- fmt.Println("文章内容", content)
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- org := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
- orgName := org.OrgName
- orgLogo := org.OrgLogo
- fmt.Println("logo", orgLogo)
- comment := models.Comment{
- Content: content,
- ParentId: parentid,
- ArticleId: artilcid,
- Ctime: time.Now().Unix(),
- CommentUserId: userOrgID,
- Status: 1,
- CommentUserAvater: orgLogo,
- CommentUserName: orgName,
- }
- err := article_service.AddComment(&comment)
- fmt.Println("错误是什么", err)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加回复内容失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "comment": comment,
- })
- }
-
- func (this *ArticleManage) GetSpreadReplay() {
- artilcid, _ := this.GetInt64("artilcid")
- fmt.Println("文章id", artilcid)
- parentid, _ := this.GetInt64("parentid")
- fmt.Println("父类id", parentid)
-
- comments, err := article_service.GetAllReplyFormId(artilcid, parentid)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "comments": comments,
- })
- }
-
- func (this *ArticleManage) ClearReplyInfo() {
- id, _ := this.GetInt64("id")
- fmt.Println("id为", id)
- err := article_service.ClearReplyInfo(id)
- fmt.Println("错误为", err)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
- return
- }
-
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *ArticleManage) DeleteReply() {
- id, _ := this.GetInt64("id")
- fmt.Println("id为", id)
- err := article_service.DeleteReply(id)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
- return
- }
-
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *ArticleManage) GetSpreadInfo() {
- parentid, _ := this.GetInt64("parentid")
- acticlid, _ := this.GetInt64("acticlid")
- fmt.Println("父类id", parentid)
- fmt.Println("文章id", acticlid)
- comments, err := article_service.GetQueryReplyInfo(parentid, acticlid)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "comments": comments,
- })
- }
-
- func (this *ArticleManage) ClearReply() {
- id, _ := this.GetInt64("id")
- fmt.Println("id是多少?", id)
- err := article_service.DeleteReply(id)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
- return
- }
-
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *ArticleManage) DeleteComments() {
- id, _ := this.GetInt64("id")
- fmt.Println("id事多少", id)
- err := article_service.DeleteReply(id)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除回复成功")
- return
- }
-
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *ArticleManage) SaveVidoDraft() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- id, _ := this.GetInt64("id")
- fmt.Println("id是多少", id)
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println("视频发布是什么呢", err)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
-
- vidname := dataBody["vid_name"].(string)
- fmt.Println("视频名称", vidname)
- if len(vidname) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
- return
- }
-
- vidpic := dataBody["vid_pic"].(string) + "?vframe/jpg/offset/1/w/300/h/200"
- fmt.Println("视频封面", vidpic)
- if len(vidpic) == 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
- return
- }
-
- vidtype := int64(dataBody["vid_type"].(float64))
- fmt.Println("视频类型", vidtype)
- if vidtype <= 0 {
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
- return
- }
- articles := models.Articles{
- Title: vidname,
- Imgs: vidpic,
- ClassId: vidtype,
- Status: 1,
- Mtime: time.Now().Unix(),
- ArticleStatus: 2,
- }
- article_service.SaveVidoDraft(&articles, userOrgID, id)
- this.ServeSuccessJSON(map[string]interface{}{
- "articls": articles,
- })
- }
-
- func (this *ArticleManage) DeleteAllReply() {
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
- idsInters := dataBody["ids"].([]interface{})
- if len(idsInters) == 0 {
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除评论失败:(没有选择评论)")
- return
- }
- }
-
- ids := make([]int64, 0)
- for _, idsInter := range idsInters {
- id := int64(idsInter.(float64))
- ids = append(ids, id)
- }
- fmt.Println("ids是什么", ids)
- err = article_service.DeleteAllReply(ids)
-
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
- return
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *ArticleManage) DeleteAllArticles() {
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
- return
- }
- idsInters := dataBody["ids"].([]interface{})
- if len(idsInters) == 0 {
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除评论失败:(没有选择评论)")
- return
- }
- }
-
- ids := make([]int64, 0)
- for _, idsInter := range idsInters {
- id := int64(idsInter.(float64))
- ids = append(ids, id)
- }
- fmt.Println("ids是什么", ids)
- err = article_service.DeleteAllArticles(ids)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
- return
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *ArticleManage) GetAllCategory() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- categorys, err := article_service.GetMenus(userOrgID)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "categorys": categorys,
- })
- }
-
- func (this *ArticleManage) GetArticleDetail() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- id, _ := this.GetInt64("id")
- fmt.Println("机构id", userOrgID)
- fmt.Println("id", id)
- articles, err := article_service.GetArticleDetailById(id, userOrgID)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "articles": articles,
- })
- }
-
- func (this *ArticleManage) GetVidoDetail() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- id, _ := this.GetInt64("id")
- fmt.Println("机构id", userOrgID)
- fmt.Println("id", id)
- articles, err := article_service.GetArticleDetailById(id, userOrgID)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "articles": articles,
- })
- }
-
- func (this *ArticleManage) GetEditArticleContent() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- id, _ := this.GetInt64("id")
- fmt.Println("机构id", userOrgID)
- fmt.Println("预览返回id", id)
- articles, err := article_service.GetArticleDetailById(id, userOrgID)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询回复内容失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "articles": articles,
- })
- }
|