product
This commit is contained in:
parent
e34824b47d
commit
eb6f21487a
|
@ -33,6 +33,8 @@ func GetById(c *gin.Context) {
|
||||||
Id: res.Id,
|
Id: res.Id,
|
||||||
Name: res.Name,
|
Name: res.Name,
|
||||||
Price: res.Price,
|
Price: res.Price,
|
||||||
|
PddUrl: res.PddUrl,
|
||||||
|
Status: res.Status,
|
||||||
CreatedAt: res.CreatedAt.Format(time.RFC3339),
|
CreatedAt: res.CreatedAt.Format(time.RFC3339),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +75,8 @@ func Search(c *gin.Context) {
|
||||||
Id: item.Id,
|
Id: item.Id,
|
||||||
Name: item.Name,
|
Name: item.Name,
|
||||||
Price: item.Price,
|
Price: item.Price,
|
||||||
|
PddUrl: item.PddUrl,
|
||||||
|
Status: item.Status,
|
||||||
CreatedAt: item.CreatedAt.Format(time.RFC3339),
|
CreatedAt: item.CreatedAt.Format(time.RFC3339),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -103,6 +107,8 @@ func Create(c *gin.Context) {
|
||||||
product := &proMod.Product{
|
product := &proMod.Product{
|
||||||
Name: request.Name,
|
Name: request.Name,
|
||||||
Price: request.Price,
|
Price: request.Price,
|
||||||
|
PddUrl: request.PddUrl,
|
||||||
|
Status: 1, //1.上架 2.下架
|
||||||
}
|
}
|
||||||
|
|
||||||
affected, err := proServ.Create(product)
|
affected, err := proServ.Create(product)
|
||||||
|
@ -129,6 +135,7 @@ func Update(c *gin.Context) {
|
||||||
product := &proMod.Product{
|
product := &proMod.Product{
|
||||||
Id: request.Id,
|
Id: request.Id,
|
||||||
Name: request.Name,
|
Name: request.Name,
|
||||||
|
PddUrl: request.PddUrl,
|
||||||
Price: request.Price,
|
Price: request.Price,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ type GetListByIdResp struct {
|
||||||
Id int64 `json:"id" example:"1"`
|
Id int64 `json:"id" example:"1"`
|
||||||
Name string `json:"name" example:"snow"`
|
Name string `json:"name" example:"snow"`
|
||||||
Price int64 `json:"price" example:"100"`
|
Price int64 `json:"price" example:"100"`
|
||||||
|
PddUrl string `json:"pdd_url" example:"http://www.baidu.com"`
|
||||||
|
Status int64 `json:"status" example:"1"`
|
||||||
CreatedAt string `json:"created_at" example:"2020-01-01 00:00:00"`
|
CreatedAt string `json:"created_at" example:"2020-01-01 00:00:00"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,12 +25,15 @@ type SearchResp struct {
|
||||||
Id int64 `json:"id" example:"1"`
|
Id int64 `json:"id" example:"1"`
|
||||||
Name string `json:"name" example:"snow"`
|
Name string `json:"name" example:"snow"`
|
||||||
Price int64 `json:"price" example:"100"`
|
Price int64 `json:"price" example:"100"`
|
||||||
|
PddUrl string `json:"pdd_url" example:"http://www.baidu.com"`
|
||||||
|
Status int64 `json:"status" example:"1"`
|
||||||
CreatedAt string `json:"created_at" example:"2020-01-01 00:00:00"`
|
CreatedAt string `json:"created_at" example:"2020-01-01 00:00:00"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateReq struct {
|
type CreateReq struct {
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
Price int64 `json:"price" validate:"required"`
|
Price int64 `json:"price" validate:"required"`
|
||||||
|
PddUrl string `json:"pdd_url" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateResp struct {
|
type CreateResp struct {
|
||||||
|
@ -37,8 +42,9 @@ type CreateResp struct {
|
||||||
|
|
||||||
type UpdateReq struct {
|
type UpdateReq struct {
|
||||||
Id int64 `json:"id" validate:"required"`
|
Id int64 `json:"id" validate:"required"`
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" `
|
||||||
Price int64 `json:"price" validate:"required"`
|
Price int64 `json:"price" `
|
||||||
|
PddUrl string `json:"pdd_url" `
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateResp struct {
|
type UpdateResp struct {
|
||||||
|
|
|
@ -19,6 +19,8 @@ type Product struct {
|
||||||
Id int64 `xorm:"pk autoincr"` //注:使用getOne 或者ID() 需要设置主键
|
Id int64 `xorm:"pk autoincr"` //注:使用getOne 或者ID() 需要设置主键
|
||||||
Name string
|
Name string
|
||||||
Price int64
|
Price int64
|
||||||
|
PddUrl string
|
||||||
|
Status int64
|
||||||
CreatedAt time.Time `xorm:"created"`
|
CreatedAt time.Time `xorm:"created"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ create table orders (
|
||||||
notify_url varchar(255),
|
notify_url varchar(255),
|
||||||
extend_parameter varchar(1024),
|
extend_parameter varchar(1024),
|
||||||
|
|
||||||
status tinyint,
|
status tinyint,-- 1.成功 2.充值中 3.充值失败 4.异常需要人工处理
|
||||||
transfer_status tinyint,
|
transfer_status tinyint,-- 1.成功 2.充值中 3. 等待充值 4.充值失败 5.异常需要人工处理
|
||||||
created_at timestamp default current_timestamp
|
created_at timestamp default current_timestamp
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -34,5 +34,7 @@ create table product (
|
||||||
id int primary key auto_increment,
|
id int primary key auto_increment,
|
||||||
name varchar(255) not null,
|
name varchar(255) not null,
|
||||||
price int,
|
price int,
|
||||||
|
pdd_url varchar(255),
|
||||||
|
status tinyint, -- 1.上架 2.下架
|
||||||
created_at timestamp default current_timestamp
|
created_at timestamp default current_timestamp
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue