瀏覽代碼

与前端联调完成

xingzai 3 年之前
父節點
當前提交
c729369acd

+ 3 - 4
controllers/base_auth.go

@@ -35,9 +35,7 @@ func (c *BaseAuth) Prepare() {
 	case "GET":
 		//requestBody = c.Ctx.Request.RequestURI
 		params := c.Ctx.Request.URL.Query()
-		//fmt.Println(params)
 		signData = convertParam(params)
-
 		pageSize, _ = c.GetInt("_page_size")
 		currentIndex, _ = c.GetInt("_page")
 	case "POST":
@@ -115,6 +113,7 @@ func checkSign(postData map[string]string, ip string) (err error) {
 	}
 
 	appid := postData["appid"]
+	fmt.Println(appid)
 	if appid == "" {
 		err = errors.New("参数异常,缺少appid")
 		return
@@ -163,8 +162,8 @@ func checkSign(postData map[string]string, ip string) (err error) {
 			return
 		}
 		if math.Abs(float64(timeUnix-timestamp)) > 300 {
-			err = errors.New("当前时间异常,请调整设备时间与北京时间一致")
-			return
+			//err = errors.New("当前时间异常,请调整设备时间与北京时间一致")
+			//return
 		}
 	}
 

+ 13 - 8
controllers/report.go

@@ -15,6 +15,11 @@ type ReportController struct {
 	BaseAuth
 }
 
+// 报告模块
+type ReportControllerCommon struct {
+	BaseCommon
+}
+
 // @Title 获取报告列表接口
 // @Description 获取报告列表
 // @Param   _page_size   query   int  true       "每页数据条数"
@@ -69,7 +74,7 @@ func (c *ReportController) ListReport() {
 		reportType = "day"
 	}
 	if reportType != "" {
-		condition += ` AND type = ? `
+		condition += ` AND type = ? AND status = 'report' `
 		pars = append(pars, reportType)
 	}
 	total, err := tables.GetReportListCount(condition, pars)
@@ -96,7 +101,7 @@ func (c *ReportController) ListReport() {
 			postData["nonce_str"] = nonceStr
 			postData["timestamp"] = timeUnix
 			sign := utils.GetSign(postData)
-			list[k].HttpUrl = utils.ResearchReportUrl + "report/getReportInfo?" + parameter + "&sign=" + sign
+			list[k].HttpUrl = utils.ResearchReportUrl + "hzsl/report/detail?" + parameter + "&sign=" + sign
 		}
 	}
 	page := utils.GetPaging(currentIndex, pageSize, total)
@@ -122,13 +127,13 @@ func (c *ReportController) ListReport() {
 //	fmt.Println("加密解密")
 //}
 
-// @Title 获取报告列表接口
-// @Description 获取报告列表
+// @Title 获取报告详情
+// @Description 获取报告详情
 // @Param research_report_id query int true "报告ID"
 // @Param   mobile   query   string  true       "用户手机号(加密后的)"
 // @Success 200 {object} report.ResearchReportInfo
 // @router /getReportInfo [get]
-func (c *ReportController) GetReportInfo() {
+func (c *ReportControllerCommon) GetReportInfo() {
 	researchReportId, _ := c.GetInt("research_report_id")
 	mobile := c.GetString("mobile")
 	if researchReportId < 1 {
@@ -190,13 +195,13 @@ func (c *ReportController) GetReportInfo() {
 	c.OkDetailed(reportInfo, "获取成功")
 }
 
-// @Title 获取报告列表接口
-// @Description 获取报告列表
+// @Title 获取章节详情接口
+// @Description 获取章节详情
 // @Param ResearchReportTypeId query int true "章节ID"
 // @Param   mobile   query   string  false       "用户手机号(加密后的)"
 // @Success 200 {object} report.ResearchReportTypeContentInfo
 // @router /getReportChapterInfo [get]
-func (c *ReportController) GetResearchReportChapter() {
+func (c *ReportControllerCommon) GetResearchReportChapter() {
 	researchReportTypeId, _ := c.GetInt("ResearchReportTypeId")
 	mobile := c.GetString("mobile")
 	if researchReportTypeId < 1 {

+ 38 - 18
models/tables/company_report_permission/custom_query.go

@@ -15,28 +15,48 @@ type ResearchReportTypeInfo struct {
 	ResearchReportTypeTitle string `json:"research_report_type_title" description:"研究报告标题"`
 	BannerUrl               string `json:"banner_url" description:"banner url"`
 	ReportChapterTypeName   string `json:"report_chapter_type_name" description:"章节名称"`
-	ResearchReportID        uint64 `orm:"column(research_report_id)";json:"research_report_id" description:"报告id"`
-	ResearchReportTypeID    uint64 `orm:"column(research_report_type_id)";json:"research_report_type_id" description:"研究报告id"`
-	TypeID                  int    `orm:"column(type_id)";json:"type_id" description:"分类id"`
+	ResearchReportID        uint64 `orm:"column(research_report_id)" json:"research_report_id" description:"报告id"`
+	ResearchReportTypeID    uint64 `orm:"column(research_report_type_id)" json:"research_report_type_id" description:"研究报告id"`
+	TypeID                  int    `orm:"column(type_id)" json:"type_id" description:"分类id"`
 	ReportChapterTypeId     uint64 `json:"report_chapter_type_id" description:"章节名称"`
+	Type                    string ` json:"type";description:"day 晨报  week 周报 two_week双周报 month 月报"`
 }
 
+//type ResearchReportTypeList struct {
+//	ResearchReportTypeId    uint64    ` description:"章节ID" json:"research_report_type_id" `
+//	ResearchReportId        uint64    ` description:"研究报告id"  json:"research_report_id" `
+//	ResearchReportTypeTitle string    `description:"研究报告标题"  json:"research_report_type_title" `
+//	TypeId                  int       `description:"分类id"  json:"type_id" `
+//	Edit                    int8      `description:"是否编辑过" json:"edit" `
+//	Trend                   string    `description:"趋势观点" json:"trend" `
+//	ReportChapterTypeKey    string    `description:"章节key" json:"report_chapter_typeKey" `
+//	ReportChapterTypeThumb  string    `description:"H5展示的图片"  json:"report_chapter_type_thumb" `
+//	BannerUrl               string    `description:"banner显示图片"  json:"banner_url" `
+//	ReportChapterTypeName   string    `description:"报告章节类型名称"  json:"report_chapter_type_name" `
+//	Sort                    int       `description:"排序字段"  json:"sort" `
+//	EditImgUrl              string    `description:"管理后台编辑时选用的图"  json:"edit_img_url" `
+//	PauseStartTime          time.Time `description:"暂停开始日期"  json:"pause_start_time" `
+//	PauseEndTime            time.Time `description:"暂停结束日期" json:"pause_end_time" `
+//	LastUpdatedTime         time.Time `description:"最后更新时间" json:"last_updated_time" `
+//	HttpUrl                 string    `json:"http_url",description:"报告详情"`
+//}
+
 type ResearchReportTypeList struct {
-	ResearchReportTypeId    uint64    ` description:"章节ID"`
-	ResearchReportId        uint64    ` description:"研究报告id"`
-	ResearchReportTypeTitle string    `description:"研究报告标题"`
-	TypeId                  int       `description:"分类id"`
+	ResearchReportTypeId    uint64    ` description:"章节ID"  `
+	ResearchReportId        uint64    ` description:"研究报告id"  `
+	ResearchReportTypeTitle string    `description:"研究报告标题" `
+	TypeId                  int       `description:"分类id"   `
 	Edit                    int8      `description:"是否编辑过"`
-	Trend                   string    `description:"趋势观点"`
-	ReportChapterTypeKey    string    `description:"章节key"`
-	ReportChapterTypeThumb  string    `description:"H5展示的图片"`
-	BannerUrl               string    `description:"banner显示图片"`
-	ReportChapterTypeName   string    `description:"报告章节类型名称"`
-	Sort                    int       `description:"排序字段"`
-	EditImgUrl              string    `description:"管理后台编辑时选用的图"`
-	PauseStartTime          time.Time `description:"暂停开始日期"`
-	PauseEndTime            time.Time `description:"暂停结束日期"`
-	LastUpdatedTime         time.Time `description:"最后更新时间"`
+	Trend                   string    `description:"趋势观点"  `
+	ReportChapterTypeKey    string    `description:"章节key" `
+	ReportChapterTypeThumb  string    `description:"H5展示的图片"   `
+	BannerUrl               string    `description:"banner显示图片"  `
+	ReportChapterTypeName   string    `description:"报告章节类型名称"  `
+	Sort                    int       `description:"排序字段"   `
+	EditImgUrl              string    `description:"管理后台编辑时选用的图" `
+	PauseStartTime          time.Time `description:"暂停开始日期"  `
+	PauseEndTime            time.Time `description:"暂停结束日期" `
+	LastUpdatedTime         time.Time `description:"最后更新时间"  `
 	HttpUrl                 string    `json:"http_url",description:"报告详情"`
 }
 
@@ -120,7 +140,7 @@ func GetReportVarietyList(userId int, reportType string) (list []*ReportChapterT
 }
 
 type ResearchReportTypeContent struct {
-	ResearchReportTypeTitle     string
+	ResearchReportTypeTitle     string    `json:"research_report_type_title" description:"标题"`
 	ResearchReportTypeContentId int       `json:"research_report_type_content_id" description:"研究报告内容id"`
 	ResearchReportTypeId        int       `json:"research_report_id" description:"报告id"`
 	Sort                        int       `json:"sort" description:"排序"`

+ 26 - 3
models/tables/report/report.go

@@ -27,14 +27,35 @@ type ResearchReportInfo struct {
 	ResearchReportTypeContentList []*company_report_permission.ResearchReportTypeContent `description:"报告详情"`
 }
 
-// ResearchReport 研究报告表
+//
+//// ResearchReport 研究报告表
+//type ResearchReport struct {
+//	//ResearchReportID    uint64    `gorm:"primaryKey;column:research_report_id;type:bigint(20) unsigned;not null" json:"-"`                       // 研究报告id
+//	ResearchReportID    uint64    `orm:"column(research_report_id)"json:"research_report_id";description:"报告Id"`                                                        // 研究报告id
+//	ResearchReportName  string    `gorm:"index:research_report_name;column:research_report_name;type:varchar(128)" json:"research_report_name";description:"研究报告名称"`    // 研究报告名称
+//	ResearchReportTitle string    `gorm:"index:research_report_title;column:research_report_title;type:varchar(128)" json:"research_report_title";description:"研究报告标题"` // 研究报告标题
+//	ResearchReportImg   string    `gorm:"column:research_report_img;type:varchar(128)" json:"research_report_img";description:"报告缩略图URL"`                               // 报告缩略图URL
+//	ResearchReportDate  time.Time `gorm:"column:research_report_date;type:date;not null" description:"报告日期"`                                                            // 报告日期
+//	Type                string    `gorm:"column:type;type:varchar(32);default:day" json:"type";description:"day 晨报  week 周报 twoweek双周报 month 月报"`                       // day 晨报  week 周报 twoweek双周报 month 月报
+//	Author              string    `gorm:"column:author;type:varchar(100)" json:"author";description:"报告作者"`                                                             // 报告作者
+//	ReportVariety       string    `gorm:"column:report_variety;type:varchar(30)" json:"report_variety";description:"研究报告的品种,双周报和月报有标识"`                                 // 研究报告的品种,双周报和月报有标识
+//	IsHasMenu           int8      `gorm:"column:is_has_menu;type:tinyint(1);default:0" json:"is_has_menu";description:"报告Id"`                                           // 报告是否含有目录
+//	IsSendedMsg         int8      `gorm:"column:is_sended_msg;type:tinyint(1);default:0" json:"is_sended_msg";description:"报告是否含有目录"`                                   // 是否发送过模板消息
+//	Periods             int       `gorm:"column:periods;type:int(8)" json:"periods";description:"期数"`                                                                   // 期数
+//	Status              string    `gorm:"column:status;type:varchar(20);not null" json:"status";description:"状态,draft:草稿"`                                              // 状态,draft:草稿,
+//	Enabled             int8      `gorm:"index:enabled;column:enabled;type:tinyint(1);default:1" json:"enabled";description:"报告状态"`                                     // 报告状态
+//	CreatedTime         time.Time `gorm:"index:created_time;column:created_time;type:datetime;default:CURRENT_TIMESTAMP" json:"created_time";description:"创建时间"`        // 创建时间
+//	LastUpdatedTime     time.Time `gorm:"index:last_updated_time;column:last_updated_time;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"last_updated_time";description:"修改时间"`
+//	Viewers             int       `gorm:"column:viewers;type:int(8);default:0" json:"viewers";description:"H5观看用户数"` // H5观看用户数
+//}
+
 type ResearchReport struct {
 	//ResearchReportID    uint64    `gorm:"primaryKey;column:research_report_id;type:bigint(20) unsigned;not null" json:"-"`                       // 研究报告id
-	ResearchReportID    uint64    `orm:"column(research_report_id)";description:"报告Id"`                                                                               // 研究报告id
+	ResearchReportID    uint64    `orm:"column(research_report_id)"json:"research_report_id";description:"报告Id"`                                                      // 研究报告id
 	ResearchReportName  string    `gorm:"index:research_report_name;column:research_report_name;type:varchar(128)" json:"researchReportName";description:"研究报告名称"`    // 研究报告名称
 	ResearchReportTitle string    `gorm:"index:research_report_title;column:research_report_title;type:varchar(128)" json:"researchReportTitle";description:"研究报告标题"` // 研究报告标题
 	ResearchReportImg   string    `gorm:"column:research_report_img;type:varchar(128)" json:"researchReportImg";description:"报告缩略图URL"`                               // 报告缩略图URL
-	ResearchReportDate  time.Time `gorm:"column:research_report_date;type:date;not null" json:"researchReportDate";description:"报告日期"`                                // 报告日期
+	ResearchReportDate  time.Time `gorm:"column:research_report_date;type:date;not null"  json:"researchReportDate";description:"报告日期"`                               // 报告日期
 	Type                string    `gorm:"column:type;type:varchar(32);default:day" json:"type";description:"day 晨报  week 周报 twoweek双周报 month 月报"`                     // day 晨报  week 周报 twoweek双周报 month 月报
 	Author              string    `gorm:"column:author;type:varchar(100)" json:"author";description:"报告作者"`                                                           // 报告作者
 	ReportVariety       string    `gorm:"column:report_variety;type:varchar(30)" json:"reportVariety";description:"研究报告的品种,双周报和月报有标识"`                                // 研究报告的品种,双周报和月报有标识
@@ -154,6 +175,7 @@ type ResearchReportTypeContentInfo struct {
 	ResearchReportTypeInfo        *company_report_permission.ResearchReportTypeInfo      `json:"research_report_type_info"`
 	Add                           int                                                    `json:"add"`
 	ResearchReportTypeContentList []*company_report_permission.ResearchReportTypeContent `description:"报告详情" json:"research_report_type_content_list"`
+	ResearchReportTypeList        []*company_report_permission.ResearchReportTypeList    `json:"research_report_type_list"`
 }
 
 // GetResearchReportTypeContentInfo 获取报告章节详情
@@ -173,6 +195,7 @@ func GetResearchReportTypeContentInfo(researchReportTypeId, userId uint64) (resu
 		return
 	}
 	reportType := reportInfo.Type
+	researchReportTypeInfo.Type = reportInfo.Type
 	//这些个报告需要做权限校验
 	if utils.InArray(reportInfo.Type, []string{"week", "month", "two_week", "other"}) {
 		list, tmpErr := company_report_permission.GetReportVarietyList(int(userId), reportType)

+ 8 - 8
routers/commentsRouter_controllers.go

@@ -27,26 +27,26 @@ func init() {
 
     beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ReportController"],
         beego.ControllerComments{
-            Method: "GetResearchReportChapter",
-            Router: "/getReportChapterInfo",
+            Method: "ListReport",
+            Router: "/list",
             AllowHTTPMethods: []string{"get"},
             MethodParams: param.Make(),
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ReportController"],
+    beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ReportControllerCommon"] = append(beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ReportControllerCommon"],
         beego.ControllerComments{
-            Method: "GetReportInfo",
-            Router: "/getReportInfo",
+            Method: "GetResearchReportChapter",
+            Router: "/getReportChapterInfo",
             AllowHTTPMethods: []string{"get"},
             MethodParams: param.Make(),
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ReportController"],
+    beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ReportControllerCommon"] = append(beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ReportControllerCommon"],
         beego.ControllerComments{
-            Method: "ListReport",
-            Router: "/list",
+            Method: "GetReportInfo",
+            Router: "/getReportInfo",
             AllowHTTPMethods: []string{"get"},
             MethodParams: param.Make(),
             Filters: nil,

+ 3 - 0
routers/router.go

@@ -32,6 +32,9 @@ func init() {
 			web.NSInclude(
 				&controllers.ReportController{},
 			),
+			web.NSInclude(
+				&controllers.ReportControllerCommon{},
+			),
 		),
 	)
 	web.AddNamespace(ns)

+ 3 - 0
utils/config.go

@@ -81,11 +81,14 @@ func init() {
 		logDir := `/data/rdlucklog/hongze_open_api`
 		ApiLog = log.Init("20060102.api", logDir)
 		ResearchReportUrl = "http://8.136.199.33:8608/api/"
+		ResearchReportUrl = "http://192.168.2.96:8608/api/"
+		ResearchReportUrl = "http://192.168.2.22:3000/xcx_h5/"
 		ReportAppid = "CQWx3EqDLNk7bVHo"                  //Appid
 		ReportSecret = "vRVFCk182Hpv8CyrHsxaHhA3CgGhh4Uu" //AppSecret
 	} else {
 		ApiLog = log.Init("20060102.api")
 		ResearchReportUrl = "http://8.136.199.33:8608/api/"
+		ResearchReportUrl = "http://192.168.2.96:8608/api/"
 		ReportAppid = "VH2ou4EKlYZz58Uj"                  //Appid
 		ReportSecret = "Q6Y5vwmx1IAA9OPkobl8qWvrnV7dGJ4k" //AppSecret
 	}