diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 6bdc5512..fb7ec8eb 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:G7XwMRXjqZGaTeOozryI7WRd+FUJqE+DYsSfura7viU= +h1:3V3a/T/te8iQqsolgRAJKr99GePHgSN9miJHUNngJ74= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -75,42 +75,41 @@ h1:G7XwMRXjqZGaTeOozryI7WRd+FUJqE+DYsSfura7viU= 20251106040137.sql h1:ppcqkVoT0o9jZcjI/TN7LuaPxXhJQhnIXEJtloP/46o= 20251106041333.sql h1:2JkxyelQ/EeB+boL5bfpnzefw32ttEGKvKchtQjWmAU= 20251106042006.sql h1:ruppYa1kAJQUU3ufQBbKGMcXrGbGJJiRPclT+dNc/YQ= -20251106050412.sql h1:1002KYtHd8AwrQTMewbs/PPHDylHDghigE/3S7PVdMA= -20251106063418.sql h1:jPW/gBnbFl4RO39lQ0ZMDtYA6xbhyD6CgQupT50HmaY= -20251106071906.sql h1:leYGKxR3EQn794aOehf0sd/ZPmOnvBMZPy5/anGmRB4= -20251106073157.sql h1:KASMzjjjk5UB7Zj8lCRtM1utc4ZnDjlnpZbtTe3vONE= -20251106074218.sql h1:Z5q5deOvLaZDPhiVTN9st3/s56RepBa2YOyrMXBdj4A= -20251106081846.sql h1:P+VsWwhGt60adDIZuE/Aa38JVp/yX1rnsdpXpxASodw= -20251106082844.sql h1:Dmi5A8i9frQZvdXYPwc7f8CisZtBH8liSXq1rI6z1iM= -20251106090021.sql h1:4JwdKgO8T46YhyWVJUxpRIwudBDlG8QN1brSOYmgQ20= -20251106144745.sql h1:nqnQCzGrVJaq8ilOEOGXeRUL1dolj+OPWKuP8A92FRA= -20251107012049.sql h1:Pff4UqltGS3clSlGr0qq8CQM56L29wyxY0FC/N/YAhU= -20251107064812.sql h1:GB9a0ZfMYTIoGNmKUG+XcYUsTnRMFfT4/dAD71uCPc4= -20251107064937.sql h1:IC5pw1Ifj30hiE6dr5NMHXaSHoQI+vRd40N5ABgBHRI= -20251107071420.sql h1:9NO3iyLEXEtWa2kSRjM/8LyzuVIk6pdFL2SuheWjB08= -20251107074318.sql h1:7fHbSRrdjOmHh/xwnjCLwoiB5cW5zeH+uxLV0vZbkIA= -20251107075050.sql h1:np+3uTOnU9QNtK7Knaw8eRMhkyB9AwrtSNHphOBxbHY= -20251107080604.sql h1:cXDBLPJDVWLTG6yEJqkJsOQ7p7VYxLM2SY+mwO8qSHo= -20251107081830.sql h1:/S7OQZo4ZnK80t28g/JyiOTZtmWG/dP5Wg2zXNMQ/iE= -20251107091033.sql h1:/cbkF1nO/IjNSIfDJJx456KJtQ9rWFXOBFAkR/M2xiE= -20251107091209.sql h1:jrLQOUeV8ji2fg0pnEcs1bw4ANUxzTSMXC/rrHLIY+M= -20251107091541.sql h1:6UqbhQQRmzA2+eKu5lIvkwOkk+lH70QLZC8Pjpjcq68= -20251110012217.sql h1:C9HpX0iyHzKjyNv/5DSAn2MCHj6MX4p5UQ/NrY7QD0w= -20251110012306.sql h1:J54yb27d30LBbYp9n1P66gFVRlxPguKu0kxmWIBBG8g= -20251110052049.sql h1:232T2x8xTczJl9nk4jxJpZXhoOGYthhxjJ7nK8Jd8vg= -20251110062042.sql h1:WnfVUXrzYoj8qdkkjO9/JQQ8agGd4GfSHQdMjo7LDAg= -20251110063202.sql h1:hSzGfwVMWa6q3vwIQZUkxKgBNCzHjB+6GKy54zfV+oQ= -20251110063633.sql h1:/VpofIAqNS1CnazEnpW/+evbzn9Kew3xDW48r57M+Xg= -20251110085551.sql h1:bFZwSmfvVbTUr/enWB82WqjG88gpqcZ6s45btUvO0uo= -20251110091516.sql h1:KkJMwPQuaZQhiqnKrNQrgP12gw9rV8T3P2o3mtGTcvY= -20251110091948.sql h1:I4odAYrJdvNf1jPw6ppDC0XdI7v6vKBACg/ABwUgA7I= -20251110092729.sql h1:l1out8soEmVP6dNjaIOtGYo6QDcoJZRI8X1sjZ5ZGmo= -20251110093522.sql h1:nsz8jCxGjEdr/bz9g+4ozfZzIP803xONjVmucad1GMc= -20251110100258.sql h1:IBqt1VZj5WjQ+l9aAFGHOCCBtzb03KlLLihFLut7itg= -20251110100545.sql h1:6/LV7751iyKxE2xI6vO1zly+aHUwxXD/IBwLcVpKxqM= -20251111072601.sql h1:dEhwrkT0hJ06/YcvQd5alvdskimcHcYT27QKAzVY5+8= -20251111073546.sql h1:JnJZ4SdOObSe6Jf8v/i/KiRxoCz5KMeXCYytQMZgkZM= -20251111074148.sql h1:95Ui1eo1P68itOz5kZDNFi2ha0ZhUF4gMYiYVcip6fo= -20251111074652.sql h1:vUZbN0qgktRQ2GAlCpdYrbld2grPiSbvcMePEQMfxPs= -20251111082257.sql h1:Zr3Xg5n+p4C8F6Evqm5PVC0pqUvPTBcq692PiUEJlT8= -20251111111017.sql h1:RNLwrUNguAy/m2h3oYwMd5VuL1juRJMS1Taqujvye08= +20251106050412.sql h1:MiEMJ1HCFYnalKuq3Z38xJeogfBAMqsTv2sG4EF8dDw= +20251106063418.sql h1:y3veDJPjKekOWLCZek/LgQwXPRhZtOppTfUXiqoL95s= +20251106071906.sql h1:/TUZA3XpMY23qEJXdkTwlzrNMvSSl6JJniPcgAttBaw= +20251106073157.sql h1:78txeibJ602DMD7huD618ZSMt6phSRzDNPTlo0PGyrc= +20251106074218.sql h1:8Xz7WywrtUnSxOHhlal53gG9rE7r86LFUt5zBFe/mIs= +20251106081846.sql h1:jp91Bf5bxGXMiUB1VIuN6y768vb2iWwow44WfCE5J5k= +20251106082844.sql h1:RHYzRO4G1fSWwf+xc/3QezZ/Iil67cZPIgNpNz3TNhQ= +20251106090021.sql h1:dFDk6mq+zjbYWmfWIrHf9DiKvvoXHjrr0++zssMTWP8= +20251106144745.sql h1:aHcr23iBFqCHer5D/SsPMXBCLjGqUYvWYfRU8jSJgIw= +20251107012049.sql h1:hu/7NHhnAkT4xK0RNtqmMDdH1Bo5EZbl7itDRjiCT+g= +20251107064812.sql h1:sfCXDQYnMf0ddrQ9oYljWJLLSt9NJjJV6o8VS3p7aZE= +20251107064937.sql h1:DlYGJ9LZFwZyR7jBP5zaGB128aIc4HAixBKPYCz9EkY= +20251107071420.sql h1:ynCdZAd2utLl+FhtWZwtahNXgIVOvuk3s/rOq7lfXA4= +20251107074318.sql h1:WE9cPhibWtZ0dbu1VEGirTeY6ijFYGMNhHdBtM32kOc= +20251107075050.sql h1:8tvneruqdynDOaJK1+0z4CH7YXZStZpGdqwIeOMLik4= +20251107080604.sql h1:8c4jd4Tql7tcdhbI9NS0tgvN+ADu9FnCf8wMUbmW7A0= +20251107081830.sql h1:SAAe3lmsm9vGXuSEsDdl7ad0EAxP5CMmFRDEgp9M7yY= +20251107091033.sql h1:JLdX/u7GUdBfjrPrMSNAqc8HtSoj0YA9iW9Vc6FJZdw= +20251107091209.sql h1:CzhYtwAwT+GHrbqcagnJE+v3mbl/rObf1IJaLCKlzrs= +20251107091541.sql h1:+3ZyWJTftDY2JeWThXuIxGWpUBnyMPyOyY4jBjdWYJI= +20251110012217.sql h1:f4Z8TuGc+XMSJ+Ekn4/PeHRE2FlHWkc5gKPJB0hAX7c= +20251110012306.sql h1:ENPyI6Kjdk6qKJQb0yJ6MCTDPAmO1WD/uhKuCSl+jYo= +20251110052049.sql h1:OrQ0acnyoQLKnTitZfnBcVr5jDslF59OFLaqT7SpdVs= +20251110062042.sql h1:9KwldQt0NpVPR86L0T4hlkfHAGau+7CiZYgu5rF+yhg= +20251110063202.sql h1:A117DuZmZ6U0jWHA3DISnr+yvBjKIr1ObrUr047YezQ= +20251110063633.sql h1:qTiC0F19JnhUIXF4LGJQ21jEV6kKGyhTr1x2kimFqPQ= +20251110085551.sql h1:HZcJM0RSC6HBaUSjKBE8MgDG8Vn9f3LmwA/OnT9Cp7I= +20251110091516.sql h1:W3AQhQLgirEWuCObbLl+Prdrbq6k6EEY1xcoWsmbog4= +20251110091948.sql h1:3tsITMrZr/T+L4wqUMz8sHS229jCJl4T0Nu3dMccxH8= +20251110092729.sql h1:uU+k88RH/e0Ns4/SmJl03RVYPscBAPuiLfxR6CJqaf0= +20251110093522.sql h1:O7upSj8VNjzvroL4IU59bfxKATOkAVGBArcUbVNq9aM= +20251110100258.sql h1://JSArUMNI3/gAtYDx2VN94C198SFW0ANjgs+p6eCRM= +20251110100545.sql h1:ENPOqeJYRpMI4e8VCKwaQgaql8se6pIidAhG2cjskBg= +20251111072601.sql h1:6p2qynJ2vr3C18peYciAbOIWOoj/+PnNcobU3wNHboQ= +20251111073546.sql h1:BORlFReAZTDLUfpS/eIf5qGkJ+FNznMGK47HRiPkfL8= +20251111074148.sql h1:qzjLGQRWo1Gg8LkJFgTb5Ak7h53tdz+eQrpJqC9+Gc0= +20251111074652.sql h1:uuThrt4wjdq4qEbvS67fF0Nfw/dlj7vGnLqywWBznqk= +20251111082257.sql h1:eUfu0tDtl9KqX7UK8is6Qc04NSQs4BXwKsykZwnVH1w= diff --git a/internal/domain/main-entities/installation/dto.go b/internal/domain/main-entities/installation/dto.go index 302025d8..758efb05 100644 --- a/internal/domain/main-entities/installation/dto.go +++ b/internal/domain/main-entities/installation/dto.go @@ -8,7 +8,7 @@ import ( ) type CreateDto struct { - Code string `json:"code" validate:"maxLength=10"` + Code *string `json:"code" validate:"maxLength=10"` Name string `json:"name" validate:"maxLength=50"` EncounterClass_Code ere.EncounterClassCode `json:"encounterClass_code" validate:"maxLength=10"` } @@ -21,25 +21,26 @@ type ReadListDto struct { } type FilterDto struct { - Code string `json:"code"` - Name string `json:"name"` + Code *string `json:"code"` + Name *string `json:"name"` EncounterClass_Code ere.EncounterClassCode `json:"encounterClass-code"` Search string `json:"search" gormhelper:"searchColumns=Code,Name"` } type ReadDetailDto struct { - Id uint16 `json:"id"` + Id *uint16 `json:"id"` Code *string `json:"code"` Includes string `json:"includes"` } type UpdateDto struct { - Id uint16 `json:"id"` + Id *uint16 `json:"id"` CreateDto } type DeleteDto struct { - Id uint16 `json:"id"` + Id *uint16 `json:"id"` + Code *string `json:"code"` } type MetaDto struct { diff --git a/internal/domain/references/organization/organization.go b/internal/domain/references/organization/organization.go index 1dfe93ad..09b19dce 100644 --- a/internal/domain/references/organization/organization.go +++ b/internal/domain/references/organization/organization.go @@ -11,21 +11,21 @@ type ( ) const ( - CSCSys ContractPositionCode = "system" // System - CSCEmp ContractPositionCode = "employee" // Pegawai - CSCInt ContractPositionCode = "intern" // PPDS + CSCSys ContractPositionCode = "sys" // System + CSCEmp ContractPositionCode = "emp" // Pegawai + CSCInt ContractPositionCode = "int" // PPDS - EPCReg EmployeePositionCode = "registration" // Admisi/Pendaftaran - EPCNur EmployeePositionCode = "nurse" // Perawat - EPCDoc EmployeePositionCode = "doctor" // Dokter - EPCNut EmployeePositionCode = "nutritionist" // Ahli gizi - EPCMwi EmployeePositionCode = "mid-wife" // Bidan - EPCLab EmployeePositionCode = "laborant" // Laboran - EPCPha EmployeePositionCode = "pharmacy" // Farmasi - EPCPay EmployeePositionCode = "payment" // Pembayaran - EPCHur EmployeePositionCode = "human-resource" // Sumber Daya Manusia - EPCGea EmployeePositionCode = "general-affair" // Bagian Umum - EPCMan EmployeePositionCode = "management" // Manajemen + EPCReg EmployeePositionCode = "reg" // Admisi/Pendaftaran + EPCNur EmployeePositionCode = "nur" // Perawat + EPCDoc EmployeePositionCode = "doc" // Dokter + EPCNut EmployeePositionCode = "nut" // Ahli gizi + EPCMwi EmployeePositionCode = "miw" // Bidan + EPCLab EmployeePositionCode = "lab" // Laboran + EPCPha EmployeePositionCode = "pha" // Farmasi + EPCPay EmployeePositionCode = "pay" // Pembayaran + EPCHur EmployeePositionCode = "hue" // Sumber Daya Manusia + EPCGea EmployeePositionCode = "gea" // Bagian Umum + EPCMan EmployeePositionCode = "man" // Manajemen IPCSpecialist = "specialist-intern" IPCNurse = "nurse-intern" diff --git a/internal/interface/main-handler/installation/handler.go b/internal/interface/main-handler/installation/handler.go index 26885689..0b3f52ef 100644 --- a/internal/interface/main-handler/installation/handler.go +++ b/internal/interface/main-handler/installation/handler.go @@ -33,21 +33,21 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) { } func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.ReadDetailDto{} sf.UrlQueryParam(&dto, *r.URL) - dto.Id = uint16(id) + dto.Code = &code res, err := u.ReadDetail(dto) rw.DataResponse(w, res, err) } func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } @@ -55,19 +55,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { return } - dto.Id = uint16(id) + dto.Code = &code res, err := u.Update(dto) rw.DataResponse(w, res, err) } func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.DeleteDto{} - dto.Id = uint16(id) + dto.Code = &code res, err := u.Delete(dto) rw.DataResponse(w, res, err) } diff --git a/internal/use-case/main-use-case/authentication/helper.go b/internal/use-case/main-use-case/authentication/helper.go index b7ccc660..c0a3bd0f 100644 --- a/internal/use-case/main-use-case/authentication/helper.go +++ b/internal/use-case/main-use-case/authentication/helper.go @@ -21,6 +21,7 @@ import ( "simrs-vx/internal/domain/main-entities/intern" em "simrs-vx/internal/domain/main-entities/midwife" en "simrs-vx/internal/domain/main-entities/nurse" + ep "simrs-vx/internal/domain/main-entities/pharmacist" esp "simrs-vx/internal/domain/main-entities/specialist-position" essp "simrs-vx/internal/domain/main-entities/subspecialist-position" eup "simrs-vx/internal/domain/main-entities/unit-position" @@ -70,7 +71,7 @@ func getDivisionPosition(employee_id uint, event *pl.Event) ([]string, error) { if len(data) > 0 { for _, dp := range data { - result = append(result, "div-"+*dp.Division_Code) + result = append(result, "div|"+*dp.Division_Code+"|"+dp.Code) } } @@ -90,7 +91,7 @@ func getInstallationPosition(employeeId uint, event *pl.Event) ([]string, error) if len(data) > 0 { for _, dp := range data { - result = append(result, "inst-"+*dp.Installation_Code+"-"+dp.Code) + result = append(result, "inst|"+*dp.Installation_Code+"|"+dp.Code) } } @@ -108,7 +109,7 @@ func getUnitPosition(employeeId uint, event *pl.Event) ([]string, error) { if len(data) > 0 { for _, dp := range data { - result = append(result, "unit-"+*dp.Unit_Code+"-"+dp.Code) + result = append(result, "unit|"+*dp.Unit_Code+"|"+dp.Code) } } @@ -126,7 +127,7 @@ func getSpecialistPosition(employeeId uint, event *pl.Event) ([]string, error) { if len(data) > 0 { for _, dp := range data { - result = append(result, "spec-"+*dp.Specialist_Code+"-"+dp.Code) + result = append(result, "spec|"+*dp.Specialist_Code+"|"+dp.Code) } } @@ -146,7 +147,7 @@ func getSubspecialistPosition(employeeId uint, event *pl.Event) ([]string, error if len(data) > 0 { for _, dp := range data { - result = append(result, "subspec-"+dp.Subspecialist.Code+"-"+dp.Code) + result = append(result, "subspec|"+dp.Subspecialist.Code+"|"+dp.Code) } } @@ -209,7 +210,7 @@ func populateRoles(user *eu.User, input eu.LoginDto, atClaims jwt.MapClaims, out } atClaims["employee_id"] = employee.Id outputData["employee_id"] = employee.Id - roles = append(roles, "emp-"+string(*employee.Position_Code)) + roles = append(roles, "emp|"+string(*employee.Position_Code)) // employee position if employee.Id > 0 && employee.Position_Code != nil { @@ -249,6 +250,14 @@ func populateRoles(user *eu.User, input eu.LoginDto, atClaims jwt.MapClaims, out } atClaims["midwife_code"] = empData.Code outputData["midwife_code"] = empData.Code + case erg.EPCPha: + empData := ep.Pharmacist{} + dg.I.Where("\"Employee_Id\" = ?", employee.Id).First(&empData) + if empData.Id == 0 { + return d.FieldErrors{"authentication": d.FieldError{Code: "auth-noPharmacist", Message: pl.GenMessage("auth-noPharmacist")}} + } + atClaims["pharmacist_code"] = empData.Code + outputData["pharmacist_code"] = empData.Code } errorGetPosition := d.FieldErrors{"authentication": d.FieldError{Code: "auth-getData-failed", Message: pl.GenMessage("auth-getData-failed")}} diff --git a/internal/use-case/main-use-case/encounter/case.go b/internal/use-case/main-use-case/encounter/case.go index d387fcc2..9381e639 100644 --- a/internal/use-case/main-use-case/encounter/case.go +++ b/internal/use-case/main-use-case/encounter/case.go @@ -3,6 +3,7 @@ package encounter import ( "errors" "fmt" + us "simrs-vx/internal/use-case/main-use-case/soapi" "strconv" "time" @@ -489,6 +490,32 @@ func UpdateStatusCode(input e.UpdateStatusDto) (*d.Data, error) { return pl.SetLogError(&event, input) } + if input.StatusCode == erc.DSCCancel { + // TODO: Prevent cancellation if the billing has been verified + + // TODO: Only "supervisi pendaftaran" could cancel encounter + + // Prevent cancellation if soapi exist + encounterId := uint(input.Id) + dataSoapi, _, err := us.ReadListData(es.ReadListDto{ + FilterDto: es.FilterDto{ + Encounter_Id: &encounterId, + }}, &event, tx) + if err != nil { + return err + } + + if len(dataSoapi) > 0 { + event.Status = "failed" + event.ErrInfo = pl.ErrorInfo{ + Code: "cancel-not-allowed", + Detail: "encounter can't be cancelled because SOAPI already exists", + Raw: errors.New("encounter has SOAPI records"), + } + return pl.SetLogError(&event, input) + } + } + mwRunner := newMiddlewareRunner(&event, tx) mwRunner.setMwType(pu.MWTPre) // Run pre-middleware diff --git a/internal/use-case/main-use-case/installation/case.go b/internal/use-case/main-use-case/installation/case.go index 5e1339da..f66bedaf 100644 --- a/internal/use-case/main-use-case/installation/case.go +++ b/internal/use-case/main-use-case/installation/case.go @@ -166,7 +166,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) { } func Update(input e.UpdateDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: input.Id} + rdDto := e.ReadDetailDto{Code: input.Code} var data *e.Installation var err error @@ -222,7 +222,7 @@ func Update(input e.UpdateDto) (*d.Data, error) { } func Delete(input e.DeleteDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: input.Id} + rdDto := e.ReadDetailDto{Code: input.Code} var data *e.Installation var err error diff --git a/internal/use-case/main-use-case/installation/helper.go b/internal/use-case/main-use-case/installation/helper.go index 3ad22892..d3d96b5c 100644 --- a/internal/use-case/main-use-case/installation/helper.go +++ b/internal/use-case/main-use-case/installation/helper.go @@ -17,7 +17,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Installation) { inputSrc = &inputTemp.CreateDto } - data.Code = inputSrc.Code + data.Code = *inputSrc.Code data.Name = inputSrc.Name data.EncounterClass_Code = inputSrc.EncounterClass_Code } diff --git a/internal/use-case/main-use-case/installation/lib.go b/internal/use-case/main-use-case/installation/lib.go index 82130c32..d75b2ecd 100644 --- a/internal/use-case/main-use-case/installation/lib.go +++ b/internal/use-case/main-use-case/installation/lib.go @@ -81,9 +81,16 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e tx = dg.I } + if input.Code != nil { + tx = tx.Where("\"Code\" = ?", *input.Code) + } + if input.Id != nil { + tx = tx.Where("\"Id\" = ?", *input.Id) + } + if err := tx. Scopes(gh.Preload(input.Includes)). - First(&data, input.Id).Error; err != nil { + First(&data).Error; err != nil { if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil { return nil, processedErr } diff --git a/internal/use-case/main-use-case/specialist-position/case.go b/internal/use-case/main-use-case/specialist-position/case.go index 2addf80d..f4031b2f 100644 --- a/internal/use-case/main-use-case/specialist-position/case.go +++ b/internal/use-case/main-use-case/specialist-position/case.go @@ -175,7 +175,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) { } func Update(input e.UpdateDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: input.Id} + rdDto := e.ReadDetailDto{Code: &input.Code} var data *e.SpecialistPosition var err error @@ -235,7 +235,7 @@ func Update(input e.UpdateDto) (*d.Data, error) { } func Delete(input e.DeleteDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: input.Id} + rdDto := e.ReadDetailDto{Code: input.Code} var data *e.SpecialistPosition var err error diff --git a/internal/use-case/main-use-case/specialist-position/lib.go b/internal/use-case/main-use-case/specialist-position/lib.go index 13c84f28..fea6bb9d 100644 --- a/internal/use-case/main-use-case/specialist-position/lib.go +++ b/internal/use-case/main-use-case/specialist-position/lib.go @@ -86,7 +86,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e case input.Id != nil: getData = tx.First(&data, input.Id) case input.Code != nil && *input.Code != "": - getData = tx.Where("code = ?", *input.Code).First(&data) + getData = tx.Where("\"Code\" = ?", *input.Code).First(&data) default: event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ diff --git a/internal/use-case/main-use-case/subspecialist/case.go b/internal/use-case/main-use-case/subspecialist/case.go index 42366adf..51509c47 100644 --- a/internal/use-case/main-use-case/subspecialist/case.go +++ b/internal/use-case/main-use-case/subspecialist/case.go @@ -13,7 +13,7 @@ import ( "gorm.io/gorm" ) -const source = "specialist" +const source = "subspecialist" func Create(input e.CreateDto) (*d.Data, error) { data := e.Subspecialist{} diff --git a/internal/use-case/main-use-case/subspecialist/lib.go b/internal/use-case/main-use-case/subspecialist/lib.go index a6c4dbc5..c5a742df 100644 --- a/internal/use-case/main-use-case/subspecialist/lib.go +++ b/internal/use-case/main-use-case/subspecialist/lib.go @@ -90,7 +90,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e if err := tx. Scopes(gh.Preload(input.Includes)). - First(&data, input.Id).Error; err != nil { + First(&data).Error; err != nil { if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil { return nil, processedErr } diff --git a/internal/use-case/main-use-case/unit-position/lib.go b/internal/use-case/main-use-case/unit-position/lib.go index d6f42936..104357e5 100644 --- a/internal/use-case/main-use-case/unit-position/lib.go +++ b/internal/use-case/main-use-case/unit-position/lib.go @@ -86,7 +86,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e case input.Id != nil: getData = tx.First(&data, input.Id) case input.Code != nil && *input.Code != "": - getData = tx.Where("code = ?", *input.Code).First(&data) + getData = tx.Where("\"Code\" = ?", *input.Code).First(&data) default: event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ diff --git a/internal/use-case/main-use-case/upload/helper.go b/internal/use-case/main-use-case/upload/helper.go index 65edb9eb..652d80fa 100644 --- a/internal/use-case/main-use-case/upload/helper.go +++ b/internal/use-case/main-use-case/upload/helper.go @@ -107,16 +107,24 @@ func setPersonAttachment(input e.CreateDto, event *pl.Event, tx *gorm.DB) (*ep.P var removeUrl string switch input.Type_Code { case eru.UCPRN: - removeUrl = *dataPerson.ResidentIdentityFileUrl + if dataPerson.ResidentIdentityFileUrl != nil { + removeUrl = *dataPerson.ResidentIdentityFileUrl + } dataPerson.ResidentIdentityFileUrl = &input.FilePath case eru.UCPDL: - removeUrl = *dataPerson.DrivingLicenseFileUrl + if dataPerson.DrivingLicenseFileUrl != nil { + removeUrl = *dataPerson.DrivingLicenseFileUrl + } dataPerson.DrivingLicenseFileUrl = &input.FilePath case eru.UCPP: - removeUrl = *dataPerson.PassportFileUrl + if dataPerson.PassportFileUrl != nil { + removeUrl = *dataPerson.PassportFileUrl + } dataPerson.PassportFileUrl = &input.FilePath case eru.UCPFC: - removeUrl = *dataPerson.FamilyIdentityFileUrl + if dataPerson.FamilyIdentityFileUrl != nil { + removeUrl = *dataPerson.FamilyIdentityFileUrl + } dataPerson.FamilyIdentityFileUrl = &input.FilePath }