|
@@ -14,12 +14,13 @@ import (
|
|
|
|
|
|
type StdDoc struct {
|
|
|
*xweb.Action
|
|
|
- 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"` //活动文库(精品推荐、兑换榜)
|
|
|
+ search xweb.Mapper `xweb:"/search"` //检索文库
|
|
|
+ indexTag xweb.Mapper `xweb:"/indexTag"` //首页搜索标签
|
|
|
+ detail xweb.Mapper `xweb:"/detail"` //文库详情
|
|
|
+ recommend xweb.Mapper `xweb:"/detail/recommend"` //相关推荐
|
|
|
+ getDoc xweb.Mapper `xweb:"/get(Show|Down)"` //文库在线查看 or 下载
|
|
|
+ topList xweb.Mapper `xweb:"/topList"` //最新文档&热门下载
|
|
|
+ activityList xweb.Mapper `xweb:"/activityList"` //活动文库(精品推荐、兑换榜)
|
|
|
}
|
|
|
|
|
|
func (stdDoc *StdDoc) Search() {
|
|
@@ -94,6 +95,36 @@ func (stdDoc *StdDoc) Detail() {
|
|
|
stdDoc.ServeJson(NewResult(rData, errMsg))
|
|
|
}
|
|
|
|
|
|
+func (stdDoc *StdDoc) Recommend() {
|
|
|
+ userId := common.ObjToString(stdDoc.GetSession("userId"))
|
|
|
+ rData, errMsg := func() (interface{}, error) {
|
|
|
+ docId := stdDoc.GetString("docId")
|
|
|
+ docTag := stdDoc.GetString("docTag")
|
|
|
+ num, _ := stdDoc.GetInt("num")
|
|
|
+ num = public.PageRange(num, 1, 10)
|
|
|
+ if strings.Index(docTag, ",") > -1 {
|
|
|
+ docTag = strings.Split(docTag, ",")[0]
|
|
|
+ }
|
|
|
+ list, _, err := rpc.GetDocQuery(userId, "", docTag, 1, num+1, "dSort")
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ returnList := []interface{}{}
|
|
|
+ for _, v := range list {
|
|
|
+ if docId == v.DocId || len(returnList) >= common.IntAll(num) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ v.PreviewImgId = fmt.Sprintf("https://%s.%s/%s", config.JyDocsAppConfig.OssBucket.Priv, config.JyDocsAppConfig.OssAdmin, v.PreviewImgId)
|
|
|
+ returnList = append(returnList, v)
|
|
|
+ }
|
|
|
+ return returnList, nil
|
|
|
+ }()
|
|
|
+ if errMsg != nil {
|
|
|
+ log.Printf("%s StdDoc detail err:%s\n", userId, errMsg.Error())
|
|
|
+ }
|
|
|
+ stdDoc.ServeJson(NewResult(rData, errMsg))
|
|
|
+}
|
|
|
+
|
|
|
func (stdDoc *StdDoc) GetDoc(sign string) {
|
|
|
userId := common.ObjToString(stdDoc.GetSession("userId"))
|
|
|
rData, errMsg := func() (interface{}, error) {
|