Browse Source

员工管理

xiaoming_global 4 years ago
parent
commit
e4c2cd914e

+ 424 - 4
controllers/article/article_controller.go View File

@@ -24,6 +24,17 @@ func ArticleRouters() {
24 24
 	beego.Router("/api/acticle/delete",&ArticleManage{},"Delete:DeleteCategorys")
25 25
 	beego.Router("/api/acticle/addvido",&ArticleManage{},"Post:Addvido")
26 26
 	beego.Router("/api/acticle/savedraft",&ArticleManage{},"Post:SaveDraft")
27
+	beego.Router("/api/acticle/prviewArticle",&ArticleManage{},"Post:PrviewArticle")
28
+	beego.Router("/api/acticle/getarticlePreview",&ArticleManage{},"Get:GetArtilcePreview")
29
+	beego.Router("/api/acticle/save",&ArticleManage{},"Post:AddDraft")
30
+	beego.Router("/api/acticle/getEditArticle",&ArticleManage{},"Get:GetArticleInfo")
31
+	beego.Router("/api/article/Delete",&ArticleManage{},"Delete:DeleteArticle")
32
+	beego.Router("/api/acticle/getMenus",&ArticleManage{},"Get:GetMenus")
33
+	beego.Router("/api/acticle/updateArticlesInfo",&ArticleManage{},"Post:UpdataArticleInfo")
34
+	beego.Router("/api/acticle/previewEditArticle",&ArticleManage{},"Post:PreviewEditArticle")
35
+	beego.Router("/api/acticle/getPreviewInfo",&ArticleManage{},"Post:GetPreviewInfo")
36
+	beego.Router("/api/acticle/getAllComment",&ArticleManage{},"Get:GetAllComment")
37
+	beego.Router("/api/acticle/getArticleCommentDetail",&ArticleManage{},"Get:GetArticleCommentDetail")
27 38
 }
28 39
 
29 40
 type ArticleManage struct {
@@ -108,10 +119,13 @@ func (this *ArticleManage) GetArticleType(){
108 119
 
109 120
 func (this *ArticleManage) GetAllArticles()  {
110 121
 	page, _ := this.GetInt64("page", 1)
122
+	fmt.Println("页面",page)
111 123
 	limit, _ := this.GetInt64("limit", 10)
112
-	searchKey := this.GetString("search", "")
113
-	classId,_ := this.GetInt64("classid",0)
114
-    fmt.Println("页面",page,"限制",limit,"关键字",searchKey,"分类号",classId)
124
+	fmt.Println("限制",limit)
125
+	searchKey := this.GetString("keyword", "")
126
+	classId,_ := this.GetInt64("id",0)
127
+	status, _ := this.GetInt64("status")
128
+	fmt.Println("页面",page,"限制",limit,"关键字",searchKey,"分类号",classId,"状态值:",status)
115 129
 
116 130
 	if page <= 0 {
117 131
 		page = 1
@@ -119,10 +133,53 @@ func (this *ArticleManage) GetAllArticles()  {
119 133
 	if limit <= 0 {
120 134
 		limit = 10
121 135
 	}
136
+
137
+
122 138
 	adminUserInfo := this.GetAdminUserInfo()
123 139
 	userOrgID := adminUserInfo.CurrentOrgId
124 140
 
125
-	articles, total, err := article_service.FindAllArticle(userOrgID, page,limit, searchKey, classId)
141
+	if(status == 1){
142
+		articles, total, err := article_service.GetPublished(userOrgID, page, limit, searchKey)
143
+		category, err := article_service.FindCategoryList(userOrgID)
144
+		if err !=nil{
145
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
146
+			return
147
+		}
148
+		this.ServeSuccessJSON(map[string]interface{}{
149
+			"articles":articles,
150
+			"total":total,
151
+			"category":category,
152
+		})
153
+	}
154
+	if(status == 2){
155
+		articles, total, err := article_service.GetDraftbox(userOrgID, page, limit, searchKey)
156
+		category, err := article_service.FindCategoryList(userOrgID)
157
+		if err !=nil{
158
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
159
+			return
160
+		}
161
+		this.ServeSuccessJSON(map[string]interface{}{
162
+			"articles":articles,
163
+			"total":total,
164
+			"category":category,
165
+		})
166
+	}
167
+
168
+	if(status == 3){
169
+		articles, total, err := article_service.GetNoPass(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
+
182
+	articles, total, err := article_service.FindAllArticle(userOrgID, page,limit, searchKey,classId)
126 183
 	fmt.Println("文章内容是是么",articles)
127 184
 	fmt.Println("total",total)
128 185
 	fmt.Println("err",err)
@@ -453,4 +510,367 @@ func (this *ArticleManage) SaveDraft()  {
453 510
 	this.ServeSuccessJSON(map[string]interface{}{
454 511
 		"savedraft":articles,
455 512
 	})
513
+}
514
+
515
+func (this *ArticleManage) PrviewArticle()  {
516
+	adminUserInfo := this.GetAdminUserInfo()
517
+	userOrgID := adminUserInfo.CurrentOrgId
518
+	dataBody := make(map[string]interface{}, 0)
519
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
520
+	fmt.Println("视频发布是什么呢",err)
521
+
522
+	if err != nil {
523
+		utils.ErrorLog(err.Error())
524
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
525
+		return
526
+	}
527
+
528
+	actname := dataBody["act_name"].(string)
529
+	if len(actname) == 0 {
530
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
531
+		return
532
+	}
533
+
534
+	actcontent := dataBody["act_content"].(string)
535
+	if len(actcontent) == 0 {
536
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章内容不能为空")
537
+		return
538
+	}
539
+
540
+	orglogo := dataBody["org_logo"].(string)
541
+	if len(orglogo) == 0 {
542
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "封面图片不能为空")
543
+		return
544
+	}
545
+
546
+	acttype := int64(dataBody["act_type"].(float64))
547
+	if  acttype <= 0 {
548
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
549
+		return
550
+	}
551
+
552
+	timenow := time.Now().Unix()
553
+	fmt.Println("姓名:",actname,"文章内容",actcontent,"图片",orglogo,"文章类型",acttype,userOrgID)
554
+	articles := models.Articles{
555
+		Title: actname,
556
+		Content: actcontent,
557
+		Imgs: orglogo,
558
+		ClassId: acttype,
559
+		UserOrgId:userOrgID,
560
+		Ctime:timenow,
561
+		Status:1,
562
+		Type:1,
563
+		ArticleStatus:3,
564
+	}
565
+	 err = article_service.AddPrviewArticle(articles)
566
+	if err !=nil{
567
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加预览失败")
568
+		return
569
+	}
570
+	this.ServeSuccessJSON(map[string]interface{}{
571
+		"art":articles,
572
+	})
573
+	fmt.Println("art是谁",articles)
574
+}
575
+
576
+func (this *ArticleManage) GetArtilcePreview()  {
577
+	adminUserInfo := this.GetAdminUserInfo()
578
+	userOrgID := adminUserInfo.CurrentOrgId
579
+	articles, err := article_service.GetArtilcePreview(userOrgID)
580
+	if err !=nil{
581
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
582
+		return
583
+	}
584
+	fmt.Println("文章内容",articles)
585
+	this.ServeSuccessJSON(map[string]interface{}{
586
+		"articles":articles,
587
+	})
588
+
589
+}
590
+
591
+func (this *ArticleManage) AddDraft() {
592
+	adminUserInfo := this.GetAdminUserInfo()
593
+	userOrgID := adminUserInfo.CurrentOrgId
594
+	dataBody := make(map[string]interface{}, 0)
595
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
596
+	fmt.Println("视频发布是什么呢", err)
597
+
598
+	if err != nil {
599
+		utils.ErrorLog(err.Error())
600
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
601
+		return
602
+	}
603
+	actname := dataBody["act_name"].(string)
604
+	if len(actname) == 0 {
605
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
606
+		return
607
+	}
608
+
609
+	actcontent := dataBody["act_content"].(string)
610
+	if len(actcontent) == 0 {
611
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章内容不能为空")
612
+		return
613
+	}
614
+
615
+	orglogo := dataBody["org_logo"].(string)
616
+	if len(orglogo) == 0 {
617
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "封面图片不能为空")
618
+		return
619
+	}
620
+
621
+	acttype := int64(dataBody["act_type"].(float64))
622
+	if acttype <= 0 {
623
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
624
+		return
625
+	}
626
+
627
+	timenow := time.Now().Unix()
628
+	fmt.Println("姓名:", actname, "文章内容", actcontent, "图片", orglogo, "文章类型", acttype, userOrgID)
629
+	articles := models.Articles{
630
+		Title:         actname,
631
+		Content:       actcontent,
632
+		Imgs:          orglogo,
633
+		ClassId:       acttype,
634
+		UserOrgId:     userOrgID,
635
+		Ctime:         timenow,
636
+		Status:        1,
637
+		Type:          1,
638
+		ArticleStatus: 2,
639
+	}
640
+	err = article_service.AddDraft(articles)
641
+	if err !=nil{
642
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "保存草稿失败")
643
+		return
644
+	}
645
+	fmt.Println("文章内容",articles)
646
+	this.ServeSuccessJSON(map[string]interface{}{
647
+		"articles":articles,
648
+	})
649
+}
650
+
651
+func (this *ArticleManage) GetArticleInfo()  {
652
+	id, _ := this.GetInt64("id")
653
+	fmt.Println("id是啥",id)
654
+	adminUserInfo := this.GetAdminUserInfo()
655
+	userOrgID := adminUserInfo.CurrentOrgId
656
+	articles, err := article_service.GetArticleInfo(userOrgID, id)
657
+	if err !=nil{
658
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询文章信息失败")
659
+		return
660
+	}
661
+	fmt.Println("内容是啥什么",articles)
662
+	this.ServeSuccessJSON(map[string]interface{}{
663
+		"articles":articles,
664
+	})
665
+}
666
+
667
+func (this *ArticleManage) DeleteArticle()  {
668
+	adminUserInfo := this.GetAdminUserInfo()
669
+	userOrgID := adminUserInfo.CurrentOrgId
670
+
671
+	dataBody := make(map[string]interface{}, 0)
672
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
673
+	if err != nil {
674
+		utils.ErrorLog(err.Error())
675
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
676
+		return
677
+	}
678
+
679
+	idsInters := dataBody["ids"].([]interface{})
680
+	if len(idsInters) == 0 {
681
+		if err != nil {
682
+			this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
683
+			return
684
+		}
685
+	}
686
+
687
+	ids := make([]int64, 0)
688
+	for _, idsInter := range idsInters {
689
+		id := int64(idsInter.(float64))
690
+		ids = append(ids, id)
691
+	}
692
+
693
+	err = article_service.DeleteArticle(ids, userOrgID)
694
+	if err !=nil{
695
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
696
+		return
697
+	}
698
+	returnData := make(map[string]interface{}, 0)
699
+	returnData["msg"] = "ok"
700
+	this.ServeSuccessJSON(returnData)
701
+	return
702
+}
703
+
704
+func (this *ArticleManage) GetMenus(){
705
+	adminUserInfo := this.GetAdminUserInfo()
706
+	userOrgID := adminUserInfo.CurrentOrgId
707
+	categorys, err := article_service.GetMenus(userOrgID)
708
+	if err !=nil{
709
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "查询失败")
710
+		return
711
+	}
712
+	this.ServeSuccessJSON(map[string]interface{}{
713
+		"categorys":categorys,
714
+	})
715
+}
716
+
717
+func (this * ArticleManage) UpdataArticleInfo(){
718
+	adminUserInfo := this.GetAdminUserInfo()
719
+	userOrgID := adminUserInfo.CurrentOrgId
720
+	id, _ := this.GetInt64("id")
721
+	fmt.Println("id是多少",id)
722
+	dataBody := make(map[string]interface{}, 0)
723
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
724
+	fmt.Println("视频发布是什么呢",err)
725
+
726
+	if err != nil {
727
+		utils.ErrorLog(err.Error())
728
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
729
+		return
730
+	}
731
+
732
+	title := dataBody["title"].(string)
733
+	if len(title) == 0 {
734
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
735
+		return
736
+	}
737
+	fmt.Println("title",title)
738
+	content := dataBody["content"].(string)
739
+	if len(content) == 0 {
740
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "内容不能为空")
741
+		return
742
+	}
743
+	fmt.Println("content",content)
744
+	images := dataBody["imgs"].(string)
745
+	fmt.Println("images",images)
746
+	classid :=int64( dataBody["class_id"].(float64))
747
+	if classid <=0 {
748
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
749
+		return
750
+	}
751
+	//classid, _ := strconv.ParseInt(class_id, 10, 64)
752
+    fmt.Println("分类号",classid)
753
+	fmt.Println("标题",title,"内容",content,"图片",images,"分类号",classid,"机构ID",userOrgID)
754
+
755
+	articles := models.Articles{
756
+		Title:   title,
757
+		Content: content,
758
+		Imgs:    images,
759
+		ClassId: classid,
760
+		Status:  1,
761
+		Mtime:   time.Now().Unix(),
762
+	}
763
+	 fmt.Println("为什么",articles)
764
+	 article_service.UpdataArticleInfo(&articles,userOrgID, id)
765
+	this.ServeSuccessJSON(map[string]interface{}{
766
+		"articls":articles,
767
+	})
768
+}
769
+
770
+func (this * ArticleManage) PreviewEditArticle()  {
771
+	adminUserInfo := this.GetAdminUserInfo()
772
+	userOrgID := adminUserInfo.CurrentOrgId
773
+	id, _ := this.GetInt64("id")
774
+	fmt.Println("id是多少",id)
775
+	dataBody := make(map[string]interface{}, 0)
776
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
777
+	fmt.Println("视频发布是什么呢",err)
778
+
779
+	if err != nil {
780
+		utils.ErrorLog(err.Error())
781
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
782
+		return
783
+	}
784
+
785
+	title := dataBody["title"].(string)
786
+	if len(title) == 0 {
787
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "文章标题不能为空")
788
+		return
789
+	}
790
+	fmt.Println("title",title)
791
+	content := dataBody["content"].(string)
792
+	if len(content) == 0 {
793
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "内容不能为空")
794
+		return
795
+	}
796
+	fmt.Println("content",content)
797
+	images := dataBody["imgs"].(string)
798
+	fmt.Println("images",images)
799
+	classid :=int64( dataBody["class_id"].(float64))
800
+	if classid <=0 {
801
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "分类号不能为空")
802
+		return
803
+	}
804
+	//classid, _ := strconv.ParseInt(class_id, 10, 64)
805
+	fmt.Println("分类号",classid)
806
+	fmt.Println("标题",title,"内容",content,"图片",images,"分类号",classid,"机构ID",userOrgID)
807
+
808
+	articles := models.Articles{
809
+		Title:   title,
810
+		Content: content,
811
+		Imgs:    images,
812
+		ClassId: classid,
813
+		Status:  1,
814
+		Mtime:   time.Now().Unix(),
815
+		ArticleStatus:3,
816
+	}
817
+
818
+	article_service.PreviewEditArticle(articles,userOrgID,id)
819
+	this.ServeSuccessJSON(map[string]interface{}{
820
+		"articls":articles,
821
+	})
822
+}
823
+
824
+func (this * ArticleManage) GetPreviewInfo()  {
825
+	adminUserInfo := this.GetAdminUserInfo()
826
+	userOrgID := adminUserInfo.CurrentOrgId
827
+	articles, err := article_service.GetPreviewInfo(userOrgID)
828
+	if err !=nil{
829
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
830
+		return
831
+	}
832
+	fmt.Println("文章内容",articles)
833
+	this.ServeSuccessJSON(map[string]interface{}{
834
+		"articles":articles,
835
+	})
836
+}
837
+
838
+func  (this * ArticleManage) GetAllComment()  {
839
+	page, _ := this.GetInt64("page", 1)
840
+	fmt.Println("页面",page)
841
+	limit, _ := this.GetInt64("limit", 10)
842
+	fmt.Println("限制",limit)
843
+	if page <= 0 {
844
+		page = 1
845
+	}
846
+	if limit <= 0 {
847
+		limit = 10
848
+	}
849
+	adminUserInfo := this.GetAdminUserInfo()
850
+	userOrgID := adminUserInfo.CurrentOrgId
851
+	articles, total, err := article_service.GetAllComment(page, limit, userOrgID)
852
+	fmt.Println("文章内容",articles)
853
+	if err !=nil{
854
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
855
+		return
856
+	}
857
+	this.ServeSuccessJSON(map[string]interface{}{
858
+		"total":total,
859
+		"articles":articles,
860
+	})
861
+}
862
+
863
+func (this * ArticleManage) GetArticleCommentDetail(){
864
+	id, _ := this.GetInt64("id")
865
+	fmt.Println("id是多少",id)
866
+	adminUserInfo := this.GetAdminUserInfo()
867
+	userOrgID := adminUserInfo.CurrentOrgId
868
+	articles, err := article_service.GetArticleCommentDetail(id, userOrgID)
869
+	if err !=nil{
870
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取预览失败")
871
+		return
872
+	}
873
+	this.ServeSuccessJSON(map[string]interface{}{
874
+		"articles":articles,
875
+	})
456 876
 }

+ 5 - 0
controllers/staff/router_collector.go View File

@@ -0,0 +1,5 @@
1
+package staff
2
+
3
+func RegisterRouters() {
4
+	staffRouters()
5
+}

+ 150 - 0
controllers/staff/staff_controller.go View File

@@ -0,0 +1,150 @@
1
+package staff
2
+
3
+import (
4
+	"github.com/astaxie/beego"
5
+   "SCRM/controllers"
6
+	"encoding/json"
7
+	"fmt"
8
+	"SCRM/utils"
9
+	"SCRM/enums"
10
+	"SCRM/models"
11
+	"SCRM/service/staff_service"
12
+	"time"
13
+)
14
+func staffRouters() {
15
+	 
16
+	beego.Router("/api/staff/addStaffInfo",&StaffManage{},"Post:AddStaffInfo")
17
+	beego.Router("/api/staff/getAllStaffInfo",&StaffManage{},"Get:GetAllStaffInfo")
18
+}
19
+
20
+type StaffManage struct {
21
+
22
+	controllers.BaseAuthAPIController
23
+}
24
+
25
+func (this *StaffManage) AddStaffInfo()  {
26
+	adminUserInfo := this.GetAdminUserInfo()
27
+	userOrgID := int64(adminUserInfo.CurrentOrgId)
28
+	fmt.Println("机构ID",userOrgID)
29
+	dataBody := make(map[string]interface{}, 0)
30
+
31
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
32
+	fmt.Println("视频发布是什么呢",err)
33
+
34
+	if err != nil {
35
+		utils.ErrorLog(err.Error())
36
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
37
+		return
38
+	}
39
+     fmt.Println("hhhhh")
40
+	staffname := dataBody["name"].(string)
41
+	if len(staffname) == 0 {
42
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "姓名不能为空")
43
+		return
44
+	}
45
+
46
+	phone := dataBody["phone"].(string)
47
+	if len(phone) == 0 {
48
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "手机不能为空")
49
+		return
50
+	}
51
+
52
+	gender := int64(dataBody["gender"].(float64))
53
+	if gender <= 0{
54
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "性别不能为空")
55
+		return
56
+	}
57
+
58
+	birthday, _ := dataBody["birthday"].(string)
59
+	if len(birthday) == 0 {
60
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "生日格式不正确")
61
+		return
62
+	}
63
+
64
+	timeLayout := "2006-01-02 15:04:05"
65
+	theTime, err := utils.ParseTimeStringToTime(timeLayout, birthday+" 00:00:00")
66
+	if err != nil {
67
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "生日格式不正确")
68
+		return
69
+	}
70
+
71
+	var staffbirthday = theTime.Unix()
72
+	fmt.Println("生日",staffbirthday)
73
+
74
+	userType := int64(dataBody["user_type"].(float64))
75
+
76
+	if userType <= 0 {
77
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "职称类型不正确")
78
+		return
79
+	}
80
+	userTitle :=int64(dataBody["user_title"].(float64))
81
+	if userTitle <= 0 {
82
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "职称名称不正确")
83
+		return
84
+	}
85
+	dochead := dataBody["dochead"].(string)
86
+	if len(dochead) == 0 {
87
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "头像不正确")
88
+		return
89
+	}
90
+	content := dataBody["content"].(string)
91
+	if len(content) == 0 {
92
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "头像不正确")
93
+		return
94
+	}
95
+
96
+	fmt.Println("姓名",staffname,"性别" ,gender,"生日",staffbirthday,"职称类型",userType,"职称名称",userTitle,"头像",dochead,"内容",content)
97
+
98
+	StaffInfo := models.SgjUserStaffInfo{
99
+		Name:      staffname,
100
+		Phone:     phone,
101
+		Birthday:  staffbirthday,
102
+		Gender:gender,
103
+		Content:content,
104
+		UserType:  userType,
105
+		UserTitle: userType,
106
+		Dochead:   dochead,
107
+		Status: 1,
108
+		UserOrgId:userOrgID,
109
+		Ctime:time.Now().Unix(),
110
+	}
111
+
112
+	err = staff_service.AddStaffInfo(StaffInfo)
113
+	if err !=nil{
114
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "插入文章失败")
115
+		return
116
+	}
117
+	this.ServeSuccessJSON(map[string]interface{}{
118
+		"staffInfo":StaffInfo,
119
+	})
120
+	return
121
+}
122
+
123
+func (this *StaffManage) GetAllStaffInfo()  {
124
+	keyword := this.GetString("keyword")
125
+	page, _ := this.GetInt64("page", 1)
126
+	fmt.Println("页面",page)
127
+	limit, _ := this.GetInt64("limit", 10)
128
+
129
+	if page <= 0 {
130
+		page = 1
131
+	}
132
+	if limit <= 0 {
133
+		limit = 10
134
+	}
135
+	fmt.Println("限制",limit)
136
+	fmt.Println("关键字",keyword,"limit",limit,"page",page)
137
+
138
+	adminUserInfo := this.GetAdminUserInfo()
139
+	userOrgID := int64(adminUserInfo.CurrentOrgId)
140
+	userStaffInfo, total, err := staff_service.GetAllStaffInfo(userOrgID, page, limit, keyword)
141
+    fmt.Println("内容",userStaffInfo,"total",total,"err",err)
142
+	if err !=nil{
143
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章分类列表失败")
144
+		return
145
+	}
146
+	this.ServeSuccessJSON(map[string]interface{}{
147
+		"userStaffInfo":userStaffInfo,
148
+		"total":total,
149
+	})
150
+}

+ 1 - 0
models/article_models.go View File

@@ -26,6 +26,7 @@ type Articles struct {
26 26
 	Content       string    `gorm:"column:content" json:"content"`
27 27
 	Type          int       `gorm:"column:type" json:"type"`
28 28
 	Num           int       `gorm:"column:num" json:"num"`
29
+	Realreadnum   int64       `gorm:"column:real_read_num" json:"real_read_num"`
29 30
 	Mtime         int64     `gorm:"column:mtime" json:"mtime"`
30 31
 	Ctime         int64     `gorm:"column:ctime" json:"ctime"`
31 32
 	ClassId       int64     `gorm:"column:class_id" json:"class_id"`

+ 20 - 0
models/user_models.go View File

@@ -35,3 +35,23 @@ type User struct {
35 35
 func (User) TableName() string {
36 36
 	return "sgj_user_user"
37 37
 }
38
+
39
+type SgjUserStaffInfo struct {
40
+	ID int64 `gorm:"column:id" json:"id" form:"id"`
41
+	Name string `gorm:"column:name" json:"name" form:"name"`
42
+	Phone string `gorm:"column:phone" json:"phone" form:"phone"`
43
+	Birthday int64 `gorm:"column:birthday" json:"birthday" form:"birthday"`
44
+	Gender int64 `gorm:"column:gender" json:"gender" form:"gender"`
45
+	UserType int64 `gorm:"column:user_type" json:"user_type" form:"user_type"`
46
+	UserTitle int64 `gorm:"column:user_title" json:"user_title" form:"user_title"`
47
+	Dochead string `gorm:"column:dochead" json:"dochead" form:"dochead"`
48
+	Content string `gorm:"column:content" json:"content" form:"content"`
49
+	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
50
+	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
51
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
52
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
53
+}
54
+
55
+func (SgjUserStaffInfo) TableName() string{
56
+	return "sgj_user_staff_info"
57
+}

+ 2 - 0
routers/router.go View File

@@ -12,6 +12,7 @@ import (
12 12
 
13 13
 	"github.com/astaxie/beego"
14 14
 	"github.com/astaxie/beego/plugins/cors"
15
+	"SCRM/controllers/staff"
15 16
 )
16 17
 
17 18
 func init() {
@@ -31,4 +32,5 @@ func init() {
31 32
 	marketing_tool.RegisterRouters()
32 33
 	article.RegisterRouters()
33 34
 	mpwechat.RegisterRouters()
35
+	staff.RegisterRouters()
34 36
 }

+ 147 - 5
service/article_service/article_category_service.go View File

@@ -25,15 +25,15 @@ func AddAritcle(articles models.Articles) error {
25 25
 	return  err
26 26
 }
27 27
 
28
-func FindAllArticle(orgID int64, page int64,limit int64, searchKey string, classId int64) (articles []*models.Articles,total int64, err error) {
28
+func FindAllArticle(orgID int64, page int64,limit int64, searchKey string,classId int64) (articles []*models.Articles,total int64, err error) {
29 29
     fmt.Println("机构ID",orgID,"搜搜索",searchKey)
30 30
 	db := service.PatientReadDB().Table("sgj_patient_articles as a ").Where("a.status=1")
31 31
 	if(orgID>0){
32 32
 	  db = db.Where("a.user_org_id=?" ,orgID)
33 33
 	}
34 34
 
35
-	if(classId>0){
36
-	  db = db.Joins("JOIN sgj_patient_articles_menu as s ON s.id = a.class_id AND s.status=1 AND user_org_id=?",orgID)
35
+	if(classId > 0){
36
+		db = db.Where("class_id = ?",classId)
37 37
 	}
38 38
 
39 39
 	if len(searchKey) > 0 {
@@ -45,7 +45,7 @@ func FindAllArticle(orgID int64, page int64,limit int64, searchKey string, class
45 45
 		err = db.Count(&total).Order("a.ctime desc").Offset(offset).Limit(limit).
46 46
 		Preload("Comments", func(db *gorm.DB) *gorm.DB {
47 47
 			return  db.Where(" status = ?",1)
48
-		}).
48
+		}).Where("article_status <> ?",3).
49 49
 		Select("a.id, a.title, a.summary, a.content, a.type, a.num, a.mtime, a.real_read_num, a.ctime, a.class_id, a.author, a.status, a.reason,a.star_num, a.comment_num,a.user_org_id, a.article_status, a.imgs, a.video_url, a.source, a.category_id, a.ttid, a.ttype, a.toid").Find(&articles).Error
50 50
 		fmt.Println("err是啥呢?",err)
51 51
 		 	if err != nil {
@@ -100,4 +100,146 @@ func DeleteCategorys(orgID int64,ids[] int64)(err error){
100 100
 func AddVido(articles models.Articles) error  {
101 101
 	err := service.PatientWriteDB().Create(&articles).Error
102 102
 	return  err
103
-}
103
+}
104
+
105
+func AddPrviewArticle(articles models.Articles)(err error) {
106
+	err = service.PatientWriteDB().Create(&articles).Error
107
+	return err
108
+}
109
+
110
+func GetArtilcePreview(OrgID int64)(models.Articles,error) {
111
+	article := models.Articles{}
112
+	err := service.PatientReadDB().Where("user_org_id = ? AND article_status = ? AND type = ?", OrgID, 3, 1).Last(&article).Error
113
+	return article, err
114
+}
115
+
116
+func AddDraft(articles models.Articles) error {
117
+	err := service.PatientReadDB().Create(&articles).Error
118
+	return  err
119
+}
120
+
121
+func GetPublished(orgID int64,page int64,limit int64, searchKey string)(articles []*models.Articles,total int64, err error) {
122
+	db := service.PatientReadDB().Table("sgj_patient_articles as a ").Where("a.status=1")
123
+	if (orgID > 0) {
124
+		db = db.Where("a.user_org_id=? AND article_status = ?", orgID,1)
125
+	}
126
+	if len(searchKey) > 0 {
127
+		searchKey = "%" + searchKey + "%"
128
+		db = db.Where("a.title LIKE ?", searchKey)
129
+	}
130
+	offset := (page - 1) * limit
131
+	err = db.Count(&total).Order("a.ctime desc").Offset(offset).Limit(limit).
132
+		Preload("Comments", func(db *gorm.DB) *gorm.DB {
133
+		return  db.Where(" status = ?",1)
134
+	}).Where("status = ?",1).
135
+		Select("a.id, a.title, a.summary, a.content, a.type, a.num, a.mtime, a.real_read_num, a.ctime, a.class_id, a.author, a.status, a.reason,a.star_num, a.comment_num,a.user_org_id, a.article_status, a.imgs, a.video_url, a.source, a.category_id, a.ttid, a.ttype, a.toid").Find(&articles).Error
136
+	fmt.Println("err是啥呢?",err)
137
+	if err != nil {
138
+		return
139
+	}
140
+	return
141
+}
142
+
143
+func GetDraftbox(orgID int64,page int64,limit int64, searchKey string)(articles []*models.Articles,total int64, err error) {
144
+	db := service.PatientReadDB().Table("sgj_patient_articles as a ").Where("a.status=1")
145
+	if (orgID > 0) {
146
+		db = db.Where("a.user_org_id=? AND article_status = ?", orgID,2)
147
+	}
148
+	if len(searchKey) > 0 {
149
+		searchKey = "%" + searchKey + "%"
150
+		db = db.Where("a.title LIKE ?", searchKey)
151
+	}
152
+	offset := (page - 1) * limit
153
+	err = db.Count(&total).Order("a.ctime desc").Offset(offset).Limit(limit).
154
+		Preload("Comments", func(db *gorm.DB) *gorm.DB {
155
+		return  db.Where(" status = ?",1)
156
+	}).Where("article_status = ? AND status = ?",2,1).
157
+		Select("a.id, a.title, a.summary, a.content, a.type, a.num, a.mtime, a.real_read_num, a.ctime, a.class_id, a.author, a.status, a.reason,a.star_num, a.comment_num,a.user_org_id, a.article_status, a.imgs, a.video_url, a.source, a.category_id, a.ttid, a.ttype, a.toid").Find(&articles).Error
158
+	fmt.Println("err是啥呢?",err)
159
+	if err != nil {
160
+		return
161
+	}
162
+	return
163
+}
164
+
165
+func GetNoPass(orgID int64,page int64,limit int64, searchKey string)(articles []*models.Articles,total int64, err error)  {
166
+	db := service.PatientReadDB().Table("sgj_patient_articles as a ").Where("a.status=1")
167
+	if (orgID > 0) {
168
+		db = db.Where("a.user_org_id=? AND article_status = ?", orgID,4)
169
+	}
170
+	if len(searchKey) > 0 {
171
+		searchKey = "%" + searchKey + "%"
172
+		db = db.Where("a.title LIKE ?", searchKey)
173
+	}
174
+	offset := (page - 1) * limit
175
+	err = db.Count(&total).Order("a.ctime desc").Offset(offset).Limit(limit).
176
+		Preload("Comments", func(db *gorm.DB) *gorm.DB {
177
+		return  db.Where(" status = ?",1)
178
+	}).Where("article_status = ? AND status = ?",4,1).
179
+		Select("a.id, a.title, a.summary, a.content, a.type, a.num, a.mtime, a.real_read_num, a.ctime, a.class_id, a.author, a.status, a.reason,a.star_num, a.comment_num,a.user_org_id, a.article_status, a.imgs, a.video_url, a.source, a.category_id, a.ttid, a.ttype, a.toid").Find(&articles).Error
180
+	fmt.Println("err是啥呢?",err)
181
+	if err != nil {
182
+		return
183
+	}
184
+	return
185
+}
186
+
187
+func GetArticleInfo(orgID int64,id int64)(articles models.Articles,err error){
188
+	err = service.PatientReadDB().Where("user_org_id = ? AND id = ? AND status = ?", orgID, id, 1).Find(&articles).Error
189
+	return  articles,err
190
+}
191
+
192
+func DeleteArticle(ids[] int64,orgID int64)(err error)  {
193
+	if len(ids) ==1{
194
+		err =	service.PatientWriteDB().Model(&models.Articles{}).Where( "id=? and user_org_id = ?",ids[0],orgID).Update(map[string]interface{}{"status":0,"mtime":time.Now().Unix()}).Error
195
+	}else {
196
+		err =	service.PatientWriteDB().Model(&models.Articles{}).Where("id IN (?) and user_org_id = ?",ids,orgID).Update(map[string]interface{}{"status":0,"mtime":time.Now().Unix()}).Error
197
+	}
198
+	return
199
+}
200
+
201
+func GetMenus(OrgID int64)(categorys []*models.ArticleCategory,err error)  {
202
+	err = service.PatientReadDB().Where("user_org_id = ?", OrgID).Find(&categorys).Error
203
+	return  categorys ,err
204
+}
205
+
206
+func UpdataArticleInfo(art *models.Articles,orgID int64,id int64){
207
+	service.PatientWriteDB().Model(art).Where("user_org_id = ? AND id = ? AND status = ?",orgID,id,1).Update(map[string]interface{}{"title":art.Title,"content":art.Content,"imgs":art.Imgs,"class_id":art.ClassId,"mtime":art.Mtime})
208
+
209
+}
210
+
211
+func PreviewEditArticle(art models.Articles,orgID int64,id int64)  {
212
+	service.PatientWriteDB().Model(art).Where("user_org_id = ? AND id = ? AND status = ?",orgID,id,1).Update(map[string]interface{}{"title":art.Title,"content":art.Content,"imgs":art.Imgs,"class_id":art.ClassId,"mtime":art.Mtime,"article_status":art.ArticleStatus})
213
+}
214
+
215
+func GetPreviewInfo(orgID int64)(models.Articles,error)  {
216
+	article := models.Articles{}
217
+	err := service.PatientReadDB().Where("user_org_id = ? AND article_status = ? AND type = ?", orgID, 3, 1).Last(&article).Error
218
+	return article, err
219
+}
220
+
221
+func GetAllComment(page int64,limit int64,orgID int64)(articles []*models.Articles,total int64, err error) {
222
+	db := service.PatientReadDB().Table("sgj_patient_articles as a ").Where("a.status=1")
223
+	if (orgID > 0) {
224
+		db = db.Where("a.user_org_id=? AND article_status = ?", orgID,1)
225
+	}
226
+	offset := (page - 1) * limit
227
+	err = db.Count(&total).Order("a.ctime desc").Offset(offset).Limit(limit).
228
+		Preload("Comments", func(db *gorm.DB) *gorm.DB {
229
+		return  db.Where(" status = ?",1)
230
+	}).
231
+		Select("a.id, a.title, a.summary, a.content, a.type, a.num, a.mtime, a.real_read_num, a.ctime, a.class_id, a.author, a.status, a.reason,a.star_num, a.comment_num,a.user_org_id, a.article_status, a.imgs, a.video_url, a.source, a.category_id, a.ttid, a.ttype, a.toid").Find(&articles).Error
232
+	fmt.Println("err是啥呢?",err)
233
+	if err != nil {
234
+		return
235
+	}
236
+	return
237
+}
238
+
239
+func GetArticleCommentDetail(articleId int64,orgID int64)(*models.Articles, error){
240
+	article := &models.Articles{}
241
+	err :=service.PatientReadDB().Where("id = ? AND user_org_id = ? AND status = ?", articleId, orgID,1).Find(article).Error
242
+	tm := time.Unix(article.Ctime, 0)
243
+	article.PublicTime = tm.Format("2006-01-02 15:04:05")
244
+	return article, err
245
+}

+ 3 - 0
service/marketing_tool_service/activity_service.go View File

@@ -164,3 +164,6 @@ func SaveActivityAndParagraph(activity *models.Activity, paragraph *models.Activ
164 164
 func SaveActivityWxShare(model *models.ActivityWxShare) error {
165 165
 	return service.PatientWriteDB().Save(model).Error
166 166
 }
167
+
168
+
169
+

+ 34 - 0
service/staff_service/staff_manager_service.go View File

@@ -0,0 +1,34 @@
1
+package staff_service
2
+
3
+import (
4
+	"SCRM/models"
5
+	"SCRM/service"
6
+)
7
+
8
+func AddStaffInfo(info models.SgjUserStaffInfo) error  {
9
+	err := service.UserWriteDB().Create(&info).Error
10
+	return  err
11
+}
12
+
13
+func  GetAllStaffInfo(orgID int64,page int64,limit int64,keyword string)(userStaffInfo  []*models.SgjUserStaffInfo,total int64,err error){
14
+
15
+	db := service.UserReadDB().Table("sgj_user_staff_info as s").Where("s.status = 1")
16
+	if(orgID>0){
17
+		db = db.Where("s.user_org_id = ?", orgID)
18
+	}
19
+
20
+	if len(keyword) >0{
21
+		keyword = "%" + keyword + "%"
22
+		db.Where("s.name LIKE ? AND s.user_title LIEK ?",keyword,keyword)
23
+	}
24
+
25
+	offset := (page - 1) * limit
26
+	err = db.Count(&total).Order("s.ctime desc").Offset(offset).Limit(limit).
27
+		Select("s.id,s.name,s.phone,s.birthday,s.gender,s.user_type,s.user_title,s.dochead,s.content,s.ctime,s.mtime,s.status,s.user_org_id").Find(&userStaffInfo).Error
28
+
29
+	if err != nil {
30
+		return
31
+	}
32
+	return
33
+}
34
+