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,
Name: res.Name,
Price: res.Price,
PddUrl: res.PddUrl,
Status: res.Status,
CreatedAt: res.CreatedAt.Format(time.RFC3339),
}
}
@ -73,6 +75,8 @@ func Search(c *gin.Context) {
Id: item.Id,
Name: item.Name,
Price: item.Price,
PddUrl: item.PddUrl,
Status: item.Status,
CreatedAt: item.CreatedAt.Format(time.RFC3339),
})
}
@ -101,8 +105,10 @@ func Create(c *gin.Context) {
}
product := &proMod.Product{
Name: request.Name,
Price: request.Price,
Name: request.Name,
Price: request.Price,
PddUrl: request.PddUrl,
Status: 1, //1.上架 2.下架
}
affected, err := proServ.Create(product)
@ -127,9 +133,10 @@ func Update(c *gin.Context) {
}
product := &proMod.Product{
Id: request.Id,
Name: request.Name,
Price: request.Price,
Id: request.Id,
Name: request.Name,
PddUrl: request.PddUrl,
Price: request.Price,
}
affected, err := proServ.Update(product)

View File

@ -8,6 +8,8 @@ type GetListByIdResp struct {
Id int64 `json:"id" example:"1"`
Name string `json:"name" example:"snow"`
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"`
}
@ -23,12 +25,15 @@ type SearchResp struct {
Id int64 `json:"id" example:"1"`
Name string `json:"name" example:"snow"`
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"`
}
type CreateReq struct {
Name string `json:"name" validate:"required"`
Price int64 `json:"price" validate:"required"`
Name string `json:"name" validate:"required"`
Price int64 `json:"price" validate:"required"`
PddUrl string `json:"pdd_url" validate:"required"`
}
type CreateResp struct {
@ -36,9 +41,10 @@ type CreateResp struct {
}
type UpdateReq struct {
Id int64 `json:"id" validate:"required"`
Name string `json:"name" validate:"required"`
Price int64 `json:"price" validate:"required"`
Id int64 `json:"id" validate:"required"`
Name string `json:"name" `
Price int64 `json:"price" `
PddUrl string `json:"pdd_url" `
}
type UpdateResp struct {

View File

@ -19,6 +19,8 @@ type Product struct {
Id int64 `xorm:"pk autoincr"` //注使用getOne 或者ID() 需要设置主键
Name string
Price int64
PddUrl string
Status int64
CreatedAt time.Time `xorm:"created"`
}

View File

@ -18,8 +18,8 @@ create table orders (
notify_url varchar(255),
extend_parameter varchar(1024),
status tinyint,
transfer_status tinyint,
status tinyint,-- 1.成功 2.充值中 3.充值失败 4.异常需要人工处理
transfer_status tinyint,-- 1.成功 2.充值中 3. 等待充值 4.充值失败 5.异常需要人工处理
created_at timestamp default current_timestamp
);
@ -34,5 +34,7 @@ create table product (
id int primary key auto_increment,
name varchar(255) not null,
price int,
pdd_url varchar(255),
status tinyint, -- 1.上架 2.下架
created_at timestamp default current_timestamp
);