port

package module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2023 License: MIT Imports: 13 Imported by: 0

README

portsafebackend

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func CompareNipp

func CompareNipp(MongoConn *mongo.Database, Colname, nipp string) bool

func DecodeGetRole

func DecodeGetRole(PublicKey, tokenStr string) (pay string, err error)

func DecodeGetRoleandUser

func DecodeGetRoleandUser(PublicKey, tokenStr string) (pay string, use string)

func DecodeGetUser

func DecodeGetUser(PublicKey, tokenStr string) (pay string, err error)

func DeleteReport

func DeleteReport(Mongoenv, publickey, dbname, colname string, r *http.Request) string

func DeleteReportData

func DeleteReportData(mongoconn *mongo.Database, colname, Repid string) (deletedid interface{}, err error)

func DeleteUser

func DeleteUser(Mongoconn *mongo.Database, colname, nipp string) (deleted interface{}, err error)

func DeleteUserforAdmin

func DeleteUserforAdmin(Mongoenv, publickey, dbname, colname string, r *http.Request) string

func EncodeWithRole

func EncodeWithRole(role, nipp, privatekey string) (string, error)

func GCFReturnStruct

func GCFReturnStruct(DataStuct any) string

func GetAllReport

func GetAllReport(PublicKey, Mongoenv, dbname, colname string, r *http.Request) string

func GetDataUserForAdmin

func GetDataUserForAdmin(PublicKey, MongoEnv, dbname, colname string, r *http.Request) string

func GetDataUserForAdmin2 added in v1.0.3

func GetDataUserForAdmin2(PublicKey, MongoEnv, dbname, colname string, r *http.Request) string

func GetOneReport

func GetOneReport(PublicKey, MongoEnv, dbname, colname string, r *http.Request) string

func HashPassword

func HashPassword(password string) (string, error)

func InsertDataReport

func InsertDataReport(Publickey, MongoEnv, dbname, colname string, r *http.Request) string

func InsertOneDoc

func InsertOneDoc(db *mongo.Database, collection string, doc interface{}) (insertedID interface{})

func InsertReport

func InsertReport(MongoConn *mongo.Database, colname string, rpt Report) (InsertedID interface{})

func InsertUserdata

func InsertUserdata(MongoConn *mongo.Database, nipp, nama, jabatan, divisi, bidang, password, role string) (InsertedID interface{})

func IsAdmin

func IsAdmin(Tokenstr, PublicKey string) bool

func IsUser

func IsUser(TokenStr, Publickey string) bool

func Login

func Login(Privatekey, MongoEnv, dbname, Colname string, r *http.Request) string

func PasswordValidator

func PasswordValidator(MongoConn *mongo.Database, colname string, userdata User) bool

func Register

func Register(Mongoenv, dbname string, r *http.Request) string

func ResetPassword

func ResetPassword(MongoEnv, publickey, dbname, colname string, r *http.Request) string

func SetConnection

func SetConnection(MongoString, dbname string) *mongo.Database

func TokenEncoder

func TokenEncoder(username, privatekey string) string

func UpdatePassword

func UpdatePassword(mongoconn *mongo.Database, user User) (Updatedid interface{})

func UpdateReport

func UpdateReport(Mongoconn *mongo.Database, ctx context.Context, emp Report) (UpdateId interface{}, err error)

Types

type Area

type Area struct {
	AreaId   string `json:"areaId" bson:"areaId"`
	AreaName string `json:"areaName" bson:"areaName"`
}

func GetAreaByName

func GetAreaByName(MongoConn *mongo.Database, areaName string) *Area

type Cred

type Cred struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
}

type Credential

type Credential struct {
	Status  bool   `json:"status" bson:"status"`
	Token   string `json:"token,omitempty" bson:"token,omitempty"`
	Message string `json:"message,omitempty" bson:"message,omitempty"`
}

type Location

type Location struct {
	LocationId   string `json:"locationId" bson:"locationId"`
	LocationName string `json:"locationName" bson:"locationName"`
}

func GetLocationByName

func GetLocationByName(MongoConn *mongo.Database, locationName string) *Location

type Payload

type Payload struct {
	User string    `json:"user"`
	Role string    `json:"role"`
	Exp  time.Time `json:"exp"`
	Iat  time.Time `json:"iat"`
	Nbf  time.Time `json:"nbf"`
}

func Decoder

func Decoder(publickey, tokenstr string) (payload Payload, err error)

type Report

type Report struct {
	Reportid             string                 `json:"reportid" bson:"reportid"`
	Date                 string                 `json:"date" bson:"date"`
	User                 User                   `json:"user" bson:"user,omitempty"`
	Location             Location               `json:"location" bson:"location"`
	Description          string                 `json:"description" bson:"description"`
	ObservationPhoto     string                 `json:"observationPhoto" bson:"observationPhoto"`
	TypeDangerousActions []TypeDangerousActions `json:"typeDangerousActions" bson:"typeDangerousActions,omitempty"`
	Area                 Area                   `json:"area" bson:"area"`
	ImmediateAction      string                 `json:"immediateAction" bson:"immediateAction"`
	ImprovementPhoto     string                 `json:"improvementPhoto" bson:"improvementPhoto"`
	CorrectiveAction     string                 `json:"correctiveAction" bson:"correctiveAction"`
}

func GetAllReportData

func GetAllReportData(Mongoconn *mongo.Database, colname string) []Report

func GetOneReportData

func GetOneReportData(mongoconn *mongo.Database, colname, Repid string) (dest Report)

type ReqUsers

type ReqUsers struct {
	Nipp string `json:"nipp"`
}

type RequestReport

type RequestReport struct {
	Reportid string `json:"reportid"`
}

type Response

type Response struct {
	Token string `json:"token,omitempty" bson:"token,omitempty"`
}

type ResponseBack

type ResponseBack struct {
	Status  int      `json:"status"`
	Message string   `json:"message"`
	Data    []string `json:"data"`
}

type ResponseDataUser

type ResponseDataUser struct {
	Status  bool   `json:"status" bson:"status"`
	Message string `json:"message,omitempty" bson:"message,omitempty"`
	Data    User   `json:"data,omitempty" bson:"data,omitempty"`
}

type ResponseEncode

type ResponseEncode struct {
	Message string `json:"message,omitempty" bson:"message,omitempty"`
	Token   string `json:"token,omitempty" bson:"token,omitempty"`
}

type ResponseReport

type ResponseReport struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
	Data    Report `json:"data"`
}

type ResponseReportBanyak

type ResponseReportBanyak struct {
	Status  int      `json:"status"`
	Message string   `json:"message"`
	Data    []Report `json:"data"`
}

type TypeDangerousActions

type TypeDangerousActions struct {
	TypeId   string   `json:"typeId" bson:"typeId"`
	TypeName string   `json:"typeName" bson:"typeName"`
	SubTypes []string `json:"subTypes" bson:"subTypes"`
}

type User

type User struct {
	Nipp     string `json:"nipp" bson:"nipp"`
	Nama     string `json:"nama" bson:"nama"`
	Jabatan  string `json:"jabatan" bson:"jabatan"`
	Divisi   string `json:"divisi" bson:"divisi"`
	Bidang   string `json:"bidang" bson:"bidang"`
	Password string `json:"password" bson:"password"`
	Role     string `json:"role,omitempty" bson:"role,omitempty"`
}

func GetAllUser

func GetAllUser(MongoConn *mongo.Database, colname string) []User

func GetOneUser

func GetOneUser(MongoConn *mongo.Database, colname string, userdata User) User

func GetOneUserByNipp

func GetOneUserByNipp(MongoConn *mongo.Database, colname, nipp string) (User, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL