Skip to content

Commit c7e29ac

Browse files
committed
Add LawsuitCNJFormat return on DecomposedCNJ
1 parent aaa3d00 commit c7e29ac

File tree

2 files changed

+52
-46
lines changed

2 files changed

+52
-46
lines changed

CNJ/cnj.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type AnalysisCNJ struct {
2222
}
2323

2424
//DecomposedCNJ returns the CNJ in decomposed manner:
25+
// lawsuitCNJFormat [NNNNNNN]-[DD].[AAAA].[J].[CT].[0000]
2526
// lawsuitNumber: [NNNNNNN]
2627
// verifyingDigit: [DD]
2728
// protocolYear: [AAAA]
@@ -32,15 +33,16 @@ type AnalysisCNJ struct {
3233
// district: district where the lawsuit was proposed, frequently a city name
3334
// uf: the uf of the correspondent district
3435
type DecomposedCNJ struct {
35-
LawsuitNumber string `json:"lawsuit_number,omitempty"`
36-
VerifyingDigit string `json:"verifying_digit,omitempty"`
37-
ProtocolYear string `json:"protocol_year,omitempty"`
38-
Segment string `json:"segment,omitempty"`
39-
Court string `json:"court,omitempty"`
40-
SourceUnit string `json:"source_unit,omitempty"`
41-
ArgNumber string `json:"arg_number,omitempty"`
42-
District string `json:"district,omitempty"`
43-
UF string `json:"UF,omitempty"`
36+
LawsuitCNJFormat string `json:"lawsuitCNJFormat,omitempty"`
37+
LawsuitNumber string `json:"lawsuit_number,omitempty"`
38+
VerifyingDigit string `json:"verifying_digit,omitempty"`
39+
ProtocolYear string `json:"protocol_year,omitempty"`
40+
Segment string `json:"segment,omitempty"`
41+
Court string `json:"court,omitempty"`
42+
SourceUnit string `json:"source_unit,omitempty"`
43+
ArgNumber string `json:"arg_number,omitempty"`
44+
District string `json:"district,omitempty"`
45+
UF string `json:"UF,omitempty"`
4446
}
4547

4648
//AnalyzeCNJ returns the complex struct AnalysisCNJ containing all the useful data from this package

CNJ/decomposer.go

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
const MATH = "00"
1010

1111
// DecomposeCNJ decompose cnj format number into the specifics:
12-
// NNNNNNN-DD.AAAA.J.TR.OOOO
12+
// lawsuitCNJFormat [NNNNNNN]-[DD].[AAAA].[J].[CT].[0000]
1313
// LawsuitNumber = [NNNNNNN]
1414
// VerifyingDigit = [DD]
1515
// ProtocolYear = [AAAA]
@@ -42,28 +42,30 @@ func DecomposeCNJ(cnj string) (DecomposedCNJ, error) {
4242
dt, err := CNJDatabase.FetchDistrict(semiCNJ)
4343
if err != nil {
4444
return DecomposedCNJ{
45-
LawsuitNumber: lawsuitNumber,
46-
VerifyingDigit: verifyingDigit,
47-
ProtocolYear: yearProtocol,
48-
Segment: segment,
49-
Court: court,
50-
SourceUnit: sourceUnit,
51-
ArgNumber: argNumber,
52-
District: err.Error(),
53-
UF: err.Error(),
45+
LawsuitCNJFormat: lawsuitNumber + "-" + verifyingDigit + "." + yearProtocol + "." + segment + "." + court + "." + sourceUnit,
46+
LawsuitNumber: lawsuitNumber,
47+
VerifyingDigit: verifyingDigit,
48+
ProtocolYear: yearProtocol,
49+
Segment: segment,
50+
Court: court,
51+
SourceUnit: sourceUnit,
52+
ArgNumber: argNumber,
53+
District: err.Error(),
54+
UF: err.Error(),
5455
}, err
5556
}
5657

5758
return DecomposedCNJ{
58-
LawsuitNumber: lawsuitNumber,
59-
VerifyingDigit: verifyingDigit,
60-
ProtocolYear: yearProtocol,
61-
Segment: segment,
62-
Court: court,
63-
SourceUnit: sourceUnit,
64-
ArgNumber: argNumber,
65-
District: dt.SourceUnit,
66-
UF: dt.UF,
59+
LawsuitCNJFormat: lawsuitNumber + "-" + verifyingDigit + "." + yearProtocol + "." + segment + "." + court + "." + sourceUnit,
60+
LawsuitNumber: lawsuitNumber,
61+
VerifyingDigit: verifyingDigit,
62+
ProtocolYear: yearProtocol,
63+
Segment: segment,
64+
Court: court,
65+
SourceUnit: sourceUnit,
66+
ArgNumber: argNumber,
67+
District: dt.SourceUnit,
68+
UF: dt.UF,
6769
}, nil
6870
} else {
6971
lawsuitNumber := cnj[0:7]
@@ -88,29 +90,31 @@ func DecomposeCNJ(cnj string) (DecomposedCNJ, error) {
8890
if err != nil {
8991
if err != nil {
9092
return DecomposedCNJ{
91-
LawsuitNumber: lawsuitNumber,
92-
VerifyingDigit: verifyingDigit,
93-
ProtocolYear: yearProtocol,
94-
Segment: segment,
95-
Court: court,
96-
SourceUnit: sourceUnit,
97-
ArgNumber: argNumber,
98-
District: err.Error(),
99-
UF: err.Error(),
93+
LawsuitCNJFormat: lawsuitNumber + "-" + verifyingDigit + "." + yearProtocol + "." + segment + "." + court + "." + sourceUnit,
94+
LawsuitNumber: lawsuitNumber,
95+
VerifyingDigit: verifyingDigit,
96+
ProtocolYear: yearProtocol,
97+
Segment: segment,
98+
Court: court,
99+
SourceUnit: sourceUnit,
100+
ArgNumber: argNumber,
101+
District: err.Error(),
102+
UF: err.Error(),
100103
}, err
101104
}
102105
}
103106

104107
return DecomposedCNJ{
105-
LawsuitNumber: lawsuitNumber,
106-
VerifyingDigit: verifyingDigit,
107-
ProtocolYear: yearProtocol,
108-
Segment: segment,
109-
Court: court,
110-
SourceUnit: sourceUnit,
111-
ArgNumber: argNumber,
112-
District: dt.District,
113-
UF: dt.UF,
108+
LawsuitCNJFormat: lawsuitNumber + "-" + verifyingDigit + "." + yearProtocol + "." + segment + "." + court + "." + sourceUnit,
109+
LawsuitNumber: lawsuitNumber,
110+
VerifyingDigit: verifyingDigit,
111+
ProtocolYear: yearProtocol,
112+
Segment: segment,
113+
Court: court,
114+
SourceUnit: sourceUnit,
115+
ArgNumber: argNumber,
116+
District: dt.District,
117+
UF: dt.UF,
114118
}, nil
115119

116120
}

0 commit comments

Comments
 (0)