11
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -31,24 +29,14 @@ func NewAddBaseMapLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddBas
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AddBaseMapLogic) AddBaseMap(req *types.AddBaseMapReq, r *http.Request) (resp *basic.Response) {
|
||||
authKey := r.Header.Get("Auth-Key")
|
||||
genentModel := gmodel.NewFsGerentModel(l.svcCtx.MysqlConn)
|
||||
_, err := genentModel.Find(l.ctx, authKey)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeUnAuth, "please login first..")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeUnAuth, "failed to get user info")
|
||||
}
|
||||
func (l *AddBaseMapLogic) AddBaseMap(req *types.AddBaseMapReq, userInfo *auth.BackendUserInfo) (resp *basic.Response) {
|
||||
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()
|
||||
err = l.svcCtx.AllModels.FsProductTemplateBasemap.Create(l.ctx, &gmodel.FsProductTemplateBasemap{
|
||||
err := l.svcCtx.AllModels.FsProductTemplateBasemap.Create(l.ctx, &gmodel.FsProductTemplateBasemap{
|
||||
Name: &req.Name,
|
||||
Url: &req.Url,
|
||||
Ctime: &now,
|
||||
|
||||
Reference in New Issue
Block a user