refactor/unit-dropping: done

This commit is contained in:
2025-12-11 17:51:08 +07:00
parent c7f2876e6e
commit 261f3cdeb3
82 changed files with 330 additions and 2765 deletions
@@ -240,8 +240,8 @@ func (obj myBase) Skip(w http.ResponseWriter, r *http.Request) {
rw.DataResponse(w, res, err)
}
func (obj myBase) RequestSwitchUnit(w http.ResponseWriter, r *http.Request) {
dto := e.SwitchUnitDto{}
func (obj myBase) RequestSwitchSpecialist(w http.ResponseWriter, r *http.Request) {
dto := e.SwitchSpecialistDto{}
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
return
@@ -252,7 +252,7 @@ func (obj myBase) RequestSwitchUnit(w http.ResponseWriter, r *http.Request) {
}
// validate request body
if valid := validateRequestSwitchUnit(w, dto); !valid {
if valid := validateRequestSwitchSpecialist(w, dto); !valid {
return
}
@@ -263,12 +263,12 @@ func (obj myBase) RequestSwitchUnit(w http.ResponseWriter, r *http.Request) {
dto.AuthInfo = *authInfo
dto.Id = uint(id)
res, err := u.RequestSwitchUnit(dto)
res, err := u.RequestSwitchSpecialist(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) ApproveSwitchUnit(w http.ResponseWriter, r *http.Request) {
dto := e.ApproveCancelUnitDto{}
func (obj myBase) ApproveSwitchSpecialist(w http.ResponseWriter, r *http.Request) {
dto := e.ApproveCancelSpecialistDto{}
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
return
@@ -286,12 +286,12 @@ func (obj myBase) ApproveSwitchUnit(w http.ResponseWriter, r *http.Request) {
dto.AuthInfo = *authInfo
dto.Id = uint(id)
res, err := u.ApproveSwitchUnit(dto)
res, err := u.ApproveSwitchSpecialist(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) CancelSwitchUnit(w http.ResponseWriter, r *http.Request) {
dto := e.ApproveCancelUnitDto{}
func (obj myBase) CancelSwitchSpecialist(w http.ResponseWriter, r *http.Request) {
dto := e.ApproveCancelSpecialistDto{}
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
return
@@ -309,7 +309,7 @@ func (obj myBase) CancelSwitchUnit(w http.ResponseWriter, r *http.Request) {
dto.AuthInfo = *authInfo
dto.Id = uint(id)
res, err := u.CancelSwitchUnit(dto)
res, err := u.CancelSwitchSpecialist(dto)
rw.DataResponse(w, res, err)
}
@@ -58,7 +58,7 @@ func validateRequestCheckIn(w http.ResponseWriter, i e.CheckinDto) (valid bool)
return true
}
func validateRequestSwitchUnit(w http.ResponseWriter, i e.SwitchUnitDto) (valid bool) {
func validateRequestSwitchSpecialist(w http.ResponseWriter, i e.SwitchSpecialistDto) (valid bool) {
// validate poly-switch-code
if i.PolySwitchCode == nil {
rw.DataResponse(w, nil, d.FieldError{
@@ -84,7 +84,7 @@ func validateRequestSwitchUnit(w http.ResponseWriter, i e.SwitchUnitDto) (valid
}
for _, v := range *i.InternalReferences {
if v.Unit_Code == nil {
if v.Specialist_Code == nil {
rw.DataResponse(w, nil, d.FieldError{
Code: dataValidationFail,
Message: "internalReferences.unit_code required",