Harden loan-order create validation and cover gin JSON binding.
Reject zero loanType/branchId/dates before insert, and assert mobile-style payloads bind through gin required tags. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
6683826662
commit
0d000f9af6
2 files changed
+42
-12
No files matched your search
@@ -152,6 +152,10 @@ func (h *handler) create(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
if dto.LoanType.Int64() <= 0 || dto.BranchId.Int64() <= 0 || dto.BornAt.IsZero() || dto.PassportGivenAt.IsZero() {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
item, err := h.repository.Create(c.Request.Context(), dto)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user