@@ -16,6 +16,7 @@ import ( | |||
"fmt" | |||
"github.com/gin-gonic/gin" | |||
"github.com/olivere/elastic/v7" | |||
"strconv" | |||
"time" | |||
) | |||
@@ -100,6 +101,7 @@ func GetDynamic(c *gin.Context) { | |||
return | |||
} | |||
docUserIds = append(docUserIds, doc.Uid) | |||
doc.IndexId = hit.Id | |||
docs = append(docs, doc) | |||
} | |||
} | |||
@@ -275,7 +277,7 @@ func ReleaseDynamic(c *gin.Context) { | |||
Uid: int64(user.AdmId), | |||
Kind: req.Kind, | |||
Content: req.Content, | |||
Image: req.Image, | |||
Image: utils.SerializeStr(req.Image), | |||
Video: req.Video, | |||
LikesNums: 0, | |||
ShareNums: 0, | |||
@@ -286,18 +288,8 @@ func ReleaseDynamic(c *gin.Context) { | |||
CreatedAt: now.Format("2006-01-02 15:04:05"), | |||
UpdatedAt: now.Format("2006-01-02 15:04:05"), | |||
} | |||
id := fmt.Sprintf("%d-%d", now.Unix(), user.AdmId) | |||
aliasName := md2.EggFriendCircleEsAlias | |||
_, err = es.EsClient.Index(). | |||
Index(aliasName). | |||
Id(id). | |||
BodyJson(m). | |||
Do(context.Background()) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
createDocRet, err := es.CreateDoc(md2.EggFriendCircleEsIndex, strconv.FormatInt(int64(user.AdmId), 10)+"_"+utils.Int64ToStr(now.Unix()), m) | |||
fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet) | |||
e.OutSuc(c, "success", nil) | |||
} |
@@ -4,6 +4,7 @@ import ( | |||
"applet/app/db" | |||
"applet/app/e" | |||
md "applet/app/md/institutional_management/egg_energy" | |||
"applet/app/svc" | |||
"applet/app/utils" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||
@@ -13,6 +14,11 @@ import ( | |||
"time" | |||
) | |||
type GetTotalDataReq struct { | |||
Year string `form:"year" binding:"required"` | |||
Month string `form:"month" binding:"required"` | |||
} | |||
type TotalDataResp struct { | |||
TotalUserCount int `json:"total_user_count"` // 平台总用户数 | |||
VerifiedUserCount int `json:"verified_user_count"` // 已认证用户数 | |||
@@ -35,8 +41,17 @@ type TotalDataResp struct { | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/homePage/totalData [GET] | |||
func GetTotalData(c *gin.Context) { | |||
year := c.Query("year") | |||
month := c.Query("month") | |||
var req GetTotalDataReq | |||
err := c.ShouldBindQuery(&req) | |||
if err != nil { | |||
err = svc.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
year := req.Year | |||
month := req.Month | |||
if year == "" || month == "" { | |||
nowStr := time.Now().Format("2006-01-02") | |||
year = strings.Split(nowStr, "-")[0] | |||
@@ -106,6 +121,10 @@ func GetActiveData(c *gin.Context) { | |||
e.OutSuc(c, resp, nil) | |||
} | |||
type GetGrowDataReq struct { | |||
Kind string `form:"kind" binding:"required"` | |||
} | |||
// GetGrowData | |||
// @Summary 首页-首页-用户增长曲线 | |||
// @Tags 首页 | |||
@@ -118,9 +137,17 @@ func GetActiveData(c *gin.Context) { | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/homePage/growData [GET] | |||
func GetGrowData(c *gin.Context) { | |||
kind := c.DefaultQuery("kind", "1") | |||
now := time.Now() | |||
var req GetGrowDataReq | |||
err := c.ShouldBindQuery(&req) | |||
if err != nil { | |||
err = svc.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
kind := req.Kind | |||
now := time.Now() | |||
dataDb := implement.NewPlatformGrowDataDb(db.Db) | |||
m, has, err := dataDb.PlatformGrowDataGetLastOne() | |||
if err != nil { | |||
@@ -34,7 +34,7 @@ type GetDynamicResp struct { | |||
} | |||
type UpdateDynamicReq struct { | |||
IndexId string `json:"index_id,required"` // 动态id | |||
IndexId string `json:"index_id" binding:"required"` // 动态id | |||
State int32 `json:"state" label:"状态(1:正常 2:隐藏)"` // 状态(1:正常 2:隐藏) | |||
IsTopUp int32 `json:"is_top_up" label:"是否置顶(1:是 2:否)"` // 是否置顶(1:是 2:否) | |||
IsPraise int32 `json:"is_praise" label:"是否被表扬(1:是 2:否)"` // 是否被表扬(1:是 2:否) | |||
@@ -47,7 +47,7 @@ type DeleteDynamicReq struct { | |||
type ReleaseDynamicReq struct { | |||
Kind int32 `json:"kind"` // 类型(1:普通 2:官方) | |||
Content string `json:"content"` // 文本内容 | |||
Image string `json:"image"` // 图片 uri | |||
Image string `json:"[]image"` // 图片 | |||
Video string `json:"video"` // 视频 uri | |||
State int32 `json:"state"` // 状态(1:正常 2:隐藏) | |||
IsTopUp int32 `json:"is_top_up"` // 是否置顶(1:是 2:否) | |||