Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 1.86 KB

README.md

File metadata and controls

60 lines (46 loc) · 1.86 KB

yxy-go

YXY(yiSchool) platform HTTP API bindings, written in go, refactored from yxy. A monolithic service written using the go-zero framework.


Features

  • APP login stage simulation.
  • Query school card balance and consumption records.
  • Query electricity surplus, recharge and usage records.
  • More...

Development

  1. Set up the go-zero development environment. reference

  2. Clone the repo.

    git clone https://github.com/zjutjh/yxy-go.git
  3. Modify api/handler.tpl template. reference

    package {{.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)
        }
    }
  4. Create or edit .api files in the api directory. reference

  5. Use goctl to automatically generate code. reference

    goctl api go -api api/yxy.api -dir . --style goZero
  6. Implement the business logic in the internal/logic directory.

Disclaimer

Completely FREE software for learning only. Any inappropriate use is at your own risk.