This commit is contained in:
duyu 2024-07-17 16:53:26 +08:00
parent e34824b47d
commit eb6f21487a
4 changed files with 29 additions and 12 deletions

View File

@ -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,
} }

View File

@ -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 {

View File

@ -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"`
} }

View File

@ -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
); );