|
@@ -269,51 +269,40 @@ func (this *UserReadRecordController) Detail() {
|
|
|
br.Ret = 200
|
|
|
}
|
|
|
|
|
|
-// Info
|
|
|
-// @Title 用户阅读统计图信息
|
|
|
-// @Description 用户阅读统计图信息
|
|
|
+// ReadCntChart
|
|
|
+// @Title 用户阅读量统计图信息
|
|
|
+// @Description 用户阅读量统计图信息
|
|
|
// @Param ChartPermissionIds query string true "品种列表"
|
|
|
// @Param ClassifyIds query string true "品种列表"
|
|
|
// @Param StartDate query string true "开始时间"
|
|
|
// @Param EndDate query string true "结束时间"
|
|
|
-// @Param KeyWord query string true "关键字"
|
|
|
+// @Param UserId query int true "用户id"
|
|
|
// @Success 200 {object} models.LoginResp
|
|
|
-// @router /chart/info [get]
|
|
|
-func (this *UserReadRecordController) Info() {
|
|
|
+// @router /readCntChart [get]
|
|
|
+func (this *UserReadRecordController) ReadCntChart() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
+ userId, _ := this.GetInt("UserId")
|
|
|
startDate := this.GetString("StartDate")
|
|
|
endDate := this.GetString("EndDate")
|
|
|
chartPermissionIds := this.GetString("ChartPermissionIds")
|
|
|
classifyIds := this.GetString("ClassifyIds")
|
|
|
- keyWord := this.GetString("KeyWord")
|
|
|
-
|
|
|
- if startDate == "" {
|
|
|
- startDate = time.Now().AddDate(-1, 0, 0).Format("2006-01-02")
|
|
|
- }
|
|
|
- if endDate == "" {
|
|
|
- endDate = time.Now().AddDate(0, 0, 1).Format("2006-01-02")
|
|
|
- }
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
|
|
|
- if keyWord != "" {
|
|
|
- condition += ` AND (real_name LIKE ? OR phone LIKE ? OR email LIKE ? OR company LIKE ?) `
|
|
|
- pars = utils.GetLikeKeywordPars(pars, keyWord, 4)
|
|
|
- }
|
|
|
if chartPermissionIds != "" {
|
|
|
ids := strings.Split(chartPermissionIds, ",")
|
|
|
if len(ids) != 0 {
|
|
|
condition += ` AND ( `
|
|
|
for i, id := range ids {
|
|
|
if i == 0 {
|
|
|
- condition += ` urp2.chart_permission_id = ? `
|
|
|
+ condition += ` urp.chart_permission_id = ? `
|
|
|
pars = append(pars, id)
|
|
|
} else {
|
|
|
- condition += ` OR urp2.chart_permission_id = ? `
|
|
|
+ condition += ` OR urp.chart_permission_id = ? `
|
|
|
pars = append(pars, id)
|
|
|
}
|
|
|
}
|
|
@@ -337,6 +326,16 @@ func (this *UserReadRecordController) Info() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if startDate == "" {
|
|
|
+ startDate = time.Now().AddDate(-1, 0, 0).Format(utils.FormatDate)
|
|
|
+ }
|
|
|
+ if endDate == "" {
|
|
|
+ endDate = time.Now().AddDate(0, 0, 1).Format(utils.FormatDate)
|
|
|
+ }
|
|
|
+ if userId > 0 {
|
|
|
+ condition += ` AND ur.user_id = ? `
|
|
|
+ pars = append(pars, userId)
|
|
|
+ }
|
|
|
readCnts, err := models.GetStaticReadCnt(condition, pars, startDate, endDate)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取阅读统计失败"
|
|
@@ -344,18 +343,42 @@ func (this *UserReadRecordController) Info() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- permissionCnts, err := models.GetStaticPermissionCnt(condition, pars, startDate, endDate)
|
|
|
+ br.Msg = "查询成功"
|
|
|
+ br.Data = readCnts
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+}
|
|
|
+
|
|
|
+// readPermissionChart
|
|
|
+// @Title 用户阅读品种图信息
|
|
|
+// @Description 用户阅读品种图信息
|
|
|
+// @Param UserId query string true "用户id"
|
|
|
+// @Success 200 {object} models.LoginResp
|
|
|
+// @router /readPermissionChart [get]
|
|
|
+func (this *UserReadRecordController) ReadPermissionChart() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ userId, _ := this.GetInt("UserId")
|
|
|
+
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ if userId > 0 {
|
|
|
+ condition += ` AND ur.user_id = ? `
|
|
|
+ pars = append(pars, userId)
|
|
|
+ }
|
|
|
+
|
|
|
+ permissionCnts, err := models.GetStaticPermissionCnt(condition, pars)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取品种阅读统计失败"
|
|
|
br.ErrMsg = "获取品种阅读统计失败,系统错误,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- resp := new(response.StaticInfoResp)
|
|
|
- resp.PermissionCntList = permissionCnts
|
|
|
- resp.ReadCntList = readCnts
|
|
|
|
|
|
- br.Data = resp
|
|
|
- br.Success = true
|
|
|
- br.Msg = "获取成功"
|
|
|
+ br.Msg = "查询成功"
|
|
|
+ br.Data = permissionCnts
|
|
|
br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
}
|