|
@@ -14,11 +14,12 @@ import (
|
|
|
|
|
|
type StdDoc struct {
|
|
|
*xweb.Action
|
|
|
- search xweb.Mapper `xweb:"/search"` //检索文库
|
|
|
- detail xweb.Mapper `xweb:"/detail"` //文库详情
|
|
|
- content xweb.Mapper `xweb:"/content"` //文库内容
|
|
|
- topList xweb.Mapper `xweb:"/topList"` //最新文档&热门下载
|
|
|
- activityList xweb.Mapper `xweb:"/activityList"` //活动文库(精品推荐、兑换榜)
|
|
|
+ search xweb.Mapper `xweb:"/search"` //检索文库
|
|
|
+ indexTag xweb.Mapper `xweb:"/indexTag"` //首页搜索标签
|
|
|
+ detail xweb.Mapper `xweb:"/detail"` //文库详情
|
|
|
+ getDoc xweb.Mapper `xweb:"/get(Show|Down)"` //文库在线查看 or 下载
|
|
|
+ topList xweb.Mapper `xweb:"/topList"` //最新文档&热门下载
|
|
|
+ activityList xweb.Mapper `xweb:"/activityList"` //活动文库(精品推荐、兑换榜)
|
|
|
}
|
|
|
|
|
|
func (stdDoc *StdDoc) Search() {
|
|
@@ -36,6 +37,9 @@ func (stdDoc *StdDoc) Search() {
|
|
|
if keyWord == "" {
|
|
|
return nil, fmt.Errorf("检索内容不能为空")
|
|
|
}
|
|
|
+ if tag == "全部" {
|
|
|
+ tag = ""
|
|
|
+ }
|
|
|
list, total, err := rpc.GetDocQuery(userId, keyWord, tag, pageNum, pageSize, sort)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
@@ -51,6 +55,10 @@ func (stdDoc *StdDoc) Search() {
|
|
|
stdDoc.ServeJson(NewResult(rData, errMsg))
|
|
|
}
|
|
|
|
|
|
+func (stdDoc *StdDoc) IndexTag() {
|
|
|
+ stdDoc.ServeJson(NewResult(config.JyDocsAppConfig.IndexSearchTag, nil))
|
|
|
+}
|
|
|
+
|
|
|
func (stdDoc *StdDoc) Detail() {
|
|
|
userId := common.ObjToString(stdDoc.GetSession("userId"))
|
|
|
rData, errMsg := func() (interface{}, error) {
|
|
@@ -64,6 +72,8 @@ func (stdDoc *StdDoc) Detail() {
|
|
|
}
|
|
|
//ossId清除
|
|
|
detail.OssPdfId = ""
|
|
|
+ detail.OssDocId = ""
|
|
|
+ detail.PreviewImgId = fmt.Sprintf("https://%s.%s/%s", config.JyDocsAppConfig.OssBucket.Priv, config.JyDocsAppConfig.OssAdmin, detail.PreviewImgId)
|
|
|
return map[string]interface{}{
|
|
|
"status": common.If(isBuy, 1, 0),
|
|
|
"detail": detail,
|
|
@@ -75,9 +85,10 @@ func (stdDoc *StdDoc) Detail() {
|
|
|
stdDoc.ServeJson(NewResult(rData, errMsg))
|
|
|
}
|
|
|
|
|
|
-func (stdDoc *StdDoc) Content() {
|
|
|
+func (stdDoc *StdDoc) GetDoc(sign string) {
|
|
|
userId := common.ObjToString(stdDoc.GetSession("userId"))
|
|
|
rData, errMsg := func() (interface{}, error) {
|
|
|
+ log.Println(sign)
|
|
|
docId := stdDoc.GetString("docId")
|
|
|
if docId == "" {
|
|
|
return nil, fmt.Errorf("参数异常")
|
|
@@ -89,7 +100,11 @@ func (stdDoc *StdDoc) Content() {
|
|
|
if !isBuy {
|
|
|
return nil, fmt.Errorf("请先兑换文档")
|
|
|
}
|
|
|
- url, err := rpc.GetFileContext(userId, detail.OssPdfId)
|
|
|
+ fileId := detail.OssPdfId
|
|
|
+ if sign == "Down" {
|
|
|
+ fileId = detail.OssDocId
|
|
|
+ }
|
|
|
+ url, err := rpc.GetFileContext(userId, fileId)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|