go_model

package module
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2023 License: MIT Imports: 2 Imported by: 6 modules, 9 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Estructuras que utilizo con frecuencia en proyectos escritos en Go

ejemplo de uso en una tabla

func Patient() *go_model.Object {
	run_Global := input.RunGlobal{
		PlaceHolder: "ch ej: 13173472-7 dni ej: 12345678 ",
	}
	textOnly := input.TextOnly{}
	phoneNumber := input.Number{Pattern: `^[0-9]{7,11}$`}

	dateAge := input.DateAge{}

	t := model.Object{
		Noun:           "patient",
		TextFieldNames: []string{"patient_name"},
		Fields: []model.Field{
			
            {Name: "id_patient", DataType: "TEXT", Legend: "Id", Input: pkHiddenNoRequiredInView, NotRenderHtml: true},
			
            {Name: "patient_run", DataType: "TEXT", Unique: true, Legend: "Run o Dni", Input: run_Global},
			
            {Name: "patient_name", DataType: "TEXT", Legend: "Nombre y Apellido(s)", Input: textOnly},
			
            {Name: "patient_birthday", DataType: "TEXT", Legend: "Edad", Input: dateAge,},
			
            {Name: "patient_contact", DataType: "TEXT", Legend: "No Teléfono", Input: phoneNumber, SkipCompletionAllowed: true,Render: true},
			
            {Name: "patient_gender", DataType: "TEXT", Legend: "Genero", Input: radioGenero, SkipValidation: true},
			
            {Name: "patient_address", DataType: "TEXT", Legend: "Dirección", Input: textPointArea},
		},
	}

	return &t
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	// si el campo comienza com id_ se considera como único y perteneciente a una tabla específica ej: id_user su tabla es user
	// otros ej: id_usuario, apellido, address, city etc
	Name                  string
	Unique                bool   //campo único en db
	Inalterable           bool   //la data en el campo sera inalterable después de la creación (¡no se puede modificar!)
	Legend                string //como se mostrara al usuario el campo en el encabezado ej: "name" por "Nombre Usuario"
	Input                 input
	SkipValidation        bool //sin validar
	SkipCompletionAllowed bool //si el campo es requerido obligatoriamente o no

	NotRenderHtml bool // si no se necesita en formulario html

}

type Object

type Object struct {
	Name           string   //nombre del objeto o tabla
	TextFieldNames []string //nombre de campos mas representativos del objeto o tabla ej: nombre, apellido
	Fields         []Field  //campos del objeto
	//operaciones permitidas según nivel de acceso ej: 0,1,2,3,4 + Create bool, Update bool, Delete bool
	OperationsAllowed map[uint8]Permissions
}

func (*Object) Columns added in v0.0.16

func (o *Object) Columns() (columns []string)

func (*Object) FilterField added in v0.0.16

func (o *Object) FilterField(nameRequired string) (fielsOut Field)

func (*Object) FilterFields added in v0.0.1

func (o *Object) FilterFields(namesRequired ...string) (fielsOut []Field)

func (*Object) FilterRemoveFields added in v0.0.16

func (o *Object) FilterRemoveFields(namesToRemove ...string) (fielsOut []Field)

func (*Object) GetFieldByName added in v0.0.16

func (o *Object) GetFieldByName(nameRq string) (fielOut Field)

func (*Object) GetID added in v0.0.4

func (o *Object) GetID(data_search map[string]string) string

func (*Object) GetRepresentativeTextField added in v0.0.16

func (o *Object) GetRepresentativeTextField(data_element map[string]string) (values string)

func (*Object) MainName added in v0.0.16

func (o *Object) MainName() string

func (*Object) PrimaryKeyName added in v0.0.1

func (o *Object) PrimaryKeyName() string

func (*Object) RenderFields added in v0.0.16

func (o *Object) RenderFields() (fielsOut []Field)

func (*Object) RequiredFields added in v0.0.16

func (o *Object) RequiredFields() (fielsOut []Field)

type Permissions

type Permissions struct {
	Create bool
	Update bool
	Delete bool
}

type Request

type Request struct {
	//usuario que ejecuta la solicitud
	*User
	// paquetes de solicitud y respuesta
	Packages []*Response
}

type Response

type Response struct {
	Type    string              `json:"t,omitempty"` //tipo solicitud respuesta: create, read, update, delete o error
	Object  string              `json:"o,omitempty"` //nombre de la tabla u objeto controlador hacia donde va la solicitud
	Module  string              `json:"m,omitempty"` //nombre del modulo controlador hacia donde va la solicitud
	Message string              `json:"g,omitempty"` //mensaje para el usuario de la solicitud
	Data    []map[string]string `json:"d,omitempty"` //data entrada y respuesta json

	SkipMeInResponse bool     `json:"-"` //  saltarme al difundir
	Recipients       []string `json:"-"` // lista de ip, token o ids según app para el reenvió al finalizar solicitud
	TargetArea       bool     `json:"-"` // si es falso el destino por defecto es publico de lo contrario sera para todos quines tengan la misma area del usuario solicitante
}

type User added in v0.0.13

type User struct {
	Token          string // token de sesión solicitante
	Ip             string
	Name           string
	Area           byte  //0 sin area.. un que byte y uint8 son lo mismo en go la idea que aca sea un valor de carácter ej: a,s,p...
	AccessLevel    uint8 // aquí valor numérico 0 a 255
	Packages       chan []*Response
	LastConnection time.Time
}

Jump to

Keyboard shortcuts

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