Implement a new endpoint in UserController to allow users to update their settings. The UserService is updated to handle the logic for updating user settings, including partial updates for various fields. Additionally, the User entity and database schema are modified to accommodate new user settings properties, ensuring persistence and retrieval of user preferences.
33 lines
1.4 KiB
C#
33 lines
1.4 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using Managing.Common;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using static Managing.Common.Enums;
|
|
|
|
namespace Managing.Infrastructure.Databases.PostgreSql.Entities;
|
|
|
|
[Table("Users")]
|
|
[Index(nameof(Name), IsUnique = true)]
|
|
public class UserEntity
|
|
{
|
|
[Key] public int Id { get; set; }
|
|
[Required] [MaxLength(255)] public required string Name { get; set; }
|
|
[MaxLength(255)] public string? AgentName { get; set; }
|
|
public string? AvatarUrl { get; set; }
|
|
public string? TelegramChannel { get; set; }
|
|
public string? OwnerWalletAddress { get; set; }
|
|
public DateTimeOffset? LastConnectionDate { get; set; }
|
|
public bool IsAdmin { get; set; }
|
|
|
|
// User Settings
|
|
[Column(TypeName = "decimal(18,8)")] public decimal? LowEthAmountAlert { get; set; }
|
|
public bool EnableAutoswap { get; set; } = false;
|
|
[Column(TypeName = "decimal(18,8)")] public decimal? AutoswapAmount { get; set; }
|
|
public int? MaxWaitingTimeForPositionToGetFilledSeconds { get; set; }
|
|
[Column(TypeName = "decimal(18,8)")] public decimal? MaxTxnGasFeePerPosition { get; set; }
|
|
public bool IsGmxEnabled { get; set; } = false;
|
|
public Confidence? MinimumConfidence { get; set; }
|
|
|
|
// Navigation properties
|
|
public virtual ICollection<AccountEntity> Accounts { get; set; } = new List<AccountEntity>();
|
|
} |