Migrate easysite from api_es to api_yal
- Remove api_es service, Dockerfile, all Go source files - Remove api_es from docker-compose.yml, nginx-ssl.conf, .env, Makefile - Replace nginx /api/ proxy with /api/v1/ → api_yal:8787 - Add amenity/upload domains, AuthResponse, GET /auth/me, GET /objects/my to api_yal - Rewrite easysite frontend: types, composables, and all 5 pages to use api_yal DTOs - Wire nuxt.config public.apiBase, add useObjects CRUD composable - Update docs references from api_es to api_yal
This commit is contained in:
@@ -83,11 +83,23 @@ func (s *objectServiceImpl) CreateObject(ctx context.Context, req *CreateObjectR
|
||||
isVerified = *req.IsVerified
|
||||
}
|
||||
|
||||
title := req.Title
|
||||
if title == "" {
|
||||
title = req.ShortName
|
||||
}
|
||||
status := models.ObjectStatusActive
|
||||
if req.Status != "" {
|
||||
status = models.ObjectStatus(req.Status)
|
||||
}
|
||||
|
||||
object := &models.Object{
|
||||
OwnerID: req.OwnerID,
|
||||
Title: title,
|
||||
ShortName: req.ShortName,
|
||||
LongName: req.LongName,
|
||||
Type: req.Type,
|
||||
Price: req.Price,
|
||||
PricePeriod: req.PricePeriod,
|
||||
Phone: req.Phone,
|
||||
Email: req.Email,
|
||||
Site: req.Site,
|
||||
@@ -98,6 +110,8 @@ func (s *objectServiceImpl) CreateObject(ctx context.Context, req *CreateObjectR
|
||||
Longitude: req.Longitude,
|
||||
IsActive: isActive,
|
||||
IsVerified: isVerified,
|
||||
Status: status,
|
||||
ViewCount: 0,
|
||||
FeedbackCount: 0,
|
||||
}
|
||||
|
||||
@@ -173,6 +187,11 @@ func (s *objectServiceImpl) ListObjects(ctx context.Context, req *ListObjectsReq
|
||||
|
||||
// Применяем фильтры
|
||||
switch {
|
||||
case req.ObjectStatus != "":
|
||||
objects, err = s.objectRepository.ListByObjectStatus(req.ObjectStatus, offset, pageSize)
|
||||
if err == nil {
|
||||
total, _ = s.countObjectsByStatusString(req.ObjectStatus)
|
||||
}
|
||||
case req.Type != "":
|
||||
objects, err = s.objectRepository.ListByType(req.Type, offset, pageSize)
|
||||
if err == nil {
|
||||
@@ -553,6 +572,9 @@ func (s *objectServiceImpl) validateCreateRequest(req *CreateObjectRequest) erro
|
||||
}
|
||||
|
||||
func (s *objectServiceImpl) applyUpdates(object *models.Object, req *UpdateObjectRequest) {
|
||||
if req.Title != nil {
|
||||
object.Title = *req.Title
|
||||
}
|
||||
if req.ShortName != nil {
|
||||
object.ShortName = *req.ShortName
|
||||
}
|
||||
@@ -562,6 +584,12 @@ func (s *objectServiceImpl) applyUpdates(object *models.Object, req *UpdateObjec
|
||||
if req.Type != nil {
|
||||
object.Type = *req.Type
|
||||
}
|
||||
if req.Price != nil {
|
||||
object.Price = *req.Price
|
||||
}
|
||||
if req.PricePeriod != nil {
|
||||
object.PricePeriod = *req.PricePeriod
|
||||
}
|
||||
if req.Phone != nil {
|
||||
object.Phone = *req.Phone
|
||||
}
|
||||
@@ -586,6 +614,9 @@ func (s *objectServiceImpl) applyUpdates(object *models.Object, req *UpdateObjec
|
||||
if req.Longitude != nil {
|
||||
object.Longitude = *req.Longitude
|
||||
}
|
||||
if req.Status != nil {
|
||||
object.Status = models.ObjectStatus(*req.Status)
|
||||
}
|
||||
if req.IsActive != nil {
|
||||
object.IsActive = *req.IsActive
|
||||
}
|
||||
@@ -610,9 +641,12 @@ func (s *objectServiceImpl) mapToObjectResponse(object *models.Object, owner *mo
|
||||
CreatedAt: object.CreatedAt,
|
||||
UpdatedAt: object.UpdatedAt,
|
||||
OwnerID: object.OwnerID,
|
||||
Title: object.Title,
|
||||
ShortName: object.ShortName,
|
||||
LongName: object.LongName,
|
||||
Type: object.Type,
|
||||
Price: object.Price,
|
||||
PricePeriod: object.PricePeriod,
|
||||
Phone: object.Phone,
|
||||
Email: object.Email,
|
||||
Site: object.Site,
|
||||
@@ -623,6 +657,8 @@ func (s *objectServiceImpl) mapToObjectResponse(object *models.Object, owner *mo
|
||||
Longitude: object.Longitude,
|
||||
IsActive: object.IsActive,
|
||||
IsVerified: object.IsVerified,
|
||||
Status: string(object.Status),
|
||||
ViewCount: object.ViewCount,
|
||||
FeedbackCount: object.FeedbackCount,
|
||||
}
|
||||
|
||||
@@ -661,18 +697,48 @@ func (s *objectServiceImpl) mapToObjectResponse(object *models.Object, owner *mo
|
||||
}
|
||||
}
|
||||
|
||||
if len(object.Images) > 0 {
|
||||
resp.Images = make([]ImageResponse, len(object.Images))
|
||||
for i, img := range object.Images {
|
||||
resp.Images[i] = ImageResponse{
|
||||
ID: img.ID,
|
||||
ObjectID: img.ObjectID,
|
||||
URL: img.URL,
|
||||
IsPrimary: img.IsPrimary,
|
||||
SortOrder: img.SortOrder,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(object.Amenities) > 0 {
|
||||
resp.Amenities = make([]AmenityResponse, len(object.Amenities))
|
||||
for i, a := range object.Amenities {
|
||||
resp.Amenities[i] = AmenityResponse{
|
||||
ID: a.ID,
|
||||
Name: a.Name,
|
||||
Category: a.Category,
|
||||
Icon: a.Icon,
|
||||
Description: a.Description,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resp
|
||||
}
|
||||
|
||||
func (s *objectServiceImpl) mapToObjectShortResponse(object *models.Object) ObjectShortResponse {
|
||||
return ObjectShortResponse{
|
||||
ID: object.ID,
|
||||
Title: object.Title,
|
||||
ShortName: object.ShortName,
|
||||
LongName: object.LongName,
|
||||
Type: object.Type,
|
||||
Price: object.Price,
|
||||
PricePeriod: object.PricePeriod,
|
||||
Address: object.Address,
|
||||
IsActive: object.IsActive,
|
||||
IsVerified: object.IsVerified,
|
||||
Status: string(object.Status),
|
||||
FeedbackCount: object.FeedbackCount,
|
||||
}
|
||||
}
|
||||
@@ -729,3 +795,7 @@ func (s *objectServiceImpl) countObjectsBySearch(query string) (int64, error) {
|
||||
// TODO: Добавить метод CountBySearch в репозиторий
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (s *objectServiceImpl) countObjectsByStatusString(status string) (int64, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user