Skip to content

Commit 27e98b7

Browse files
authored
Fin 74 (#25)
* FIN-74 wip adding audit logs * FIN-74 WIP audit * FIN-74 refact log * FIN-74 added Iloggable to entities
1 parent 8f4113e commit 27e98b7

41 files changed

Lines changed: 747 additions & 33 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Fin-Backend.sln.DotSettings.user

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ABadHttpRequestException_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F58fd8e539d784853aa0a483642931ebf4c000_003F16_003Fbb4f7d05_003FBadHttpRequestException_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
33
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACallerIdentifier_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F71f2ec7617c4a98abe150a490d848fca9f9da94acbda7b12e237ec81dcd3_003FCallerIdentifier_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
44
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACancellationToken_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003F3c32b6774a69464667352a9e262bc924c57674f811c382e29abe8dbe3639f4c_003FCancellationToken_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
5+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADayOfWeek_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F2beab19a5e094b7480e8f255095b9e76e26800_003F77_003Fbe7e7f31_003FDayOfWeek_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
56
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADecimal_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fb926483dd9373e252824fb9f8bdf906c40ada3256d27f68392f486b2c1f6c_003FDecimal_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
67
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFieldInfo_002ECoreCLR_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fa4f51f201dca40bd938f37a528b1d91b4f1089a8ba612a057c4732bf7c21aad_003FFieldInfo_002ECoreCLR_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
8+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIMongoCollection_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3c17fe633e8c430094c5074d1511b9d6268000_003Fbc_003F3863f8c1_003FIMongoCollection_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
79
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AList_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003F1c3f7d5c03bf77051eb8a758fb3549c4e2d4cb3dc6f6d567a94a315044961e_003FList_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
810
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AList_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F1cb0ee423e6b413691aee222686aa63eb400_003F09_003F397dd16b_003FList_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
911
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AModelBuilder_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fd83f823935e343bfaf4ef4c6263b8a12291438_003F33_003Fc1982b24_003FModelBuilder_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
@@ -20,6 +22,7 @@
2022
&lt;Project Location="/home/rafaelchicovis/git/fin-backend/Fin.Test" Presentation="&amp;lt;Fin.Test&amp;gt;" /&gt;
2123
&lt;/SessionState&gt;</s:String>
2224
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=Fin_002EApplication_002FResources_002FEmailTemplates_002FEmailTemplates/@EntryIndexedValue">True</s:Boolean>
25+
2326
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=Fin_002EApplication_002FResources_002FEmailTemplates_002FResources_002Ees_002DEN/@EntryIndexedValue">False</s:Boolean>
2427
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=Fin_002EApplication_002FResources_002FEmailTemplates_002FResources_002Ees_002DEN/@EntryIndexRemoved">True</s:Boolean>
2528
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=Fin_002EApplication_002FResources_002FEmailTemplates_002FResources/@EntryIndexedValue">False</s:Boolean>

Fin.Api/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
}
77
},
88
"ConnectionStrings": {
9-
"DefaultConnection": "Host=localhost;Port=5432;Database=fin_app;Username=fin_app;Password=fin_app"
9+
"DefaultConnection": "Host=localhost;Port=5432;Database=fin_app;Username=fin_app;Password=fin_app",
10+
"MongoDbConnection": "mongodb://localhost:27017"
1011
},
1112
"AllowedHosts": "*",
1213
"ApiSettings": {

Fin.Domain/CardBrands/Entities/CardBrand.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Fin.Domain.CardBrands.Entities;
66

7-
public class CardBrand: IAuditedEntity
7+
public class CardBrand: IAuditedEntity, ILoggable
88
{
99
public string Name { get; set; }
1010
public string Icon { get; set; }
@@ -36,4 +36,19 @@ public void Update(CardBrandInput input)
3636
Color = input.Color;
3737

3838
}
39+
40+
public object GetLog()
41+
{
42+
return new
43+
{
44+
Id,
45+
CreatedAt,
46+
CreatedBy,
47+
UpdatedAt,
48+
UpdatedBy,
49+
Name,
50+
Color,
51+
Icon
52+
};
53+
}
3954
}

Fin.Domain/CreditCards/Entities/CreditCard.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Fin.Domain.CreditCards.Entities;
88

9-
public class CreditCard: IAuditedTenantEntity
9+
public class CreditCard: ILoggableAuditedTenantEntity
1010
{
1111
public string Name { get; private set; }
1212
public string Color { get; private set; }
@@ -63,4 +63,25 @@ public void Update(CreditCardInput input)
6363
}
6464

6565
public void ToggleInactivated() => Inactivated = !Inactivated;
66+
67+
public object GetLog()
68+
{
69+
return new
70+
{
71+
Id,
72+
CreatedAt,
73+
CreatedBy,
74+
UpdatedAt,
75+
UpdatedBy,
76+
TenantId,
77+
Name,
78+
Color,
79+
Icon,
80+
Limit,
81+
DueDay,
82+
ClosingDay,
83+
DebitWalletId,
84+
FinancialInstitutionId,
85+
};
86+
}
6687
}

Fin.Domain/Fin.Domain.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,4 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
</PropertyGroup>
77

8-
<ItemGroup>
9-
<Folder Include="CardBrands\Enums\" />
10-
</ItemGroup>
11-
128
</Project>

Fin.Domain/FinancialInstitutions/Entities/FinancialInstitution.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using Fin.Domain.CreditCards.Entities;
22
using Fin.Domain.FinancialInstitutions.Dtos;
33
using Fin.Domain.FinancialInstitutions.Enums;
4+
using Fin.Domain.Global.Decorators;
45
using Fin.Domain.Global.Interfaces;
56
using Fin.Domain.Wallets.Entities;
67

78
namespace Fin.Domain.FinancialInstitutions.Entities;
89

9-
public class FinancialInstitution : IAuditedEntity
10+
public class FinancialInstitution : IAuditedEntity, ILoggable
1011
{
1112
public string Name { get; set; }
1213
public string Code { get; set; }
@@ -47,4 +48,21 @@ public void Update(FinancialInstitutionInput input)
4748
}
4849

4950
public void ToggleInactive() => Inactive = !Inactive;
51+
public object GetLog()
52+
{
53+
return new
54+
{
55+
Id,
56+
CreatedAt,
57+
CreatedBy,
58+
UpdatedAt,
59+
UpdatedBy,
60+
Code,
61+
Icon,
62+
Color,
63+
Inactive,
64+
Type,
65+
TypeDescription = Type.GetTranslateKey(),
66+
};
67+
}
5068
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
using Fin.Domain.Global.Decorators;
2+
13
namespace Fin.Domain.FinancialInstitutions.Enums
24
{
35
public enum FinancialInstitutionType
46
{
7+
[FrontTranslateKey("finCore.features.financialInstitutions.type.bank")]
58
Bank = 0,
9+
[FrontTranslateKey("finCore.features.financialInstitutions.type.digitalBank")]
610
DigitalBank = 1,
11+
[FrontTranslateKey("finCore.features.financialInstitutions.type.foodCard")]
712
FoodCard = 2,
813
}
914
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System.Reflection;
2+
3+
namespace Fin.Domain.Global.Decorators;
4+
5+
[AttributeUsage(AttributeTargets.Field)]
6+
public class FrontTranslateKeyAttribute(string translateKey): Attribute
7+
{
8+
public string TranslateKey { get; } = translateKey;
9+
}
10+
11+
12+
public static class FrontTranslateKeyExtension
13+
{
14+
public static string GetTranslateKey<T>(this T valeu, bool throwIfNotFoundMessage = true)
15+
{
16+
var type = valeu.GetType();
17+
var memberInfo = type.GetMember(valeu.ToString() ?? string.Empty);
18+
19+
if (memberInfo.Length > 0)
20+
{
21+
var attribute = memberInfo[0].GetCustomAttribute<FrontTranslateKeyAttribute>();
22+
if (attribute != null)
23+
{
24+
return attribute.TranslateKey;
25+
}
26+
}
27+
28+
return throwIfNotFoundMessage
29+
? throw new ArgumentException($"Cannot get translate key {valeu}")
30+
: string.Empty;
31+
}
32+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Fin.Domain.Global.Interfaces;
2+
3+
public interface ILoggable
4+
{
5+
object GetLog();
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Fin.Domain.Global.Interfaces;
2+
3+
public interface ILoggableAuditedTenantEntity: ILoggable, IAuditedEntity, ITenantEntity
4+
{
5+
6+
}

0 commit comments

Comments
 (0)