add media url for create donate case

This commit is contained in:
harold 2025-08-26 10:31:32 +05:00
parent 238421c69f
commit 9e4553c6f3
7 changed files with 26 additions and 7 deletions

View File

@ -46,6 +46,7 @@ func CreateDonat(donatService model.DonatService) echo.HandlerFunc {
body.DonatUser,
body.TargetID,
body.Amount,
body.MediaUrl,
)
if err != nil {
return request.JSON(http.StatusInternalServerError, err.Error())
@ -91,6 +92,7 @@ func CreateTestDonat(donatService model.DonatService) echo.HandlerFunc {
body.Text,
body.DonatUser,
body.TargetID,
body.MediaUrl,
body.Amount,
)

View File

@ -76,13 +76,21 @@ type DonatService interface {
CheckToken(request echo.Context) (api.CheckTokenResponse, error)
CreateDonat(ctx context.Context, streamerLogin, text, donatUser string, targetID *int, amount int) (CreateDonatResponse, error)
CreateDonat(
ctx context.Context,
streamerLogin, text,
donatUser string,
targetID *int,
amount int,
mediaUrl *string,
) (CreateDonatResponse, error)
CreateTestDonat(
ctx context.Context,
streamerID int,
text string,
donatUser string,
targetID *int,
mediaURL *string,
amount int,
) error
@ -142,6 +150,7 @@ type DonatRepo interface {
amount int,
text string,
donatUser string,
mediaUrl *string,
status string,
) error

View File

@ -266,10 +266,11 @@ type DonatAndWidget struct {
}
type CreateDonatBody struct {
TargetID *int `json:"targetID"`
Amount int `json:"amount"`
Text string `json:"text"`
DonatUser string `json:"donatUser"`
TargetID *int `json:"targetID"`
Amount int `json:"amount"`
Text string `json:"text"`
DonatUser string `json:"donatUser"`
MediaUrl *string `json:"mediaUrl"`
}
type DonationStat struct {

View File

@ -39,6 +39,7 @@ CREATE TABLE IF NOT EXISTS donats (
target_id INTEGER,
paid_time TIMESTAMP,
is_test BOOLEAN DEFAULT 'false',
media_url VARCHAR(255),
status VARCHAR(50) NOT NULL DEFAULT 'pending',

View File

@ -40,8 +40,8 @@ func GetMediaUrl(mediaType model.MediaType) string {
}
var CreateDonat = `
INSERT INTO donats (streamer_id, widget_id, text, amount, donat_user, order_id, target_id, status, paid_time, is_test)
VALUES (@streamer_id, @widget_id, @text, @amount, @donat_user, @order_id, @target_id, @status, @paid_time, @is_test)
INSERT INTO donats (streamer_id, widget_id, text, amount, donat_user, order_id, target_id, status, paid_time, is_test, media_url)
VALUES (@streamer_id, @widget_id, @text, @amount, @donat_user, @order_id, @target_id, @status, @paid_time, @is_test, @media_url)
RETURNING id;
`
var MarkDonatView = `

View File

@ -33,6 +33,7 @@ func (repoDonat *RepoDonat) CreateDonat(
amount int,
text string,
donatUser string,
mediaUrl *string,
status string,
) error {
args := pgx.NamedArgs{
@ -44,6 +45,7 @@ func (repoDonat *RepoDonat) CreateDonat(
"amount": amount,
"status": status,
"donat_user": donatUser,
"media_url": mediaUrl,
"is_test": false,
"paid_time": nil,
}

View File

@ -95,6 +95,7 @@ func (donatService *ServiceDonat) CreateDonat(
donatUser string,
targetID *int,
amount int,
mediaUrl *string,
) (model.CreateDonatResponse, error) {
donatePage, err := donatService.donatRepo.GetDonatPageByLogin(ctx, streamerLogin)
@ -128,6 +129,7 @@ func (donatService *ServiceDonat) CreateDonat(
amount,
text,
donatUser,
mediaUrl,
"pending",
)
if err != nil {
@ -153,6 +155,7 @@ func (donatService *ServiceDonat) CreateTestDonat(
text string,
donatUser string,
targetID *int,
mediaUrl *string,
amount int,
) error {
orderID := uuid.New()
@ -180,6 +183,7 @@ func (donatService *ServiceDonat) CreateTestDonat(
amount,
text,
donatUser,
mediaUrl,
"test_donat",
)
if err != nil {