This commit is contained in:
laodaming 2023-06-08 11:03:20 +08:00
parent e790be8c1a
commit a9e0f6b98e
18 changed files with 44 additions and 47 deletions

View File

@ -3,10 +3,9 @@ package main
import (
"flag"
"fmt"
"fusenapi/data-transfer/internal/config"
"fusenapi/data-transfer/internal/handler"
"fusenapi/data-transfer/internal/svc"
config2 "fusenapi/server/data-transfer/internal/config"
handler2 "fusenapi/server/data-transfer/internal/handler"
svc2 "fusenapi/server/data-transfer/internal/svc"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
@ -17,14 +16,14 @@ var configFile = flag.String("f", "etc/data-transfer.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
var c config2.Config
conf.MustLoad(*configFile, &c)
server := rest.MustNewServer(c.RestConf)
defer server.Stop()
ctx := svc.NewServiceContext(c)
handler.RegisterHandlers(server, ctx)
ctx := svc2.NewServiceContext(c)
handler2.RegisterHandlers(server, ctx)
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
server.Start()

View File

@ -1,12 +1,12 @@
package config
import (
"fusenapi/data-transfer/internal/types"
types2 "fusenapi/server/data-transfer/internal/types"
"github.com/zeromicro/go-zero/rest"
)
type Config struct {
rest.RestConf
SourceMysql string
Auth types.Auth
Auth types2.Auth
}

View File

@ -2,18 +2,17 @@ package handler
import (
"errors"
logic2 "fusenapi/server/data-transfer/internal/logic"
svc2 "fusenapi/server/data-transfer/internal/svc"
"net/http"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"fusenapi/data-transfer/internal/logic"
"fusenapi/data-transfer/internal/svc"
)
func GetStandardLogoListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
func GetStandardLogoListHandler(svcCtx *svc2.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
l := logic.NewGetStandardLogoListLogic(r.Context(), svcCtx)
l := logic2.NewGetStandardLogoListLogic(r.Context(), svcCtx)
resp := l.GetStandardLogoList()
if resp != nil {
httpx.OkJsonCtx(r.Context(), w, resp)

View File

@ -2,14 +2,13 @@
package handler
import (
svc2 "fusenapi/server/data-transfer/internal/svc"
"net/http"
"fusenapi/data-transfer/internal/svc"
"github.com/zeromicro/go-zero/rest"
)
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
func RegisterHandlers(server *rest.Server, serverCtx *svc2.ServiceContext) {
server.AddRoutes(
[]rest.Route{
{

View File

@ -2,9 +2,9 @@ package logic
import (
"context"
"fusenapi/data-transfer/internal/svc"
"fusenapi/data-transfer/internal/types"
"fusenapi/model"
svc2 "fusenapi/server/data-transfer/internal/svc"
types2 "fusenapi/server/data-transfer/internal/types"
"fusenapi/utils/basic"
"github.com/zeromicro/go-zero/core/logx"
@ -13,10 +13,10 @@ import (
type GetStandardLogoListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
svcCtx *svc2.ServiceContext
}
func NewGetStandardLogoListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetStandardLogoListLogic {
func NewGetStandardLogoListLogic(ctx context.Context, svcCtx *svc2.ServiceContext) *GetStandardLogoListLogic {
return &GetStandardLogoListLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
@ -25,16 +25,16 @@ func NewGetStandardLogoListLogic(ctx context.Context, svcCtx *svc.ServiceContext
}
// 获取标准logo列表
func (l *GetStandardLogoListLogic) GetStandardLogoList() (resp *types.Response) {
func (l *GetStandardLogoListLogic) GetStandardLogoList() (resp *types2.Response) {
standardLogoModel := model.NewFsStandardLogoModel(l.svcCtx.MysqlConn)
logoList, err := standardLogoModel.GetAll(l.ctx)
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get standard logo list")
}
list := make([]types.GetStandardLogoListRsp, 0, len(logoList))
list := make([]types2.GetStandardLogoListRsp, 0, len(logoList))
for _, v := range logoList {
list = append(list, types.GetStandardLogoListRsp{
list = append(list, types2.GetStandardLogoListRsp{
Id: v.Id,
Name: v.Name,
Url: v.Image,

View File

@ -1,17 +1,17 @@
package svc
import (
"fusenapi/data-transfer/internal/config"
config2 "fusenapi/server/data-transfer/internal/config"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
type ServiceContext struct {
Config config.Config
Config config2.Config
MysqlConn sqlx.SqlConn
}
func NewServiceContext(c config.Config) *ServiceContext {
func NewServiceContext(c config2.Config) *ServiceContext {
return &ServiceContext{
Config: c,
MysqlConn: sqlx.NewMysql(c.SourceMysql),

View File

@ -1,7 +1,7 @@
package config
import (
"fusenapi/product/internal/types"
"fusenapi/server/product/internal/types"
"github.com/zeromicro/go-zero/rest"
)

View File

@ -7,9 +7,9 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"fusenapi/product/internal/logic"
"fusenapi/product/internal/svc"
"fusenapi/product/internal/types"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
"fusenapi/server/product/internal/types"
)
func GetProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {

View File

@ -7,8 +7,8 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"fusenapi/product/internal/logic"
"fusenapi/product/internal/svc"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
)
func GetSizeByProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {

View File

@ -7,9 +7,9 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"fusenapi/product/internal/logic"
"fusenapi/product/internal/svc"
"fusenapi/product/internal/types"
"fusenapi/server/product/internal/logic"
"fusenapi/server/product/internal/svc"
"fusenapi/server/product/internal/types"
)
func GetSuccessRecommandHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {

View File

@ -4,7 +4,7 @@ package handler
import (
"net/http"
"fusenapi/product/internal/svc"
"fusenapi/server/product/internal/svc"
"github.com/zeromicro/go-zero/rest"
)

View File

@ -7,8 +7,8 @@ import (
"fmt"
"fusenapi/constants"
"fusenapi/model"
"fusenapi/product/internal/svc"
"fusenapi/product/internal/types"
"fusenapi/server/product/internal/svc"
"fusenapi/server/product/internal/types"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/format"

View File

@ -10,8 +10,8 @@ import (
"fusenapi/utils/format"
"strings"
"fusenapi/product/internal/svc"
"fusenapi/product/internal/types"
"fusenapi/server/product/internal/svc"
"fusenapi/server/product/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)

View File

@ -4,8 +4,8 @@ import (
"context"
"errors"
"fusenapi/model"
"fusenapi/product/internal/svc"
"fusenapi/product/internal/types"
"fusenapi/server/product/internal/svc"
"fusenapi/server/product/internal/types"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/image"

View File

@ -1,7 +1,7 @@
package svc
import (
"fusenapi/product/internal/config"
"fusenapi/server/product/internal/config"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)

View File

@ -4,9 +4,9 @@ import (
"flag"
"fmt"
"fusenapi/product/internal/config"
"fusenapi/product/internal/handler"
"fusenapi/product/internal/svc"
"fusenapi/server/product/internal/config"
"fusenapi/server/product/internal/handler"
"fusenapi/server/product/internal/svc"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"