fix
This commit is contained in:
parent
e790be8c1a
commit
a9e0f6b98e
|
@ -3,10 +3,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
config2 "fusenapi/server/data-transfer/internal/config"
|
||||||
"fusenapi/data-transfer/internal/config"
|
handler2 "fusenapi/server/data-transfer/internal/handler"
|
||||||
"fusenapi/data-transfer/internal/handler"
|
svc2 "fusenapi/server/data-transfer/internal/svc"
|
||||||
"fusenapi/data-transfer/internal/svc"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/conf"
|
"github.com/zeromicro/go-zero/core/conf"
|
||||||
"github.com/zeromicro/go-zero/rest"
|
"github.com/zeromicro/go-zero/rest"
|
||||||
|
@ -17,14 +16,14 @@ var configFile = flag.String("f", "etc/data-transfer.yaml", "the config file")
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
var c config.Config
|
var c config2.Config
|
||||||
conf.MustLoad(*configFile, &c)
|
conf.MustLoad(*configFile, &c)
|
||||||
|
|
||||||
server := rest.MustNewServer(c.RestConf)
|
server := rest.MustNewServer(c.RestConf)
|
||||||
defer server.Stop()
|
defer server.Stop()
|
||||||
|
|
||||||
ctx := svc.NewServiceContext(c)
|
ctx := svc2.NewServiceContext(c)
|
||||||
handler.RegisterHandlers(server, ctx)
|
handler2.RegisterHandlers(server, ctx)
|
||||||
|
|
||||||
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
|
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
|
||||||
server.Start()
|
server.Start()
|
|
@ -1,12 +1,12 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fusenapi/data-transfer/internal/types"
|
types2 "fusenapi/server/data-transfer/internal/types"
|
||||||
"github.com/zeromicro/go-zero/rest"
|
"github.com/zeromicro/go-zero/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
rest.RestConf
|
rest.RestConf
|
||||||
SourceMysql string
|
SourceMysql string
|
||||||
Auth types.Auth
|
Auth types2.Auth
|
||||||
}
|
}
|
|
@ -2,18 +2,17 @@ package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
logic2 "fusenapi/server/data-transfer/internal/logic"
|
||||||
|
svc2 "fusenapi/server/data-transfer/internal/svc"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"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) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
l := logic.NewGetStandardLogoListLogic(r.Context(), svcCtx)
|
l := logic2.NewGetStandardLogoListLogic(r.Context(), svcCtx)
|
||||||
resp := l.GetStandardLogoList()
|
resp := l.GetStandardLogoList()
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
@ -2,14 +2,13 @@
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
svc2 "fusenapi/server/data-transfer/internal/svc"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"fusenapi/data-transfer/internal/svc"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest"
|
"github.com/zeromicro/go-zero/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
func RegisterHandlers(server *rest.Server, serverCtx *svc2.ServiceContext) {
|
||||||
server.AddRoutes(
|
server.AddRoutes(
|
||||||
[]rest.Route{
|
[]rest.Route{
|
||||||
{
|
{
|
|
@ -2,9 +2,9 @@ package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fusenapi/data-transfer/internal/svc"
|
|
||||||
"fusenapi/data-transfer/internal/types"
|
|
||||||
"fusenapi/model"
|
"fusenapi/model"
|
||||||
|
svc2 "fusenapi/server/data-transfer/internal/svc"
|
||||||
|
types2 "fusenapi/server/data-transfer/internal/types"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
@ -13,10 +13,10 @@ import (
|
||||||
type GetStandardLogoListLogic struct {
|
type GetStandardLogoListLogic struct {
|
||||||
logx.Logger
|
logx.Logger
|
||||||
ctx context.Context
|
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{
|
return &GetStandardLogoListLogic{
|
||||||
Logger: logx.WithContext(ctx),
|
Logger: logx.WithContext(ctx),
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
|
@ -25,16 +25,16 @@ func NewGetStandardLogoListLogic(ctx context.Context, svcCtx *svc.ServiceContext
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取标准logo列表
|
// 获取标准logo列表
|
||||||
func (l *GetStandardLogoListLogic) GetStandardLogoList() (resp *types.Response) {
|
func (l *GetStandardLogoListLogic) GetStandardLogoList() (resp *types2.Response) {
|
||||||
standardLogoModel := model.NewFsStandardLogoModel(l.svcCtx.MysqlConn)
|
standardLogoModel := model.NewFsStandardLogoModel(l.svcCtx.MysqlConn)
|
||||||
logoList, err := standardLogoModel.GetAll(l.ctx)
|
logoList, err := standardLogoModel.GetAll(l.ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get standard logo list")
|
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 {
|
for _, v := range logoList {
|
||||||
list = append(list, types.GetStandardLogoListRsp{
|
list = append(list, types2.GetStandardLogoListRsp{
|
||||||
Id: v.Id,
|
Id: v.Id,
|
||||||
Name: v.Name,
|
Name: v.Name,
|
||||||
Url: v.Image,
|
Url: v.Image,
|
|
@ -1,17 +1,17 @@
|
||||||
package svc
|
package svc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fusenapi/data-transfer/internal/config"
|
config2 "fusenapi/server/data-transfer/internal/config"
|
||||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ServiceContext struct {
|
type ServiceContext struct {
|
||||||
Config config.Config
|
Config config2.Config
|
||||||
|
|
||||||
MysqlConn sqlx.SqlConn
|
MysqlConn sqlx.SqlConn
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServiceContext(c config.Config) *ServiceContext {
|
func NewServiceContext(c config2.Config) *ServiceContext {
|
||||||
return &ServiceContext{
|
return &ServiceContext{
|
||||||
Config: c,
|
Config: c,
|
||||||
MysqlConn: sqlx.NewMysql(c.SourceMysql),
|
MysqlConn: sqlx.NewMysql(c.SourceMysql),
|
|
@ -1,7 +1,7 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fusenapi/product/internal/types"
|
"fusenapi/server/product/internal/types"
|
||||||
"github.com/zeromicro/go-zero/rest"
|
"github.com/zeromicro/go-zero/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
|
||||||
"fusenapi/product/internal/logic"
|
"fusenapi/server/product/internal/logic"
|
||||||
"fusenapi/product/internal/svc"
|
"fusenapi/server/product/internal/svc"
|
||||||
"fusenapi/product/internal/types"
|
"fusenapi/server/product/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func GetProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
|
||||||
"fusenapi/product/internal/logic"
|
"fusenapi/server/product/internal/logic"
|
||||||
"fusenapi/product/internal/svc"
|
"fusenapi/server/product/internal/svc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetSizeByProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func GetSizeByProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
|
||||||
"fusenapi/product/internal/logic"
|
"fusenapi/server/product/internal/logic"
|
||||||
"fusenapi/product/internal/svc"
|
"fusenapi/server/product/internal/svc"
|
||||||
"fusenapi/product/internal/types"
|
"fusenapi/server/product/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetSuccessRecommandHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func GetSuccessRecommandHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
|
|
@ -4,7 +4,7 @@ package handler
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"fusenapi/product/internal/svc"
|
"fusenapi/server/product/internal/svc"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest"
|
"github.com/zeromicro/go-zero/rest"
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"fusenapi/constants"
|
"fusenapi/constants"
|
||||||
"fusenapi/model"
|
"fusenapi/model"
|
||||||
"fusenapi/product/internal/svc"
|
"fusenapi/server/product/internal/svc"
|
||||||
"fusenapi/product/internal/types"
|
"fusenapi/server/product/internal/types"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/format"
|
"fusenapi/utils/format"
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
"fusenapi/utils/format"
|
"fusenapi/utils/format"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"fusenapi/product/internal/svc"
|
"fusenapi/server/product/internal/svc"
|
||||||
"fusenapi/product/internal/types"
|
"fusenapi/server/product/internal/types"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fusenapi/model"
|
"fusenapi/model"
|
||||||
"fusenapi/product/internal/svc"
|
"fusenapi/server/product/internal/svc"
|
||||||
"fusenapi/product/internal/types"
|
"fusenapi/server/product/internal/types"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/image"
|
"fusenapi/utils/image"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package svc
|
package svc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fusenapi/product/internal/config"
|
"fusenapi/server/product/internal/config"
|
||||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"fusenapi/product/internal/config"
|
"fusenapi/server/product/internal/config"
|
||||||
"fusenapi/product/internal/handler"
|
"fusenapi/server/product/internal/handler"
|
||||||
"fusenapi/product/internal/svc"
|
"fusenapi/server/product/internal/svc"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/conf"
|
"github.com/zeromicro/go-zero/core/conf"
|
||||||
"github.com/zeromicro/go-zero/rest"
|
"github.com/zeromicro/go-zero/rest"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user