6.7.0: Описание товаров и редизайн выполнения
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m24s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m24s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17732,6 +17732,7 @@ type ShoppingItem struct {
|
||||
BoardID int `json:"board_id"`
|
||||
AuthorID int `json:"author_id"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
GroupName *string `json:"group_name,omitempty"`
|
||||
VolumeBase float64 `json:"volume_base"`
|
||||
RepetitionPeriod *string `json:"repetition_period,omitempty"`
|
||||
@@ -17743,6 +17744,7 @@ type ShoppingItem struct {
|
||||
|
||||
type ShoppingItemRequest struct {
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
GroupName *string `json:"group_name,omitempty"`
|
||||
VolumeBase *float64 `json:"volume_base,omitempty"`
|
||||
RepetitionPeriod *string `json:"repetition_period,omitempty"`
|
||||
@@ -18487,7 +18489,7 @@ func (a *App) getShoppingItemsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
items := []ShoppingItem{}
|
||||
rows, err := a.DB.Query(`
|
||||
SELECT
|
||||
si.id, si.user_id, si.board_id, si.author_id, si.name, si.group_name,
|
||||
si.id, si.user_id, si.board_id, si.author_id, si.name, si.description, si.group_name,
|
||||
si.volume_base, si.repetition_period::text, si.next_show_at, si.completed,
|
||||
si.last_completed_at, si.created_at
|
||||
FROM shopping_items si
|
||||
@@ -18503,6 +18505,7 @@ func (a *App) getShoppingItemsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
for rows.Next() {
|
||||
var item ShoppingItem
|
||||
var description sql.NullString
|
||||
var groupName sql.NullString
|
||||
var repetitionPeriod sql.NullString
|
||||
var nextShowAt sql.NullTime
|
||||
@@ -18510,7 +18513,7 @@ func (a *App) getShoppingItemsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var createdAt time.Time
|
||||
|
||||
err := rows.Scan(
|
||||
&item.ID, &item.UserID, &item.BoardID, &item.AuthorID, &item.Name, &groupName,
|
||||
&item.ID, &item.UserID, &item.BoardID, &item.AuthorID, &item.Name, &description, &groupName,
|
||||
&item.VolumeBase, &repetitionPeriod, &nextShowAt, &item.Completed,
|
||||
&lastCompletedAt, &createdAt,
|
||||
)
|
||||
@@ -18519,6 +18522,9 @@ func (a *App) getShoppingItemsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
continue
|
||||
}
|
||||
|
||||
if description.Valid {
|
||||
item.Description = &description.String
|
||||
}
|
||||
if groupName.Valid {
|
||||
item.GroupName = &groupName.String
|
||||
}
|
||||
@@ -18599,10 +18605,10 @@ func (a *App) createShoppingItemHandler(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
var itemID int
|
||||
err = a.DB.QueryRow(`
|
||||
INSERT INTO shopping_items (user_id, board_id, author_id, name, group_name, volume_base, repetition_period)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7::interval)
|
||||
INSERT INTO shopping_items (user_id, board_id, author_id, name, description, group_name, volume_base, repetition_period)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8::interval)
|
||||
RETURNING id
|
||||
`, boardOwnerID, boardID, userID, strings.TrimSpace(req.Name), req.GroupName, volumeBase, req.RepetitionPeriod).Scan(&itemID)
|
||||
`, boardOwnerID, boardID, userID, strings.TrimSpace(req.Name), req.Description, req.GroupName, volumeBase, req.RepetitionPeriod).Scan(&itemID)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Error creating shopping item: %v", err)
|
||||
@@ -18616,6 +18622,7 @@ func (a *App) createShoppingItemHandler(w http.ResponseWriter, r *http.Request)
|
||||
BoardID: boardID,
|
||||
AuthorID: userID,
|
||||
Name: strings.TrimSpace(req.Name),
|
||||
Description: req.Description,
|
||||
GroupName: req.GroupName,
|
||||
VolumeBase: volumeBase,
|
||||
RepetitionPeriod: req.RepetitionPeriod,
|
||||
@@ -18651,6 +18658,7 @@ func (a *App) getShoppingItemHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
var item ShoppingItem
|
||||
var description sql.NullString
|
||||
var groupName sql.NullString
|
||||
var repetitionPeriod sql.NullString
|
||||
var nextShowAt sql.NullTime
|
||||
@@ -18659,13 +18667,13 @@ func (a *App) getShoppingItemHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
err = a.DB.QueryRow(`
|
||||
SELECT
|
||||
si.id, si.user_id, si.board_id, si.author_id, si.name, si.group_name,
|
||||
si.id, si.user_id, si.board_id, si.author_id, si.name, si.description, si.group_name,
|
||||
si.volume_base, si.repetition_period::text, si.next_show_at, si.completed,
|
||||
si.last_completed_at, si.created_at
|
||||
FROM shopping_items si
|
||||
WHERE si.id = $1 AND si.deleted = FALSE
|
||||
`, itemID).Scan(
|
||||
&item.ID, &item.UserID, &item.BoardID, &item.AuthorID, &item.Name, &groupName,
|
||||
&item.ID, &item.UserID, &item.BoardID, &item.AuthorID, &item.Name, &description, &groupName,
|
||||
&item.VolumeBase, &repetitionPeriod, &nextShowAt, &item.Completed,
|
||||
&lastCompletedAt, &createdAt,
|
||||
)
|
||||
@@ -18693,6 +18701,9 @@ func (a *App) getShoppingItemHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if description.Valid {
|
||||
item.Description = &description.String
|
||||
}
|
||||
if groupName.Valid {
|
||||
item.GroupName = &groupName.String
|
||||
}
|
||||
@@ -18774,9 +18785,9 @@ func (a *App) updateShoppingItemHandler(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
_, err = a.DB.Exec(`
|
||||
UPDATE shopping_items
|
||||
SET name = $1, group_name = $2, volume_base = $3, repetition_period = $4::interval, updated_at = NOW()
|
||||
WHERE id = $5
|
||||
`, strings.TrimSpace(req.Name), req.GroupName, volumeBase, req.RepetitionPeriod, itemID)
|
||||
SET name = $1, description = $2, group_name = $3, volume_base = $4, repetition_period = $5::interval, updated_at = NOW()
|
||||
WHERE id = $6
|
||||
`, strings.TrimSpace(req.Name), req.Description, req.GroupName, volumeBase, req.RepetitionPeriod, itemID)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Error updating shopping item: %v", err)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE shopping_items DROP COLUMN description;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE shopping_items ADD COLUMN description TEXT;
|
||||
Reference in New Issue
Block a user