实现多商户履约平台基础

This commit is contained in:
yml2213
2026-07-30 12:02:32 +08:00
parent dde6f2c269
commit 83429456a6
41 changed files with 5487 additions and 504 deletions
+11 -8
View File
@@ -3,6 +3,7 @@ package handler
import (
"strconv"
"affiliate_dash/internal/middleware"
"affiliate_dash/internal/model"
"affiliate_dash/internal/pkg/response"
"affiliate_dash/internal/service"
@@ -22,11 +23,12 @@ func (h *SkinHandler) List(c *gin.Context) {
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
size, _ := strconv.Atoi(c.DefaultQuery("size", "20"))
q := service.SkinListQuery{
Page: page,
Size: size,
Keyword: c.Query("keyword"),
Game: c.Query("game"),
Category: c.Query("category"),
MerchantID: middleware.GetMerchantID(c),
Page: page,
Size: size,
Keyword: c.Query("keyword"),
Game: c.Query("game"),
Category: c.Query("category"),
}
if s := c.Query("status"); s != "" {
v, _ := strconv.Atoi(s)
@@ -42,7 +44,7 @@ func (h *SkinHandler) List(c *gin.Context) {
func (h *SkinHandler) Get(c *gin.Context) {
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
skin, err := h.svc.Get(uint(id))
skin, err := h.svc.Get(middleware.GetMerchantID(c), uint(id))
if err != nil {
response.NotFound(c, err.Error())
return
@@ -79,6 +81,7 @@ func (h *SkinHandler) Create(c *gin.Context) {
req.Game = "和平精英"
}
skin := &model.Skin{
MerchantID: middleware.GetMerchantID(c),
Name: req.Name,
SKU: req.SKU,
Game: req.Game,
@@ -108,7 +111,7 @@ func (h *SkinHandler) Update(c *gin.Context) {
delete(updates, "id")
delete(updates, "created_at")
delete(updates, "updated_at")
if err := h.svc.Update(uint(id), updates); err != nil {
if err := h.svc.Update(middleware.GetMerchantID(c), uint(id), updates); err != nil {
response.BadRequest(c, err.Error())
return
}
@@ -117,7 +120,7 @@ func (h *SkinHandler) Update(c *gin.Context) {
func (h *SkinHandler) Delete(c *gin.Context) {
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
if err := h.svc.Delete(uint(id)); err != nil {
if err := h.svc.Delete(middleware.GetMerchantID(c), uint(id)); err != nil {
response.BadRequest(c, err.Error())
return
}