Update project from local
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package utils
|
||||
|
||||
import "strings"
|
||||
|
||||
func Contains(s, substr string) bool {
|
||||
return strings.Contains(strings.ToLower(s), strings.ToLower(substr))
|
||||
}
|
||||
package utils
|
||||
|
||||
import "strings"
|
||||
|
||||
func Contains(s, substr string) bool {
|
||||
return strings.Contains(strings.ToLower(s), strings.ToLower(substr))
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"golang.org/x/text/language"
|
||||
"golang.org/x/text/message"
|
||||
)
|
||||
|
||||
func FormatRibuan(amount int) string {
|
||||
p := message.NewPrinter(language.Indonesian)
|
||||
formated := p.Sprintf("%v", amount)
|
||||
return formated
|
||||
}
|
||||
package utils
|
||||
|
||||
import (
|
||||
"golang.org/x/text/language"
|
||||
"golang.org/x/text/message"
|
||||
)
|
||||
|
||||
func FormatRibuan(amount int) string {
|
||||
p := message.NewPrinter(language.Indonesian)
|
||||
formated := p.Sprintf("%v", amount)
|
||||
return formated
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GenerateRandomID(text string) string {
|
||||
seed := text + time.Now().String()
|
||||
hash := md5.Sum([]byte(seed))
|
||||
randomID := hex.EncodeToString(hash[:])
|
||||
randomID = strings.ReplaceAll(randomID, "-", "")
|
||||
return "sas" + randomID
|
||||
}
|
||||
package utils
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GenerateRandomID(text string) string {
|
||||
seed := text + time.Now().String()
|
||||
hash := md5.Sum([]byte(seed))
|
||||
randomID := hex.EncodeToString(hash[:])
|
||||
randomID = strings.ReplaceAll(randomID, "-", "")
|
||||
return "sas" + randomID
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/gommon/log"
|
||||
)
|
||||
|
||||
func GetJSONRawBody(c echo.Context) map[string]interface{} {
|
||||
|
||||
jsonBody := make(map[string]interface{})
|
||||
err := json.NewDecoder(c.Request().Body).Decode(&jsonBody)
|
||||
if err != nil {
|
||||
|
||||
log.Error("empty json body")
|
||||
return nil
|
||||
}
|
||||
|
||||
return jsonBody
|
||||
}
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/gommon/log"
|
||||
)
|
||||
|
||||
func GetJSONRawBody(c echo.Context) map[string]interface{} {
|
||||
|
||||
jsonBody := make(map[string]interface{})
|
||||
err := json.NewDecoder(c.Request().Body).Decode(&jsonBody)
|
||||
if err != nil {
|
||||
|
||||
log.Error("empty json body")
|
||||
return nil
|
||||
}
|
||||
|
||||
return jsonBody
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func SplitStrings(text string, count int) string {
|
||||
words := strings.Split(text, " ")
|
||||
var result strings.Builder
|
||||
|
||||
for i := 0; i < len(words); i += count {
|
||||
if i+count < len(words) {
|
||||
result.WriteString(strings.Join(words[i:i+count], " ") + "\n")
|
||||
} else {
|
||||
result.WriteString(strings.Join(words[i:], " "))
|
||||
}
|
||||
}
|
||||
|
||||
return result.String()
|
||||
}
|
||||
package utils
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func SplitStrings(text string, count int) string {
|
||||
words := strings.Split(text, " ")
|
||||
var result strings.Builder
|
||||
|
||||
for i := 0; i < len(words); i += count {
|
||||
if i+count < len(words) {
|
||||
result.WriteString(strings.Join(words[i:i+count], " ") + "\n")
|
||||
} else {
|
||||
result.WriteString(strings.Join(words[i:], " "))
|
||||
}
|
||||
}
|
||||
|
||||
return result.String()
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"cpone/models"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetIdSurveyMcu(id string) string {
|
||||
return id
|
||||
}
|
||||
|
||||
func ConcatHxIncludeSurveyMcu(dataSurveyMcu []models.SurveyMcu) string {
|
||||
var elements []string
|
||||
|
||||
if len(dataSurveyMcu) > 0 {
|
||||
for _, x := range dataSurveyMcu {
|
||||
// radio button
|
||||
if len(x.DataListItemSurveyMcu) > 0 {
|
||||
for _, v := range x.DataListItemSurveyMcu {
|
||||
elements = append(elements, "[name='radio-"+v.IDItemSurvey+"']", "[name='default-radio-"+v.IDItemSurvey+"']", "[name='id-radio']")
|
||||
}
|
||||
}
|
||||
|
||||
// saran
|
||||
if len(x.DataListItemSurveyMcuSaran) > 0 {
|
||||
for _, v := range x.DataListItemSurveyMcuSaran {
|
||||
elements = append(elements, "[name='saranmcu-"+v.IDItemSurveyMcuSaran+"']", "[name='default-saranmcu-"+v.IDItemSurveyMcuSaran+"']", "[name='id-saran']")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Gabungkan semua elemen dengan koma
|
||||
return strings.Join(elements, ", ")
|
||||
}
|
||||
package utils
|
||||
|
||||
import (
|
||||
"cpone/models"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetIdSurveyMcu(id string) string {
|
||||
return id
|
||||
}
|
||||
|
||||
func ConcatHxIncludeSurveyMcu(dataSurveyMcu []models.SurveyMcu) string {
|
||||
var elements []string
|
||||
|
||||
if len(dataSurveyMcu) > 0 {
|
||||
for _, x := range dataSurveyMcu {
|
||||
// radio button
|
||||
if len(x.DataListItemSurveyMcu) > 0 {
|
||||
for _, v := range x.DataListItemSurveyMcu {
|
||||
elements = append(elements, "[name='radio-"+v.IDItemSurvey+"']", "[name='default-radio-"+v.IDItemSurvey+"']", "[name='id-radio']")
|
||||
}
|
||||
}
|
||||
|
||||
// saran
|
||||
if len(x.DataListItemSurveyMcuSaran) > 0 {
|
||||
for _, v := range x.DataListItemSurveyMcuSaran {
|
||||
elements = append(elements, "[name='saranmcu-"+v.IDItemSurveyMcuSaran+"']", "[name='default-saranmcu-"+v.IDItemSurveyMcuSaran+"']", "[name='id-saran']")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Gabungkan semua elemen dengan koma
|
||||
return strings.Join(elements, ", ")
|
||||
}
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func ViewMulti(c echo.Context, cmp []templ.Component) error {
|
||||
var stringHtml string = ""
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
var err error
|
||||
for _, x := range cmp {
|
||||
err = x.Render(c.Request().Context(), buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
stringHtml += buf.String()
|
||||
}
|
||||
|
||||
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
|
||||
|
||||
return c.String(http.StatusOK, stringHtml)
|
||||
|
||||
}
|
||||
|
||||
func View(c echo.Context, cmp templ.Component) error {
|
||||
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
|
||||
|
||||
return cmp.Render(c.Request().Context(), c.Response().Writer)
|
||||
}
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func ViewMulti(c echo.Context, cmp []templ.Component) error {
|
||||
var stringHtml string = ""
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
var err error
|
||||
for _, x := range cmp {
|
||||
err = x.Render(c.Request().Context(), buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
stringHtml += buf.String()
|
||||
}
|
||||
|
||||
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
|
||||
|
||||
return c.String(http.StatusOK, stringHtml)
|
||||
|
||||
}
|
||||
|
||||
func View(c echo.Context, cmp templ.Component) error {
|
||||
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
|
||||
|
||||
return cmp.Render(c.Request().Context(), c.Response().Writer)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user