Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
019a717706
@ -2,14 +2,22 @@
|
|||||||
name=${1%%\\*}
|
name=${1%%\\*}
|
||||||
#进入对应服务目录
|
#进入对应服务目录
|
||||||
cd server/$name
|
cd server/$name
|
||||||
|
#把https加密密钥对复制进来
|
||||||
|
cp /opt/env.yaml ./
|
||||||
|
cp /opt/server.fusen.3718.cn.pem ./
|
||||||
|
cp /opt/server.fusen.3718.cn.key ./
|
||||||
#构建二进制文件
|
#构建二进制文件
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ./bin/api-$name-srv ./$name.go
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ./bin/api-$name-srv ./$name.go
|
||||||
#删除之前旧的镜像
|
|
||||||
docker rmi -f api-$name-srv:latest
|
|
||||||
docker rmi -f registry.cn-hangzhou.aliyuncs.com/fusen-test/fusen_docker_hub:latest
|
|
||||||
#打包docker镜像
|
#打包docker镜像
|
||||||
docker build -t api-$name-srv:latest .
|
docker build -t api-$name-srv:latest .
|
||||||
|
#删除临时复制进来的文件
|
||||||
|
rm ./env.yaml
|
||||||
|
rm ./server.fusen.3718.cn.pem
|
||||||
|
rm ./server.fusen.3718.cn.key
|
||||||
#打tag(测试环境,正式把命名空间fusentest改成fusen)
|
#打tag(测试环境,正式把命名空间fusentest改成fusen)
|
||||||
docker tag api-$name-srv:latest registry.cn-hangzhou.aliyuncs.com/fusen-test/$name:latest
|
docker tag api-$name-srv:latest registry.cn-hangzhou.aliyuncs.com/fusen-test/$name:latest
|
||||||
#推送到阿里云镜像库(测试环境,正式把命名空间fusentest改成fusen)
|
#推送到阿里云镜像库(测试环境,正式把命名空间fusentest改成fusen)
|
||||||
docker push registry.cn-hangzhou.aliyuncs.com/fusen-test/$name:latest
|
docker push registry.cn-hangzhou.aliyuncs.com/fusen-test/$name:latest
|
||||||
|
#上传了的镜像
|
||||||
|
docker rmi -f api-$name-srv:latest
|
||||||
|
docker rmi -f registry.cn-hangzhou.aliyuncs.com/fusen-test/$name:latest
|
||||||
|
@ -14,6 +14,7 @@ func (a *FsAddressModel) GetOne(ctx context.Context, addressId int64, userId int
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *FsAddressModel) GetUserAllAddress(ctx context.Context, userId int64) (resp []*FsAddressWithDefault, err error) {
|
func (a *FsAddressModel) GetUserAllAddress(ctx context.Context, userId int64) (resp []*FsAddressWithDefault, err error) {
|
||||||
|
resp = make([]*FsAddressWithDefault, 0)
|
||||||
|
|
||||||
var dbresp []*FsAddress
|
var dbresp []*FsAddress
|
||||||
err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`user_id` = ? and `status` = 1", userId).Order("`ltime` DESC").Find(&dbresp).Error
|
err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`user_id` = ? and `status` = 1", userId).Order("`ltime` DESC").Find(&dbresp).Error
|
||||||
|
@ -91,23 +91,20 @@ func main() {
|
|||||||
routes...))
|
routes...))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Backends = append(Backends, NewBackend(mux,
|
||||||
|
fmt.Sprintf("http://%s:%d", "localhost", 9501),
|
||||||
|
"/api/v1/namespaces/kubernetes-dashboard"))
|
||||||
|
|
||||||
// 定义用于服务Vue dist文件夹的静态文件服务器
|
// 定义用于服务Vue dist文件夹的静态文件服务器
|
||||||
fs := http.FileServer(http.Dir(vueBuild))
|
fs := http.FileServer(http.Dir(vueBuild))
|
||||||
indexHtmlPath := vueBuild + "/index.html"
|
indexHtmlPath := vueBuild + "/index.html"
|
||||||
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if strings.HasPrefix(r.URL.Path, "/api/") {
|
if strings.HasPrefix(r.URL.Path, "/api/") {
|
||||||
|
|
||||||
r.ParseMultipartForm(100 << 20)
|
r.ParseMultipartForm(100 << 20)
|
||||||
// if err != nil {
|
|
||||||
// logx.Error(err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 对/api开头的请求进行反向代理
|
// 对/api开头的请求进行反向代理
|
||||||
proxy := httputil.NewSingleHostReverseProxy(apiURL)
|
proxy := httputil.NewSingleHostReverseProxy(apiURL)
|
||||||
proxy.ServeHTTP(w, r)
|
proxy.ServeHTTP(w, r)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// 根据请求路径判断是服务静态文件或者是返回index.html
|
// 根据请求路径判断是服务静态文件或者是返回index.html
|
||||||
idx := strings.Index(r.URL.Path[1:], "/")
|
idx := strings.Index(r.URL.Path[1:], "/")
|
||||||
|
@ -48,7 +48,7 @@ run_server() {
|
|||||||
|
|
||||||
# 循环检查screen进程是否存在
|
# 循环检查screen进程是否存在
|
||||||
|
|
||||||
[ -f .gitignore ] || echo $server_name > .gitignore
|
[ -f .gitignore ] || (echo "$server_name" > .gitignore && echo "main" >> .gitignore)
|
||||||
# 使用 screen 运行 go run <server_name>.go
|
# 使用 screen 运行 go run <server_name>.go
|
||||||
|
|
||||||
echo "Running $server_name"
|
echo "Running $server_name"
|
||||||
|
1
server/auth/.gitignore
vendored
1
server/auth/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
auth
|
auth
|
||||||
|
main
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
FROM alpine
|
FROM alpine
|
||||||
|
|
||||||
WORKDIR /www/fusenapi/
|
WORKDIR /www/fusenapi/
|
||||||
COPY ./bin/api-assistant-srv /www/fusenapi/
|
COPY ./bin/api-auth-srv /www/fusenapi/
|
||||||
COPY ./etc /www/fusenapi/etc
|
COPY ./env.yaml /opt/
|
||||||
CMD ["/www/fusenapi/api-assistant-srv"]
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
|
CMD ["/www/fusenapi/api-auth-srv"]
|
||||||
|
@ -2,6 +2,7 @@ Name: auth
|
|||||||
Host: localhost
|
Host: localhost
|
||||||
Port: 9980
|
Port: 9980
|
||||||
ReplicaId: 10
|
ReplicaId: 10
|
||||||
|
HomePage: "http://www.fusen.3718.cn"
|
||||||
MainAddress: "https://server.fusen.3718.cn:9900"
|
MainAddress: "https://server.fusen.3718.cn:9900"
|
||||||
WebsocketAddr: "https://server.fusen.3718.cn:9914"
|
WebsocketAddr: "https://server.fusen.3718.cn:9914"
|
||||||
SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen"
|
SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen"
|
||||||
|
@ -12,6 +12,7 @@ type Config struct {
|
|||||||
Auth types.Auth
|
Auth types.Auth
|
||||||
ReplicaId uint64
|
ReplicaId uint64
|
||||||
|
|
||||||
|
HomePage string
|
||||||
MainAddress string
|
MainAddress string
|
||||||
WebsocketAddr string
|
WebsocketAddr string
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ func init() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeLimit = check.NewTimelimit[string](EmailTaskResendTime)
|
TimeLimit = check.NewTimeLimit[string](EmailTaskResendTime)
|
||||||
|
|
||||||
// Initialize the email manager
|
// Initialize the email manager
|
||||||
EmailManager = &EmailSender{
|
EmailManager = &EmailSender{
|
||||||
@ -60,9 +60,10 @@ type EmailFormat struct {
|
|||||||
ConfirmationLink string // fs确认连接
|
ConfirmationLink string // fs确认连接
|
||||||
SenderName string // 发送人
|
SenderName string // 发送人
|
||||||
SenderTitle string // 发送标题
|
SenderTitle string // 发送标题
|
||||||
Extend map[string]string
|
Extend map[string]string // 扩展参数
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 验证邮件格式是否符合要求
|
||||||
func (eformat *EmailFormat) Vaild() error {
|
func (eformat *EmailFormat) Vaild() error {
|
||||||
|
|
||||||
// 1. 检查模板名称
|
// 1. 检查模板名称
|
||||||
@ -123,39 +124,47 @@ type EmailTask struct {
|
|||||||
SendTime time.Time // 处理的任务时间
|
SendTime time.Time // 处理的任务时间
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ProcessEmailTasks 是 EmailSender 结构体的方法,用于处理邮件任务。
|
||||||
func (m *EmailSender) ProcessEmailTasks() {
|
func (m *EmailSender) ProcessEmailTasks() {
|
||||||
for {
|
for {
|
||||||
|
// 从 EmailTasks 通道中接收邮件任务
|
||||||
emailformat, ok := <-m.EmailTasks
|
emailformat, ok := <-m.EmailTasks
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Println("Email task channel closed")
|
log.Println("Email task channel closed")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 验证邮件格式是否合法
|
||||||
err := emailformat.Vaild()
|
err := emailformat.Vaild()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加锁,避免并发修改 emailSending 字典
|
||||||
m.lock.Lock()
|
m.lock.Lock()
|
||||||
|
|
||||||
|
// 检查 emailSending 字典中是否已存在相同的任务
|
||||||
_, isSending := m.emailSending[emailformat.UniqueKey]
|
_, isSending := m.emailSending[emailformat.UniqueKey]
|
||||||
if isSending {
|
if isSending {
|
||||||
m.lock.Unlock()
|
m.lock.Unlock()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 将邮件任务添加到 emailSending 字典中
|
||||||
m.emailSending[emailformat.UniqueKey] = &EmailTask{
|
m.emailSending[emailformat.UniqueKey] = &EmailTask{
|
||||||
Email: emailformat,
|
Email: emailformat,
|
||||||
SendTime: time.Now().UTC(),
|
SendTime: time.Now().UTC(),
|
||||||
}
|
}
|
||||||
m.lock.Unlock()
|
m.lock.Unlock()
|
||||||
|
|
||||||
// Acquire a token
|
// 获取一个信号量,限制同时发送的邮件任务数量
|
||||||
m.semaphore <- struct{}{}
|
m.semaphore <- struct{}{}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer func() { <-m.semaphore }() // Release a token
|
defer func() { <-m.semaphore }() // 释放一个信号量
|
||||||
|
|
||||||
|
// 渲染邮件模板内容
|
||||||
content := RenderEmailTemplate(
|
content := RenderEmailTemplate(
|
||||||
emailformat.TemplateName,
|
emailformat.TemplateName,
|
||||||
emailformat.CompanyName,
|
emailformat.CompanyName,
|
||||||
@ -164,34 +173,41 @@ func (m *EmailSender) ProcessEmailTasks() {
|
|||||||
emailformat.SenderTitle,
|
emailformat.SenderTitle,
|
||||||
emailformat.Extend,
|
emailformat.Extend,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 发送邮件
|
||||||
err := smtp.SendMail("smtp.gmail.com:587", m.Auth, m.FromEmail, []string{emailformat.TargetEmail}, content)
|
err := smtp.SendMail("smtp.gmail.com:587", m.Auth, m.FromEmail, []string{emailformat.TargetEmail}, content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to send email to %s: %v\n", emailformat, err)
|
log.Printf("Failed to send email to %s: %v\n", emailformat, err)
|
||||||
|
// 重新发送邮件
|
||||||
m.Resend(emailformat.UniqueKey, content)
|
m.Resend(emailformat.UniqueKey, content)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resend 重发邮件
|
// Resend 是 EmailSender 结构体的方法,用于重发邮件。
|
||||||
func (m *EmailSender) Resend(uniqueKey string, content []byte) {
|
func (m *EmailSender) Resend(uniqueKey string, content []byte) {
|
||||||
|
// 等待一段时间后重发邮件,避免频繁重发
|
||||||
time.Sleep(m.ResendTimeLimit)
|
time.Sleep(m.ResendTimeLimit)
|
||||||
|
|
||||||
m.lock.Lock()
|
m.lock.Lock()
|
||||||
defer m.lock.Unlock()
|
defer m.lock.Unlock()
|
||||||
// Check if the email task still exists and has not been sent successfully
|
|
||||||
|
// 检查邮件任务是否仍存在并且未成功发送
|
||||||
if task, ok := m.emailSending[uniqueKey]; ok && task.SendTime.Add(m.ResendTimeLimit).After(time.Now().UTC()) {
|
if task, ok := m.emailSending[uniqueKey]; ok && task.SendTime.Add(m.ResendTimeLimit).After(time.Now().UTC()) {
|
||||||
err := smtp.SendMail(task.Email.TargetEmail, m.Auth, m.FromEmail, []string{task.Email.TargetEmail}, content)
|
err := smtp.SendMail(task.Email.TargetEmail, m.Auth, m.FromEmail, []string{task.Email.TargetEmail}, content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to resend email to %s: %v\n", task.Email.TargetEmail, err)
|
log.Printf("Failed to resend email to %s: %v\n", task.Email.TargetEmail, err)
|
||||||
} else {
|
} else {
|
||||||
|
// 从 emailSending 字典中删除已成功发送的邮件任务
|
||||||
delete(m.emailSending, uniqueKey)
|
delete(m.emailSending, uniqueKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearExpiredTasks 清除过期的邮件任务
|
// ClearExpiredTasks 是 EmailSender 结构体的方法,用于清除过期的邮件任务。
|
||||||
func (m *EmailSender) ClearExpiredTasks() {
|
func (m *EmailSender) ClearExpiredTasks() {
|
||||||
|
// 每分钟触发一次清除操作
|
||||||
ticker := time.NewTicker(time.Minute)
|
ticker := time.NewTicker(time.Minute)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
@ -199,6 +215,7 @@ func (m *EmailSender) ClearExpiredTasks() {
|
|||||||
<-ticker.C
|
<-ticker.C
|
||||||
|
|
||||||
m.lock.Lock()
|
m.lock.Lock()
|
||||||
|
// 遍历 emailSending 字典,删除发送时间超过一定限制的过期任务
|
||||||
for email, task := range m.emailSending {
|
for email, task := range m.emailSending {
|
||||||
if task.SendTime.Add(m.ResendTimeLimit).Before(time.Now().UTC()) {
|
if task.SendTime.Add(m.ResendTimeLimit).Before(time.Now().UTC()) {
|
||||||
delete(m.emailSending, email)
|
delete(m.emailSending, email)
|
||||||
@ -208,8 +225,19 @@ func (m *EmailSender) ClearExpiredTasks() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func RenderEmailTemplate(templateName, companyName, confirmationLink, senderName, senderTitle string, extend map[string]string) []byte {
|
// RenderEmailTemplate 是一个渲染邮件模板的函数,根据给定的参数生成邮件内容。
|
||||||
|
// 参数:
|
||||||
|
// - templateName: 邮件模板的名称
|
||||||
|
// - companyName: 公司名称
|
||||||
|
// - confirmationLink: 确认链接
|
||||||
|
// - senderName: 发件人姓名
|
||||||
|
// - senderTitle: 发件人职务
|
||||||
|
// - extend: 扩展字段,包含其他自定义键值对的映射
|
||||||
|
// 返回值:
|
||||||
|
// - []byte: 渲染后的邮件内容(以字节切片形式返回)
|
||||||
|
|
||||||
|
func RenderEmailTemplate(templateName, companyName, confirmationLink, senderName, senderTitle string, extend map[string]string) []byte {
|
||||||
|
// 创建一个包含邮件模板所需数据的映射
|
||||||
data := map[string]string{
|
data := map[string]string{
|
||||||
"CompanyName": companyName,
|
"CompanyName": companyName,
|
||||||
"ConfirmationLink": confirmationLink,
|
"ConfirmationLink": confirmationLink,
|
||||||
@ -217,16 +245,20 @@ func RenderEmailTemplate(templateName, companyName, confirmationLink, senderName
|
|||||||
"SenderTitle": senderTitle,
|
"SenderTitle": senderTitle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 将扩展字段中的键值对添加到数据映射中
|
||||||
for k, v := range extend {
|
for k, v := range extend {
|
||||||
data[k] = v
|
data[k] = v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 创建一个字节缓冲区,用于存储渲染后的邮件内容
|
||||||
var result bytes.Buffer
|
var result bytes.Buffer
|
||||||
// result.Write([]byte("MIME-version: 1.0;\nContent-Type: text/html; charset=\"UTF-8\";\n\n"))
|
|
||||||
|
// 使用给定的数据映射执行邮件模板渲染
|
||||||
err := tpls.ExecuteTemplate(&result, templateName, data)
|
err := tpls.ExecuteTemplate(&result, templateName, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 将渲染后的邮件内容转换为字节切片并返回
|
||||||
return result.Bytes()
|
return result.Bytes()
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import (
|
|||||||
"fusenapi/server/auth/internal/svc"
|
"fusenapi/server/auth/internal/svc"
|
||||||
"fusenapi/server/auth/internal/types"
|
"fusenapi/server/auth/internal/types"
|
||||||
|
|
||||||
"github.com/474420502/requests"
|
|
||||||
"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"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@ -57,7 +56,7 @@ func FinishRegister(svcCtx *svc.ServiceContext, user *gmodel.FsUser, token *auth
|
|||||||
event.Data = wevent.DataEmailRegister{
|
event.Data = wevent.DataEmailRegister{
|
||||||
JwtToken: jwtToken,
|
JwtToken: jwtToken,
|
||||||
}
|
}
|
||||||
err = CommonNotify(svcCtx.Config.WebsocketAddr, token.Wid, event)
|
err = wevent.CommonNotify(svcCtx.Config.WebsocketAddr, token.Wid, event)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// logx.Error(err, token.TraceId)
|
// logx.Error(err, token.TraceId)
|
||||||
return err
|
return err
|
||||||
@ -66,34 +65,6 @@ func FinishRegister(svcCtx *svc.ServiceContext, user *gmodel.FsUser, token *auth
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CommonNotify(WebsocketAddr, wid string, event *wevent.WebsocketEvent) error {
|
|
||||||
|
|
||||||
reqWebsocketAddr := fmt.Sprintf("%s/api/websocket/common_notify", WebsocketAddr)
|
|
||||||
tp := requests.Post(reqWebsocketAddr)
|
|
||||||
tp.SetBodyJson(requests.M{
|
|
||||||
"wid": wid,
|
|
||||||
"data": event,
|
|
||||||
})
|
|
||||||
|
|
||||||
wresp, err := tp.Execute()
|
|
||||||
if err != nil {
|
|
||||||
// logx.Error(err, token.TraceId)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
result := wresp.Json()
|
|
||||||
|
|
||||||
if !result.Get("code").Exists() {
|
|
||||||
return fmt.Errorf("send %s is error", reqWebsocketAddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
if result.Get("code").Int() != 200 {
|
|
||||||
return fmt.Errorf("%s", result.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *UserEmailConfirmationLogic) UserEmailConfirmation(req *types.RequestEmailConfirmation, userinfo *auth.UserInfo) (resp *basic.Response) {
|
func (l *UserEmailConfirmationLogic) UserEmailConfirmation(req *types.RequestEmailConfirmation, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
// userinfo 传入值时, 一定不为null
|
// userinfo 传入值时, 一定不为null
|
||||||
@ -176,7 +147,7 @@ func (l *UserEmailConfirmationLogic) UserEmailConfirmation(req *types.RequestEma
|
|||||||
}
|
}
|
||||||
|
|
||||||
event := wevent.NewWebsocketEventSuccess(wevent.UserResetToken, rt.TraceId)
|
event := wevent.NewWebsocketEventSuccess(wevent.UserResetToken, rt.TraceId)
|
||||||
err = CommonNotify(l.svcCtx.Config.MainAddress, rt.Wid, event)
|
err = wevent.CommonNotify(l.svcCtx.Config.MainAddress, rt.Wid, event)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err, rt.TraceId)
|
logx.Error(err, rt.TraceId)
|
||||||
return resp.SetStatus(basic.CodeResetPasswordErr, err.Error())
|
return resp.SetStatus(basic.CodeResetPasswordErr, err.Error())
|
||||||
|
@ -50,7 +50,7 @@ func (l *UserResetPasswordHtmlLogic) UserResetPasswordHtml(req *types.RequestUse
|
|||||||
func (l *UserResetPasswordHtmlLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
func (l *UserResetPasswordHtmlLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||||
|
|
||||||
err := tpls.ExecuteTemplate(w, "reset_confirm.tpl", map[string]string{
|
err := tpls.ExecuteTemplate(w, "reset_confirm.tpl", map[string]string{
|
||||||
"HomePage": "http://www.fusen.3718.cn",
|
"HomePage": l.svcCtx.Config.HomePage,
|
||||||
"ResetToken": l.ResetToken,
|
"ResetToken": l.ResetToken,
|
||||||
"ResetPasswordLink": l.svcCtx.Config.MainAddress + "/api/auth/reset/password",
|
"ResetPasswordLink": l.svcCtx.Config.MainAddress + "/api/auth/reset/password",
|
||||||
})
|
})
|
||||||
|
@ -51,7 +51,7 @@ func (l *UserResetPasswordLogic) UserResetPassword(req *types.RequestUserResetPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if time.Since(rt.CreateAt) > 30*time.Minute {
|
if time.Since(rt.CreateAt) > 30*time.Minute {
|
||||||
return resp.SetStatusWithMessage(basic.CodeOAuthConfirmationTimeoutErr, "Verification links expire after 30 minute.")
|
return resp.SetStatusWithMessage(basic.CodeOAuthConfirmationTimeoutErr, "verification links expire after 30 minute.")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = l.svcCtx.AllModels.FsUser.Transaction(l.ctx, func(tx *gorm.DB) error {
|
err = l.svcCtx.AllModels.FsUser.Transaction(l.ctx, func(tx *gorm.DB) error {
|
||||||
@ -67,7 +67,7 @@ func (l *UserResetPasswordLogic) UserResetPassword(req *types.RequestUserResetPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if *user.PasswordHash == req.NewPassword {
|
if *user.PasswordHash == req.NewPassword {
|
||||||
return fmt.Errorf("the password is the same as the old one. It needs to be changed")
|
return fmt.Errorf("the password is the same as the old one. it needs to be changed")
|
||||||
}
|
}
|
||||||
|
|
||||||
return tx.Where("id = ?", rt.UserId).Update("PasswordHash", req.NewPassword).Error
|
return tx.Where("id = ?", rt.UserId).Update("PasswordHash", req.NewPassword).Error
|
||||||
@ -79,7 +79,7 @@ func (l *UserResetPasswordLogic) UserResetPassword(req *types.RequestUserResetPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
event := wevent.NewWebsocketEventSuccess(wevent.UserResetToken, rt.TraceId)
|
event := wevent.NewWebsocketEventSuccess(wevent.UserResetToken, rt.TraceId)
|
||||||
err = CommonNotify(l.svcCtx.Config.WebsocketAddr, rt.Wid, event)
|
err = wevent.CommonNotify(l.svcCtx.Config.WebsocketAddr, rt.Wid, event)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err, rt.TraceId)
|
logx.Error(err, rt.TraceId)
|
||||||
return resp.SetStatusWithMessage(basic.CodeResetPasswordErr, err.Error())
|
return resp.SetStatusWithMessage(basic.CodeResetPasswordErr, err.Error())
|
||||||
|
1
server/base/.gitignore
vendored
1
server/base/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
base
|
base
|
||||||
|
main
|
||||||
|
8
server/base/Dockerfile
Executable file
8
server/base/Dockerfile
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
FROM alpine
|
||||||
|
|
||||||
|
WORKDIR /www/fusenapi/
|
||||||
|
COPY ./bin/api-base-srv /www/fusenapi/
|
||||||
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
|
CMD ["/www/fusenapi/api-base-srv"]
|
1
server/canteen/.gitignore
vendored
1
server/canteen/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
canteen
|
canteen
|
||||||
|
main
|
||||||
|
@ -2,5 +2,7 @@ FROM alpine
|
|||||||
|
|
||||||
WORKDIR /www/fusenapi/
|
WORKDIR /www/fusenapi/
|
||||||
COPY ./bin/api-canteen-srv /www/fusenapi/
|
COPY ./bin/api-canteen-srv /www/fusenapi/
|
||||||
COPY ./etc /www/fusenapi/etc
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
CMD ["/www/fusenapi/api-canteen-srv"]
|
CMD ["/www/fusenapi/api-canteen-srv"]
|
||||||
|
2
server/collection/.gitignore
vendored
Normal file
2
server/collection/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
collection
|
||||||
|
main
|
8
server/collection/Dockerfile
Executable file
8
server/collection/Dockerfile
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
FROM alpine
|
||||||
|
|
||||||
|
WORKDIR /www/fusenapi/
|
||||||
|
COPY ./bin/api-collection-srv /www/fusenapi/
|
||||||
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
|
CMD ["/www/fusenapi/api-collection-srv"]
|
@ -27,6 +27,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
Path: "/api/collection/get_collect_product_list",
|
Path: "/api/collection/get_collect_product_list",
|
||||||
Handler: GetCollectProductListHandler(serverCtx),
|
Handler: GetCollectProductListHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/api/collection/test_ai",
|
||||||
|
Handler: TestAiHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
35
server/collection/internal/handler/testaihandler.go
Normal file
35
server/collection/internal/handler/testaihandler.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"fusenapi/server/collection/internal/logic"
|
||||||
|
"fusenapi/server/collection/internal/svc"
|
||||||
|
"fusenapi/server/collection/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAiHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
var req types.TestAiReq
|
||||||
|
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建一个业务逻辑层实例
|
||||||
|
l := logic.NewTestAiLogic(r.Context(), svcCtx)
|
||||||
|
|
||||||
|
rl := reflect.ValueOf(l)
|
||||||
|
basic.BeforeLogic(w, r, rl)
|
||||||
|
|
||||||
|
resp := l.TestAi(&req, userinfo)
|
||||||
|
|
||||||
|
if !basic.AfterLogic(w, r, rl, resp) {
|
||||||
|
basic.NormalAfterLogic(w, r, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
96
server/collection/internal/logic/testailogic.go
Normal file
96
server/collection/internal/logic/testailogic.go
Normal file
File diff suppressed because one or more lines are too long
@ -40,6 +40,10 @@ type GetCollectProductListRspItem struct {
|
|||||||
IsDeleted int64 `json:"is_deleted"`
|
IsDeleted int64 `json:"is_deleted"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TestAiReq struct {
|
||||||
|
Num int `form:"num"`
|
||||||
|
}
|
||||||
|
|
||||||
type Request struct {
|
type Request struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
server/data-transfer/.gitignore
vendored
1
server/data-transfer/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
data-transfer
|
data-transfer
|
||||||
|
main
|
||||||
|
@ -2,5 +2,7 @@ FROM alpine
|
|||||||
|
|
||||||
WORKDIR /www/fusenapi/
|
WORKDIR /www/fusenapi/
|
||||||
COPY ./bin/api-data-transfer-srv /www/fusenapi/
|
COPY ./bin/api-data-transfer-srv /www/fusenapi/
|
||||||
COPY ./etc /www/fusenapi/etc
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
CMD ["/www/fusenapi/api-data-transfer-srv"]
|
CMD ["/www/fusenapi/api-data-transfer-srv"]
|
||||||
|
1
server/home-user-auth/.gitignore
vendored
1
server/home-user-auth/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
home-user-auth
|
home-user-auth
|
||||||
|
main
|
||||||
|
@ -2,5 +2,7 @@ FROM alpine
|
|||||||
|
|
||||||
WORKDIR /www/fusenapi/
|
WORKDIR /www/fusenapi/
|
||||||
COPY ./bin/api-home-user-auth-srv /www/fusenapi/
|
COPY ./bin/api-home-user-auth-srv /www/fusenapi/
|
||||||
COPY ./etc /www/fusenapi/etc
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
CMD ["/www/fusenapi/api-home-user-auth-srv"]
|
CMD ["/www/fusenapi/api-home-user-auth-srv"]
|
||||||
|
1
server/info/.gitignore
vendored
1
server/info/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
info
|
info
|
||||||
|
main
|
||||||
|
8
server/info/Dockerfile
Executable file
8
server/info/Dockerfile
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
FROM alpine
|
||||||
|
|
||||||
|
WORKDIR /www/fusenapi/
|
||||||
|
COPY ./bin/api-info-srv /www/fusenapi/
|
||||||
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
|
CMD ["/www/fusenapi/api-info-srv"]
|
1
server/map-library/.gitignore
vendored
1
server/map-library/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
map-library
|
map-library
|
||||||
|
main
|
||||||
|
@ -2,5 +2,7 @@ FROM alpine
|
|||||||
|
|
||||||
WORKDIR /www/fusenapi/
|
WORKDIR /www/fusenapi/
|
||||||
COPY ./bin/api-map-library-srv /www/fusenapi/
|
COPY ./bin/api-map-library-srv /www/fusenapi/
|
||||||
COPY ./etc /www/fusenapi/etc
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
CMD ["/www/fusenapi/api-map-library-srv"]
|
CMD ["/www/fusenapi/api-map-library-srv"]
|
||||||
|
1
server/order/.gitignore
vendored
1
server/order/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
order
|
order
|
||||||
|
main
|
||||||
|
8
server/order/Dockerfile
Executable file
8
server/order/Dockerfile
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
FROM alpine
|
||||||
|
|
||||||
|
WORKDIR /www/fusenapi/
|
||||||
|
COPY ./bin/api-order-srv /www/fusenapi/
|
||||||
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
|
CMD ["/www/fusenapi/api-order-srv"]
|
1
server/pay/.gitignore
vendored
1
server/pay/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
pay
|
pay
|
||||||
|
main
|
||||||
|
@ -2,5 +2,7 @@ FROM alpine
|
|||||||
|
|
||||||
WORKDIR /www/fusenapi/
|
WORKDIR /www/fusenapi/
|
||||||
COPY ./bin/api-pay-srv /www/fusenapi/
|
COPY ./bin/api-pay-srv /www/fusenapi/
|
||||||
COPY ./etc /www/fusenapi/etc
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
CMD ["/www/fusenapi/api-pay-srv"]
|
CMD ["/www/fusenapi/api-pay-srv"]
|
||||||
|
1
server/product-model/.gitignore
vendored
1
server/product-model/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
product-model
|
product-model
|
||||||
|
main
|
||||||
|
@ -2,5 +2,7 @@ FROM alpine
|
|||||||
|
|
||||||
WORKDIR /www/fusenapi/
|
WORKDIR /www/fusenapi/
|
||||||
COPY ./bin/api-product-model-srv /www/fusenapi/
|
COPY ./bin/api-product-model-srv /www/fusenapi/
|
||||||
COPY ./etc /www/fusenapi/etc
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
CMD ["/www/fusenapi/api-product-model-srv"]
|
CMD ["/www/fusenapi/api-product-model-srv"]
|
||||||
|
1
server/product-template-tag/.gitignore
vendored
1
server/product-template-tag/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
product-template-tag
|
product-template-tag
|
||||||
|
main
|
||||||
|
@ -2,5 +2,7 @@ FROM alpine
|
|||||||
|
|
||||||
WORKDIR /www/fusenapi/
|
WORKDIR /www/fusenapi/
|
||||||
COPY ./bin/api-product-template-tag-srv /www/fusenapi/
|
COPY ./bin/api-product-template-tag-srv /www/fusenapi/
|
||||||
COPY ./etc /www/fusenapi/etc
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
CMD ["/www/fusenapi/api-product-template-tag-srv"]
|
CMD ["/www/fusenapi/api-product-template-tag-srv"]
|
||||||
|
1
server/product-template/.gitignore
vendored
1
server/product-template/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
product-template
|
product-template
|
||||||
|
main
|
||||||
|
@ -2,5 +2,7 @@ FROM alpine
|
|||||||
|
|
||||||
WORKDIR /www/fusenapi/
|
WORKDIR /www/fusenapi/
|
||||||
COPY ./bin/api-product-template-srv /www/fusenapi/
|
COPY ./bin/api-product-template-srv /www/fusenapi/
|
||||||
COPY ./etc /www/fusenapi/etc
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
CMD ["/www/fusenapi/api-product-template-srv"]
|
CMD ["/www/fusenapi/api-product-template-srv"]
|
||||||
|
1
server/product/.gitignore
vendored
1
server/product/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
product
|
product
|
||||||
|
main
|
||||||
|
@ -2,5 +2,7 @@ FROM alpine
|
|||||||
|
|
||||||
WORKDIR /www/fusenapi/
|
WORKDIR /www/fusenapi/
|
||||||
COPY ./bin/api-product-srv /www/fusenapi/
|
COPY ./bin/api-product-srv /www/fusenapi/
|
||||||
COPY ./etc /www/fusenapi/etc
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
CMD ["/www/fusenapi/api-product-srv"]
|
CMD ["/www/fusenapi/api-product-srv"]
|
||||||
|
@ -49,7 +49,6 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
|||||||
tStatus := int64(1)
|
tStatus := int64(1)
|
||||||
tReq := gmodel.GetAllTagByParamsReq{
|
tReq := gmodel.GetAllTagByParamsReq{
|
||||||
Status: &tStatus,
|
Status: &tStatus,
|
||||||
OrderBy: "`sort` DESC",
|
|
||||||
WithChild: true, //需要子集
|
WithChild: true, //需要子集
|
||||||
Category: 1, //前台网站用的
|
Category: 1, //前台网站用的
|
||||||
Level: 2, //等级是2的
|
Level: 2, //等级是2的
|
||||||
@ -425,20 +424,6 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
|
|||||||
if _, ok = req.MapTagProp[productInfo.Id]; ok {
|
if _, ok = req.MapTagProp[productInfo.Id]; ok {
|
||||||
item.CoverDefault = req.MapTagProp[productInfo.Id]
|
item.CoverDefault = req.MapTagProp[productInfo.Id]
|
||||||
}
|
}
|
||||||
//千人千面处理
|
|
||||||
/*r := image.ThousandFaceImageFormatReq{
|
|
||||||
Size: int(req.Size),
|
|
||||||
IsThousandFace: 0,
|
|
||||||
Cover: *productInfo.Cover,
|
|
||||||
CoverImg: *productInfo.CoverImg,
|
|
||||||
ProductId: productInfo.Id,
|
|
||||||
UserId: req.User.Id,
|
|
||||||
}
|
|
||||||
if req.User.Id != 0 {
|
|
||||||
r.IsThousandFace = int(*req.User.IsThousandFace)
|
|
||||||
}
|
|
||||||
image.ThousandFaceImageFormat(&r)
|
|
||||||
item.Cover = r.Cover*/
|
|
||||||
//加入分类产品切片
|
//加入分类产品切片
|
||||||
productListRsp = append(productListRsp, item)
|
productListRsp = append(productListRsp, item)
|
||||||
}
|
}
|
||||||
|
1
server/resource/.gitignore
vendored
1
server/resource/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
resource
|
resource
|
||||||
|
main
|
||||||
|
8
server/resource/Dockerfile
Executable file
8
server/resource/Dockerfile
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
FROM alpine
|
||||||
|
|
||||||
|
WORKDIR /www/fusenapi/
|
||||||
|
COPY ./bin/api-resource-srv /www/fusenapi/
|
||||||
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
|
CMD ["/www/fusenapi/api-resource-srv"]
|
1
server/shopping-cart/.gitignore
vendored
1
server/shopping-cart/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
shopping-cart
|
shopping-cart
|
||||||
|
main
|
||||||
|
@ -2,5 +2,7 @@ FROM alpine
|
|||||||
|
|
||||||
WORKDIR /www/fusenapi/
|
WORKDIR /www/fusenapi/
|
||||||
COPY ./bin/api-shopping-cart-srv /www/fusenapi/
|
COPY ./bin/api-shopping-cart-srv /www/fusenapi/
|
||||||
COPY ./etc /www/fusenapi/etc
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
CMD ["/www/fusenapi/api-shopping-cart-srv"]
|
CMD ["/www/fusenapi/api-shopping-cart-srv"]
|
||||||
|
1
server/upload/.gitignore
vendored
1
server/upload/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
upload
|
upload
|
||||||
|
main
|
||||||
|
@ -2,5 +2,7 @@ FROM alpine
|
|||||||
|
|
||||||
WORKDIR /www/fusenapi/
|
WORKDIR /www/fusenapi/
|
||||||
COPY ./bin/api-upload-srv /www/fusenapi/
|
COPY ./bin/api-upload-srv /www/fusenapi/
|
||||||
COPY ./etc /www/fusenapi/etc
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
CMD ["/www/fusenapi/api-upload-srv"]
|
CMD ["/www/fusenapi/api-upload-srv"]
|
||||||
|
1
server/webset/.gitignore
vendored
1
server/webset/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
webset
|
webset
|
||||||
|
main
|
||||||
|
@ -2,5 +2,7 @@ FROM alpine
|
|||||||
|
|
||||||
WORKDIR /www/fusenapi/
|
WORKDIR /www/fusenapi/
|
||||||
COPY ./bin/api-webset-srv /www/fusenapi/
|
COPY ./bin/api-webset-srv /www/fusenapi/
|
||||||
COPY ./etc /www/fusenapi/etc
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
CMD ["/www/fusenapi/api-webset-srv"]
|
CMD ["/www/fusenapi/api-webset-srv"]
|
||||||
|
1
server/websocket/.gitignore
vendored
1
server/websocket/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
websocket
|
websocket
|
||||||
|
main
|
||||||
|
@ -2,5 +2,7 @@ FROM alpine
|
|||||||
|
|
||||||
WORKDIR /www/fusenapi/
|
WORKDIR /www/fusenapi/
|
||||||
COPY ./bin/api-websocket-srv /www/fusenapi/
|
COPY ./bin/api-websocket-srv /www/fusenapi/
|
||||||
COPY ./etc /www/fusenapi/etc
|
COPY ./env.yaml /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.pem /opt/
|
||||||
|
COPY ./server.fusen.3718.cn.key /opt/
|
||||||
CMD ["/www/fusenapi/api-websocket-srv"]
|
CMD ["/www/fusenapi/api-websocket-srv"]
|
||||||
|
@ -115,7 +115,7 @@ func (w *wsConnectItem) consumeRenderImageData() {
|
|||||||
}()
|
}()
|
||||||
select {
|
select {
|
||||||
case <-w.extendRenderProperty.renderCtx.Done():
|
case <-w.extendRenderProperty.renderCtx.Done():
|
||||||
panic("=========渲染取消旧的上下文=======")
|
panic("=========检测到模板标签/颜色变化,渲染取消旧的任务=======")
|
||||||
case <-tmpChan:
|
case <-tmpChan:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -277,6 +277,10 @@ func (w *wsConnectItem) getProductRelateionInfo(renderImageData *websocket_data.
|
|||||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取对应开启云渲染模板失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取对应开启云渲染模板失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||||
return nil, nil, nil, errors.New("获取对应开启云渲染模板失败")
|
return nil, nil, nil, errors.New("获取对应开启云渲染模板失败")
|
||||||
}
|
}
|
||||||
|
if productTemplate.TemplateInfo == nil || *productTemplate.TemplateInfo == "" {
|
||||||
|
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "模板设计信息是空的", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, 0, 0, 0)
|
||||||
|
return nil, nil, nil, errors.New("模板设计信息是空的")
|
||||||
|
}
|
||||||
//根据模板找到模型
|
//根据模板找到模型
|
||||||
model3d, err = w.logic.svcCtx.AllModels.FsProductModel3d.FindOne(w.logic.ctx, *productTemplate.ModelId)
|
model3d, err = w.logic.svcCtx.AllModels.FsProductModel3d.FindOne(w.logic.ctx, *productTemplate.ModelId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -288,6 +292,10 @@ func (w *wsConnectItem) getProductRelateionInfo(renderImageData *websocket_data.
|
|||||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取对应模型失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, 0, 0, 0)
|
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取对应模型失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, 0, 0, 0)
|
||||||
return nil, nil, nil, errors.New("获取对应模型失败")
|
return nil, nil, nil, errors.New("获取对应模型失败")
|
||||||
}
|
}
|
||||||
|
if model3d.ModelInfo == nil || *model3d.ModelInfo == "" {
|
||||||
|
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "模型设计信息是空的", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, 0, 0)
|
||||||
|
return nil, nil, nil, errors.New("模型设计信息是空的")
|
||||||
|
}
|
||||||
//根据模型id获取尺寸信息
|
//根据模型id获取尺寸信息
|
||||||
productSize, err = w.logic.svcCtx.AllModels.FsProductSize.FindOne(w.logic.ctx, *model3d.SizeId)
|
productSize, err = w.logic.svcCtx.AllModels.FsProductSize.FindOne(w.logic.ctx, *model3d.SizeId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -18,6 +18,9 @@ service collection {
|
|||||||
//获取收藏列表
|
//获取收藏列表
|
||||||
@handler GetCollectProductListHandler
|
@handler GetCollectProductListHandler
|
||||||
get /api/collection/get_collect_product_list(GetCollectProductListReq) returns (response);
|
get /api/collection/get_collect_product_list(GetCollectProductListReq) returns (response);
|
||||||
|
//测试
|
||||||
|
@handler TestAiHandler
|
||||||
|
get /api/collection/test_ai(TestAiReq) returns (response);
|
||||||
}
|
}
|
||||||
|
|
||||||
//收藏产品
|
//收藏产品
|
||||||
@ -53,3 +56,7 @@ type GetCollectProductListRspItem {
|
|||||||
IsShelf int64 `json:"is_shelf"`
|
IsShelf int64 `json:"is_shelf"`
|
||||||
IsDeleted int64 `json:"is_deleted"`
|
IsDeleted int64 `json:"is_deleted"`
|
||||||
}
|
}
|
||||||
|
//测试
|
||||||
|
type TestAiReq {
|
||||||
|
Num int `form:"num"`
|
||||||
|
}
|
@ -56,7 +56,7 @@ var (
|
|||||||
CodeUserIdNotFoundErr = &StatusResponse{5051, "user not found"} // 未找到用户
|
CodeUserIdNotFoundErr = &StatusResponse{5051, "user not found"} // 未找到用户
|
||||||
CodePasswordErr = &StatusResponse{5052, "invalid password"} // 无效密码
|
CodePasswordErr = &StatusResponse{5052, "invalid password"} // 无效密码
|
||||||
CodeEmailExistsErr = &StatusResponse{5053, "email exists"} // email存在
|
CodeEmailExistsErr = &StatusResponse{5053, "email exists"} // email存在
|
||||||
CodeEmailTimeShortErr = &StatusResponse{5053, "email with the time of resend is too short"} // email存在
|
CodeEmailTimeShortErr = &StatusResponse{5053, "email with the time of resend is too short"} // email重发的时间太短
|
||||||
CodeResetPasswordErr = &StatusResponse{5054, "reset password error"} // 无效密码
|
CodeResetPasswordErr = &StatusResponse{5054, "reset password error"} // 无效密码
|
||||||
|
|
||||||
CodeSafeValueRangeErr = &StatusResponse{5040, "value not in range"} // 值不在范围内
|
CodeSafeValueRangeErr = &StatusResponse{5040, "value not in range"} // 值不在范围内
|
||||||
|
@ -15,9 +15,9 @@ type TimeLimit[T comparable] struct {
|
|||||||
dur time.Duration
|
dur time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTimelimit构造函数,接收限频的时间间隔
|
// NewTimeLimit构造函数,接收限频的时间间隔
|
||||||
// 并初始化内部字典和间隔字段
|
// 并初始化内部字典和间隔字段
|
||||||
func NewTimelimit[T comparable](dur time.Duration) *TimeLimit[T] {
|
func NewTimeLimit[T comparable](dur time.Duration) *TimeLimit[T] {
|
||||||
return &TimeLimit[T]{
|
return &TimeLimit[T]{
|
||||||
dict: make(map[T]struct{}),
|
dict: make(map[T]struct{}),
|
||||||
dur: dur,
|
dur: dur,
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package wevent
|
package wevent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/474420502/requests"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 和前端交流的事件机制
|
// 和前端交流的事件机制
|
||||||
@ -22,6 +25,34 @@ type WebsocketEvent struct {
|
|||||||
Data any `json:"data"` // 关注的数据
|
Data any `json:"data"` // 关注的数据
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CommonNotify(WebsocketAddr, wid string, event *WebsocketEvent) error {
|
||||||
|
|
||||||
|
reqWebsocketAddr := fmt.Sprintf("%s/api/websocket/common_notify", WebsocketAddr)
|
||||||
|
tp := requests.Post(reqWebsocketAddr)
|
||||||
|
tp.SetBodyJson(requests.M{
|
||||||
|
"wid": wid,
|
||||||
|
"data": event,
|
||||||
|
})
|
||||||
|
|
||||||
|
wresp, err := tp.Execute()
|
||||||
|
if err != nil {
|
||||||
|
// logx.Error(err, token.TraceId)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := wresp.Json()
|
||||||
|
|
||||||
|
if !result.Get("code").Exists() {
|
||||||
|
return fmt.Errorf("send %s is error", reqWebsocketAddr)
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.Get("code").Int() != 200 {
|
||||||
|
return fmt.Errorf("%s", result.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// NewWebsocketEvent 创建一个Websocket事件
|
// NewWebsocketEvent 创建一个Websocket事件
|
||||||
func NewWebsocketEvent(etype EventType, TraceId string) *WebsocketEvent {
|
func NewWebsocketEvent(etype EventType, TraceId string) *WebsocketEvent {
|
||||||
return &WebsocketEvent{
|
return &WebsocketEvent{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user