add url
This commit is contained in:
		
							parent
							
								
									53d466afbe
								
							
						
					
					
						commit
						251176a7ff
					
				| 
						 | 
				
			
			@ -30,12 +30,13 @@ func GetById(c *gin.Context) {
 | 
			
		|||
	if res != nil {
 | 
			
		||||
 | 
			
		||||
		response = &proEnt.GetListByIdResp{
 | 
			
		||||
			Id:         res.Id,
 | 
			
		||||
			Name:       res.Name,
 | 
			
		||||
			Price:      res.Price,
 | 
			
		||||
			ProductUrl: res.ProductUrl,
 | 
			
		||||
			Status:     res.Status,
 | 
			
		||||
			CreatedAt:  res.CreatedAt.Format(time.RFC3339),
 | 
			
		||||
			Id:          res.Id,
 | 
			
		||||
			Name:        res.Name,
 | 
			
		||||
			Price:       res.Price,
 | 
			
		||||
			ProductUrl:  res.ProductUrl,
 | 
			
		||||
			ProductUrl2: res.ProductUrl2,
 | 
			
		||||
			Status:      res.Status,
 | 
			
		||||
			CreatedAt:   res.CreatedAt.Format(time.RFC3339),
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -72,12 +73,13 @@ func Search(c *gin.Context) {
 | 
			
		|||
	if len(res) > 0 {
 | 
			
		||||
		for _, item := range res {
 | 
			
		||||
			response = append(response, &proEnt.SearchResp{
 | 
			
		||||
				Id:         item.Id,
 | 
			
		||||
				Name:       item.Name,
 | 
			
		||||
				Price:      item.Price,
 | 
			
		||||
				ProductUrl: item.ProductUrl,
 | 
			
		||||
				Status:     item.Status,
 | 
			
		||||
				CreatedAt:  item.CreatedAt.Format(time.RFC3339),
 | 
			
		||||
				Id:          item.Id,
 | 
			
		||||
				Name:        item.Name,
 | 
			
		||||
				Price:       item.Price,
 | 
			
		||||
				ProductUrl:  item.ProductUrl,
 | 
			
		||||
				ProductUrl2: item.ProductUrl2,
 | 
			
		||||
				Status:      item.Status,
 | 
			
		||||
				CreatedAt:   item.CreatedAt.Format(time.RFC3339),
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -105,10 +107,11 @@ func Create(c *gin.Context) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	product := &proMod.Product{
 | 
			
		||||
		Name:       request.Name,
 | 
			
		||||
		Price:      request.Price,
 | 
			
		||||
		ProductUrl: request.ProductUrl,
 | 
			
		||||
		Status:     1, //1.上架 2.下架
 | 
			
		||||
		Name:        request.Name,
 | 
			
		||||
		Price:       request.Price,
 | 
			
		||||
		ProductUrl:  request.ProductUrl,
 | 
			
		||||
		ProductUrl2: request.ProductUrl2,
 | 
			
		||||
		Status:      1, //1.上架 2.下架
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	affected, err := proServ.Create(product)
 | 
			
		||||
| 
						 | 
				
			
			@ -133,10 +136,11 @@ func Update(c *gin.Context) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	product := &proMod.Product{
 | 
			
		||||
		Id:         request.Id,
 | 
			
		||||
		Name:       request.Name,
 | 
			
		||||
		ProductUrl: request.ProductUrl,
 | 
			
		||||
		Price:      request.Price,
 | 
			
		||||
		Id:          request.Id,
 | 
			
		||||
		Name:        request.Name,
 | 
			
		||||
		ProductUrl:  request.ProductUrl,
 | 
			
		||||
		ProductUrl2: request.ProductUrl2,
 | 
			
		||||
		Price:       request.Price,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	affected, err := proServ.Update(product)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,6 +33,7 @@ func GetOrder(c *gin.Context) {
 | 
			
		|||
			MerchantId:      item.MerchantId,
 | 
			
		||||
			ProductId:       item.ProductId,
 | 
			
		||||
			ProductUrl:      product.ProductUrl,
 | 
			
		||||
			ProductUrl2:      product.ProductUrl2,
 | 
			
		||||
			OutTradeNo:      item.OutTradeNo,
 | 
			
		||||
			RechargeAccount: item.RechargeAccount,
 | 
			
		||||
			AccountType:     item.AccountType,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,12 +5,13 @@ type GetListByIdReq struct {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
type GetListByIdResp struct {
 | 
			
		||||
	Id         int64  `json:"id"  example:"1"`
 | 
			
		||||
	Name       string `json:"name" example:"snow"`
 | 
			
		||||
	Price      int64  `json:"price" example:"100"`
 | 
			
		||||
	ProductUrl string `json:"product_url" example:"http://www.baidu.com"`
 | 
			
		||||
	Status     int64  `json:"status" example:"1"`
 | 
			
		||||
	CreatedAt  string `json:"created_at" example:"2020-01-01 00:00:00"`
 | 
			
		||||
	Id          int64  `json:"id"  example:"1"`
 | 
			
		||||
	Name        string `json:"name" example:"snow"`
 | 
			
		||||
	Price       int64  `json:"price" example:"100"`
 | 
			
		||||
	ProductUrl  string `json:"product_url" example:"http://www.baidu.com"`
 | 
			
		||||
	ProductUrl2 string `json:"product_url2" example:"http://www.baidu.com"`
 | 
			
		||||
	Status      int64  `json:"status" example:"1"`
 | 
			
		||||
	CreatedAt   string `json:"created_at" example:"2020-01-01 00:00:00"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type SearcgReq struct {
 | 
			
		||||
| 
						 | 
				
			
			@ -22,18 +23,20 @@ type SearcgReq struct {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
type SearchResp struct {
 | 
			
		||||
	Id         int64  `json:"id"  example:"1"`
 | 
			
		||||
	Name       string `json:"name" example:"snow"`
 | 
			
		||||
	Price      int64  `json:"price" example:"100"`
 | 
			
		||||
	ProductUrl string `json:"product_url" example:"http://www.baidu.com"`
 | 
			
		||||
	Status     int64  `json:"status" example:"1"`
 | 
			
		||||
	CreatedAt  string `json:"created_at" example:"2020-01-01 00:00:00"`
 | 
			
		||||
	Id          int64  `json:"id"  example:"1"`
 | 
			
		||||
	Name        string `json:"name" example:"snow"`
 | 
			
		||||
	Price       int64  `json:"price" example:"100"`
 | 
			
		||||
	ProductUrl  string `json:"product_url" example:"http://www.baidu.com"`
 | 
			
		||||
	ProductUrl2 string `json:"product_url2" example:"http://www.baidu.com"`
 | 
			
		||||
	Status      int64  `json:"status" example:"1"`
 | 
			
		||||
	CreatedAt   string `json:"created_at" example:"2020-01-01 00:00:00"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type CreateReq struct {
 | 
			
		||||
	Name       string `json:"name" validate:"required"`
 | 
			
		||||
	Price      int64  `json:"price" validate:"required"`
 | 
			
		||||
	ProductUrl string `json:"product_url" validate:"required"`
 | 
			
		||||
	Name        string `json:"name" validate:"required"`
 | 
			
		||||
	Price       int64  `json:"price" validate:"required"`
 | 
			
		||||
	ProductUrl  string `json:"product_url" validate:"required"`
 | 
			
		||||
	ProductUrl2 string `json:"product_url2"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type CreateResp struct {
 | 
			
		||||
| 
						 | 
				
			
			@ -41,10 +44,11 @@ type CreateResp struct {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
type UpdateReq struct {
 | 
			
		||||
	Id         int64  `json:"id" validate:"required"`
 | 
			
		||||
	Name       string `json:"name" `
 | 
			
		||||
	Price      int64  `json:"price" `
 | 
			
		||||
	ProductUrl string `json:"product_url" `
 | 
			
		||||
	Id          int64  `json:"id" validate:"required"`
 | 
			
		||||
	Name        string `json:"name" `
 | 
			
		||||
	Price       int64  `json:"price" `
 | 
			
		||||
	ProductUrl  string `json:"product_url" `
 | 
			
		||||
	ProductUrl2 string `json:"product_url2" `
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type UpdateResp struct {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,6 +9,7 @@ type GetOrderResp struct {
 | 
			
		|||
	MerchantId      int64  `json:"merchant_id"`
 | 
			
		||||
	ProductId       int64  `json:"product_id"`
 | 
			
		||||
	ProductUrl      string `json:"product_url"`
 | 
			
		||||
	ProductUrl2     string `json:"product_url2"`
 | 
			
		||||
	OutTradeNo      string `json:"out_trade_no"`
 | 
			
		||||
	RechargeAccount string `json:"recharge_account"`
 | 
			
		||||
	AccountType     int64  `json:"account_type"`
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,12 +17,13 @@ var (
 | 
			
		|||
 * Product
 | 
			
		||||
 */
 | 
			
		||||
type Product struct {
 | 
			
		||||
	Id         int64 `xorm:"pk autoincr"` //注:使用getOne 或者ID() 需要设置主键
 | 
			
		||||
	Name       string
 | 
			
		||||
	Price      int64
 | 
			
		||||
	ProductUrl string
 | 
			
		||||
	Status     int64
 | 
			
		||||
	CreatedAt  time.Time `xorm:"created"`
 | 
			
		||||
	Id          int64 `xorm:"pk autoincr"` //注:使用getOne 或者ID() 需要设置主键
 | 
			
		||||
	Name        string
 | 
			
		||||
	Price       int64
 | 
			
		||||
	ProductUrl  string
 | 
			
		||||
	ProductUrl2 string
 | 
			
		||||
	Status      int64
 | 
			
		||||
	CreatedAt   time.Time `xorm:"created"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,6 +36,7 @@ create table product (
 | 
			
		|||
    name varchar(255) not null, 
 | 
			
		||||
    price int,
 | 
			
		||||
    product_url varchar(255),
 | 
			
		||||
    product_url2 varchar(255),
 | 
			
		||||
    status tinyint, -- 1.上架 2.下架
 | 
			
		||||
    created_at timestamp default current_timestamp
 | 
			
		||||
);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue