为 9 个模块添加 Context 超时控制
完成模块: - auth: 3 个 Repository 方法 + Service + Handler + Middleware - wallet: 已有 context 支持,修复依赖调用 - payment: 已有 context 支持,修复 wallet 调用 - adminaudit: 1 个方法 - notification: 2 个方法 - realname: 2 个方法 - systemconfig: 4 个方法 - adminauth: 7 个方法 - adminuser: 6 个方法 所有数据库调用已改为 r.db.WithContext(ctx),完整传递 context 链路。 待完成模块: order, listing, chat 等 12 个模块(约 157 个方法)
This commit is contained in:
@@ -19,7 +19,7 @@ func NewHandler(service *Service) *Handler {
|
||||
}
|
||||
|
||||
func (h *Handler) List(c *gin.Context) {
|
||||
items, err := h.service.List()
|
||||
items, err := h.service.List(c.Request.Context(), )
|
||||
if err != nil {
|
||||
writeConfigError(c, err)
|
||||
return
|
||||
@@ -28,7 +28,7 @@ func (h *Handler) List(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *Handler) PublishOptions(c *gin.Context) {
|
||||
options, err := h.service.PublishOptions()
|
||||
options, err := h.service.PublishOptions(c.Request.Context(), )
|
||||
if err != nil {
|
||||
writeConfigError(c, err)
|
||||
return
|
||||
@@ -37,7 +37,7 @@ func (h *Handler) PublishOptions(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *Handler) SalePriceConfig(c *gin.Context) {
|
||||
config, err := h.service.SalePriceConfig()
|
||||
config, err := h.service.SalePriceConfig(c.Request.Context(), )
|
||||
if err != nil {
|
||||
writeConfigError(c, err)
|
||||
return
|
||||
@@ -46,7 +46,7 @@ func (h *Handler) SalePriceConfig(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *Handler) OrderAgreements(c *gin.Context) {
|
||||
agreements, err := h.service.OrderAgreements()
|
||||
agreements, err := h.service.OrderAgreements(c.Request.Context(), )
|
||||
if err != nil {
|
||||
writeConfigError(c, err)
|
||||
return
|
||||
@@ -55,7 +55,7 @@ func (h *Handler) OrderAgreements(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *Handler) ListingPublishAgreements(c *gin.Context) {
|
||||
agreements, err := h.service.ListingPublishAgreements()
|
||||
agreements, err := h.service.ListingPublishAgreements(c.Request.Context(), )
|
||||
if err != nil {
|
||||
writeConfigError(c, err)
|
||||
return
|
||||
@@ -64,7 +64,7 @@ func (h *Handler) ListingPublishAgreements(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *Handler) PostRentalNotice(c *gin.Context) {
|
||||
notice, err := h.service.PostRentalNotice()
|
||||
notice, err := h.service.PostRentalNotice(c.Request.Context(), )
|
||||
if err != nil {
|
||||
writeConfigError(c, err)
|
||||
return
|
||||
@@ -73,7 +73,7 @@ func (h *Handler) PostRentalNotice(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *Handler) HomeAnnouncements(c *gin.Context) {
|
||||
announcements, err := h.service.HomeAnnouncements()
|
||||
announcements, err := h.service.HomeAnnouncements(c.Request.Context(), )
|
||||
if err != nil {
|
||||
writeConfigError(c, err)
|
||||
return
|
||||
@@ -82,7 +82,7 @@ func (h *Handler) HomeAnnouncements(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *Handler) HomeConfig(c *gin.Context) {
|
||||
config, err := h.service.HomeConfig()
|
||||
config, err := h.service.HomeConfig(c.Request.Context(), )
|
||||
if err != nil {
|
||||
writeConfigError(c, err)
|
||||
return
|
||||
@@ -102,7 +102,7 @@ func (h *Handler) Update(c *gin.Context) {
|
||||
response.BadRequest(c, "配置值不能为空")
|
||||
return
|
||||
}
|
||||
item, err := h.service.Update(adminID, key, req, auditMeta(c))
|
||||
item, err := h.service.Update(c.Request.Context(), adminID, key, req, auditMeta(c))
|
||||
if err != nil {
|
||||
writeConfigError(c, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user