Browse Source

新增项目前后端初步联调

Ohio-HYF 3 years ago
parent
commit
9104b4725e

+ 1 - 0
handler/product_findAll.go

@@ -51,6 +51,7 @@ func (h *FindAllProductHandler) run() {
 		log.Info("FindAllProduct fail,req:%+v", h.req)
 		return
 	}
+	h.resp.Message = "查询成功"
 	h.resp.Data = res
 }
 func (h *FindAllProductHandler) checkParam() error {

+ 13 - 11
model/gorm_model/product.go

@@ -6,18 +6,20 @@ import (
 )
 
 type YounggeeProduct struct {
-	ProductID    int64       `gorm:"column:product_id;primary_key"` // 商品id
-	ProductName  string    `gorm:"column:product_name"`           // 商品名称
-	ProductType  int64       `gorm:"column:product_type"`           // 商品类型
-	ShopAddress  string    `gorm:"column:shop_address"`           // 店铺地址,商品类型为线下品牌时需填写
-	ProductPrice int64     `gorm:"column:product_price"`          // 商品价值
-	ProductUrl   string    `gorm:"column:product_url"`            // 商品链接,可为电商网址、公司官网、大众点评的店铺地址等可以说明商品信息或者品牌信息的线上地址;
-	EnterpriseID int64       `gorm:"column:enterprise_id"`          // 所属企业id
-	CreatedAt    time.Time `gorm:"column:created_at"`             // 创建时间
-	UpdatedAt    time.Time `gorm:"column:updated_at"`             // 更新时间
-	BrandName    string    `gorm:"column:brand_name"`
+	ProductID     int64       `gorm:"column:product_id;primary_key;AUTO_INCREMENT"` // 商品id
+	ProductName   string    `gorm:"column:product_name"`                          // 商品名称
+	ProductType   int64       `gorm:"column:product_type"`                          // 商品类型
+	ShopAddress   string    `gorm:"column:shop_address"`                          // 店铺地址,商品类型为线下品牌时需填写
+	ProductPrice  int64     `gorm:"column:product_price"`                         // 商品价值
+	ProductDetail string    `gorm:"column:product_detail"`
+	ProductUrl    string    `gorm:"column:product_url"`   // 商品链接,可为电商网址、公司官网、大众点评的店铺地址等可以说明商品信息或者品牌信息的线上地址;
+	EnterpriseID  int64       `gorm:"column:enterprise_id"` // 所属企业id
+	CreatedAt     time.Time `gorm:"column:created_at"`    // 创建时间
+	UpdatedAt     time.Time `gorm:"column:updated_at"`    // 更新时间
+	BrandName     string    `gorm:"column:brand_name"`
 }
 
 func (m *YounggeeProduct) TableName() string {
 	return "younggee_product"
-}
+}
+

+ 4 - 3
model/http_model/product_create.go

@@ -7,9 +7,10 @@ type CreateProductPhoto struct {
 
 type CreateProductRequest struct {
 	ProductId     int64                `json:"product_id"`
-	ProductName   string               `json:"product_name"`   // 商品名称
-	ProductType   int64                `json:"product_type"`   // 商品类型
-	ShopAddress   string               `json:"shop_address"`   // 店铺地址,商品类型为线下品牌时需填写
+	ProductName   string               `json:"product_name"` // 商品名称
+	ProductType   int64                `json:"product_type"` // 商品类型
+	ShopAddress   string               `json:"shop_address"` // 店铺地址,商品类型为线下品牌时需填写
+	ProductDetail string               `json:"product_detail"`
 	ProductPrice  int64                `json:"product_price"`  // 商品价值
 	ProductPhotos []CreateProductPhoto `json:"product_photos"` // 商品图片列表
 	ProductUrl    string               `json:"product_url"`    // 商品链接,可为电商网址、公司官网、大众点评的店铺地址等可以说明商品信息或者品牌信息的线上地址;

+ 5 - 4
model/http_model/product_find.go

@@ -11,10 +11,11 @@ type ProductPhoto struct {
 
 type FindProductData struct {
 	ProductID     int64          `json:"product_id"`
-	ProductName   string         `json:"product_name"`   // 商品名称
-	ProductType   int64          `json:"product_type"`   // 商品类型
-	ShopAddress   string         `json:"shop_address"`   // 店铺地址,商品类型为线下品牌时需填写
-	ProductPrice  int64          `json:"product_price"`  // 商品价值
+	ProductName   string         `json:"product_name"`  // 商品名称
+	ProductType   int64          `json:"product_type"`  // 商品类型
+	ShopAddress   string         `json:"shop_address"`  // 店铺地址,商品类型为线下品牌时需填写
+	ProductPrice  int64          `json:"product_price"` // 商品价值
+	ProductDetail string         `json:"product_detail"`
 	ProductPhotos []ProductPhoto `json:"product_photos"` // 商品图片列表
 	ProductUrl    string         `json:"product_url"`    // 商品链接,可为电商网址、公司官网、大众点评的店铺地址等可以说明商品信息或者品牌信息的线上地址;
 	EnterpriseID  int64          `json:"enterprise_id"`  // 所属企业id

+ 26 - 23
service/product.go

@@ -14,13 +14,14 @@ type product struct {
 
 func (*product) Create(ctx context.Context, newProduct http_model.CreateProductRequest, enterpriseID int64) (*http_model.CreateProductData, error) {
 	product := gorm_model.YounggeeProduct{
-		ProductName:  newProduct.ProductName,
-		ProductType:  newProduct.ProductType,
-		ShopAddress:  newProduct.ShopAddress,
-		ProductPrice: newProduct.ProductPrice,
-		ProductUrl:   newProduct.ProductUrl,
-		EnterpriseID: enterpriseID,
-		BrandName:    newProduct.BrandName,
+		ProductName:   newProduct.ProductName,
+		ProductType:   newProduct.ProductType,
+		ShopAddress:   newProduct.ShopAddress,
+		ProductPrice:  newProduct.ProductPrice,
+		ProductDetail: newProduct.ProductDetail,
+		ProductUrl:    newProduct.ProductUrl,
+		EnterpriseID:  enterpriseID,
+		BrandName:     newProduct.BrandName,
 	}
 	productID, err := db.CreateProduct(ctx, product)
 	if err != nil {
@@ -48,14 +49,15 @@ func (*product) Create(ctx context.Context, newProduct http_model.CreateProductR
 
 func (*product) Update(ctx context.Context, newProduct http_model.CreateProductRequest, enterpriseID int64) (*http_model.CreateProductData, error) {
 	product := gorm_model.YounggeeProduct{
-		ProductID:    newProduct.ProductId,
-		ProductName:  newProduct.ProductName,
-		ProductType:  newProduct.ProductType,
-		ShopAddress:  newProduct.ShopAddress,
-		ProductPrice: newProduct.ProductPrice,
-		ProductUrl:   newProduct.ProductUrl,
-		EnterpriseID: enterpriseID,
-		BrandName:    newProduct.BrandName,
+		ProductID:     newProduct.ProductId,
+		ProductName:   newProduct.ProductName,
+		ProductType:   newProduct.ProductType,
+		ShopAddress:   newProduct.ShopAddress,
+		ProductPrice:  newProduct.ProductPrice,
+		ProductDetail: newProduct.ProductDetail,
+		ProductUrl:    newProduct.ProductUrl,
+		EnterpriseID:  enterpriseID,
+		BrandName:     newProduct.BrandName,
 	}
 	productID, err := db.UpdateProduct(ctx, product)
 	if err != nil {
@@ -114,14 +116,15 @@ func (*product) FindByID(ctx context.Context, productID int64) (*http_model.Find
 		return nil, err
 	}
 	findProductData := http_model.FindProductData{
-		ProductID:    product.ProductID,
-		ProductName:  product.ProductName,
-		ProductType:  product.ProductType,
-		ShopAddress:  product.ShopAddress,
-		ProductPrice: product.ProductPrice,
-		ProductUrl:   product.ProductUrl,
-		EnterpriseID: product.EnterpriseID,
-		BrandName:    product.BrandName,
+		ProductID:     product.ProductID,
+		ProductName:   product.ProductName,
+		ProductType:   product.ProductType,
+		ShopAddress:   product.ShopAddress,
+		ProductPrice:  product.ProductPrice,
+		ProductDetail: product.ProductDetail,
+		ProductUrl:    product.ProductUrl,
+		EnterpriseID:  product.EnterpriseID,
+		BrandName:     product.BrandName,
 	}
 	for _, photo := range productPhotos {
 		productPhoto := http_model.ProductPhoto{