Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
		
						commit
						178cda5402
					
				@ -9,7 +9,6 @@ import (
 | 
				
			|||||||
	"fusenapi/utils/fssql"
 | 
						"fusenapi/utils/fssql"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/zeromicro/go-zero/core/logx"
 | 
					 | 
				
			||||||
	"gorm.io/gorm"
 | 
						"gorm.io/gorm"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -222,7 +221,7 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
 | 
				
			|||||||
					Utime:    &now,
 | 
										Utime:    &now,
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				logx.Error(metadata)
 | 
									// logx.Error(metadata)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				err = txUserInfo.Where("module = 'profile' and user_id = ?", *uinfo.UserId).Take(nil).Error
 | 
									err = txUserInfo.Where("module = 'profile' and user_id = ?", *uinfo.UserId).Take(nil).Error
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
 | 
				
			|||||||
@ -49,7 +49,7 @@ func (l *UserAddAddressLogic) UserAddAddress(req *types.RequestAddAddress, useri
 | 
				
			|||||||
			isDefautl int64  = 1     // 默认地址为1
 | 
								isDefautl int64  = 1     // 默认地址为1
 | 
				
			||||||
		)
 | 
							)
 | 
				
			||||||
		createOne := &gmodel.FsAddress{ // 构建FsAddress结构体
 | 
							createOne := &gmodel.FsAddress{ // 构建FsAddress结构体
 | 
				
			||||||
			Name:      &req.Name,
 | 
								AddressName: &req.Name,
 | 
				
			||||||
			FirstName:   &req.FirstName,
 | 
								FirstName:   &req.FirstName,
 | 
				
			||||||
			LastName:    &req.LastName,
 | 
								LastName:    &req.LastName,
 | 
				
			||||||
			Mobile:      &req.Mobile,
 | 
								Mobile:      &req.Mobile,
 | 
				
			||||||
@ -68,12 +68,12 @@ func (l *UserAddAddressLogic) UserAddAddress(req *types.RequestAddAddress, useri
 | 
				
			|||||||
			logx.Error(err)                              // 日志记录错误
 | 
								logx.Error(err)                              // 日志记录错误
 | 
				
			||||||
			return resp.SetStatus(basic.CodeDbCreateErr) // 返回数据库创建错误
 | 
								return resp.SetStatus(basic.CodeDbCreateErr) // 返回数据库创建错误
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return resp.SetStatus(basic.CodeOK, map[string]int64{"id": created.Id}) // 返回成功并返回地址ID
 | 
							return resp.SetStatus(basic.CodeOK, map[string]int64{"id": created.AddressId}) // 返回成功并返回地址ID
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	address := &gmodel.FsAddress{
 | 
						address := &gmodel.FsAddress{
 | 
				
			||||||
		Id:        req.Id,
 | 
							AddressId:   req.Id,
 | 
				
			||||||
		Name:      &req.Name,
 | 
							AddressName: &req.Name,
 | 
				
			||||||
		FirstName:   &req.FirstName,
 | 
							FirstName:   &req.FirstName,
 | 
				
			||||||
		LastName:    &req.LastName,
 | 
							LastName:    &req.LastName,
 | 
				
			||||||
		Mobile:      &req.Mobile,
 | 
							Mobile:      &req.Mobile,
 | 
				
			||||||
@ -94,5 +94,5 @@ func (l *UserAddAddressLogic) UserAddAddress(req *types.RequestAddAddress, useri
 | 
				
			|||||||
		return resp.SetStatus(basic.CodeDbUpdateErr)
 | 
							return resp.SetStatus(basic.CodeDbUpdateErr)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return resp.SetStatus(basic.CodeOK, map[string]int64{"id": address.Id})
 | 
						return resp.SetStatus(basic.CodeOK, map[string]int64{"id": address.AddressId})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										35
									
								
								server/info/internal/handler/addressaddhandler.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								server/info/internal/handler/addressaddhandler.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					package handler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"net/http"
 | 
				
			||||||
 | 
						"reflect"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"fusenapi/utils/basic"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/logic"
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/svc"
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/types"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func AddressAddHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 | 
				
			||||||
 | 
						return func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							var req types.AddressNameRequest
 | 
				
			||||||
 | 
							userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 创建一个业务逻辑层实例
 | 
				
			||||||
 | 
							l := logic.NewAddressAddLogic(r.Context(), svcCtx)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							rl := reflect.ValueOf(l)
 | 
				
			||||||
 | 
							basic.BeforeLogic(w, r, rl)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							resp := l.AddressAdd(&req, userinfo)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if !basic.AfterLogic(w, r, rl, resp) {
 | 
				
			||||||
 | 
								basic.NormalAfterLogic(w, r, resp)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										35
									
								
								server/info/internal/handler/addressdefaulthandler.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								server/info/internal/handler/addressdefaulthandler.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					package handler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"net/http"
 | 
				
			||||||
 | 
						"reflect"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"fusenapi/utils/basic"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/logic"
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/svc"
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/types"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func AddressDefaultHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 | 
				
			||||||
 | 
						return func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							var req types.AddressIdRequest
 | 
				
			||||||
 | 
							userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 创建一个业务逻辑层实例
 | 
				
			||||||
 | 
							l := logic.NewAddressDefaultLogic(r.Context(), svcCtx)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							rl := reflect.ValueOf(l)
 | 
				
			||||||
 | 
							basic.BeforeLogic(w, r, rl)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							resp := l.AddressDefault(&req, userinfo)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if !basic.AfterLogic(w, r, rl, resp) {
 | 
				
			||||||
 | 
								basic.NormalAfterLogic(w, r, resp)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										35
									
								
								server/info/internal/handler/addressdeletehandler.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								server/info/internal/handler/addressdeletehandler.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					package handler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"net/http"
 | 
				
			||||||
 | 
						"reflect"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"fusenapi/utils/basic"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/logic"
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/svc"
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/types"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func AddressDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 | 
				
			||||||
 | 
						return func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							var req types.AddressIdRequest
 | 
				
			||||||
 | 
							userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 创建一个业务逻辑层实例
 | 
				
			||||||
 | 
							l := logic.NewAddressDeleteLogic(r.Context(), svcCtx)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							rl := reflect.ValueOf(l)
 | 
				
			||||||
 | 
							basic.BeforeLogic(w, r, rl)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							resp := l.AddressDelete(&req, userinfo)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if !basic.AfterLogic(w, r, rl, resp) {
 | 
				
			||||||
 | 
								basic.NormalAfterLogic(w, r, resp)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										35
									
								
								server/info/internal/handler/addressupdatehandler.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								server/info/internal/handler/addressupdatehandler.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					package handler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"net/http"
 | 
				
			||||||
 | 
						"reflect"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"fusenapi/utils/basic"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/logic"
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/svc"
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/types"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func AddressUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 | 
				
			||||||
 | 
						return func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							var req types.AddressObjectRequest
 | 
				
			||||||
 | 
							userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 创建一个业务逻辑层实例
 | 
				
			||||||
 | 
							l := logic.NewAddressUpdateLogic(r.Context(), svcCtx)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							rl := reflect.ValueOf(l)
 | 
				
			||||||
 | 
							basic.BeforeLogic(w, r, rl)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							resp := l.AddressUpdate(&req, userinfo)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if !basic.AfterLogic(w, r, rl, resp) {
 | 
				
			||||||
 | 
								basic.NormalAfterLogic(w, r, resp)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -17,6 +17,26 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 | 
				
			|||||||
				Path:    "/api/info/user",
 | 
									Path:    "/api/info/user",
 | 
				
			||||||
				Handler: InfoHandler(serverCtx),
 | 
									Handler: InfoHandler(serverCtx),
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									Method:  http.MethodPost,
 | 
				
			||||||
 | 
									Path:    "/api/info/address/default",
 | 
				
			||||||
 | 
									Handler: AddressDefaultHandler(serverCtx),
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									Method:  http.MethodPost,
 | 
				
			||||||
 | 
									Path:    "/api/info/address/add",
 | 
				
			||||||
 | 
									Handler: AddressAddHandler(serverCtx),
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									Method:  http.MethodPost,
 | 
				
			||||||
 | 
									Path:    "/api/info/address/update",
 | 
				
			||||||
 | 
									Handler: AddressUpdateHandler(serverCtx),
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									Method:  http.MethodPost,
 | 
				
			||||||
 | 
									Path:    "/api/info/address/delete",
 | 
				
			||||||
 | 
									Handler: AddressDeleteHandler(serverCtx),
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										43
									
								
								server/info/internal/logic/addressaddlogic.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								server/info/internal/logic/addressaddlogic.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,43 @@
 | 
				
			|||||||
 | 
					package logic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"fusenapi/utils/auth"
 | 
				
			||||||
 | 
						"fusenapi/utils/basic"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/svc"
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/types"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/logx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type AddressAddLogic struct {
 | 
				
			||||||
 | 
						logx.Logger
 | 
				
			||||||
 | 
						ctx    context.Context
 | 
				
			||||||
 | 
						svcCtx *svc.ServiceContext
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewAddressAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddressAddLogic {
 | 
				
			||||||
 | 
						return &AddressAddLogic{
 | 
				
			||||||
 | 
							Logger: logx.WithContext(ctx),
 | 
				
			||||||
 | 
							ctx:    ctx,
 | 
				
			||||||
 | 
							svcCtx: svcCtx,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 处理进入前逻辑w,r
 | 
				
			||||||
 | 
					// func (l *AddressAddLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
					// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (l *AddressAddLogic) AddressAdd(req *types.AddressNameRequest, userinfo *auth.UserInfo) (resp *basic.Response) {
 | 
				
			||||||
 | 
						// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
 | 
				
			||||||
 | 
						// userinfo 传入值时, 一定不为null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return resp.SetStatus(basic.CodeOK)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
 | 
				
			||||||
 | 
					// func (l *AddressAddLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
 | 
				
			||||||
 | 
					// // httpx.OkJsonCtx(r.Context(), w, resp)
 | 
				
			||||||
 | 
					// }
 | 
				
			||||||
							
								
								
									
										43
									
								
								server/info/internal/logic/addressdefaultlogic.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								server/info/internal/logic/addressdefaultlogic.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,43 @@
 | 
				
			|||||||
 | 
					package logic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"fusenapi/utils/auth"
 | 
				
			||||||
 | 
						"fusenapi/utils/basic"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/svc"
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/types"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/logx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type AddressDefaultLogic struct {
 | 
				
			||||||
 | 
						logx.Logger
 | 
				
			||||||
 | 
						ctx    context.Context
 | 
				
			||||||
 | 
						svcCtx *svc.ServiceContext
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewAddressDefaultLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddressDefaultLogic {
 | 
				
			||||||
 | 
						return &AddressDefaultLogic{
 | 
				
			||||||
 | 
							Logger: logx.WithContext(ctx),
 | 
				
			||||||
 | 
							ctx:    ctx,
 | 
				
			||||||
 | 
							svcCtx: svcCtx,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 处理进入前逻辑w,r
 | 
				
			||||||
 | 
					// func (l *AddressDefaultLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
					// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (l *AddressDefaultLogic) AddressDefault(req *types.AddressIdRequest, userinfo *auth.UserInfo) (resp *basic.Response) {
 | 
				
			||||||
 | 
						// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
 | 
				
			||||||
 | 
						// userinfo 传入值时, 一定不为null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return resp.SetStatus(basic.CodeOK)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
 | 
				
			||||||
 | 
					// func (l *AddressDefaultLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
 | 
				
			||||||
 | 
					// // httpx.OkJsonCtx(r.Context(), w, resp)
 | 
				
			||||||
 | 
					// }
 | 
				
			||||||
							
								
								
									
										43
									
								
								server/info/internal/logic/addressdeletelogic.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								server/info/internal/logic/addressdeletelogic.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,43 @@
 | 
				
			|||||||
 | 
					package logic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"fusenapi/utils/auth"
 | 
				
			||||||
 | 
						"fusenapi/utils/basic"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/svc"
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/types"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/logx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type AddressDeleteLogic struct {
 | 
				
			||||||
 | 
						logx.Logger
 | 
				
			||||||
 | 
						ctx    context.Context
 | 
				
			||||||
 | 
						svcCtx *svc.ServiceContext
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewAddressDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddressDeleteLogic {
 | 
				
			||||||
 | 
						return &AddressDeleteLogic{
 | 
				
			||||||
 | 
							Logger: logx.WithContext(ctx),
 | 
				
			||||||
 | 
							ctx:    ctx,
 | 
				
			||||||
 | 
							svcCtx: svcCtx,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 处理进入前逻辑w,r
 | 
				
			||||||
 | 
					// func (l *AddressDeleteLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
					// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (l *AddressDeleteLogic) AddressDelete(req *types.AddressIdRequest, userinfo *auth.UserInfo) (resp *basic.Response) {
 | 
				
			||||||
 | 
						// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
 | 
				
			||||||
 | 
						// userinfo 传入值时, 一定不为null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return resp.SetStatus(basic.CodeOK)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
 | 
				
			||||||
 | 
					// func (l *AddressDeleteLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
 | 
				
			||||||
 | 
					// // httpx.OkJsonCtx(r.Context(), w, resp)
 | 
				
			||||||
 | 
					// }
 | 
				
			||||||
							
								
								
									
										43
									
								
								server/info/internal/logic/addressupdatelogic.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								server/info/internal/logic/addressupdatelogic.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,43 @@
 | 
				
			|||||||
 | 
					package logic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"fusenapi/utils/auth"
 | 
				
			||||||
 | 
						"fusenapi/utils/basic"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/svc"
 | 
				
			||||||
 | 
						"fusenapi/server/info/internal/types"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/zeromicro/go-zero/core/logx"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type AddressUpdateLogic struct {
 | 
				
			||||||
 | 
						logx.Logger
 | 
				
			||||||
 | 
						ctx    context.Context
 | 
				
			||||||
 | 
						svcCtx *svc.ServiceContext
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewAddressUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddressUpdateLogic {
 | 
				
			||||||
 | 
						return &AddressUpdateLogic{
 | 
				
			||||||
 | 
							Logger: logx.WithContext(ctx),
 | 
				
			||||||
 | 
							ctx:    ctx,
 | 
				
			||||||
 | 
							svcCtx: svcCtx,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 处理进入前逻辑w,r
 | 
				
			||||||
 | 
					// func (l *AddressUpdateLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
					// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (l *AddressUpdateLogic) AddressUpdate(req *types.AddressObjectRequest, userinfo *auth.UserInfo) (resp *basic.Response) {
 | 
				
			||||||
 | 
						// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
 | 
				
			||||||
 | 
						// userinfo 传入值时, 一定不为null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return resp.SetStatus(basic.CodeOK)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
 | 
				
			||||||
 | 
					// func (l *AddressUpdateLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
 | 
				
			||||||
 | 
					// // httpx.OkJsonCtx(r.Context(), w, resp)
 | 
				
			||||||
 | 
					// }
 | 
				
			||||||
@ -39,6 +39,7 @@ func NewInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoLogic {
 | 
				
			|||||||
var ModuleTable map[string]string = map[string]string{
 | 
					var ModuleTable map[string]string = map[string]string{
 | 
				
			||||||
	"userinfo": "fs_user_info",
 | 
						"userinfo": "fs_user_info",
 | 
				
			||||||
	"material": "fs_user_material",
 | 
						"material": "fs_user_material",
 | 
				
			||||||
 | 
						"address":  "fs_address", // TODO: 地址列表
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ModuleQuery struct {
 | 
					type ModuleQuery struct {
 | 
				
			||||||
 | 
				
			|||||||
@ -9,6 +9,19 @@ type UserInfoRequest struct {
 | 
				
			|||||||
	Module []string `json:"module"`
 | 
						Module []string `json:"module"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type AddressObjectRequest struct {
 | 
				
			||||||
 | 
						AddressId int64  `json:"address_id"` // 地址id
 | 
				
			||||||
 | 
						Address   string `json:"address"`    // 地址
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type AddressIdRequest struct {
 | 
				
			||||||
 | 
						AddressId int64 `json:"address_id"` // 地址id
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type AddressNameRequest struct {
 | 
				
			||||||
 | 
						Address string `json:"address"` // 地址
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Request struct {
 | 
					type Request struct {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -32,10 +45,10 @@ type File struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Meta struct {
 | 
					type Meta struct {
 | 
				
			||||||
	TotalCount  int64 `json:"totalCount"`
 | 
						TotalCount  int64 `json:"total_count"`
 | 
				
			||||||
	PageCount   int64 `json:"pageCount"`
 | 
						PageCount   int64 `json:"page_count"`
 | 
				
			||||||
	CurrentPage int   `json:"currentPage"`
 | 
						CurrentPage int   `json:"current_page"`
 | 
				
			||||||
	PerPage     int   `json:"perPage"`
 | 
						PerPage     int   `json:"per_page"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Set 设置Response的Code和Message值
 | 
					// Set 设置Response的Code和Message值
 | 
				
			||||||
 | 
				
			|||||||
@ -12,10 +12,35 @@ import "basic.api"
 | 
				
			|||||||
service info {
 | 
					service info {
 | 
				
			||||||
	@handler InfoHandler
 | 
						@handler InfoHandler
 | 
				
			||||||
	post /api/info/user(UserInfoRequest) returns (response);
 | 
						post /api/info/user(UserInfoRequest) returns (response);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						@handler AddressDefaultHandler
 | 
				
			||||||
 | 
						post /api/info/address/default(AddressIdRequest) returns (response);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						@handler AddressAddHandler
 | 
				
			||||||
 | 
						post /api/info/address/add(AddressNameRequest) returns (response);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						@handler AddressUpdateHandler
 | 
				
			||||||
 | 
						post /api/info/address/update(AddressObjectRequest) returns (response);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						@handler AddressDeleteHandler
 | 
				
			||||||
 | 
						post /api/info/address/delete(AddressIdRequest) returns (response);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type (
 | 
					type (
 | 
				
			||||||
	UserInfoRequest {
 | 
						UserInfoRequest {
 | 
				
			||||||
		Module []string `json:"module"`
 | 
							Module []string `json:"module"`
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						AddressObjectRequest {
 | 
				
			||||||
 | 
							AddressId int64  `json:"address_id"` // 地址id
 | 
				
			||||||
 | 
							AddressName   string `json:"address_name"`    // 地址
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						AddressIdRequest {
 | 
				
			||||||
 | 
							AddressId int64 `json:"address_id"` // 地址id
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						AddressNameRequest {
 | 
				
			||||||
 | 
							AddressName string `json:"address_name"` // 地址
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user