This commit is contained in:
eson
2023-06-08 18:55:08 +08:00
parent 8c3ce4e896
commit 73e1fd09aa
8 changed files with 66 additions and 24 deletions

View File

@@ -30,6 +30,9 @@ func (l *UserAddressListLogic) UserAddressList(req *types.Request) (resp *types.
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
m := model.NewFsAddressModel(l.svcCtx.MysqlConn)
user := auth.GetUserInfoFormCtx(l.ctx)
if user.UserId == 0 {
return resp.SetStatus(basic.CodeUnAuth)
}
// model里设置了 返回值. 和 types 里的一至可以直接返回
data, err := m.FindDataAddressList(l.ctx, user.UserId)
if err != nil {

View File

@@ -0,0 +1,28 @@
package logic
import (
"testing"
)
func TestCaseAddressList(t *testing.T) {
// http.NewRequest("POST", "http://localhost:8888/user/login", body io.Reader)
// ses := requests.NewSession()
// tp := ses.Post("http://localhost:8888/user/login")
// resp, err := tp.SetBodyAuto(map[string]interface{}{
// "name": "devenv@sina.cn",
// "pwd": "$2y$13$6UFDMZQMEfqFYiNLpiUCi.B3fpvGEamPAjIgzUqv/u7jT05nB3pOC",
// }, requests.TypeFormData).Execute()
// if err != nil {
// panic(err)
// }
// log.Println(string(resp.Content()))
// resp, err = ses.Get("http://localhost:8888/user/address-list").Execute()
// if err != nil {
// panic(err)
// }
// log.Println(string(resp.Content()))
}