2023-06-25 03:28:37 +00:00
|
|
|
package logic
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fusenapi/model/gmodel"
|
2023-06-26 10:21:50 +00:00
|
|
|
"fusenapi/utils/auth"
|
2023-06-25 03:28:37 +00:00
|
|
|
"fusenapi/utils/basic"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"context"
|
|
|
|
|
2023-06-25 06:11:47 +00:00
|
|
|
"fusenapi/server/product-template/internal/svc"
|
|
|
|
"fusenapi/server/product-template/internal/types"
|
2023-06-25 03:28:37 +00:00
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
)
|
|
|
|
|
|
|
|
type AddBaseMapLogic struct {
|
|
|
|
logx.Logger
|
|
|
|
ctx context.Context
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewAddBaseMapLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddBaseMapLogic {
|
|
|
|
return &AddBaseMapLogic{
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
ctx: ctx,
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-26 10:21:50 +00:00
|
|
|
func (l *AddBaseMapLogic) AddBaseMap(req *types.AddBaseMapReq, userInfo *auth.BackendUserInfo) (resp *basic.Response) {
|
2023-06-25 03:28:37 +00:00
|
|
|
req.Name = strings.Trim(req.Name, " ")
|
|
|
|
req.Url = strings.Trim(req.Url, " ")
|
|
|
|
if req.Name == "" || req.Url == "" {
|
|
|
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param is empty")
|
|
|
|
}
|
|
|
|
now := time.Now().Unix()
|
2023-06-26 10:21:50 +00:00
|
|
|
err := l.svcCtx.AllModels.FsProductTemplateBasemap.Create(l.ctx, &gmodel.FsProductTemplateBasemap{
|
2023-06-25 03:28:37 +00:00
|
|
|
Name: &req.Name,
|
|
|
|
Url: &req.Url,
|
|
|
|
Ctime: &now,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
logx.Error(err)
|
|
|
|
return resp.SetStatusWithMessage(basic.CodeSaveErr, "failed to add base map")
|
|
|
|
}
|
|
|
|
return resp.SetStatusWithMessage(basic.CodeOK, "success")
|
|
|
|
}
|