@@ -3,11 +3,14 @@ package comm | |||
import ( | |||
"applet/app/db" | |||
"applet/app/e" | |||
"applet/app/md/comm" | |||
"applet/app/utils/cache" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||
enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" | |||
"github.com/aliyun/aliyun-oss-go-sdk/oss" | |||
"github.com/gin-gonic/gin" | |||
"time" | |||
) | |||
// GetOssUrl | |||
@@ -61,3 +64,63 @@ func GetOssUrl(c *gin.Context) { | |||
e.OutSuc(c, signedURL, nil) | |||
} | |||
// AccessRecords | |||
// @Summary 通用请求-访问记录-页面记录 | |||
// @Tags 访问记录 | |||
// @Description 页面记录 | |||
// @Accept json | |||
// @Produce json | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @Param req body comm.AccessRecordsReq true "页面标识" | |||
// @Success 200 {string} "success" | |||
// @Success 200 {string} "data exist" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/v1/comm/accessRecords [POST] | |||
func AccessRecords(c *gin.Context) { | |||
var req *comm.AccessRecordsReq | |||
if err1 := c.ShouldBindJSON(&req); err1 != nil { | |||
e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error()) | |||
return | |||
} | |||
if req.Index == "" { | |||
e.OutErr(c, e.ERR_INVALID_ARGS, nil) | |||
return | |||
} | |||
val, exists := c.Get("user") | |||
if !exists { | |||
e.OutErr(c, e.ERR_USER_CHECK_ERR, nil) | |||
return | |||
} | |||
user, ok := val.(*model.User) | |||
if !ok { | |||
e.OutErr(c, e.ERR_USER_CHECK_ERR, nil) | |||
return | |||
} | |||
date := time.Now().Format("2006-01-02") | |||
recordsDb := implement.NewEggAccessRecordsDb(db.Db) | |||
exist, err := recordsDb.EggAccessRecordsExist(user.Id, date, req.Index) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, nil) | |||
} | |||
if exist { | |||
e.OutSuc(c, "data exist", nil) | |||
return | |||
} | |||
m := model.EggAccessRecords{ | |||
Uid: user.Id, | |||
PageIndex: req.Index, | |||
Date: date, | |||
} | |||
_, err = recordsDb.EggAccessRecordsInsert(&m) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, nil) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
} |
@@ -0,0 +1,5 @@ | |||
package comm | |||
type AccessRecordsReq struct { | |||
Index string `json:"index,required"` // 页面标签 | |||
} |
@@ -111,5 +111,6 @@ func route(r *gin.RouterGroup) { | |||
} | |||
func rComm(r *gin.RouterGroup) { | |||
r.GET("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL | |||
r.GET("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL | |||
r.GET("/accessRecords", comm.AccessRecords) // 访问记录 | |||
} |
@@ -407,6 +407,53 @@ const docTemplate = `{ | |||
} | |||
} | |||
}, | |||
"/api/v1/comm/accessRecords": { | |||
"post": { | |||
"description": "页面记录", | |||
"consumes": [ | |||
"application/json" | |||
], | |||
"produces": [ | |||
"application/json" | |||
], | |||
"tags": [ | |||
"访问记录" | |||
], | |||
"summary": "通用请求-访问记录-页面记录", | |||
"parameters": [ | |||
{ | |||
"type": "string", | |||
"description": "验证参数Bearer和token空格拼接", | |||
"name": "Authorization", | |||
"in": "header", | |||
"required": true | |||
}, | |||
{ | |||
"description": "页面标识", | |||
"name": "req", | |||
"in": "body", | |||
"required": true, | |||
"schema": { | |||
"$ref": "#/definitions/comm.AccessRecordsReq" | |||
} | |||
} | |||
], | |||
"responses": { | |||
"200": { | |||
"description": "data exist", | |||
"schema": { | |||
"type": "string" | |||
} | |||
}, | |||
"400": { | |||
"description": "具体错误", | |||
"schema": { | |||
"$ref": "#/definitions/md.Response" | |||
} | |||
} | |||
} | |||
} | |||
}, | |||
"/api/v1/comm/getOssUrl": { | |||
"get": { | |||
"description": "上传许可链接(获取)", | |||
@@ -1572,6 +1619,15 @@ const docTemplate = `{ | |||
} | |||
} | |||
}, | |||
"comm.AccessRecordsReq": { | |||
"type": "object", | |||
"properties": { | |||
"index": { | |||
"description": "页面标签", | |||
"type": "string" | |||
} | |||
} | |||
}, | |||
"md.AdvertisingBasic": { | |||
"type": "object", | |||
"properties": { | |||
@@ -401,6 +401,53 @@ | |||
} | |||
} | |||
}, | |||
"/api/v1/comm/accessRecords": { | |||
"post": { | |||
"description": "页面记录", | |||
"consumes": [ | |||
"application/json" | |||
], | |||
"produces": [ | |||
"application/json" | |||
], | |||
"tags": [ | |||
"访问记录" | |||
], | |||
"summary": "通用请求-访问记录-页面记录", | |||
"parameters": [ | |||
{ | |||
"type": "string", | |||
"description": "验证参数Bearer和token空格拼接", | |||
"name": "Authorization", | |||
"in": "header", | |||
"required": true | |||
}, | |||
{ | |||
"description": "页面标识", | |||
"name": "req", | |||
"in": "body", | |||
"required": true, | |||
"schema": { | |||
"$ref": "#/definitions/comm.AccessRecordsReq" | |||
} | |||
} | |||
], | |||
"responses": { | |||
"200": { | |||
"description": "data exist", | |||
"schema": { | |||
"type": "string" | |||
} | |||
}, | |||
"400": { | |||
"description": "具体错误", | |||
"schema": { | |||
"$ref": "#/definitions/md.Response" | |||
} | |||
} | |||
} | |||
} | |||
}, | |||
"/api/v1/comm/getOssUrl": { | |||
"get": { | |||
"description": "上传许可链接(获取)", | |||
@@ -1566,6 +1613,15 @@ | |||
} | |||
} | |||
}, | |||
"comm.AccessRecordsReq": { | |||
"type": "object", | |||
"properties": { | |||
"index": { | |||
"description": "页面标签", | |||
"type": "string" | |||
} | |||
} | |||
}, | |||
"md.AdvertisingBasic": { | |||
"type": "object", | |||
"properties": { | |||
@@ -12,6 +12,12 @@ definitions: | |||
description: 总数据量 | |||
type: integer | |||
type: object | |||
comm.AccessRecordsReq: | |||
properties: | |||
index: | |||
description: 页面标签 | |||
type: string | |||
type: object | |||
md.AdvertisingBasic: | |||
properties: | |||
android_ad_is_open: | |||
@@ -1116,6 +1122,37 @@ paths: | |||
summary: 广告位详情 | |||
tags: | |||
- 广告位详情 | |||
/api/v1/comm/accessRecords: | |||
post: | |||
consumes: | |||
- application/json | |||
description: 页面记录 | |||
parameters: | |||
- description: 验证参数Bearer和token空格拼接 | |||
in: header | |||
name: Authorization | |||
required: true | |||
type: string | |||
- description: 页面标识 | |||
in: body | |||
name: req | |||
required: true | |||
schema: | |||
$ref: '#/definitions/comm.AccessRecordsReq' | |||
produces: | |||
- application/json | |||
responses: | |||
"200": | |||
description: data exist | |||
schema: | |||
type: string | |||
"400": | |||
description: 具体错误 | |||
schema: | |||
$ref: '#/definitions/md.Response' | |||
summary: 通用请求-访问记录-页面记录 | |||
tags: | |||
- 访问记录 | |||
/api/v1/comm/getOssUrl: | |||
get: | |||
consumes: | |||
@@ -32,7 +32,7 @@ require ( | |||
) | |||
require ( | |||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241123093254-20bf9e0d7fc0 | |||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241125012958-44d150a46684 | |||
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241123093218-87b65e51eea3 | |||
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be | |||
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 | |||