templates

package
v0.0.0-...-1d8daf6 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const ApiTmpl = `` /* 2721-byte string literal not displayed */
View Source
const EntityTmpl = `
package entity

import (
	"time"

	"github.com/golang/protobuf/ptypes"
	"github.com/mirzakhany/pm/protobuf/{{ .Pkg.NamePlural | lower }}"
)

type {{ .Pkg.Name }} struct {
	tableName struct{} ` + "`pg:\"{{ .Pkg.NamePlural | lower }},alias:{{ .Pkg.EntityAlias }}\"`" + ` //nolint
	ID        uint64   ` + "`pg:\",pk\"`" + `
	UUID      string   ` + "`pg:\"default:gen_random_uuid()\"`" + `
	Title     string
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (rm {{ .Pkg.Name }}) ToProto() *{{ .Pkg.NamePlural | lower }}.{{ .Pkg.Name }} {
	c, _ := ptypes.TimestampProto(rm.CreatedAt)
	u, _ := ptypes.TimestampProto(rm.UpdatedAt)

	{{ .Pkg.Name | lower }} := &{{ .Pkg.NamePlural | lower }}.{{ .Pkg.Name }}{
		Id:        rm.ID,
		Uuid:      rm.UUID,
		Title:     rm.Title,
		CreatedAt: c,
		UpdatedAt: u,
	}
	return {{ .Pkg.Name | lower }}
}

func {{ .Pkg.Name }}ToProtoList(rml []{{ .Pkg.Name }}) []*{{ .Pkg.NamePlural | lower }}.{{ .Pkg.Name }} {
	var r []*{{ .Pkg.NamePlural | lower }}.{{ .Pkg.Name }}
	for _, i := range rml {
		r = append(r, i.ToProto())
	}
	return r
}

func {{ .Pkg.Name }}FromProto({{ .Pkg.Name | lower }} *{{ .Pkg.NamePlural | lower }}.{{ .Pkg.Name }}) {{ .Pkg.Name }} {
	c, _ := ptypes.Timestamp({{ .Pkg.Name | lower }}.CreatedAt)
	u, _ := ptypes.Timestamp({{ .Pkg.Name | lower }}.UpdatedAt)

	return {{ .Pkg.Name }}{
		ID:        {{ .Pkg.Name | lower }}.Id,
		UUID:      {{ .Pkg.Name | lower }}.Uuid,
		Title:     {{ .Pkg.Name | lower }}.Title,
		CreatedAt: c,
		UpdatedAt: u,
	}
}

`
View Source
const ProtoTmpl = `` /* 2307-byte string literal not displayed */
View Source
const RepositoryTestTmpl = `` /* 1811-byte string literal not displayed */
View Source
const RepositoryTmpl = `` /* 3433-byte string literal not displayed */
View Source
const ServiceTestTmpl = `` /* 5867-byte string literal not displayed */
View Source
const ServiceTmpl = `` /* 4759-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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