123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876 |
- package article
-
- import (
- "github.com/astaxie/beego"
- "fmt"
- "SCRM/controllers"
- "SCRM/service/article_service"
- "SCRM/enums"
- "SCRM/models"
- "time"
- "SCRM/utils"
- "encoding/json"
- "strconv"
- )
-
- 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/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{},"Get: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/previewEditArticle",&ArticleManage{},"Post:PreviewEditArticle")
- beego.Router("/api/acticle/getPreviewInfo",&ArticleManage{},"Post:GetPreviewInfo")
- beego.Router("/api/acticle/getAllComment",&ArticleManage{},"Get:GetAllComment")
- beego.Router("/api/acticle/getArticleCommentDetail",&ArticleManage{},"Get:GetArticleCommentDetail")
- }
-
- 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)
- 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:1,
- }
- err = article_service.AddAritcle(articles)
- 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", "")
- 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
-
- if(status == 1){
- articles, total, err := article_service.GetPublished(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 == 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) 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)
- err = article_service.AddCategory(category)
- fmt.Println(err)
- if err !=nil{
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加分类失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "category":category,
- })
- }
-
- func (this *ArticleManage) GetCategorys() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- page, _ := this.GetInt64("page", 1)
- limit, _ := this.GetInt64("limit", 10)
- 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))
- //sors, _ := strconv.ParseInt(sort, 10, 64)
- 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,
- }
-
- 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,
- }
-
- 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)
- if err !=nil{
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询文章信息失败")
- return
- }
- fmt.Println("内容是啥什么",articles)
- this.ServeSuccessJSON(map[string]interface{}{
- "articles":articles,
- })
- }
-
- 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) 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(),
- }
- fmt.Println("为什么",articles)
- 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:3,
- }
-
- article_service.PreviewEditArticle(articles,userOrgID,id)
- this.ServeSuccessJSON(map[string]interface{}{
- "articls":articles,
- })
- }
-
- func (this * ArticleManage) GetPreviewInfo() {
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- articles, err := article_service.GetPreviewInfo(userOrgID)
- if err !=nil{
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
- return
- }
- 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
- 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)
- adminUserInfo := this.GetAdminUserInfo()
- userOrgID := adminUserInfo.CurrentOrgId
- articles, err := article_service.GetArticleCommentDetail(id, userOrgID)
- if err !=nil{
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "articles":articles,
- })
- }
|