diff --git a/backend/go.mod b/backend/go.mod
index 2e3c5b9..14cf030 100644
--- a/backend/go.mod
+++ b/backend/go.mod
@@ -5,7 +5,10 @@ go 1.24.3
require (
github.com/gin-gonic/gin v1.10.1
github.com/go-playground/validator/v10 v10.27.0
+ github.com/go-redis/redis/v8 v8.11.5
github.com/golang-jwt/jwt/v5 v5.2.2
+ github.com/google/uuid v1.6.0
+ github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438
github.com/jackc/pgx/v5 v5.7.5
github.com/spf13/viper v1.20.1
github.com/swaggo/files v1.0.1
@@ -13,6 +16,7 @@ require (
github.com/swaggo/swag v1.16.4
go.uber.org/fx v1.24.0
go.uber.org/zap v1.27.0
+ golang.org/x/crypto v0.39.0
)
require (
@@ -31,12 +35,8 @@ require (
github.com/go-openapi/swag v0.23.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
- github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/goccy/go-json v0.10.5 // indirect
- github.com/gofrs/uuid/v5 v5.3.2 // indirect
- github.com/google/uuid v1.6.0 // indirect
- github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
@@ -49,6 +49,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
+ github.com/rafiulgits/go-automapper v0.1.4 // indirect
github.com/sagikazarmark/locafero v0.9.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.14.0 // indirect
@@ -60,7 +61,6 @@ require (
go.uber.org/dig v1.19.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.18.0 // indirect
- golang.org/x/crypto v0.39.0 // indirect
golang.org/x/net v0.41.0 // indirect
golang.org/x/sync v0.15.0 // indirect
golang.org/x/sys v0.33.0 // indirect
diff --git a/backend/go.sum b/backend/go.sum
index a3584bd..fca8104 100644
--- a/backend/go.sum
+++ b/backend/go.sum
@@ -49,8 +49,6 @@ github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIx
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
-github.com/gofrs/uuid/v5 v5.3.2 h1:2jfO8j3XgSwlz/wHqemAEugfnTlikAYHhnqQ8Xh4fE0=
-github.com/gofrs/uuid/v5 v5.3.2/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
@@ -91,10 +89,18 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
+github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
+github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
+github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
+github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
+github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
+github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/rafiulgits/go-automapper v0.1.4 h1:JiuPl3kjixpngxoDHLXKUfWYIPNLYO7EIGN+m6X0zFk=
+github.com/rafiulgits/go-automapper v0.1.4/go.mod h1:5R1UXVz04qYUVBQMSOJfC6472yAZIT2wWIl/zx4aNvo=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/sagikazarmark/locafero v0.9.0 h1:GbgQGNtTrEmddYDSAH9QLRyfAHY12md+8YFTqyMTC9k=
@@ -190,6 +196,10 @@ google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/backend/internal/database/models.go b/backend/internal/database/models.go
index b46bdf0..5ca3d0a 100644
--- a/backend/internal/database/models.go
+++ b/backend/internal/database/models.go
@@ -53,13 +53,13 @@ type Profile struct {
type ProfileSetting struct {
ID int64
ProfileID int64
- HideFulfilled *bool
- HideProfileDetails *bool
- HideForUnauthenticated *bool
- HideBirthday *bool
- HideDates *bool
- Captcha *bool
- FollowersOnlyInteraction *bool
+ HideFulfilled bool
+ HideProfileDetails bool
+ HideForUnauthenticated bool
+ HideBirthday bool
+ HideDates bool
+ Captcha bool
+ FollowersOnlyInteraction bool
}
type Session struct {
diff --git a/backend/internal/database/query.sql.go b/backend/internal/database/query.sql.go
index f4d80d1..7847220 100644
--- a/backend/internal/database/query.sql.go
+++ b/backend/internal/database/query.sql.go
@@ -383,7 +383,7 @@ type GetProfileByUsernameRestrictedRow struct {
AvatarUrl *string
Color string
ColorGrad string
- HideProfileDetails *bool
+ HideProfileDetails bool
}
func (q *Queries) GetProfileByUsernameRestricted(ctx context.Context, arg GetProfileByUsernameRestrictedParams) (GetProfileByUsernameRestrictedRow, error) {
@@ -456,7 +456,7 @@ type GetProfilesRestrictedRow struct {
AvatarUrl *string
Color string
ColorGrad string
- HideProfileDetails *bool
+ HideProfileDetails bool
}
func (q *Queries) GetProfilesRestricted(ctx context.Context, arg GetProfilesRestrictedParams) ([]GetProfilesRestrictedRow, error) {
@@ -1035,13 +1035,13 @@ WHERE id = $1
type UpdateProfileSettingsParams struct {
ID int64
- HideFulfilled *bool
- HideProfileDetails *bool
- HideForUnauthenticated *bool
- HideBirthday *bool
- HideDates *bool
- Captcha *bool
- FollowersOnlyInteraction *bool
+ HideFulfilled bool
+ HideProfileDetails bool
+ HideForUnauthenticated bool
+ HideBirthday bool
+ HideDates bool
+ Captcha bool
+ FollowersOnlyInteraction bool
}
func (q *Queries) UpdateProfileSettings(ctx context.Context, arg UpdateProfileSettingsParams) error {
diff --git a/backend/internal/dto/profile.go b/backend/internal/dto/profile.go
new file mode 100644
index 0000000..8b8de98
--- /dev/null
+++ b/backend/internal/dto/profile.go
@@ -0,0 +1,37 @@
+// Copyright (c) 2025 Nikolai Papin
+//
+// This file is part of Easywish
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+// the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+package dto
+
+type ProfileDto struct {
+ Name string `json:"name"`
+ Bio string `json:"bio"`
+ AvatarUrl string `json:"avatar_url"`
+ Birthday int64 `json:"birthday"`
+ Color string `json:"color"`
+ ColorGrad string `json:"color_grad"`
+}
+
+type ProfileSettingsDto struct {
+ HideFulfilled bool `json:"hide_fulfilled"`
+ HideProfileDetails bool `json:"hide_profile_details"`
+ HideForUnauthenticated bool `json:"hide_for_unauthenticated"`
+ HideBirthday bool `json:"hide_birthday"`
+ HideDates bool `json:"hide_dates"`
+ Captcha bool `json:"captcha"`
+ FollowersOnlyInteraction bool `json:"followers_only_interaction"`
+}
diff --git a/backend/internal/models/profile.go b/backend/internal/models/profile.go
new file mode 100644
index 0000000..a29a0b3
--- /dev/null
+++ b/backend/internal/models/profile.go
@@ -0,0 +1,18 @@
+// Copyright (c) 2025 Nikolai Papin
+//
+// This file is part of Easywish
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+// the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+package models
diff --git a/backend/internal/services/profile.go b/backend/internal/services/profile.go
new file mode 100644
index 0000000..6a0e1e7
--- /dev/null
+++ b/backend/internal/services/profile.go
@@ -0,0 +1,69 @@
+// Copyright (c) 2025 Nikolai Papin
+//
+// This file is part of Easywish
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+// the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+package services
+
+import (
+ "easywish/internal/database"
+ "easywish/internal/dto"
+
+ "github.com/go-redis/redis/v8"
+ "go.uber.org/zap"
+)
+
+type ProfileService interface {
+ GetProfileByUsername(cinfo dto.ClientInfo, username string) (dto.ProfileDto, error)
+ GetMyProfile(cinfo dto.ClientInfo) (dto.ProfileDto, error)
+ UpdateProfile(cinfo dto.ClientInfo, newProfile dto.ProfileDto) (bool, error)
+ GetProfileSettings(cinfo dto.ClientInfo) (dto.ProfileSettingsDto, error)
+ UpdateProfileSettings(cinfo dto.ClientInfo, newProfileSettings dto.ProfileSettingsDto) (bool, error)
+ UploadAvatar(cinfo dto.ClientInfo, filePath string)
+}
+
+type profileServiceImpl struct {
+ log *zap.Logger
+ dbctx database.DbContext
+ redis *redis.Client
+}
+
+func NewProfileService(_log *zap.Logger, _dbctx database.DbContext, _redis *redis.Client) ProfileService {
+ return &profileServiceImpl{log: _log, dbctx: _dbctx, redis: _redis}
+}
+
+func (p *profileServiceImpl) GetMyProfile(cinfo dto.ClientInfo) (dto.ProfileDto, error) {
+ panic("unimplemented")
+}
+
+func (p *profileServiceImpl) GetProfileByUsername(cinfo dto.ClientInfo, username string) (dto.ProfileDto, error) {
+ panic("unimplemented")
+}
+
+func (p *profileServiceImpl) GetProfileSettings(cinfo dto.ClientInfo) (dto.ProfileSettingsDto, error) {
+ panic("unimplemented")
+}
+
+func (p *profileServiceImpl) UpdateProfile(cinfo dto.ClientInfo, newProfile dto.ProfileDto) (bool, error) {
+ panic("unimplemented")
+}
+
+func (p *profileServiceImpl) UpdateProfileSettings(cinfo dto.ClientInfo, newProfileSettings dto.ProfileSettingsDto) (bool, error) {
+ panic("unimplemented")
+}
+
+func (p *profileServiceImpl) UploadAvatar(cinfo dto.ClientInfo, filePath string) {
+ panic("unimplemented")
+}
diff --git a/backend/internal/utils/mapSpecial/profileDto.go b/backend/internal/utils/mapSpecial/profileDto.go
new file mode 100644
index 0000000..f1d36c8
--- /dev/null
+++ b/backend/internal/utils/mapSpecial/profileDto.go
@@ -0,0 +1,31 @@
+// Copyright (c) 2025 Nikolai Papin
+//
+// This file is part of Easywish
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+// the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+package mapspecial
+
+import (
+ "easywish/internal/database"
+ "easywish/internal/dto"
+
+ "github.com/rafiulgits/go-automapper"
+)
+
+func Map(dbModel database.Profile, dtoModel dto.ProfileDto) {
+ automapper.Map(dbModel, &dbModel, func(src *database.Profile, dst *dto.ProfileDto) {
+ dst.Birthday = int64(dbModel.Birthday.Time.UnixMilli())
+ })
+}
diff --git a/sqlc/schema.sql b/sqlc/schema.sql
index 0722f13..9faa747 100644
--- a/sqlc/schema.sql
+++ b/sqlc/schema.sql
@@ -86,11 +86,11 @@ CREATE TABLE IF NOT EXISTS "profiles" (
CREATE TABLE IF NOT EXISTS "profile_settings" (
id BIGSERIAL PRIMARY KEY,
profile_id BIGINT UNIQUE NOT NULL REFERENCES profiles(id) ON DELETE CASCADE,
- hide_fulfilled BOOLEAN DEFAULT TRUE,
- hide_profile_details BOOLEAN DEFAULT FALSE,
- hide_for_unauthenticated BOOLEAN DEFAULT FALSE,
- hide_birthday BOOLEAN DEFAULT FALSE,
- hide_dates BOOLEAN DEFAULT FALSE,
- captcha BOOLEAN DEFAULT FALSE,
- followers_only_interaction BOOLEAN DEFAULT FALSE
+ hide_fulfilled BOOLEAN NOT NULL DEFAULT TRUE,
+ hide_profile_details BOOLEAN NOT NULL DEFAULT FALSE,
+ hide_for_unauthenticated BOOLEAN NOT NULL DEFAULT FALSE,
+ hide_birthday BOOLEAN NOT NULL DEFAULT FALSE,
+ hide_dates BOOLEAN NOT NULL DEFAULT FALSE,
+ captcha BOOLEAN NOT NULL DEFAULT FALSE,
+ followers_only_interaction BOOLEAN NOT NULL DEFAULT FALSE
)