Skip to content

Commit

Permalink
Revert "添加积分不足时的报错 + 简历分析 (#279)"
Browse files Browse the repository at this point in the history
This reverts commit 0a573e3.
  • Loading branch information
flycash committed Nov 27, 2024
1 parent 0a573e3 commit 104aa2a
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 475 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ cover.out
/internal/cases/internal/integration/logs
/internal/skill/internal/integration/logs
/internal/feedback/internal/integration/logs
/internal/resume/internal/integration/logs
/config/cert/

local_test.go
Expand Down
2 changes: 1 addition & 1 deletion .run/docker.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name=".script/integration_test_compose.yml: Compose 部署" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker">
<configuration default="false" name="docker" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker">
<deployment type="docker-compose.yml">
<settings>
<option name="envFilePath" value="" />
Expand Down
3 changes: 1 addition & 2 deletions internal/ai/internal/errs/code.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package errs

var (
SystemError = ErrorCode{Code: 516001, Msg: "系统错误"}
InsufficientCredit = ErrorCode{Code: 516002, Msg: "积分不足"}
SystemError = ErrorCode{Code: 516001, Msg: "系统错误"}
)

type ErrorCode struct {
Expand Down
49 changes: 16 additions & 33 deletions internal/ai/internal/web/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import (
"github.com/ecodeclub/ginx"
"github.com/ecodeclub/ginx/session"
"github.com/ecodeclub/webook/internal/ai/internal/domain"
"github.com/ecodeclub/webook/internal/ai/internal/errs"
"github.com/ecodeclub/webook/internal/ai/internal/service"
"github.com/ecodeclub/webook/internal/ai/internal/service/llm/handler/credit"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
)

type Handler struct {
Expand All @@ -31,45 +28,31 @@ func (h *Handler) PrivateRoutes(server *gin.Engine) {
func (h *Handler) LLMAsk(ctx *ginx.Context, req LLMRequest, sess session.Session) (ginx.Result, error) {
uid := sess.Claims().Uid
resp, err := h.generalSvc.LLMAsk(ctx, uid, req.Biz, req.Input)
switch {
case errors.Is(err, credit.ErrInsufficientCredit):
return ginx.Result{
Code: errs.InsufficientCredit.Code,
Msg: errs.InsufficientCredit.Msg,
}, nil
case err == nil:
return ginx.Result{
Data: LLMResponse{
Amount: resp.Amount,
RawResult: resp.Answer,
},
}, nil
default:
if err != nil {
return systemErrorResult, err
}
return ginx.Result{
Data: LLMResponse{
Amount: resp.Amount,
RawResult: resp.Answer,
},
}, nil
}

func (h *Handler) AnalysisJd(ctx *ginx.Context, req JDRequest, sess session.Session) (ginx.Result, error) {
uid := sess.Claims().Uid
resp, err := h.jdSvc.Evaluate(ctx, uid, req.JD)
switch {
case errors.Is(err, credit.ErrInsufficientCredit):
return ginx.Result{
Code: errs.InsufficientCredit.Code,
Msg: errs.InsufficientCredit.Msg,
}, nil
case err == nil:
return ginx.Result{
Data: JDResponse{
Amount: resp.Amount,
TechScore: h.newJD(resp.TechScore),
BizScore: h.newJD(resp.BizScore),
PosScore: h.newJD(resp.PosScore),
},
}, nil
default:
if err != nil {
return systemErrorResult, err
}
return ginx.Result{
Data: JDResponse{
Amount: resp.Amount,
TechScore: h.newJD(resp.TechScore),
BizScore: h.newJD(resp.BizScore),
PosScore: h.newJD(resp.PosScore),
},
}, nil

}

Expand Down
20 changes: 0 additions & 20 deletions internal/resume/internal/domain/analysis.go

This file was deleted.

2 changes: 0 additions & 2 deletions internal/resume/internal/errs/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package errs

var (
SystemError = ErrorCode{Code: 515001, Msg: "系统错误"}
// InsufficientCredit 这个不管说是客户端错误还是服务端错误,都有点勉强,所以随便用一个 5
InsufficientCredit = ErrorCode{Code: 515002, Msg: "积分不足"}
)

type ErrorCode struct {
Expand Down
135 changes: 0 additions & 135 deletions internal/resume/internal/integration/analysis_handler_test.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"testing"
"time"

"github.com/ecodeclub/webook/internal/ai"

"github.com/ecodeclub/ekit/iox"
"github.com/ecodeclub/ekit/sqlx"
"github.com/ecodeclub/webook/internal/resume/internal/domain"
Expand Down Expand Up @@ -64,9 +62,7 @@ func (s *ExperienceTestSuite) SetupSuite() {

module := startup.InitModule(&cases.Module{
ExamineSvc: examSvc,
},
&ai.Module{},
)
})
econf.Set("server", map[string]any{"contextTimeout": "1s"})
server := egin.Load("server").Build()

Expand Down
6 changes: 1 addition & 5 deletions internal/resume/internal/integration/project_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"strconv"
"testing"

"github.com/ecodeclub/webook/internal/ai"

"github.com/ecodeclub/ekit/iox"
"github.com/ecodeclub/ekit/slice"
"github.com/ecodeclub/ginx/session"
Expand Down Expand Up @@ -84,9 +82,7 @@ func (s *ProjectTestSuite) SetupSuite() {
module := startup.InitModule(&cases.Module{
ExamineSvc: examSvc,
Svc: caseSvc,
},
&ai.Module{},
)
})
econf.Set("server", map[string]any{"contextTimeout": "1s"})
server := egin.Load("server").Build()
server.Use(func(ctx *gin.Context) {
Expand Down
6 changes: 1 addition & 5 deletions internal/resume/internal/integration/startup/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package startup

import (
"github.com/ecodeclub/webook/internal/ai"
"github.com/ecodeclub/webook/internal/cases"
"github.com/ecodeclub/webook/internal/resume"
"github.com/ecodeclub/webook/internal/resume/internal/repository"
Expand All @@ -14,7 +13,7 @@ import (
"github.com/google/wire"
)

func InitModule(caModule *cases.Module, aiModule *ai.Module) *resume.Module {
func InitModule(caModule *cases.Module) *resume.Module {
wire.Build(
testioc.InitDB,
dao.NewResumeProjectDAO,
Expand All @@ -23,13 +22,10 @@ func InitModule(caModule *cases.Module, aiModule *ai.Module) *resume.Module {
repository.NewExperience,
service.NewService,
service.NewExperienceService,
service.NewAnalysisService,
wire.FieldsOf(new(*cases.Module), "ExamineSvc"),
wire.FieldsOf(new(*cases.Module), "Svc"),
wire.FieldsOf(new(*ai.Module), "Svc"),
web.NewHandler,
web.NewExperienceHandler,
web.NewAnalysisHandler,
wire.Struct(new(resume.Module), "*"),
)
return new(resume.Module)
Expand Down
11 changes: 3 additions & 8 deletions internal/resume/internal/integration/startup/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 104aa2a

Please sign in to comment.