This commit is contained in:
duyu 2024-07-17 17:04:25 +08:00
parent eb6f21487a
commit 81d3966130
6 changed files with 58 additions and 49 deletions

View File

@ -30,12 +30,12 @@ func GetById(c *gin.Context) {
if res != nil {
response = &proEnt.GetListByIdResp{
Id: res.Id,
Name: res.Name,
Price: res.Price,
PddUrl: res.PddUrl,
Status: res.Status,
CreatedAt: res.CreatedAt.Format(time.RFC3339),
Id: res.Id,
Name: res.Name,
Price: res.Price,
ProductUrl: res.ProductUrl,
Status: res.Status,
CreatedAt: res.CreatedAt.Format(time.RFC3339),
}
}
@ -72,12 +72,12 @@ 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,
PddUrl: item.PddUrl,
Status: item.Status,
CreatedAt: item.CreatedAt.Format(time.RFC3339),
Id: item.Id,
Name: item.Name,
Price: item.Price,
ProductUrl: item.ProductUrl,
Status: item.Status,
CreatedAt: item.CreatedAt.Format(time.RFC3339),
})
}
}
@ -105,10 +105,10 @@ func Create(c *gin.Context) {
}
product := &proMod.Product{
Name: request.Name,
Price: request.Price,
PddUrl: request.PddUrl,
Status: 1, //1.上架 2.下架
Name: request.Name,
Price: request.Price,
ProductUrl: request.ProductUrl,
Status: 1, //1.上架 2.下架
}
affected, err := proServ.Create(product)
@ -133,10 +133,10 @@ func Update(c *gin.Context) {
}
product := &proMod.Product{
Id: request.Id,
Name: request.Name,
PddUrl: request.PddUrl,
Price: request.Price,
Id: request.Id,
Name: request.Name,
ProductUrl: request.ProductUrl,
Price: request.Price,
}
affected, err := proServ.Update(product)

View File

@ -6,12 +6,13 @@ import (
common "com.snow.auto_monitor/app/http/controllers"
transEnt "com.snow.auto_monitor/app/http/entities/transfersys"
orderMod "com.snow.auto_monitor/app/models/orders"
ransServ "com.snow.auto_monitor/app/services/transfersys"
proServ "com.snow.auto_monitor/app/services/product"
transServ "com.snow.auto_monitor/app/services/transfersys"
"github.com/gin-gonic/gin"
)
func GetOrder(c *gin.Context) {
item, err := ransServ.ReadGroup()
item, err := transServ.ReadGroup()
if err != nil {
common.Error(c, 400, err.Error())
return
@ -19,12 +20,19 @@ func GetOrder(c *gin.Context) {
var response *transEnt.GetOrderResp = nil
product, err := proServ.GetById(item.ProductId)
if err != nil {
common.Error(c, 400, "产品不存在")
return
}
if item != nil {
response = &transEnt.GetOrderResp{
Id: item.Id,
OrderNo: item.OrderNo,
MerchantId: item.MerchantId,
ProductId: item.ProductId,
ProductUrl: product.ProductUrl,
OutTradeNo: item.OutTradeNo,
RechargeAccount: item.RechargeAccount,
AccountType: item.AccountType,
@ -67,7 +75,7 @@ func FinishOrder(c *gin.Context) {
TransferStatus: int64(status),
}
affected, err := ransServ.FinishOrder(orders)
affected, err := transServ.FinishOrder(orders)
if err != nil || affected == 0 {
common.Error(c, 400, "无法修改已完成订单")
return

View File

@ -5,12 +5,12 @@ type GetListByIdReq struct {
}
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"`
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"`
}
type SearcgReq struct {
@ -22,18 +22,18 @@ type SearcgReq struct {
}
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"`
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"`
}
type CreateReq struct {
Name string `json:"name" validate:"required"`
Price int64 `json:"price" validate:"required"`
PddUrl string `json:"pdd_url" validate:"required"`
Name string `json:"name" validate:"required"`
Price int64 `json:"price" validate:"required"`
ProductUrl string `json:"product_url" validate:"required"`
}
type CreateResp struct {
@ -41,10 +41,10 @@ type CreateResp struct {
}
type UpdateReq struct {
Id int64 `json:"id" validate:"required"`
Name string `json:"name" `
Price int64 `json:"price" `
PddUrl string `json:"pdd_url" `
Id int64 `json:"id" validate:"required"`
Name string `json:"name" `
Price int64 `json:"price" `
ProductUrl string `json:"product_url" `
}
type UpdateResp struct {

View File

@ -8,6 +8,7 @@ type GetOrderResp struct {
OrderNo string `json:"order_no"`
MerchantId int64 `json:"merchant_id"`
ProductId int64 `json:"product_id"`
ProductUrl string `json:"product_url"`
OutTradeNo string `json:"out_trade_no"`
RechargeAccount string `json:"recharge_account"`
AccountType int64 `json:"account_type"`

View File

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

View File

@ -34,7 +34,7 @@ create table product (
id int primary key auto_increment,
name varchar(255) not null,
price int,
pdd_url varchar(255),
product_url varchar(255),
status tinyint, -- 1.上架 2.下架
created_at timestamp default current_timestamp
);