Giter Site home page Giter Site logo

comunion-backend's Introduction

Ceres

The Comunion business backend service.

Projects

We have chosen the ego to support the config and other common behaviors of web project. Fistly, you have to read the documents of Ego seriously.

The user interface API we will support as HTTP APIs, and the eth event will be trigger from other service by gRpc interfaces.

Pleas see more informations at Implementation Notes

Description

Comunion Backend Service

References

EGO

HomePage

GORM

HomePage

Running the app

# development
$ go run main.go

Project structure

├── config (Config)
│   ├── local.toml
├── logs (Log)
├── pkg (Source codes)
│   ├── invoker
│   ├── model (DB models)
│   │   ├── dto
│   │   ├── mysql
│   │   └── transport
│   └── router (API routers)
├── .gitignore
├── go.mod (modules)
├── go.sum
├── main.go (main)
├── README.md

Manual to devlop

router

// pkg/router/router.go
r.GET("/api/enums/:id", core.Handle(api.EnumInfo))

handler

// pkg/router/api/enum.go
func EnumInfo(c *core.Context) {
	id := cast.ToInt(c.Param("id"))
	if id == 0 {
		c.JSONE(1, "bad request", nil)
		return
	}
	info, _ := mysql.EnumInfo(invoker.Db, id)
	c.JSONOK(info)
}

model

// pkg/model/mysql/enum.go
type Enum struct {
	Id int `gorm:"AUTO_INCREMENT;comment:'id'"`
	GroupKey string `gorm:"not null;comment:'unique key'"`
	GroupTitle string `gorm:"not null;comment:'group title'"`
	Key int `gorm:"not null;comment:'key'"`
	Title string `gorm:"not null;comment:'title'"`
	Ctime int64 `gorm:"not null;comment:'created at'"`
	Utime int64 `gorm:"not null;comment:'updated at'"`
	Dtime int64 `gorm:"not null;comment:'deleted at'"`
	
}

query

// pkg/model/mysql/enum.go
func EnumInfo(db *gorm.DB, paramId int) (resp Enum, err error) {
	var sql = "`id`= ?"
	var binds = []interface{}{paramId}

	if err = db.Model(Enum{}).Where(sql, binds...).First(&resp).Error; err != nil {
		invoker.Logger.Error("enum info error", zap.Error(err))
		return
	}
	return
}

dto (optional)

// pkg/model/dto/enum.go
type EnumCreate struct {
	Id int `json:"id" binding:""` // id
	GroupKey string `json:"groupKey" binding:""` // group key
	GroupTitle string `json:"groupTitle" binding:""` // group title
	Key int `json:"key" binding:""` // key
	Title string `json:"title" binding:""` // title
}

comunion-backend's People

Contributors

wujunze avatar erguotou520 avatar nigelvon avatar

Watchers

James Cloos avatar

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.