Giter Club home page Giter Club logo

fc2-arquitetura-hexagonal's People

Contributors

allancordeiro avatar andersonluizpereira avatar argentinaluiz avatar liggitt avatar wesleywillians avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fc2-arquitetura-hexagonal's Issues

Duplicação do objeto no banco ao mudar status para enabled/disabled (Modulo Arquitetura Hexagonal)

Tarde pessoal,

na aula Enable e Disable Handlers e considerações finais do modulo, após a criação handler de disable e enable product, eu percebi que ele duplicava o registro no banco para arrumar isso e preciso arrumar no seguinte local:

PATH: /adapters/db/product.go

func (p *ProductDb) Save(product application.ProductInterface) (application.ProductInterface, error) {
	var rows int
	p.db.QueryRow(`select id from products where id=?`, product.GetID()).Scan(&rows)
	if rows == 0 {
		_, err := p.create(product)
		if err != nil {
			return nil, err
		}
	} else {
		_, err := p.update(product)
		if err != nil {
			return nil, err
		}
	}
	return product, nil
}

Desta forma vocês estão retornando o ID e na verdade querem um count(*) um quantidade de registros existente com aquele determinado ID, como esse select não faz um retorno do tipo int e sim um []string ele não consegue jogar o retorno na variável rows e o valor por padrão de um objeto declarado do tipo int e 0. Para arrumar esse comportamento sugiro essa alteração abaixo.

func (p *ProductDb) Save(product application.ProductInterface) (application.ProductInterface, error) {
	var rows int
	p.db.QueryRow(`select count(*) from products where id=?`, product.GetID()).Scan(&rows)
	if rows == 0 {
		_, err := p.create(product)
		if err != nil {
			return nil, err
		}
	} else {
		_, err := p.update(product)
		if err != nil {
			return nil, err
		}
	}
	return product, nil
}

Obrigado e até mais.

Erro ao realizar build do Dockerfile

Ao rodar

docker build .

Estou tendo o seguinte erro

[+] Building 12.0s (6/11)                                                                                                            
 => [internal] load build definition from Dockerfile                                                                            0.0s
 => => transferring dockerfile: 38B                                                                                             0.0s
 => [internal] load .dockerignore                                                                                               0.0s
 => => transferring context: 2B                                                                                                 0.0s
 => [internal] load metadata for docker.io/library/golang:1.16                                                                  1.6s
 => [1/8] FROM docker.io/library/golang:1.16@sha256:5f6a4662de3efc6d6bb812d02e9de3d8698eea16b8eb7281f03e6f3e8383018e            0.0s
 => CACHED [2/8] WORKDIR /go/src                                                                                                0.0s
 => ERROR [3/8] RUN go get -u github.com/spf13/cobra@latest &&     go install github.com/golang/mock/[email protected] &&     go  10.4s
------                                                                                                                               
 > [3/8] RUN go get -u github.com/spf13/cobra@latest &&     go install github.com/golang/mock/[email protected] &&     go install github.com/spf13/cobra-cli@latest:
#6 10.38 go get github.com/spf13/cobra@latest: module github.com/spf13/cobra: Get "https://proxy.golang.org/github.com/spf13/cobra/@v/list": dial tcp: lookup proxy.golang.org on 172.17.192.1:53: read udp 172.17.0.2:38208->172.17.192.1:53: i/o timeout
------
executor failed running [/bin/sh -c go get -u github.com/spf13/cobra@latest &&     go install github.com/golang/mock/[email protected] &&     go install github.com/spf13/cobra-cli@latest]: exit code: 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.