add edit func sample station

This commit is contained in:
2024-05-29 15:49:23 +07:00
parent d4883a2582
commit d2de950d5e
3 changed files with 443 additions and 2 deletions

View File

@@ -198,6 +198,10 @@ func (ss *MDSampleStationServices) EditMDSampleStation(id string, code string, n
logger, _ := zap.NewProduction()
var ret models.MDSampleStation
if strings.ToUpper(group) == "LAB" {
group = " "
}
// cek existeing code & name
var count int
var prmCode = "%" + code + "%"
@@ -209,7 +213,7 @@ func (ss *MDSampleStationServices) EditMDSampleStation(id string, code string, n
AND T_SampleStationIsActive = 'Y'
AND T_SampleStationID <> ?
`
err := dbx.Handlex.Get(count, q, prmCode, prmName, id)
err := dbx.Handlex.Get(&count, q, prmCode, prmName, id)
if err != nil {
defer logger.Sync()
logger.Error("cek duplicate", zap.Any("code", code), zap.Any("name", name))
@@ -218,7 +222,7 @@ func (ss *MDSampleStationServices) EditMDSampleStation(id string, code string, n
if count > 0 {
defer logger.Sync()
logger.Error("duplicate data", zap.Any("code", code), zap.Any("name", name))
return ret, fmt.Errorf("query failed")
return ret, fmt.Errorf("duplicate kode atau nama")
}
// update data