YXY(yiSchool) platform HTTP API bindings, written in go, refactored from yxy. A monolithic service written using the go-zero framework.
- APP login stage simulation.
- Query school card balance and consumption records.
- Query electricity surplus, recharge and usage records.
- More...
-
Set up the
go-zero
development environment. reference -
Clone the repo.
git clone https://github.com/zjutjh/yxy-go.git
-
Modify
api/handler.tpl
template. referencepackage {{.PkgName}} import ( "net/http" "github.com/zeromicro/go-zero/rest/httpx" "yxy-go/pkg/response" {{.ImportPackages}} ) {{if .HasDoc}}{{.Doc}}{{end}} func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { {{if .HasRequest}}var req types.{{.RequestType}} if err := httpx.Parse(r, &req); err != nil { response.ParamErrorResponse(r, w, err) return } {{end}}l := {{.LogicName}}.New{{.LogicType}}(r.Context(), svcCtx) {{if .HasResp}}resp, {{end}}err := l.{{.Call}}({{if .HasRequest}}&req{{end}}) response.HttpResponse(r, w, resp, err) } }
-
Create or edit
.api
files in theapi
directory. reference -
Use
goctl
to automatically generate code. referencegoctl api go -api api/yxy.api -dir . --style goZero
-
Implement the business logic in the
internal/logic
directory.
Completely FREE software for learning only. Any inappropriate use is at your own risk.