add autologon, + generate password btn peserta dashboard pic

This commit is contained in:
2024-07-13 15:37:44 +07:00
parent 57d160b62a
commit 938e6d60f1
21 changed files with 1412 additions and 198 deletions

View File

@@ -1,11 +1,15 @@
package mcu_corporate_services
import (
"bytes"
"cpone/db"
"cpone/models"
dbx "cpone/package/database"
"encoding/json"
"fmt"
"io"
"math"
"net/http"
"strconv"
"go.uber.org/zap"
@@ -51,10 +55,13 @@ func (tdps *TabDaftarPesertaServices) GetListMcuDaftarPeserta(id string, current
ELSE ' '
END AS jenisKelamin,
M_PatientDOB,
FLOOR(DATEDIFF(CURDATE(), M_PatientDOB)/ 365.25) AS age
FLOOR(DATEDIFF(CURDATE(), M_PatientDOB)/ 365.25) AS age,
IFNULL(authPatientEmail, "none") AS authPatientEmail,
IFNULL(authPatientIsActive, "N") AS authPatientIsActive
FROM t_orderheader
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
AND M_PatientIsActive = 'Y'
LEFT JOIN auth_patient ON M_PatientID = authPatientM_PatientID AND authPatientIsActive = 'Y'
WHERE T_OrderHeaderIsActive = 'Y' AND T_OrderHeaderMgm_McuID = ?
ORDER BY T_OrderHeaderLabNumber ASC
LIMIT ? OFFSET ?`
@@ -239,3 +246,61 @@ func (tdps *TabDaftarPesertaServices) GetListReportPeserta(orderheaderID string,
return ret, nil
}
func (tdps *TabDaftarPesertaServices) GenerataPasswordMCU(mgmMCUID string, host string) (models.GeneratePasswordResponse, error) {
// Generate email dan password utk seluruh peserta mgm mcu
// https://devcpone.aplikasi.web.id/one-api/tools/auth_patient/generate/<XID>
// <XID> : mgmMcuID
if host == "localhost:5000" {
host = "https://devcpone.aplikasi.web.id"
}
logger, _ := zap.NewProduction()
var ret models.GeneratePasswordResponse
uri := host + "/one-api/tools/auth_patient/generate/" + mgmMCUID
payload := []byte{}
resp, err := http.Post(uri, "application/json", bytes.NewBuffer(payload))
if err != nil {
return ret, fmt.Errorf("error request generate password: %v", err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return ret, fmt.Errorf("error read body respoonse")
}
if err := json.Unmarshal(body, &ret); err != nil {
return ret, fmt.Errorf("error unmarshal json respoonse")
}
defer logger.Sync()
logger.Info("response", zap.Any("data", ret))
return ret, nil
}
func (tdps *TabDaftarPesertaServices) GetAkunPeserta(patientID string) (models.AuthPatient, error) {
logger, _ := zap.NewProduction()
var ret models.AuthPatient
q := `
SELECT
authPatientID,
authPatientM_PatientID,
authPatientEmail,
authPatientPassword,
authPatientIsActive
FROM auth_patient
WHERE authPatientM_PatientID = ?
AND authPatientIsActive = 'Y'
`
if err := dbx.Handlex.Get(&ret, q, patientID); err != nil {
return ret, fmt.Errorf("error get akun peserta")
}
logger.Info("response", zap.Any("data", ret))
return ret, nil
}

View File

@@ -67,10 +67,15 @@ func (ls *ServicesLogin) Login(username string, password string) (models.Respons
return resp, nil
}
func (ls *ServicesLogin) MultiSignIn(username string, password string) (models.Response, error) {
func (ls *ServicesLogin) MultiSignIn(username string, password string, host string) (models.Response, error) {
logger, _ := zap.NewProduction()
var ret models.Response
uri := "https://devcpone.aplikasi.web.id/one-api/v1/system/auth/multi_login"
if host == "localhost:5000" {
host = "https://devcpone.aplikasi.web.id"
}
uri := host + "/one-api/v1/system/auth/multi_login"
params := url.Values{}
params.Add("username", username)