框架基本搭建完成

This commit is contained in:
2022-04-03 12:30:50 +08:00
commit ec4c957b25
31 changed files with 1353 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
package controller
import (
"drive-linked/pkg/dto"
"drive-linked/pkg/service"
"encoding/json"
"github.com/kataras/iris/v12"
"io/ioutil"
"net/http"
)
func UserProfile(ctx iris.Context) {
serv := service.NewUsersService(ctx)
switch ctx.Request().Method {
// GET
case http.MethodGet:
serv.GetOneUser(ctx.Params().GetString("name"), service.MethodUserName)
return
// POST
case http.MethodPost:
//TODO:错误处理
body, err := ioutil.ReadAll(ctx.Request().Body)
if err != nil {
return
}
var req dto.QueryUser
err = json.Unmarshal(body, &req)
if err != nil {
return
}
serv.GetOneUser(req.Value, req.Method)
return
}
}