add change password pic and pat service and handler
This commit is contained in:
102
services/corporate/account.services.go
Normal file
102
services/corporate/account.services.go
Normal file
@@ -0,0 +1,102 @@
|
||||
package corporate_services
|
||||
|
||||
import (
|
||||
"cpone/db"
|
||||
"cpone/models"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type AccountService struct {
|
||||
AccountStore db.AppStore
|
||||
}
|
||||
|
||||
func NewAccountService(aStore db.AppStore) *AccountService {
|
||||
return &AccountService{
|
||||
AccountStore: aStore,
|
||||
}
|
||||
}
|
||||
|
||||
func (as *AccountService) ChangePasswordPIC(token string, currPassword string, newPassword string) (models.ResponseStatus, error) {
|
||||
var ret models.ResponseStatus
|
||||
|
||||
uri := "/one-api/mockup/system/menu/change_password_pic"
|
||||
|
||||
params := url.Values{}
|
||||
params.Add("new", newPassword)
|
||||
params.Add("old", currPassword)
|
||||
params.Add("token", token)
|
||||
|
||||
req, err := http.PostForm(uri, params)
|
||||
if err != nil {
|
||||
ret = models.ResponseStatus{
|
||||
Status: "ERR",
|
||||
Message: "error request change password",
|
||||
}
|
||||
return ret, err
|
||||
}
|
||||
defer req.Body.Close()
|
||||
|
||||
resp, err := io.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
ret = models.ResponseStatus{
|
||||
Status: "ERR",
|
||||
Message: "error read response",
|
||||
}
|
||||
return ret, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &ret)
|
||||
if err != nil {
|
||||
ret = models.ResponseStatus{
|
||||
Status: "ERR",
|
||||
Message: "error unmarshal response",
|
||||
}
|
||||
return ret, err
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (as *AccountService) ChangePasswordPAT(token string, currPassword string, newPassword string) (models.ResponseStatus, error) {
|
||||
var ret models.ResponseStatus
|
||||
|
||||
uri := "/one-api/mockup/system/menu/change_password_pat"
|
||||
|
||||
params := url.Values{}
|
||||
params.Add("new", newPassword)
|
||||
params.Add("old", currPassword)
|
||||
params.Add("token", token)
|
||||
|
||||
req, err := http.PostForm(uri, params)
|
||||
if err != nil {
|
||||
ret = models.ResponseStatus{
|
||||
Status: "ERR",
|
||||
Message: "error request change password",
|
||||
}
|
||||
return ret, err
|
||||
}
|
||||
defer req.Body.Close()
|
||||
|
||||
resp, err := io.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
ret = models.ResponseStatus{
|
||||
Status: "ERR",
|
||||
Message: "error read response",
|
||||
}
|
||||
return ret, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &ret)
|
||||
if err != nil {
|
||||
ret = models.ResponseStatus{
|
||||
Status: "ERR",
|
||||
Message: "error unmarshal response",
|
||||
}
|
||||
return ret, err
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
@@ -196,14 +196,15 @@ func (tkf *TabKelainanFisikServices) GetKelainanFisikPresentase(mcuID string) (m
|
||||
count(distinct T_OrderHeaderID) as total
|
||||
FROM t_kelainan_fisik
|
||||
JOIN t_orderheader ON T_KelainanFiskT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN mcu_summaryfisik ON T_KelainanFiskMcu_SummaryFisikID = Mcu_SummaryFisikID
|
||||
JOIN mcu_summaryfisik ON T_KelainanFiskMcu_SummaryFisikID = Mcu_SummaryFisikID AND
|
||||
Mcu_SummaryFisikID NOT IN (63,67,68,69,70,71,72,73)
|
||||
join mcu_kelainan on Mcu_SummaryFisikMcu_KelainanID = Mcu_KelainanID
|
||||
join mcu_kelainangroup on Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID
|
||||
where T_KelainanFiskIsActive = 'Y' and T_OrderHeaderMgm_McuID = ? AND
|
||||
Mcu_KelainanClasification NOT IN ('who','kemenkes','JNC-VIII','ESC/ESH')
|
||||
group by Mcu_KelainanID
|
||||
ORDER BY total DESC
|
||||
LIMIt 10
|
||||
LIMIT 10
|
||||
`
|
||||
if err := dbx.Handlex.Select(&data, q, mcuID); err != nil {
|
||||
return option, fmt.Errorf("error get data kelainan fisik: %v", err)
|
||||
|
||||
@@ -262,10 +262,12 @@ func (tkg *TabKelainanGlobalServices) GetKelainanGlobalV2(mcuID string) (models.
|
||||
count(distinct T_OrderHeaderID) as Total
|
||||
FROM t_kelainan_fisik
|
||||
JOIN t_orderheader ON T_KelainanFiskT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN mcu_summaryfisik ON T_KelainanFiskMcu_SummaryFisikID = Mcu_SummaryFisikID
|
||||
JOIN mcu_summaryfisik ON T_KelainanFiskMcu_SummaryFisikID = Mcu_SummaryFisikID AND
|
||||
Mcu_SummaryFisikID NOT IN (63,67,68,69,70,71,72,73)
|
||||
join mcu_kelainan on Mcu_SummaryFisikMcu_KelainanID = Mcu_KelainanID
|
||||
join mcu_kelainangroup on Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID
|
||||
where T_KelainanFiskIsActive = 'Y' and T_OrderHeaderMgm_McuID = ?
|
||||
where T_KelainanFiskIsActive = 'Y' and T_OrderHeaderMgm_McuID = ? AND
|
||||
Mcu_KelainanClasification NOT IN ('who','kemenkes','JNC-VIII','ESC/ESH')
|
||||
group by Mcu_KelainanID
|
||||
) a
|
||||
|
||||
|
||||
@@ -289,11 +289,13 @@ func (tks *TabKesimpulanServices) GetListKesimpulanFisikV2(id string) ([]models.
|
||||
count(distinct T_OrderHeaderID) as total
|
||||
FROM t_kelainan_fisik
|
||||
JOIN t_orderheader ON T_KelainanFiskT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN mcu_summaryfisik ON T_KelainanFiskMcu_SummaryFisikID = Mcu_SummaryFisikID
|
||||
JOIN mcu_summaryfisik ON T_KelainanFiskMcu_SummaryFisikID = Mcu_SummaryFisikID AND
|
||||
Mcu_SummaryFisikID NOT IN (63,67,68,69,70,71,72,73)
|
||||
join mcu_kelainan on Mcu_SummaryFisikMcu_KelainanID = Mcu_KelainanID
|
||||
join mcu_kelainangroup on Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID
|
||||
where T_KelainanFiskIsActive = 'Y' and T_OrderHeaderMgm_McuID = ?
|
||||
group by Mcu_KelainanID
|
||||
where T_KelainanFiskIsActive = 'Y' and T_OrderHeaderMgm_McuID = ? AND
|
||||
Mcu_KelainanClasification NOT IN ('who','kemenkes','JNC-VIII','ESC/ESH')
|
||||
group by Mcu_KelainanID
|
||||
ORDER BY total DESC
|
||||
LIMIT 3
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user