mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-08 12:11:03 +08:00
Add GetUserPayments() API.
This commit is contained in:
@@ -88,6 +88,8 @@ p, *, *, GET, /api/get-application, *, *
|
|||||||
p, *, *, GET, /api/get-user, *, *
|
p, *, *, GET, /api/get-user, *, *
|
||||||
p, *, *, GET, /api/get-user-application, *, *
|
p, *, *, GET, /api/get-user-application, *, *
|
||||||
p, *, *, GET, /api/get-resources, *, *
|
p, *, *, GET, /api/get-resources, *, *
|
||||||
|
p, *, *, GET, /api/get-product, *, *
|
||||||
|
p, *, *, GET, /api/get-providers, *, *
|
||||||
p, *, *, POST, /api/unlink, *, *
|
p, *, *, POST, /api/unlink, *, *
|
||||||
p, *, *, POST, /api/set-password, *, *
|
p, *, *, POST, /api/set-password, *, *
|
||||||
p, *, *, POST, /api/send-verification-code, *, *
|
p, *, *, POST, /api/send-verification-code, *, *
|
||||||
|
@@ -50,6 +50,24 @@ func (c *ApiController) GetPayments() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserPayments
|
||||||
|
// @Title GetUserPayments
|
||||||
|
// @Tag Payment API
|
||||||
|
// @Description get payments for a user
|
||||||
|
// @Param owner query string true "The owner of payments"
|
||||||
|
// @Param organization query string true "The organization of the user"
|
||||||
|
// @Param user query string true "The username of the user"
|
||||||
|
// @Success 200 {array} object.Payment The Response object
|
||||||
|
// @router /get-user-payments [get]
|
||||||
|
func (c *ApiController) GetUserPayments() {
|
||||||
|
owner := c.Input().Get("owner")
|
||||||
|
organization := c.Input().Get("organization")
|
||||||
|
user := c.Input().Get("user")
|
||||||
|
|
||||||
|
payments := object.GetUserPayments(owner, organization, user)
|
||||||
|
c.ResponseOk(payments)
|
||||||
|
}
|
||||||
|
|
||||||
// @Title GetPayment
|
// @Title GetPayment
|
||||||
// @Tag Payment API
|
// @Tag Payment API
|
||||||
// @Description get payment
|
// @Description get payment
|
||||||
|
@@ -29,14 +29,17 @@ type Payment struct {
|
|||||||
CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
|
CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
|
||||||
DisplayName string `xorm:"varchar(100)" json:"displayName"`
|
DisplayName string `xorm:"varchar(100)" json:"displayName"`
|
||||||
|
|
||||||
Provider string `xorm:"varchar(100)" json:"provider"`
|
Provider string `xorm:"varchar(100)" json:"provider"`
|
||||||
Type string `xorm:"varchar(100)" json:"type"`
|
Type string `xorm:"varchar(100)" json:"type"`
|
||||||
Organization string `xorm:"varchar(100)" json:"organization"`
|
Organization string `xorm:"varchar(100)" json:"organization"`
|
||||||
User string `xorm:"varchar(100)" json:"user"`
|
User string `xorm:"varchar(100)" json:"user"`
|
||||||
ProductId string `xorm:"varchar(100)" json:"productId"`
|
ProductId string `xorm:"varchar(100)" json:"productId"`
|
||||||
ProductName string `xorm:"varchar(100)" json:"productName"`
|
ProductName string `xorm:"varchar(100)" json:"productName"`
|
||||||
Price float64 `json:"price"`
|
|
||||||
Currency string `xorm:"varchar(100)" json:"currency"`
|
Detail string `xorm:"varchar(100)" json:"detail"`
|
||||||
|
Tag string `xorm:"varchar(100)" json:"tag"`
|
||||||
|
Currency string `xorm:"varchar(100)" json:"currency"`
|
||||||
|
Price float64 `json:"price"`
|
||||||
|
|
||||||
PayUrl string `xorm:"varchar(2000)" json:"payUrl"`
|
PayUrl string `xorm:"varchar(2000)" json:"payUrl"`
|
||||||
State string `xorm:"varchar(100)" json:"state"`
|
State string `xorm:"varchar(100)" json:"state"`
|
||||||
@@ -62,6 +65,16 @@ func GetPayments(owner string) []*Payment {
|
|||||||
return payments
|
return payments
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUserPayments(owner string, organization string, user string) []*Payment {
|
||||||
|
payments := []*Payment{}
|
||||||
|
err := adapter.Engine.Desc("created_time").Find(&payments, &Payment{Owner: owner, Organization: organization, User: user})
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return payments
|
||||||
|
}
|
||||||
|
|
||||||
func GetPaginationPayments(owner string, offset, limit int, field, value, sortField, sortOrder string) []*Payment {
|
func GetPaginationPayments(owner string, offset, limit int, field, value, sortField, sortOrder string) []*Payment {
|
||||||
payments := []*Payment{}
|
payments := []*Payment{}
|
||||||
session := GetSession(owner, offset, limit, field, value, sortField, sortOrder)
|
session := GetSession(owner, offset, limit, field, value, sortField, sortOrder)
|
||||||
|
@@ -197,8 +197,10 @@ func BuyProduct(id string, providerId string, user *User, host string) (string,
|
|||||||
User: user.Name,
|
User: user.Name,
|
||||||
ProductId: productId,
|
ProductId: productId,
|
||||||
ProductName: productName,
|
ProductName: productName,
|
||||||
Price: product.Price,
|
Detail: product.Detail,
|
||||||
|
Tag: product.Tag,
|
||||||
Currency: product.Currency,
|
Currency: product.Currency,
|
||||||
|
Price: product.Price,
|
||||||
PayUrl: payUrl,
|
PayUrl: payUrl,
|
||||||
State: "Created",
|
State: "Created",
|
||||||
}
|
}
|
||||||
|
@@ -159,6 +159,7 @@ func initAPI() {
|
|||||||
beego.Router("/api/buy-product", &controllers.ApiController{}, "POST:BuyProduct")
|
beego.Router("/api/buy-product", &controllers.ApiController{}, "POST:BuyProduct")
|
||||||
|
|
||||||
beego.Router("/api/get-payments", &controllers.ApiController{}, "GET:GetPayments")
|
beego.Router("/api/get-payments", &controllers.ApiController{}, "GET:GetPayments")
|
||||||
|
beego.Router("/api/get-user-payments", &controllers.ApiController{}, "GET:GetUserPayments")
|
||||||
beego.Router("/api/get-payment", &controllers.ApiController{}, "GET:GetPayment")
|
beego.Router("/api/get-payment", &controllers.ApiController{}, "GET:GetPayment")
|
||||||
beego.Router("/api/update-payment", &controllers.ApiController{}, "POST:UpdatePayment")
|
beego.Router("/api/update-payment", &controllers.ApiController{}, "POST:UpdatePayment")
|
||||||
beego.Router("/api/add-payment", &controllers.ApiController{}, "POST:AddPayment")
|
beego.Router("/api/add-payment", &controllers.ApiController{}, "POST:AddPayment")
|
||||||
|
Reference in New Issue
Block a user