已完成用户APP首期功能开发
交付用户端首期页面、配套接口、后台资源及测试文档。用户APP构建、静态分析和三个管理后台构建通过;完整测试仍有2项失败,后端模型注释检查未通过,详见交付记录。
This commit is contained in:
@@ -59,6 +59,7 @@ func ConfirmContentRead(ctx *gin.Context) {
|
||||
}
|
||||
var request struct {
|
||||
ContentIdentity string `json:"content_identity" binding:"required"`
|
||||
ContentVersion *int `json:"content_version"` // 新客户端必须发送实际展示版本,旧客户端保持兼容。
|
||||
ClientVersion string `json:"client_version"`
|
||||
DeviceIdentity string `json:"device_identity"`
|
||||
RequestNo string `json:"request_no" binding:"required"`
|
||||
@@ -68,7 +69,15 @@ func ConfirmContentRead(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
var content models.CmsContent
|
||||
if impl.DBService.Where("identity = ? AND publish_status = ?", request.ContentIdentity, "published").First(&content).Error != nil {
|
||||
query := impl.DBService.Where("identity = ? AND publish_status = ? AND status = ?", request.ContentIdentity, "published", common.StatusEnable)
|
||||
if request.ContentVersion != nil {
|
||||
if *request.ContentVersion < 1 {
|
||||
infra.Response.Error(ctx, errcode.ErrInvalidArgument)
|
||||
return
|
||||
}
|
||||
query = query.Where("version_no = ?", *request.ContentVersion)
|
||||
}
|
||||
if query.First(&content).Error != nil {
|
||||
infra.Response.Error(ctx, errcode.ErrRecordNotFound)
|
||||
return
|
||||
}
|
||||
@@ -83,6 +92,11 @@ func ConfirmContentRead(ctx *gin.Context) {
|
||||
infra.Response.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
// 同一幂等号不能把其他内容或其他版本的确认冒充本次确认。
|
||||
if existing.CmsContentID != content.ID || existing.VersionNo != content.VersionNo {
|
||||
infra.Response.Error(ctx, errcode.ErrInvalidArgument)
|
||||
return
|
||||
}
|
||||
record = existing
|
||||
}
|
||||
infra.Response.Success(ctx, gin.H{"identity": record.Identity, "content_version": record.VersionNo})
|
||||
|
||||
Reference in New Issue
Block a user