├── .github └── workflows │ └── go.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── Makefile ├── README.md ├── assets ├── 55cd141f9679755a3d298ce15d5d45850886f82a.jpg ├── 609f41af717bbcc4e0287dde2f978ceb0551c2f7.jpg └── 面试系统交流群.png ├── common ├── announcestatus.go ├── config.go ├── config.yaml.example ├── config_test.go ├── database.go ├── gender.go ├── grpcerror.go ├── jsonwebtoken.go ├── jsonwebtoken_test.go ├── performance.go ├── permission.go ├── slice.go ├── sms │ ├── generatesms.go │ ├── sendsms.go │ ├── smsconfig.go │ └── smshandler.go └── timeconfig.go ├── dal ├── gen.go ├── model │ ├── admins.gen.go │ ├── admits.gen.go │ ├── announce_configs.gen.go │ ├── applicant_questions.gen.go │ ├── applicant_sms.gen.go │ ├── applicant_times.gen.go │ ├── applicants.gen.go │ ├── configuration.gen.go │ ├── evaluation_standards.gen.go │ ├── forms.gen.go │ ├── guide.gen.go │ ├── intents.gen.go │ ├── questions.gen.go │ ├── receive_sms.gen.go │ ├── remarks.gen.go │ ├── rooms.gen.go │ ├── scores.gen.go │ ├── time_configs.gen.go │ └── times.gen.go ├── query │ ├── admins.gen.go │ ├── admits.gen.go │ ├── announce_configs.gen.go │ ├── applicant_questions.gen.go │ ├── applicant_sms.gen.go │ ├── applicant_times.gen.go │ ├── applicants.gen.go │ ├── configuration.gen.go │ ├── evaluation_standards.gen.go │ ├── forms.gen.go │ ├── gen.go │ ├── guide.gen.go │ ├── intents.gen.go │ ├── questions.gen.go │ ├── receive_sms.gen.go │ ├── remarks.gen.go │ ├── rooms.gen.go │ ├── scores.gen.go │ ├── time_configs.gen.go │ └── times.gen.go └── sql │ └── hr.sql ├── docker-compose.yml ├── go.mod ├── go.sum ├── hr-admin-api ├── Dockerfile ├── api │ ├── admin.api │ ├── applicant.api │ ├── config.api │ ├── evaluation.api │ ├── exam.api │ ├── remarks.api │ ├── room.api │ ├── scores.api │ ├── sms.api │ ├── statistics.api │ ├── timeconfig.api │ └── times.api ├── etc │ └── hr-admin.yaml ├── hr-admin-swagger.json ├── hr-admin.api ├── hr-admin.go └── internal │ ├── config │ └── config.go │ ├── handler │ ├── admin │ │ ├── getadmininfohandler.go │ │ ├── getfrontendconfighandler.go │ │ ├── getoauthconfighandler.go │ │ ├── loginhandler.go │ │ ├── logouthandler.go │ │ └── setdefaultstandardhandler.go │ ├── applicant │ │ ├── admitresethandler.go │ │ ├── admitsethandler.go │ │ ├── deleteapplicanthandler.go │ │ ├── getapplicantgrouphandler.go │ │ ├── getapplicantinfohandler.go │ │ ├── getapplicantscoreshandler.go │ │ ├── getnamelisthandler.go │ │ └── setapplicanttimeextendhandler.go │ ├── config │ │ ├── getconfighandler.go │ │ ├── getsmsserviceconfighandler.go │ │ └── setconfighandler.go │ ├── evaluation │ │ ├── addevaluationhandler.go │ │ ├── deleteevaluationhandler.go │ │ ├── getevaluationinfohandler.go │ │ ├── getevaluationlisthandler.go │ │ └── updateevaluationhandler.go │ ├── exam │ │ ├── createexamhandler.go │ │ ├── deleteexamhandler.go │ │ ├── getexambyapplicantidhandler.go │ │ ├── getexamgrouphandler.go │ │ └── updateexamhandler.go │ ├── pinghandler.go │ ├── remarks │ │ ├── deleteremarkshandler.go │ │ ├── getremarkshandler.go │ │ ├── getremarkslisthandler.go │ │ └── postremarkshandler.go │ ├── room │ │ ├── getallroomhandler.go │ │ ├── getpushablelisthandler.go │ │ ├── pushapplicanthandler.go │ │ ├── setmyroomhandler.go │ │ ├── setroomcommenthandler.go │ │ ├── setroomgrouphandler.go │ │ └── setroomstatushandler.go │ ├── routes.go │ ├── scores │ │ ├── deletescorehandler.go │ │ ├── getrankhandler.go │ │ ├── getscoreshandler.go │ │ └── postscorehandler.go │ ├── sms │ │ ├── getapplicantsmshandler.go │ │ ├── gethistorysmshandler.go │ │ ├── getsmsconfighandler.go │ │ ├── receivesmshandler.go │ │ └── sendsmshandler.go │ ├── statistics │ │ ├── getclasshandler.go │ │ └── getdailynewhandler.go │ ├── timeconfig │ │ └── posttimeconfighandler.go │ └── times │ │ ├── cleartimehandler.go │ │ ├── getexporthandler.go │ │ ├── getschedulehandler.go │ │ ├── getstatisticshandler.go │ │ └── postuploadhandler.go │ ├── logic │ ├── admin │ │ ├── getadmininfologic.go │ │ ├── getfrontendconfiglogic.go │ │ ├── getoauthconfiglogic.go │ │ ├── loginlogic.go │ │ ├── logoutlogic.go │ │ └── setdefaultstandardlogic.go │ ├── applicant │ │ ├── admitresetlogic.go │ │ ├── admitsetlogic.go │ │ ├── deleteapplicantlogic.go │ │ ├── getapplicantgrouplogic.go │ │ ├── getapplicantinfologic.go │ │ ├── getapplicantscoreslogic.go │ │ ├── getnamelistlogic.go │ │ └── setapplicanttimeextendlogic.go │ ├── common.go │ ├── config │ │ ├── getconfiglogic.go │ │ ├── getsmsserviceconfiglogic.go │ │ └── setconfiglogic.go │ ├── evaluation │ │ ├── addevaluationlogic.go │ │ ├── deleteevaluationlogic.go │ │ ├── getevaluationinfologic.go │ │ ├── getevaluationlistlogic.go │ │ └── updateevaluationlogic.go │ ├── exam │ │ ├── createexamlogic.go │ │ ├── deleteexamlogic.go │ │ ├── getexambyapplicantidlogic.go │ │ ├── getexamgrouplogic.go │ │ └── updateexamlogic.go │ ├── pinglogic.go │ ├── remarks │ │ ├── deleteremarkslogic.go │ │ ├── getremarkslistlogic.go │ │ ├── getremarkslogic.go │ │ └── postremarkslogic.go │ ├── room │ │ ├── getallroomlogic.go │ │ ├── getpushablelistlogic.go │ │ ├── pushapplicantlogic.go │ │ ├── setmyroomlogic.go │ │ ├── setroomcommentlogic.go │ │ ├── setroomgrouplogic.go │ │ └── setroomstatuslogic.go │ ├── scores │ │ ├── deletescorelogic.go │ │ ├── getranklogic.go │ │ ├── getscoreslogic.go │ │ └── postscorelogic.go │ ├── sms │ │ ├── getapplicantsmslogic.go │ │ ├── gethistorysmslogic.go │ │ ├── getsmsconfiglogic.go │ │ ├── receivesmslogic.go │ │ └── sendsmslogic.go │ ├── statistics │ │ ├── getclasslogic.go │ │ └── getdailynewlogic.go │ ├── timeconfig │ │ └── posttimeconfiglogic.go │ └── times │ │ ├── cleartimelogic.go │ │ ├── getexportlogic.go │ │ ├── getschedulelogic.go │ │ ├── getstatisticslogic.go │ │ └── postuploadlogic.go │ ├── svc │ └── servicecontext.go │ └── types │ └── types.go ├── hr-admin-service ├── Dockerfile ├── admin.go ├── admin.proto ├── etc │ └── admin.yaml ├── hrservice │ └── hrservice.go ├── internal │ ├── config │ │ └── config.go │ ├── cronjob │ │ ├── main.go │ │ ├── sendsmsjob.go │ │ └── testjob.go │ ├── logic │ │ ├── addevaluationlogic.go │ │ ├── adminloginlogic.go │ │ ├── adminloginlogic_test.go │ │ ├── adminlogoutlogic.go │ │ ├── cleartimeslogic.go │ │ ├── common.go │ │ ├── common_test.go │ │ ├── createquestionlogic.go │ │ ├── deleteapplicantlogic.go │ │ ├── deleteevaluationlogic.go │ │ ├── deletequestionlogic.go │ │ ├── deleteremarklogic.go │ │ ├── deletescorelogic.go │ │ ├── exporttimeslogic.go │ │ ├── getadmininfologic.go │ │ ├── getallroomlogic.go │ │ ├── getapplicantinfologic.go │ │ ├── getapplicantnamelistlogic.go │ │ ├── getapplicantquestionslogic.go │ │ ├── getapplicantscoreslogic.go │ │ ├── getapplicantslogic.go │ │ ├── getapplicantslogic_test.go │ │ ├── getapplicantsmslogic.go │ │ ├── getconfiglogic.go │ │ ├── getevaluationinfologic.go │ │ ├── getevaluationslogic.go │ │ ├── getfrontendconfiglogic.go │ │ ├── gethistorysmslogic.go │ │ ├── getoauthconfiglogic.go │ │ ├── getpushablelistlogic.go │ │ ├── getquestionslogic.go │ │ ├── getranklogic.go │ │ ├── getremarklistlogic.go │ │ ├── getremarklogic.go │ │ ├── getschedulelogic.go │ │ ├── getscorelogic.go │ │ ├── getsmsconfiglogic.go │ │ ├── getsmsserviceconfiglogic.go │ │ ├── getstatisticsclassifylogic.go │ │ ├── getstatisticsdailynewlogic.go │ │ ├── getstatisticsdailynewlogic_test.go │ │ ├── gettimesstatisticslogic.go │ │ ├── pinglogic.go │ │ ├── postremarklogic.go │ │ ├── postscorelogic.go │ │ ├── posttimeconfiglogic.go │ │ ├── pushapplicantlogic.go │ │ ├── receivesmslogic.go │ │ ├── sendsmslogic.go │ │ ├── setapplicantadmitlogic.go │ │ ├── setapplicanttimeextendlogic.go │ │ ├── setdefaultstandardlogic.go │ │ ├── setmyroomlogic.go │ │ ├── setroomcommentlogic.go │ │ ├── setroomgrouplogic.go │ │ ├── setroomstatuslogic.go │ │ ├── updateconfiglogic.go │ │ ├── updateevaluationlogic.go │ │ ├── updatequestionlogic.go │ │ └── uploadtimeslogic.go │ ├── server │ │ └── hrserviceserver.go │ └── svc │ │ └── servicecontext.go └── pb │ └── hr-admin-service │ ├── admin.pb.go │ └── admin_grpc.pb.go ├── hr-api ├── Dockerfile ├── api │ ├── announce.api │ ├── exam.api │ ├── form.api │ ├── joinus.api │ └── timeconfig.api ├── etc │ └── hr.yaml ├── hr-swagger.json ├── hr.api ├── hr.go └── internal │ ├── config │ └── config.go │ ├── handler │ ├── announce │ │ └── getannouncestatushandler.go │ ├── exam │ │ ├── getexamhandler.go │ │ ├── getguidehandler.go │ │ └── setexamhandler.go │ ├── form │ │ ├── getformgroupshandler.go │ │ ├── getformhandler.go │ │ └── getformintenthandler.go │ ├── joinus │ │ ├── getcanapplyhandler.go │ │ ├── getcanselecthandler.go │ │ ├── getformhandler.go │ │ ├── getintentshandler.go │ │ ├── getresulthandler.go │ │ ├── getreviewhandler.go │ │ ├── getstephandler.go │ │ ├── gettimehandler.go │ │ ├── getwechathandler.go │ │ ├── loginhandler.go │ │ ├── postapplyhandler.go │ │ └── selecttimehandler.go │ ├── pinghandler.go │ ├── routes.go │ └── timeconfig │ │ └── gettimeconfighandler.go │ ├── logic │ ├── announce │ │ └── getannouncestatuslogic.go │ ├── exam │ │ ├── getexamlogic.go │ │ ├── getguidelogic.go │ │ └── setexamlogic.go │ ├── form │ │ ├── getformgroupslogic.go │ │ ├── getformintentlogic.go │ │ └── getformlogic.go │ ├── joinus │ │ ├── getcanapplylogic.go │ │ ├── getcanselectlogic.go │ │ ├── getformlogic.go │ │ ├── getintentslogic.go │ │ ├── getresultlogic.go │ │ ├── getreviewlogic.go │ │ ├── getsteplogic.go │ │ ├── gettimelogic.go │ │ ├── getwechatlogic.go │ │ ├── loginlogic.go │ │ ├── postapplylogic.go │ │ └── selecttimelogic.go │ ├── pinglogic.go │ └── timeconfig │ │ └── gettimeconfiglogic.go │ ├── svc │ └── servicecontext.go │ └── types │ └── types.go ├── hr-service ├── Dockerfile ├── etc │ └── hr.yaml ├── hr.go ├── hr.proto ├── hrservice │ └── hrservice.go ├── internal │ ├── config │ │ └── config.go │ ├── logic │ │ ├── common.go │ │ ├── common_test.go │ │ ├── getannouncestatuslogic.go │ │ ├── getannouncestatuslogic_test.go │ │ ├── getcanjoinlogic.go │ │ ├── getexamlogic.go │ │ ├── getexamlogic_test.go │ │ ├── getformformatlogic.go │ │ ├── getformgroupslogic.go │ │ ├── getformintentlogic.go │ │ ├── getguidelogic.go │ │ ├── getintentlistlogic.go │ │ ├── getmyformlogic.go │ │ ├── getmyresultlogic.go │ │ ├── getmysteplogic.go │ │ ├── getreviewlogic.go │ │ ├── getreviewlogic_test.go │ │ ├── gettimeconfiglogic.go │ │ ├── gettimelogic.go │ │ ├── getwechatinfologic.go │ │ ├── loginlogic.go │ │ ├── loginlogic_test.go │ │ ├── migrate_test.go │ │ ├── pinglogic.go │ │ ├── postapplylogic.go │ │ ├── postexamlogic.go │ │ └── selecttimelogic.go │ ├── server │ │ └── hrserviceserver.go │ └── svc │ │ └── servicecontext.go └── pb │ └── hr-service │ ├── hr.pb.go │ └── hr_grpc.pb.go └── unittest ├── docker-compose.yml ├── init_data.sql └── nginx-conf.d └── hr.conf /.gitignore: -------------------------------------------------------------------------------- 1 | # ---> Go 2 | # If you prefer the allow list template instead of the deny list, see community template: 3 | # https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore 4 | # 5 | # Binaries for programs and plugins 6 | *.exe 7 | *.exe~ 8 | *.dll 9 | *.so 10 | *.dylib 11 | 12 | # Test binary, built with `cmd unittest -c` 13 | *.test 14 | 15 | # Output of the cmd coverage tool, specifically when used with LiteIDE 16 | *.out 17 | 18 | # Dependency directories (remove the comment below to include it) 19 | # vendor/ 20 | 21 | # Go workspace file 22 | go.work 23 | 24 | # 单元测试 MySQL 数据 25 | unittest/mysql 26 | 27 | # 单元测试备份数据 28 | unittest/backup 29 | 30 | # 项目构建目录 31 | build 32 | 33 | # 项目配置文件 34 | common/config.yaml -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "hr-front"] 2 | path = hr-front 3 | url = https://github.com/scutrobotlab/HR_Frontend 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | gen_dal: 2 | cd dal && go run . 3 | 4 | gen_api: 5 | cd hr-api && goctl api go --api hr.api --dir . 6 | cd hr-admin-api && goctl api go --api hr-admin.api --dir . 7 | 8 | gen_swagger: 9 | cd hr-api && goctl api plugin -plugin goctl-swagger="swagger --filename hr-swagger.json" --api hr.api -dir . 10 | cd hr-admin-api && goctl api plugin -plugin goctl-swagger="swagger --filename hr-admin-swagger.json" --api hr-admin.api -dir . 11 | 12 | gen_service: 13 | cd hr-service && goctl rpc protoc hr.proto --go_out=./pb --go-grpc_out=./pb --zrpc_out=. 14 | cd hr-admin-service && goctl rpc protoc admin.proto --go_out=./pb --go-grpc_out=./pb --zrpc_out=. 15 | 16 | build_go: 17 | cd hr-api && go build -o ../build/hr-api -ldflags="-w -s" . 18 | cd hr-admin-api && go build -o ../build/hr-admin-api -ldflags="-w -s" . 19 | cd hr-service && go build -o ../build/hr-service -ldflags="-w -s" . 20 | cd hr-admin-service && go build -o ../build/hr-admin-service -ldflags="-w -s" . 21 | 22 | docker: 23 | cd hr-api && goctl docker --version 1.20 && cd .. 24 | cd hr-admin-api && goctl docker --version 1.20 && cd .. 25 | cd hr-service && goctl docker --version 1.20 && cd .. 26 | cd hr-admin-service && goctl docker --version 1.20 && cd .. 27 | 28 | init_config: 29 | cp common/config.yaml.example common/config.yaml 30 | -------------------------------------------------------------------------------- /assets/55cd141f9679755a3d298ce15d5d45850886f82a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scutrobotlab/HR_Go/d2c5be3056cdd1b58db81ba89a84c7416538f60b/assets/55cd141f9679755a3d298ce15d5d45850886f82a.jpg -------------------------------------------------------------------------------- /assets/609f41af717bbcc4e0287dde2f978ceb0551c2f7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scutrobotlab/HR_Go/d2c5be3056cdd1b58db81ba89a84c7416538f60b/assets/609f41af717bbcc4e0287dde2f978ceb0551c2f7.jpg -------------------------------------------------------------------------------- /assets/面试系统交流群.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scutrobotlab/HR_Go/d2c5be3056cdd1b58db81ba89a84c7416538f60b/assets/面试系统交流群.png -------------------------------------------------------------------------------- /common/announcestatus.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | const ( 4 | HaveNotAppliedForm = "HaveNotAppliedForm" 5 | HaveNotSelectedTime = "HaveNotSelectedTime" 6 | HaveNotInterview = "HaveNotInterview" 7 | Interviewed = "Interviewed" 8 | Admitted = "Admitted" 9 | Failed = "Failed" 10 | HaveNotPublished = "HaveNotPublished" 11 | ) 12 | -------------------------------------------------------------------------------- /common/config.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "fmt" 5 | "github.com/zeromicro/go-zero/core/conf" 6 | "os" 7 | "os/exec" 8 | ) 9 | 10 | type Config struct { 11 | Debug bool 12 | Url struct { 13 | BaseUrl string 14 | AdminUrl string 15 | WechatUrl string 16 | } 17 | Groups []string 18 | Intents struct { 19 | Min int32 20 | Max int32 21 | Parallel bool 22 | } 23 | OAuth struct { 24 | ClientId string 25 | ClientSecret string 26 | RedirectUrl string 27 | } 28 | } 29 | 30 | func GetConfig(path string) (Config, error) { 31 | var config Config 32 | pathEnv := os.Getenv("COMMON_CONFIG_PATH") 33 | if pathEnv != "" { 34 | path = pathEnv 35 | } 36 | // 如果配置文件不存在,则从配置文件模板复制 37 | if _, err := os.Stat(path); os.IsNotExist(err) { 38 | command := exec.Command("cp", fmt.Sprintf("%s.example", path), path) 39 | err = command.Run() 40 | if err != nil { 41 | return config, err 42 | } 43 | } 44 | err := conf.Load(path, &config) 45 | return config, err 46 | } 47 | -------------------------------------------------------------------------------- /common/config.yaml.example: -------------------------------------------------------------------------------- 1 | debug: false 2 | url: 3 | baseUrl: 4 | adminUrl: 5 | wechatUrl: 6 | groups: 7 | - 机械 8 | - 电控 9 | - 视觉 10 | intents: 11 | min: 1 12 | max: 2 13 | parallel: false 14 | oAuth: 15 | clientID: 16 | clientSecret: 17 | redirectUrl: 18 | -------------------------------------------------------------------------------- /common/config_test.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestInit(t *testing.T) { 9 | config, err := GetConfig("./config.yaml") 10 | if err != nil { 11 | return 12 | } 13 | fmt.Printf("%+v\n", config) 14 | } 15 | -------------------------------------------------------------------------------- /common/database.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "HR_Go/dal/model" 5 | "gorm.io/gorm" 6 | ) 7 | 8 | var Models = []any{ 9 | &model.Admin{}, 10 | &model.Admit{}, 11 | &model.AnnounceConfig{}, 12 | &model.ApplicantQuestion{}, 13 | &model.ApplicantSm{}, 14 | &model.ApplicantTime{}, 15 | &model.Applicant{}, 16 | &model.Configuration{}, 17 | &model.EvaluationStandard{}, 18 | &model.Form{}, 19 | &model.Guide{}, 20 | &model.Intent{}, 21 | &model.Question{}, 22 | &model.ReceiveSm{}, 23 | &model.Remark{}, 24 | &model.Room{}, 25 | &model.Score{}, 26 | &model.TimeConfig{}, 27 | &model.Time{}, 28 | } 29 | 30 | // AutoMigrate 自动迁移 31 | func AutoMigrate(db *gorm.DB) error { 32 | return db.AutoMigrate(Models...) 33 | } 34 | -------------------------------------------------------------------------------- /common/gender.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | const ( 4 | GenderUnknown = 0 5 | GenderMale = 1 6 | GenderFemale = 2 7 | GenderUnspecified = 9 8 | ) 9 | 10 | func GenderIntToString(gender int32) string { 11 | switch gender { 12 | case GenderUnknown: 13 | return "unknown" 14 | case GenderMale: 15 | return "male" 16 | case GenderFemale: 17 | return "female" 18 | case GenderUnspecified: 19 | return "unspecified" 20 | } 21 | return "" 22 | } 23 | 24 | func GenderStringToInt(gender string) int32 { 25 | switch gender { 26 | case "unknown": 27 | return GenderUnknown 28 | case "male": 29 | return GenderMale 30 | case "female": 31 | return GenderFemale 32 | case "unspecified": 33 | return GenderUnspecified 34 | } 35 | return GenderUnknown 36 | } 37 | -------------------------------------------------------------------------------- /common/jsonwebtoken.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "github.com/golang-jwt/jwt/v4" 5 | "time" 6 | ) 7 | 8 | type Auth struct { 9 | AccessSecret string 10 | AccessExpire int64 11 | } 12 | 13 | // GetLoginJwtToken 获取登录Token 14 | func GetLoginJwtToken(auth Auth, userInfo UserInfo) (string, error) { 15 | payload := make(map[string]any) 16 | payload["id"] = userInfo.Id 17 | payload["per"] = userInfo.Permission 18 | return GetJwtToken(auth, payload) 19 | } 20 | 21 | // GetJwtToken 22 | // 获取 Jwt Token 23 | func GetJwtToken(auth Auth, payload map[string]any) (string, error) { 24 | token, err := generateJwtToken(auth.AccessSecret, time.Now().Unix(), auth.AccessExpire, payload) 25 | return token, err 26 | } 27 | 28 | // generateJwtToken 29 | // @secretKey: JWT 加解密密钥 30 | // @iat: 时间戳 31 | // @seconds: 过期时间,单位秒 32 | // @payload: 数据载体 33 | func generateJwtToken(secretKey string, iat, seconds int64, payload map[string]any) (string, error) { 34 | claims := make(jwt.MapClaims) 35 | claims["exp"] = iat + seconds 36 | claims["iat"] = iat 37 | for k, v := range payload { 38 | claims[k] = v 39 | } 40 | token := jwt.New(jwt.SigningMethodHS256) 41 | token.Claims = claims 42 | return token.SignedString([]byte(secretKey)) 43 | } 44 | -------------------------------------------------------------------------------- /common/performance.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | type TimeLogger struct { 9 | StartTime time.Time 10 | TimeMap map[int]int64 11 | Enabled bool 12 | } 13 | 14 | func NewTimeLogger(enabled bool) *TimeLogger { 15 | return &TimeLogger{ 16 | StartTime: time.Now(), 17 | TimeMap: make(map[int]int64), 18 | Enabled: enabled, 19 | } 20 | } 21 | 22 | func (t *TimeLogger) Log(id int) { 23 | if !t.Enabled { 24 | return 25 | } 26 | since := time.Since(t.StartTime).Milliseconds() 27 | t.TimeMap[id] += since 28 | fmt.Printf("id: %d, time: %dms\t", id, since) 29 | for i := int64(0); i < since; i++ { 30 | fmt.Print(".") 31 | } 32 | fmt.Println() 33 | t.StartTime = time.Now() 34 | } 35 | 36 | func (t *TimeLogger) PrintResult() { 37 | if !t.Enabled { 38 | return 39 | } 40 | fmt.Println("===================== Total time =====================") 41 | for id, item := range t.TimeMap { 42 | fmt.Printf("id: %d, time: %dms\n", id, item) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /common/permission.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | ) 7 | 8 | const ( 9 | Unknown = iota // 没有登录 10 | Applicant // 面试者 11 | Admin // 管理员(面试官) 12 | SuperAdmin // 超级管理员(虎王id=1) 13 | ) 14 | 15 | type ( 16 | UserInfo struct { 17 | Id int64 `json:"id"` 18 | Permission int32 `json:"per"` 19 | } 20 | ) 21 | 22 | func GetUserInfo(ctx context.Context) *UserInfo { 23 | id := ctx.Value("id") 24 | var idValue int64 25 | if id == nil { 26 | idValue = Unknown 27 | } else { 28 | idValue, _ = id.(json.Number).Int64() 29 | } 30 | 31 | permission := ctx.Value("per") 32 | var permissionValue int64 33 | if permission == nil { 34 | permissionValue = Unknown 35 | } else { 36 | permissionValue, _ = permission.(json.Number).Int64() 37 | } 38 | 39 | return &UserInfo{Id: idValue, Permission: int32(permissionValue)} 40 | } 41 | -------------------------------------------------------------------------------- /common/slice.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | func NotNullList[T any](list []T) []T { 4 | if len(list) == 0 { 5 | return []T{} 6 | } 7 | return list 8 | } 9 | -------------------------------------------------------------------------------- /common/sms/sendsms.go: -------------------------------------------------------------------------------- 1 | package sms 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "net/http" 7 | "net/url" 8 | "time" 9 | ) 10 | 11 | type SmsBaoConfig struct { 12 | SendUrl string 13 | Username string 14 | Password string 15 | Debug bool 16 | } 17 | 18 | func SendSms(config SmsBaoConfig, phone string, content string) error { 19 | if config.Debug { 20 | fmt.Printf("%s: --- send sms to %s: %s\n", time.Now().Format(time.DateTime), phone, content) 21 | return nil 22 | } 23 | 24 | encodedContent := url.QueryEscape(content) 25 | response, err := http.Get(fmt.Sprintf("%s?u=%s&p=%s&m=%s&c=%s", config.SendUrl, config.Username, config.Password, phone, encodedContent)) 26 | if err != nil { 27 | return err 28 | } 29 | defer response.Body.Close() 30 | respBody, err := io.ReadAll(response.Body) 31 | if err != nil { 32 | return err 33 | } 34 | 35 | respStr := string(respBody) 36 | switch respStr { 37 | case "0": 38 | return nil 39 | case "30": 40 | return fmt.Errorf("密码错误") 41 | case "40": 42 | return fmt.Errorf("账号不存在") 43 | case "41": 44 | return fmt.Errorf("余额不足") 45 | case "43": 46 | return fmt.Errorf("IP地址限制") 47 | case "50": 48 | return fmt.Errorf("内容含有敏感词") 49 | case "51": 50 | return fmt.Errorf("手机号码不正确") 51 | default: 52 | return fmt.Errorf("未知错误") 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /common/timeconfig.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "HR_Go/dal/model" 5 | "HR_Go/dal/query" 6 | "github.com/samber/lo" 7 | "time" 8 | ) 9 | 10 | const ( 11 | ApplyFormStart = "apply_form_start" 12 | ApplyFormEnd = "apply_form_end" 13 | SelectTimeStart = "select_time_start" 14 | SelectTimeEnd = "select_time_end" 15 | PublishResultStart = "publish_result_start" 16 | ShowInterviewQuestions = "show_interview_questions" 17 | ReviewThisSeason = "review_this_season" 18 | FirstInterviewDate = "first_interview_date" 19 | ) 20 | 21 | func GetTimeConfig(q *query.Query, key string) time.Time { 22 | timeConfigs, err := q.TimeConfig.Find() 23 | if err != nil { 24 | return time.Time{} 25 | } 26 | 27 | find, b := lo.Find(timeConfigs, func(item *model.TimeConfig) bool { 28 | return item.Key == key 29 | }) 30 | if b { 31 | return find.Value 32 | } else { 33 | return time.Time{} 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /dal/gen.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "gorm.io/driver/mysql" 5 | "gorm.io/gen" 6 | "gorm.io/gorm" 7 | ) 8 | 9 | const dsn = "root:123456@(localhost:3306)/hr?charset=utf8mb4&parseTime=True&loc=Local" 10 | 11 | func main() { 12 | g := gen.NewGenerator(gen.Config{ 13 | OutPath: "./query", 14 | Mode: gen.WithoutContext | gen.WithDefaultQuery | gen.WithQueryInterface, // generate mode 15 | FieldWithTypeTag: true, 16 | FieldWithIndexTag: true, 17 | }) 18 | 19 | db, _ := gorm.Open(mysql.Open(dsn)) 20 | g.UseDB(db) // reuse your gorm db 21 | 22 | g.ApplyBasic( 23 | // Generate structs from all tables of current database 24 | g.GenerateAllTable()..., 25 | ) 26 | // Generate the code 27 | g.Execute() 28 | } 29 | -------------------------------------------------------------------------------- /dal/model/announce_configs.gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by gorm.io/gen. DO NOT EDIT. 2 | // Code generated by gorm.io/gen. DO NOT EDIT. 3 | // Code generated by gorm.io/gen. DO NOT EDIT. 4 | 5 | package model 6 | 7 | const TableNameAnnounceConfig = "announce_configs" 8 | 9 | // AnnounceConfig mapped from table 10 | type AnnounceConfig struct { 11 | ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"` 12 | Status string `gorm:"column:status;type:varchar(255);not null;comment:状态名称" json:"status"` // 状态名称 13 | Body string `gorm:"column:body;type:text;not null;comment:状态内容" json:"body"` // 状态内容 14 | } 15 | 16 | // TableName AnnounceConfig's table name 17 | func (*AnnounceConfig) TableName() string { 18 | return TableNameAnnounceConfig 19 | } 20 | -------------------------------------------------------------------------------- /dal/model/configuration.gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by gorm.io/gen. DO NOT EDIT. 2 | // Code generated by gorm.io/gen. DO NOT EDIT. 3 | // Code generated by gorm.io/gen. DO NOT EDIT. 4 | 5 | package model 6 | 7 | import ( 8 | "time" 9 | 10 | "gorm.io/gorm" 11 | ) 12 | 13 | const TableNameConfiguration = "configuration" 14 | 15 | // Configuration mapped from table 16 | type Configuration struct { 17 | ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"` 18 | Key string `gorm:"column:key;type:varchar(255);not null;uniqueIndex:configuration_key_unique,priority:1;comment:键" json:"key"` // 键 19 | Value string `gorm:"column:value;type:varchar(255);not null;comment:值" json:"value"` // 值 20 | DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3)" json:"deleted_at"` 21 | CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"` 22 | UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"` 23 | } 24 | 25 | // TableName Configuration's table name 26 | func (*Configuration) TableName() string { 27 | return TableNameConfiguration 28 | } 29 | -------------------------------------------------------------------------------- /dal/model/guide.gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by gorm.io/gen. DO NOT EDIT. 2 | // Code generated by gorm.io/gen. DO NOT EDIT. 3 | // Code generated by gorm.io/gen. DO NOT EDIT. 4 | 5 | package model 6 | 7 | import ( 8 | "time" 9 | 10 | "gorm.io/gorm" 11 | ) 12 | 13 | const TableNameGuide = "guide" 14 | 15 | // Guide mapped from table 16 | type Guide struct { 17 | ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"` 18 | Group_ string `gorm:"column:group;type:varchar(32);not null;uniqueIndex:guide_group_unique,priority:1;comment:组别" json:"group"` // 组别 19 | Guide string `gorm:"column:guide;type:json;not null;comment:指南" json:"guide"` // 指南 20 | DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3)" json:"deleted_at"` 21 | CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"` 22 | UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"` 23 | } 24 | 25 | // TableName Guide's table name 26 | func (*Guide) TableName() string { 27 | return TableNameGuide 28 | } 29 | -------------------------------------------------------------------------------- /dal/model/questions.gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by gorm.io/gen. DO NOT EDIT. 2 | // Code generated by gorm.io/gen. DO NOT EDIT. 3 | // Code generated by gorm.io/gen. DO NOT EDIT. 4 | 5 | package model 6 | 7 | import ( 8 | "time" 9 | 10 | "gorm.io/gorm" 11 | ) 12 | 13 | const TableNameQuestion = "questions" 14 | 15 | // Question mapped from table 16 | type Question struct { 17 | ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"` 18 | Question string `gorm:"column:question;type:text;not null;comment:问题内容" json:"question"` // 问题内容 19 | Group_ string `gorm:"column:group;type:varchar(32);not null;comment:问题所属组别" json:"group"` // 问题所属组别 20 | DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3)" json:"deleted_at"` 21 | CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"` 22 | UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"` 23 | } 24 | 25 | // TableName Question's table name 26 | func (*Question) TableName() string { 27 | return TableNameQuestion 28 | } 29 | -------------------------------------------------------------------------------- /dal/model/receive_sms.gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by gorm.io/gen. DO NOT EDIT. 2 | // Code generated by gorm.io/gen. DO NOT EDIT. 3 | // Code generated by gorm.io/gen. DO NOT EDIT. 4 | 5 | package model 6 | 7 | import ( 8 | "time" 9 | 10 | "gorm.io/gorm" 11 | ) 12 | 13 | const TableNameReceiveSm = "receive_sms" 14 | 15 | // ReceiveSm mapped from table 16 | type ReceiveSm struct { 17 | ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"` 18 | Phone string `gorm:"column:phone;type:varchar(16);not null;index:receive_sms_phone_index,priority:1;comment:手机号码" json:"phone"` // 手机号码 19 | Content string `gorm:"column:content;type:text;not null;comment:内容" json:"content"` // 内容 20 | DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3)" json:"deleted_at"` 21 | CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"` 22 | UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"` 23 | } 24 | 25 | // TableName ReceiveSm's table name 26 | func (*ReceiveSm) TableName() string { 27 | return TableNameReceiveSm 28 | } 29 | -------------------------------------------------------------------------------- /dal/model/time_configs.gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by gorm.io/gen. DO NOT EDIT. 2 | // Code generated by gorm.io/gen. DO NOT EDIT. 3 | // Code generated by gorm.io/gen. DO NOT EDIT. 4 | 5 | package model 6 | 7 | import ( 8 | "time" 9 | ) 10 | 11 | const TableNameTimeConfig = "time_configs" 12 | 13 | // TimeConfig mapped from table 14 | type TimeConfig struct { 15 | Key string `gorm:"column:key;type:varchar(255);primaryKey;comment:键" json:"key"` // 键 16 | Value time.Time `gorm:"column:value;type:datetime(3);not null;comment:值" json:"value"` // 值 17 | } 18 | 19 | // TableName TimeConfig's table name 20 | func (*TimeConfig) TableName() string { 21 | return TableNameTimeConfig 22 | } 23 | -------------------------------------------------------------------------------- /hr-admin-api/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.20-alpine AS builder 2 | 3 | LABEL stage=gobuilder 4 | 5 | ENV CGO_ENABLED 0 6 | ENV GOPROXY https://goproxy.cn,direct 7 | RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories 8 | 9 | RUN apk update --no-cache && apk add --no-cache tzdata 10 | 11 | WORKDIR /build 12 | 13 | ADD go.mod . 14 | ADD go.sum . 15 | RUN go mod download 16 | COPY . . 17 | WORKDIR /build/hr-admin-api 18 | RUN go build -ldflags="-s -w" -o /app/hr-admin-api . 19 | 20 | 21 | FROM scratch 22 | 23 | COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt 24 | COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai 25 | ENV TZ Asia/Shanghai 26 | 27 | WORKDIR /app 28 | COPY --from=builder /app/hr-admin-api /app/hr-admin-api 29 | 30 | CMD ["./hr-admin-api", "-f", "etc/config.yaml"] 31 | -------------------------------------------------------------------------------- /hr-admin-api/api/config.api: -------------------------------------------------------------------------------- 1 | syntax = "v1" 2 | 3 | info( 4 | title: "Human Resource" 5 | desc: "华南虎面试系统" 6 | author: "22-信息-常霆钰" 7 | email: "1067088037@qq.com" 8 | version: "v1" 9 | ) 10 | 11 | type ( 12 | GetConfigReq { 13 | Key string `path:"key"` 14 | } 15 | 16 | GetConfigResp { 17 | Key string `json:"key"` 18 | Value string `json:"value"` 19 | } 20 | 21 | SetConfigReq { 22 | Key string `path:"key"` 23 | Value string `form:"value"` 24 | } 25 | 26 | SetConfigResp { 27 | Key string `json:"key"` 28 | Value string `json:"value"` 29 | } 30 | 31 | GetSmsServiceConfigResp { 32 | Debug bool `json:"debug"` 33 | Enabled bool `json:"enabled"` 34 | SendUrl string `json:"sendUrl"` 35 | UserName string `json:"userName"` 36 | } 37 | ) 38 | 39 | @server( 40 | prefix: /api/admin/config 41 | group: config 42 | jwt: Auth 43 | ) 44 | service hr-admin { 45 | @doc "获取配置" 46 | @handler GetConfig 47 | get /key/:key (GetConfigReq) returns (GetConfigResp) 48 | 49 | @doc "设置配置" 50 | @handler SetConfig 51 | post /key/:key (SetConfigReq) returns (SetConfigResp) 52 | 53 | @doc "获取短信服务配置" 54 | @handler GetSmsServiceConfig 55 | get /sms-service returns (GetSmsServiceConfigResp) 56 | } -------------------------------------------------------------------------------- /hr-admin-api/api/statistics.api: -------------------------------------------------------------------------------- 1 | syntax = "v1" 2 | 3 | info( 4 | title: "Human Resource" 5 | desc: "华南虎面试系统" 6 | author: "22-信息-常霆钰" 7 | email: "1067088037@qq.com" 8 | version: "v1" 9 | ) 10 | 11 | type ( 12 | DailyNewApplicant { 13 | Date string `json:"date"` 14 | Counts int32 `json:"counts"` 15 | } 16 | 17 | DailyNewResp { 18 | Applicants []DailyNewApplicant `json:"applicants"` 19 | } 20 | 21 | ClassReq { 22 | Group string `form:"group"` 23 | Key string `form:"key"` 24 | } 25 | 26 | ClassItem { 27 | Key string `json:"key"` 28 | Count int32 `json:"count"` 29 | } 30 | 31 | ClassResp { 32 | Class []ClassItem `json:"class"` 33 | } 34 | ) 35 | 36 | @server( 37 | prefix: /api/admin/statistics 38 | group: statistics 39 | jwt: Auth 40 | ) 41 | service hr-admin { 42 | @doc "获取每日新增" 43 | @handler GetDailyNew 44 | get /dailynew returns (DailyNewResp) 45 | 46 | @doc "获取分类统计" 47 | @handler GetClass 48 | get /class (ClassReq) returns (ClassResp) 49 | } -------------------------------------------------------------------------------- /hr-admin-api/api/timeconfig.api: -------------------------------------------------------------------------------- 1 | syntax = "v1" 2 | 3 | info( 4 | title: "Human Resource" 5 | desc: "华南虎面试系统" 6 | author: "22-信息-常霆钰" 7 | email: "1067088037@qq.com" 8 | version: "v1" 9 | ) 10 | 11 | type ( 12 | TimeConfigItem { 13 | Key string `json:"key"` 14 | Value string `json:"value"` 15 | } 16 | 17 | PostTimeConfigReq { 18 | TimeConfigs []TimeConfigItem `json:"timeConfigs"` 19 | } 20 | 21 | PostTimeConfigResp { 22 | TimeConfigs []TimeConfigItem `json:"timeConfigs"` 23 | } 24 | ) 25 | 26 | @server( 27 | prefix: /api/admin/time-config 28 | group: timeconfig 29 | jwt: Auth 30 | ) 31 | service hr-admin { 32 | // 与PHP版本略有不同,删去了Path参数key 33 | @doc "更新时间配置" 34 | @handler PostTimeConfig 35 | post / (PostTimeConfigReq) returns (PostTimeConfigResp) 36 | } -------------------------------------------------------------------------------- /hr-admin-api/etc/hr-admin.yaml: -------------------------------------------------------------------------------- 1 | Name: hr-admin 2 | Host: 0.0.0.0 3 | Port: 8889 4 | Etcd: 5 | Hosts: 6 | - 127.0.0.1:2379 7 | Key: admin.rpc 8 | Auth: 9 | AccessSecret: "12345678.debug" 10 | AccessExpire: 28800 11 | -------------------------------------------------------------------------------- /hr-admin-api/hr-admin.api: -------------------------------------------------------------------------------- 1 | syntax = "v1" 2 | 3 | info( 4 | title: "Human Resource" 5 | desc: "华南虎面试系统" 6 | author: "22-信息-常霆钰" 7 | email: "1067088037@qq.com" 8 | version: "v1" 9 | ) 10 | 11 | import "api/admin.api" 12 | import "api/applicant.api" 13 | import "api/config.api" 14 | import "api/evaluation.api" 15 | import "api/exam.api" 16 | import "api/remarks.api" 17 | import "api/scores.api" 18 | import "api/statistics.api" 19 | import "api/timeconfig.api" 20 | import "api/times.api" 21 | import "api/sms.api" 22 | import "api/room.api" 23 | 24 | type PingResp { 25 | Ping string `json:"ping"` 26 | } 27 | 28 | @server( 29 | prefix : /api/admin 30 | ) 31 | service hr-admin { 32 | @doc "Ping" 33 | @handler Ping 34 | get /ping returns (PingResp) 35 | } -------------------------------------------------------------------------------- /hr-admin-api/hr-admin.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "net/http" 7 | 8 | "HR_Go/hr-admin-api/internal/config" 9 | "HR_Go/hr-admin-api/internal/handler" 10 | "HR_Go/hr-admin-api/internal/svc" 11 | 12 | "github.com/zeromicro/go-zero/core/conf" 13 | "github.com/zeromicro/go-zero/rest" 14 | ) 15 | 16 | var configFile = flag.String("f", "etc/hr-admin.yaml", "the config file") 17 | 18 | func main() { 19 | flag.Parse() 20 | 21 | var c config.Config 22 | conf.MustLoad(*configFile, &c) 23 | 24 | server := rest.MustNewServer(c.RestConf, rest.WithUnauthorizedCallback(unauthorizedCallback)) 25 | defer server.Stop() 26 | 27 | ctx := svc.NewServiceContext(c) 28 | handler.RegisterHandlers(server, ctx) 29 | 30 | fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) 31 | server.Start() 32 | } 33 | 34 | func unauthorizedCallback(w http.ResponseWriter, r *http.Request, err error) { 35 | w.WriteHeader(http.StatusUnauthorized) 36 | _, err = w.Write([]byte(err.Error())) 37 | if err != nil { 38 | return 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /hr-admin-api/internal/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "HR_Go/common" 5 | "github.com/zeromicro/go-zero/core/discov" 6 | "github.com/zeromicro/go-zero/rest" 7 | ) 8 | 9 | type Config struct { 10 | rest.RestConf 11 | Auth common.Auth 12 | Etcd discov.EtcdConf 13 | } 14 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/admin/getadmininfohandler.go: -------------------------------------------------------------------------------- 1 | package admin 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/admin" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetAdminInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := admin.NewGetAdminInfoLogic(r.Context(), svcCtx) 14 | resp, err := l.GetAdminInfo() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/admin/getfrontendconfighandler.go: -------------------------------------------------------------------------------- 1 | package admin 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/admin" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetFrontendConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := admin.NewGetFrontendConfigLogic(r.Context(), svcCtx) 14 | resp, err := l.GetFrontendConfig() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/admin/getoauthconfighandler.go: -------------------------------------------------------------------------------- 1 | package admin 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/admin" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetOAuthConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := admin.NewGetOAuthConfigLogic(r.Context(), svcCtx) 14 | resp, err := l.GetOAuthConfig() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/admin/loginhandler.go: -------------------------------------------------------------------------------- 1 | package admin 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/admin" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func LoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.LoginReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := admin.NewLoginLogic(r.Context(), svcCtx) 21 | resp, err := l.Login(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/admin/logouthandler.go: -------------------------------------------------------------------------------- 1 | package admin 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/admin" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func LogoutHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := admin.NewLogoutLogic(r.Context(), svcCtx) 14 | err := l.Logout() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.Ok(w) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/admin/setdefaultstandardhandler.go: -------------------------------------------------------------------------------- 1 | package admin 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/admin" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func SetDefaultStandardHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.SetDefaultStandardReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := admin.NewSetDefaultStandardLogic(r.Context(), svcCtx) 21 | err := l.SetDefaultStandard(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/applicant/admitresethandler.go: -------------------------------------------------------------------------------- 1 | package applicant 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/applicant" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func AdmitResetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.AdmitResetReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := applicant.NewAdmitResetLogic(r.Context(), svcCtx) 21 | err := l.AdmitReset(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/applicant/admitsethandler.go: -------------------------------------------------------------------------------- 1 | package applicant 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/applicant" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func AdmitSetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.AdmitSetReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := applicant.NewAdmitSetLogic(r.Context(), svcCtx) 21 | err := l.AdmitSet(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/applicant/deleteapplicanthandler.go: -------------------------------------------------------------------------------- 1 | package applicant 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/applicant" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func DeleteApplicantHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.DeleteApplicantReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := applicant.NewDeleteApplicantLogic(r.Context(), svcCtx) 21 | err := l.DeleteApplicant(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/applicant/getapplicantgrouphandler.go: -------------------------------------------------------------------------------- 1 | package applicant 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/applicant" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetApplicantGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetGroupReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := applicant.NewGetApplicantGroupLogic(r.Context(), svcCtx) 21 | resp, err := l.GetApplicantGroup(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/applicant/getapplicantinfohandler.go: -------------------------------------------------------------------------------- 1 | package applicant 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/applicant" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetApplicantInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetInfoReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := applicant.NewGetApplicantInfoLogic(r.Context(), svcCtx) 21 | resp, err := l.GetApplicantInfo(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/applicant/getapplicantscoreshandler.go: -------------------------------------------------------------------------------- 1 | package applicant 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/applicant" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetApplicantScoresHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetScoresReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := applicant.NewGetApplicantScoresLogic(r.Context(), svcCtx) 21 | resp, err := l.GetApplicantScores(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/applicant/getnamelisthandler.go: -------------------------------------------------------------------------------- 1 | package applicant 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/applicant" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetNameListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := applicant.NewGetNameListLogic(r.Context(), svcCtx) 14 | resp, err := l.GetNameList() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/applicant/setapplicanttimeextendhandler.go: -------------------------------------------------------------------------------- 1 | package applicant 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/applicant" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func SetApplicantTimeExtendHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.SetApplicantTimeExtendReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := applicant.NewSetApplicantTimeExtendLogic(r.Context(), svcCtx) 21 | err := l.SetApplicantTimeExtend(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/config/getconfighandler.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/config" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetConfigReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := config.NewGetConfigLogic(r.Context(), svcCtx) 21 | resp, err := l.GetConfig(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/config/getsmsserviceconfighandler.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/config" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetSmsServiceConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := config.NewGetSmsServiceConfigLogic(r.Context(), svcCtx) 14 | resp, err := l.GetSmsServiceConfig() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/config/setconfighandler.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/config" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func SetConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.SetConfigReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := config.NewSetConfigLogic(r.Context(), svcCtx) 21 | resp, err := l.SetConfig(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/evaluation/addevaluationhandler.go: -------------------------------------------------------------------------------- 1 | package evaluation 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/evaluation" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func AddEvaluationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.AddEvaluationReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := evaluation.NewAddEvaluationLogic(r.Context(), svcCtx) 21 | resp, err := l.AddEvaluation(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/evaluation/deleteevaluationhandler.go: -------------------------------------------------------------------------------- 1 | package evaluation 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/evaluation" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func DeleteEvaluationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.DeleteEvaluationReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := evaluation.NewDeleteEvaluationLogic(r.Context(), svcCtx) 21 | err := l.DeleteEvaluation(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/evaluation/getevaluationinfohandler.go: -------------------------------------------------------------------------------- 1 | package evaluation 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/evaluation" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetEvaluationInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetEvaluationInfoReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := evaluation.NewGetEvaluationInfoLogic(r.Context(), svcCtx) 21 | resp, err := l.GetEvaluationInfo(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/evaluation/getevaluationlisthandler.go: -------------------------------------------------------------------------------- 1 | package evaluation 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/evaluation" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetEvaluationListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := evaluation.NewGetEvaluationListLogic(r.Context(), svcCtx) 14 | resp, err := l.GetEvaluationList() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/evaluation/updateevaluationhandler.go: -------------------------------------------------------------------------------- 1 | package evaluation 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/evaluation" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func UpdateEvaluationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.UpdateEvaluationReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := evaluation.NewUpdateEvaluationLogic(r.Context(), svcCtx) 21 | resp, err := l.UpdateEvaluation(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/exam/createexamhandler.go: -------------------------------------------------------------------------------- 1 | package exam 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/exam" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func CreateExamHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.CreateExamReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := exam.NewCreateExamLogic(r.Context(), svcCtx) 21 | resp, err := l.CreateExam(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/exam/deleteexamhandler.go: -------------------------------------------------------------------------------- 1 | package exam 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/exam" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func DeleteExamHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.DeleteExamReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := exam.NewDeleteExamLogic(r.Context(), svcCtx) 21 | resp, err := l.DeleteExam(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/exam/getexambyapplicantidhandler.go: -------------------------------------------------------------------------------- 1 | package exam 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/exam" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetExamByApplicantIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetExamByApplicantIdReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := exam.NewGetExamByApplicantIdLogic(r.Context(), svcCtx) 21 | resp, err := l.GetExamByApplicantId(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/exam/getexamgrouphandler.go: -------------------------------------------------------------------------------- 1 | package exam 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/exam" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetExamGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetExamGroupReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := exam.NewGetExamGroupLogic(r.Context(), svcCtx) 21 | resp, err := l.GetExamGroup(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/exam/updateexamhandler.go: -------------------------------------------------------------------------------- 1 | package exam 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/exam" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func UpdateExamHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.UpdateExamReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := exam.NewUpdateExamLogic(r.Context(), svcCtx) 21 | resp, err := l.UpdateExam(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/pinghandler.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func PingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := logic.NewPingLogic(r.Context(), svcCtx) 14 | resp, err := l.Ping() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/remarks/deleteremarkshandler.go: -------------------------------------------------------------------------------- 1 | package remarks 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/remarks" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func DeleteRemarksHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.DeleteRemarksReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := remarks.NewDeleteRemarksLogic(r.Context(), svcCtx) 21 | err := l.DeleteRemarks(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/remarks/getremarkshandler.go: -------------------------------------------------------------------------------- 1 | package remarks 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/remarks" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetRemarksHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetRemarksReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := remarks.NewGetRemarksLogic(r.Context(), svcCtx) 21 | resp, err := l.GetRemarks(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/remarks/getremarkslisthandler.go: -------------------------------------------------------------------------------- 1 | package remarks 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/remarks" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetRemarksListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetRemarksListReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := remarks.NewGetRemarksListLogic(r.Context(), svcCtx) 21 | resp, err := l.GetRemarksList(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/remarks/postremarkshandler.go: -------------------------------------------------------------------------------- 1 | package remarks 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/remarks" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func PostRemarksHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.PostRemarksReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := remarks.NewPostRemarksLogic(r.Context(), svcCtx) 21 | resp, err := l.PostRemarks(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/room/getallroomhandler.go: -------------------------------------------------------------------------------- 1 | package room 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/room" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetAllRoomHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := room.NewGetAllRoomLogic(r.Context(), svcCtx) 14 | resp, err := l.GetAllRoom() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/room/getpushablelisthandler.go: -------------------------------------------------------------------------------- 1 | package room 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/room" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetPushableListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := room.NewGetPushableListLogic(r.Context(), svcCtx) 14 | resp, err := l.GetPushableList() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/room/pushapplicanthandler.go: -------------------------------------------------------------------------------- 1 | package room 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/room" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func PushApplicantHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.PushApplicantReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := room.NewPushApplicantLogic(r.Context(), svcCtx) 21 | err := l.PushApplicant(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/room/setmyroomhandler.go: -------------------------------------------------------------------------------- 1 | package room 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/room" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func SetMyRoomHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.SetMyRoomReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := room.NewSetMyRoomLogic(r.Context(), svcCtx) 21 | err := l.SetMyRoom(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/room/setroomcommenthandler.go: -------------------------------------------------------------------------------- 1 | package room 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/room" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func SetRoomCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.SetRoomCommentReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := room.NewSetRoomCommentLogic(r.Context(), svcCtx) 21 | err := l.SetRoomComment(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/room/setroomgrouphandler.go: -------------------------------------------------------------------------------- 1 | package room 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/room" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func SetRoomGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.SetRoomGroupReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := room.NewSetRoomGroupLogic(r.Context(), svcCtx) 21 | err := l.SetRoomGroup(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/room/setroomstatushandler.go: -------------------------------------------------------------------------------- 1 | package room 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/room" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func SetRoomStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.SetRoomStatusReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := room.NewSetRoomStatusLogic(r.Context(), svcCtx) 21 | err := l.SetRoomStatus(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/scores/deletescorehandler.go: -------------------------------------------------------------------------------- 1 | package scores 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/scores" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func DeleteScoreHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.DeleteScoreReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := scores.NewDeleteScoreLogic(r.Context(), svcCtx) 21 | resp, err := l.DeleteScore(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/scores/getrankhandler.go: -------------------------------------------------------------------------------- 1 | package scores 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/scores" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetRankHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetRankReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := scores.NewGetRankLogic(r.Context(), svcCtx) 21 | resp, err := l.GetRank(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/scores/getscoreshandler.go: -------------------------------------------------------------------------------- 1 | package scores 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/scores" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetScoresHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetScoreReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := scores.NewGetScoresLogic(r.Context(), svcCtx) 21 | resp, err := l.GetScores(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/scores/postscorehandler.go: -------------------------------------------------------------------------------- 1 | package scores 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/scores" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func PostScoreHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.PostScoreReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := scores.NewPostScoreLogic(r.Context(), svcCtx) 21 | resp, err := l.PostScore(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/sms/getapplicantsmshandler.go: -------------------------------------------------------------------------------- 1 | package sms 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/sms" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetApplicantSmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetApplicantSmsReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := sms.NewGetApplicantSmsLogic(r.Context(), svcCtx) 21 | resp, err := l.GetApplicantSms(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/sms/gethistorysmshandler.go: -------------------------------------------------------------------------------- 1 | package sms 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/sms" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetHistorySmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetHistorySmsReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := sms.NewGetHistorySmsLogic(r.Context(), svcCtx) 21 | resp, err := l.GetHistorySms(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/sms/getsmsconfighandler.go: -------------------------------------------------------------------------------- 1 | package sms 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/sms" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetSmsConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := sms.NewGetSmsConfigLogic(r.Context(), svcCtx) 14 | resp, err := l.GetSmsConfig() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/sms/receivesmshandler.go: -------------------------------------------------------------------------------- 1 | package sms 2 | 3 | import ( 4 | "net/http" 5 | "strconv" 6 | 7 | "HR_Go/hr-admin-api/internal/logic/sms" 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | "github.com/zeromicro/go-zero/rest/httpx" 11 | ) 12 | 13 | func ReceiveSmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 14 | return func(w http.ResponseWriter, r *http.Request) { 15 | var req types.ReceiveSmsReq 16 | if err := httpx.Parse(r, &req); err != nil { 17 | httpx.ErrorCtx(r.Context(), w, err) 18 | return 19 | } 20 | 21 | l := sms.NewReceiveSmsLogic(r.Context(), svcCtx) 22 | resp, err := l.ReceiveSms(&req) 23 | if err != nil { 24 | httpx.ErrorCtx(r.Context(), w, err) 25 | } else { 26 | _, err := w.Write([]byte(strconv.Itoa(int(resp.Code)))) 27 | if err != nil { 28 | return 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/sms/sendsmshandler.go: -------------------------------------------------------------------------------- 1 | package sms 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/sms" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func SendSmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.SendSmsReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := sms.NewSendSmsLogic(r.Context(), svcCtx) 21 | err := l.SendSms(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/statistics/getclasshandler.go: -------------------------------------------------------------------------------- 1 | package statistics 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/statistics" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetClassHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.ClassReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := statistics.NewGetClassLogic(r.Context(), svcCtx) 21 | resp, err := l.GetClass(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/statistics/getdailynewhandler.go: -------------------------------------------------------------------------------- 1 | package statistics 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/statistics" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetDailyNewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := statistics.NewGetDailyNewLogic(r.Context(), svcCtx) 14 | resp, err := l.GetDailyNew() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/timeconfig/posttimeconfighandler.go: -------------------------------------------------------------------------------- 1 | package timeconfig 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/timeconfig" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func PostTimeConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.PostTimeConfigReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := timeconfig.NewPostTimeConfigLogic(r.Context(), svcCtx) 21 | resp, err := l.PostTimeConfig(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/times/cleartimehandler.go: -------------------------------------------------------------------------------- 1 | package times 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/times" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func ClearTimeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.ClearTimeReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := times.NewClearTimeLogic(r.Context(), svcCtx) 21 | err := l.ClearTime(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/times/getexporthandler.go: -------------------------------------------------------------------------------- 1 | package times 2 | 3 | import ( 4 | "io" 5 | "net/http" 6 | "os" 7 | 8 | "HR_Go/hr-admin-api/internal/logic/times" 9 | "HR_Go/hr-admin-api/internal/svc" 10 | "HR_Go/hr-admin-api/internal/types" 11 | "github.com/zeromicro/go-zero/rest/httpx" 12 | ) 13 | 14 | func GetExportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 15 | return func(w http.ResponseWriter, r *http.Request) { 16 | var req types.GetExportReq 17 | if err := httpx.Parse(r, &req); err != nil { 18 | httpx.ErrorCtx(r.Context(), w, err) 19 | return 20 | } 21 | 22 | l := times.NewGetExportLogic(r.Context(), svcCtx) 23 | bytes, err := l.GetExport(&req) 24 | if err != nil { 25 | httpx.ErrorCtx(r.Context(), w, err) 26 | } else { 27 | tempDir, err := os.MkdirTemp("", "export") 28 | if err != nil { 29 | return 30 | } 31 | file, err := os.CreateTemp(tempDir, "export.csv") 32 | if err != nil { 33 | return 34 | } 35 | defer os.Remove(file.Name()) 36 | _, err = io.WriteString(file, string(bytes)) 37 | if err != nil { 38 | return 39 | } 40 | http.ServeFile(w, r, file.Name()) 41 | return 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/times/getschedulehandler.go: -------------------------------------------------------------------------------- 1 | package times 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/times" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetScheduleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetScheduleReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := times.NewGetScheduleLogic(r.Context(), svcCtx) 21 | resp, err := l.GetSchedule(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/times/getstatisticshandler.go: -------------------------------------------------------------------------------- 1 | package times 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/times" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetStatisticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := times.NewGetStatisticsLogic(r.Context(), svcCtx) 14 | resp, err := l.GetStatistics() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-admin-api/internal/handler/times/postuploadhandler.go: -------------------------------------------------------------------------------- 1 | package times 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-admin-api/internal/logic/times" 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func PostUploadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.PostUploadReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := times.NewPostUploadLogic(r.Context(), svcCtx) 21 | err := l.PostUpload(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.Ok(w) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/admin/getfrontendconfiglogic.go: -------------------------------------------------------------------------------- 1 | package admin 2 | 3 | import ( 4 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 5 | "context" 6 | 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type GetFrontendConfigLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewGetFrontendConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFrontendConfigLogic { 20 | return &GetFrontendConfigLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *GetFrontendConfigLogic) GetFrontendConfig() (resp *types.FrontendConfig, err error) { 28 | configResp, err := l.svcCtx.AdminService.GetFrontendConfig(l.ctx, &hr_admin_service.AdminIdReq{AdminId: 0}) 29 | if err != nil { 30 | return nil, err 31 | } 32 | 33 | return &types.FrontendConfig{ 34 | Debug: configResp.Debug, 35 | OAuth: types.OAuth{ 36 | ClientId: configResp.ClientId, 37 | RedirectUri: configResp.RedirectUri, 38 | }, 39 | Url: types.Url{ 40 | AdminUri: configResp.AdminUri, 41 | WechatUri: configResp.WechatUri, 42 | BaseUri: configResp.BaseUri, 43 | }, 44 | }, nil 45 | } 46 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/admin/logoutlogic.go: -------------------------------------------------------------------------------- 1 | package admin 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type LogoutLogic struct { 13 | logx.Logger 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | } 17 | 18 | func NewLogoutLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LogoutLogic { 19 | return &LogoutLogic{ 20 | Logger: logx.WithContext(ctx), 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | } 24 | } 25 | 26 | func (l *LogoutLogic) Logout() error { 27 | _, err := l.svcCtx.AdminService.AdminLogout(l.ctx, &hr_admin_service.AdminIdReq{AdminId: common.GetUserInfo(l.ctx).Id}) 28 | if err != nil { 29 | return err 30 | } 31 | 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/admin/setdefaultstandardlogic.go: -------------------------------------------------------------------------------- 1 | package admin 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type SetDefaultStandardLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewSetDefaultStandardLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetDefaultStandardLogic { 21 | return &SetDefaultStandardLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *SetDefaultStandardLogic) SetDefaultStandard(req *types.SetDefaultStandardReq) error { 29 | _, err := l.svcCtx.AdminService.SetDefaultStandard(l.ctx, &hr_admin_service.SetDefaultStandardReq{ 30 | AdminId: common.GetUserInfo(l.ctx).Id, 31 | StandardId: req.StandardId, 32 | }) 33 | if err != nil { 34 | return err 35 | } 36 | 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/applicant/admitresetlogic.go: -------------------------------------------------------------------------------- 1 | package applicant 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type AdmitResetLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewAdmitResetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdmitResetLogic { 21 | return &AdmitResetLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *AdmitResetLogic) AdmitReset(req *types.AdmitResetReq) error { 29 | _, err := l.svcCtx.AdminService.SetApplicantAdmit(l.ctx, &hr_admin_service.SetApplicantAdmitReq{ 30 | ApplicantId: req.ApplicantId, 31 | Group: req.Group, 32 | Admit: false, 33 | AdminId: common.GetUserInfo(l.ctx).Id, 34 | }) 35 | if err != nil { 36 | return err 37 | } 38 | 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/applicant/admitsetlogic.go: -------------------------------------------------------------------------------- 1 | package applicant 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type AdmitSetLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewAdmitSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdmitSetLogic { 21 | return &AdmitSetLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *AdmitSetLogic) AdmitSet(req *types.AdmitSetReq) error { 29 | _, err := l.svcCtx.AdminService.SetApplicantAdmit(l.ctx, &hr_admin_service.SetApplicantAdmitReq{ 30 | ApplicantId: req.ApplicantId, 31 | Group: req.Group, 32 | Admit: true, 33 | AdminId: common.GetUserInfo(l.ctx).Id, 34 | }) 35 | if err != nil { 36 | return err 37 | } 38 | 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/applicant/deleteapplicantlogic.go: -------------------------------------------------------------------------------- 1 | package applicant 2 | 3 | import ( 4 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 5 | "context" 6 | 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteApplicantLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewDeleteApplicantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteApplicantLogic { 20 | return &DeleteApplicantLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *DeleteApplicantLogic) DeleteApplicant(req *types.DeleteApplicantReq) error { 28 | _, err := l.svcCtx.AdminService.DeleteApplicant(l.ctx, &hr_admin_service.ApplicantIdReq{ApplicantId: req.Id}) 29 | if err != nil { 30 | return err 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/applicant/getapplicantscoreslogic.go: -------------------------------------------------------------------------------- 1 | package applicant 2 | 3 | import ( 4 | "HR_Go/hr-admin-api/internal/logic" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type GetApplicantScoresLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewGetApplicantScoresLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetApplicantScoresLogic { 21 | return &GetApplicantScoresLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *GetApplicantScoresLogic) GetApplicantScores(req *types.GetScoresReq) (resp *types.GetScoresResp, err error) { 29 | scoresResp, err := l.svcCtx.AdminService.GetApplicantScores(l.ctx, &hr_admin_service.ApplicantIdReq{ApplicantId: req.Id}) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | return &types.GetScoresResp{ 35 | Scores: logic.ScoresGrpcToApi(scoresResp.Scores), 36 | }, nil 37 | } 38 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/applicant/getnamelistlogic.go: -------------------------------------------------------------------------------- 1 | package applicant 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/hr-admin-api/internal/logic" 6 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 7 | "context" 8 | 9 | "HR_Go/hr-admin-api/internal/svc" 10 | "HR_Go/hr-admin-api/internal/types" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type GetNameListLogic struct { 16 | logx.Logger 17 | ctx context.Context 18 | svcCtx *svc.ServiceContext 19 | } 20 | 21 | func NewGetNameListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetNameListLogic { 22 | return &GetNameListLogic{ 23 | Logger: logx.WithContext(ctx), 24 | ctx: ctx, 25 | svcCtx: svcCtx, 26 | } 27 | } 28 | 29 | func (l *GetNameListLogic) GetNameList() (resp *types.GetNameListResp, err error) { 30 | list, err := l.svcCtx.AdminService.GetApplicantNameList(l.ctx, &hr_admin_service.AdminIdReq{AdminId: common.GetUserInfo(l.ctx).Id}) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.GetNameListResp{ 36 | List: logic.NameListGrpcToApi(list.NameList), 37 | }, nil 38 | } 39 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/applicant/setapplicanttimeextendlogic.go: -------------------------------------------------------------------------------- 1 | package applicant 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | "encoding/json" 8 | 9 | "HR_Go/hr-admin-api/internal/svc" 10 | "HR_Go/hr-admin-api/internal/types" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type SetApplicantTimeExtendLogic struct { 16 | logx.Logger 17 | ctx context.Context 18 | svcCtx *svc.ServiceContext 19 | } 20 | 21 | func NewSetApplicantTimeExtendLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetApplicantTimeExtendLogic { 22 | return &SetApplicantTimeExtendLogic{ 23 | Logger: logx.WithContext(ctx), 24 | ctx: ctx, 25 | svcCtx: svcCtx, 26 | } 27 | } 28 | 29 | func (l *SetApplicantTimeExtendLogic) SetApplicantTimeExtend(req *types.SetApplicantTimeExtendReq) error { 30 | bytes, err := json.Marshal(req.Extend) 31 | if err != nil { 32 | return err 33 | } 34 | _, err = l.svcCtx.AdminService.SetApplicantTimeExtend(l.ctx, &hr_admin_service.SetApplicantTimeExtendReq{ 35 | ApplicantId: req.AppicantId, 36 | AdminId: common.GetUserInfo(l.ctx).Id, 37 | Group: req.Group, 38 | Extend: string(bytes), 39 | }) 40 | if err != nil { 41 | return err 42 | } 43 | 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/config/getconfiglogic.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 5 | "context" 6 | 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type GetConfigLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewGetConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetConfigLogic { 20 | return &GetConfigLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *GetConfigLogic) GetConfig(req *types.GetConfigReq) (resp *types.GetConfigResp, err error) { 28 | config, err := l.svcCtx.AdminService.GetConfig(l.ctx, &hr_admin_service.GetConfigReq{Key: req.Key}) 29 | if err != nil { 30 | return nil, err 31 | } 32 | 33 | return &types.GetConfigResp{ 34 | Key: config.Key, 35 | Value: config.Value, 36 | }, nil 37 | } 38 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/config/getsmsserviceconfiglogic.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type GetSmsServiceConfigLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewGetSmsServiceConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSmsServiceConfigLogic { 21 | return &GetSmsServiceConfigLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *GetSmsServiceConfigLogic) GetSmsServiceConfig() (resp *types.GetSmsServiceConfigResp, err error) { 29 | config, err := l.svcCtx.AdminService.GetSmsServiceConfig(l.ctx, &hr_admin_service.AdminIdReq{AdminId: common.GetUserInfo(l.ctx).Id}) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | return &types.GetSmsServiceConfigResp{ 35 | Debug: config.Debug, 36 | Enabled: config.Enabled, 37 | SendUrl: config.SendUrl, 38 | UserName: config.UserName, 39 | }, nil 40 | } 41 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/config/setconfiglogic.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 5 | "context" 6 | 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type SetConfigLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewSetConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetConfigLogic { 20 | return &SetConfigLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *SetConfigLogic) SetConfig(req *types.SetConfigReq) (resp *types.SetConfigResp, err error) { 28 | config, err := l.svcCtx.AdminService.UpdateConfig(l.ctx, &hr_admin_service.UpdateConfigReq{ 29 | Key: req.Key, 30 | Value: req.Value, 31 | }) 32 | if err != nil { 33 | return nil, err 34 | } 35 | 36 | return &types.SetConfigResp{ 37 | Key: config.Key, 38 | Value: config.Value, 39 | }, nil 40 | } 41 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/evaluation/deleteevaluationlogic.go: -------------------------------------------------------------------------------- 1 | package evaluation 2 | 3 | import ( 4 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 5 | "context" 6 | 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteEvaluationLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewDeleteEvaluationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteEvaluationLogic { 20 | return &DeleteEvaluationLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *DeleteEvaluationLogic) DeleteEvaluation(req *types.DeleteEvaluationReq) error { 28 | _, err := l.svcCtx.AdminService.DeleteEvaluation(l.ctx, &hr_admin_service.DeleteEvaluationReq{EvaluationId: req.Id}) 29 | if err != nil { 30 | return err 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/evaluation/getevaluationlistlogic.go: -------------------------------------------------------------------------------- 1 | package evaluation 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/hr-admin-api/internal/logic" 6 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 7 | "context" 8 | 9 | "HR_Go/hr-admin-api/internal/svc" 10 | "HR_Go/hr-admin-api/internal/types" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type GetEvaluationListLogic struct { 16 | logx.Logger 17 | ctx context.Context 18 | svcCtx *svc.ServiceContext 19 | } 20 | 21 | func NewGetEvaluationListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetEvaluationListLogic { 22 | return &GetEvaluationListLogic{ 23 | Logger: logx.WithContext(ctx), 24 | ctx: ctx, 25 | svcCtx: svcCtx, 26 | } 27 | } 28 | 29 | func (l *GetEvaluationListLogic) GetEvaluationList() (resp *types.GetEvaluationListResp, err error) { 30 | evaluations, err := l.svcCtx.AdminService.GetEvaluations(l.ctx, &hr_admin_service.AdminIdReq{AdminId: common.GetUserInfo(l.ctx).Id}) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.GetEvaluationListResp{ 36 | List: logic.EvaluationsGrpcToApi(evaluations.Evaluations), 37 | }, nil 38 | } 39 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/exam/createexamlogic.go: -------------------------------------------------------------------------------- 1 | package exam 2 | 3 | import ( 4 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 5 | "context" 6 | 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type CreateExamLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewCreateExamLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateExamLogic { 20 | return &CreateExamLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *CreateExamLogic) CreateExam(req *types.CreateExamReq) (resp *types.CreateExamResp, err error) { 28 | questionResp, err := l.svcCtx.AdminService.CreateQuestion(l.ctx, &hr_admin_service.CreateQuestionReq{ 29 | Group: req.Group, 30 | Question: req.Question, 31 | }) 32 | if err != nil { 33 | return nil, err 34 | } 35 | question := questionResp.Question 36 | 37 | return &types.CreateExamResp{ 38 | Question: types.Question{ 39 | Id: question.Id, 40 | Group: question.Group, 41 | Question: question.Question, 42 | }, 43 | }, nil 44 | } 45 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/exam/deleteexamlogic.go: -------------------------------------------------------------------------------- 1 | package exam 2 | 3 | import ( 4 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 5 | "context" 6 | 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteExamLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewDeleteExamLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteExamLogic { 20 | return &DeleteExamLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *DeleteExamLogic) DeleteExam(req *types.DeleteExamReq) (resp *types.DeleteExamResp, err error) { 28 | _, err = l.svcCtx.AdminService.DeleteQuestion(l.ctx, &hr_admin_service.DeleteQuestionReq{QuestionId: req.Id}) 29 | if err != nil { 30 | return nil, err 31 | } 32 | 33 | return &types.DeleteExamResp{ 34 | Id: req.Id, 35 | }, nil 36 | } 37 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/exam/getexambyapplicantidlogic.go: -------------------------------------------------------------------------------- 1 | package exam 2 | 3 | import ( 4 | "HR_Go/hr-admin-api/internal/logic" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type GetExamByApplicantIdLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewGetExamByApplicantIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExamByApplicantIdLogic { 21 | return &GetExamByApplicantIdLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *GetExamByApplicantIdLogic) GetExamByApplicantId(req *types.GetExamByApplicantIdReq) (resp *types.GetExamByApplicantIdResp, err error) { 29 | questionsResp, err := l.svcCtx.AdminService.GetApplicantQuestions(l.ctx, &hr_admin_service.ApplicantIdReq{ApplicantId: req.ApplicantId}) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | return &types.GetExamByApplicantIdResp{ 35 | ApplicantId: req.ApplicantId, 36 | Questions: logic.QuestionAndAnswerGrpcToApi(questionsResp.Questions), 37 | }, nil 38 | } 39 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/exam/updateexamlogic.go: -------------------------------------------------------------------------------- 1 | package exam 2 | 3 | import ( 4 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 5 | "context" 6 | 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type UpdateExamLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewUpdateExamLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateExamLogic { 20 | return &UpdateExamLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *UpdateExamLogic) UpdateExam(req *types.UpdateExamReq) (resp *types.UpdateExamResp, err error) { 28 | _, err = l.svcCtx.AdminService.UpdateQuestion(l.ctx, &hr_admin_service.UpdateQuestionReq{ 29 | Question: &hr_admin_service.Question{ 30 | Id: req.Id, 31 | Group: req.Group, 32 | Question: req.Question, 33 | }}) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | return &types.UpdateExamResp{ 39 | Id: req.Id, 40 | }, nil 41 | } 42 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/pinglogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 5 | "context" 6 | 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type PingLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic { 20 | return &PingLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *PingLogic) Ping() (resp *types.PingResp, err error) { 28 | ping, err := l.svcCtx.AdminService.Ping(l.ctx, &hr_admin_service.PingRequest{Ping: "ping"}) 29 | if err != nil { 30 | return nil, err 31 | } 32 | return &types.PingResp{Ping: ping.Pong}, nil 33 | } 34 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/remarks/deleteremarkslogic.go: -------------------------------------------------------------------------------- 1 | package remarks 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type DeleteRemarksLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewDeleteRemarksLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteRemarksLogic { 21 | return &DeleteRemarksLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *DeleteRemarksLogic) DeleteRemarks(req *types.DeleteRemarksReq) error { 29 | _, err := l.svcCtx.AdminService.DeleteRemark(l.ctx, &hr_admin_service.DeleteRemarkReq{ 30 | ApplicantId: req.Id, 31 | AdminId: common.GetUserInfo(l.ctx).Id, 32 | }) 33 | if err != nil { 34 | return err 35 | } 36 | 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/remarks/getremarkslistlogic.go: -------------------------------------------------------------------------------- 1 | package remarks 2 | 3 | import ( 4 | "HR_Go/hr-admin-api/internal/logic" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type GetRemarksListLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewGetRemarksListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRemarksListLogic { 21 | return &GetRemarksListLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *GetRemarksListLogic) GetRemarksList(req *types.GetRemarksListReq) (resp *types.GetRemarksListResp, err error) { 29 | remarkList, err := l.svcCtx.AdminService.GetRemarkList(l.ctx, &hr_admin_service.GetRemarkListReq{ApplicantId: req.Id}) 30 | if err != nil { 31 | if logic.ErrorIsNotFound(err) { 32 | return &types.GetRemarksListResp{ 33 | Remarks: make([]types.RemarkItem, 0), 34 | }, nil 35 | } 36 | return nil, err 37 | } 38 | 39 | return &types.GetRemarksListResp{ 40 | Remarks: logic.RemarkGrpcToApi(remarkList.Remarks), 41 | }, nil 42 | } 43 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/remarks/postremarkslogic.go: -------------------------------------------------------------------------------- 1 | package remarks 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type PostRemarksLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewPostRemarksLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostRemarksLogic { 21 | return &PostRemarksLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *PostRemarksLogic) PostRemarks(req *types.PostRemarksReq) (resp *types.RemarksResp, err error) { 29 | remarkResp, err := l.svcCtx.AdminService.PostRemark(l.ctx, &hr_admin_service.PostRemarkReq{ 30 | ApplicantId: req.Id, 31 | AdminId: common.GetUserInfo(l.ctx).Id, 32 | Remark: req.Remark, 33 | }) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | return &types.RemarksResp{ 39 | AdminId: remarkResp.AdminId, 40 | ApplicantId: remarkResp.ApplicantId, 41 | Remark: remarkResp.Remark, 42 | }, nil 43 | } 44 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/room/getallroomlogic.go: -------------------------------------------------------------------------------- 1 | package room 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/hr-admin-api/internal/logic" 6 | "HR_Go/hr-admin-service/hrservice" 7 | "context" 8 | 9 | "HR_Go/hr-admin-api/internal/svc" 10 | "HR_Go/hr-admin-api/internal/types" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type GetAllRoomLogic struct { 16 | logx.Logger 17 | ctx context.Context 18 | svcCtx *svc.ServiceContext 19 | } 20 | 21 | func NewGetAllRoomLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAllRoomLogic { 22 | return &GetAllRoomLogic{ 23 | Logger: logx.WithContext(ctx), 24 | ctx: ctx, 25 | svcCtx: svcCtx, 26 | } 27 | } 28 | 29 | func (l *GetAllRoomLogic) GetAllRoom() (resp *types.GetRoomResp, err error) { 30 | allRoom, err := l.svcCtx.AdminService.GetAllRoom(l.ctx, &hrservice.AdminIdReq{AdminId: common.GetUserInfo(l.ctx).Id}) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.GetRoomResp{ 36 | Rooms: logic.RoomGrpcToApi(allRoom.Rooms), 37 | MyRoomName: allRoom.MyRoomName, 38 | MyRoomId: allRoom.MyRoomId, 39 | }, nil 40 | } 41 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/room/getpushablelistlogic.go: -------------------------------------------------------------------------------- 1 | package room 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/hr-admin-api/internal/logic" 6 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 7 | "context" 8 | 9 | "HR_Go/hr-admin-api/internal/svc" 10 | "HR_Go/hr-admin-api/internal/types" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type GetPushableListLogic struct { 16 | logx.Logger 17 | ctx context.Context 18 | svcCtx *svc.ServiceContext 19 | } 20 | 21 | func NewGetPushableListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPushableListLogic { 22 | return &GetPushableListLogic{ 23 | Logger: logx.WithContext(ctx), 24 | ctx: ctx, 25 | svcCtx: svcCtx, 26 | } 27 | } 28 | 29 | func (l *GetPushableListLogic) GetPushableList() (resp *types.GetPushableListResp, err error) { 30 | pushableList, err := l.svcCtx.AdminService.GetPushableList(l.ctx, &hr_admin_service.AdminIdReq{AdminId: common.GetUserInfo(l.ctx).Id}) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.GetPushableListResp{ 36 | Applicants: logic.PushableApplicantGrpcToApi(pushableList.Applicants), 37 | }, nil 38 | } 39 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/room/pushapplicantlogic.go: -------------------------------------------------------------------------------- 1 | package room 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type PushApplicantLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewPushApplicantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PushApplicantLogic { 21 | return &PushApplicantLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *PushApplicantLogic) PushApplicant(req *types.PushApplicantReq) error { 29 | _, err := l.svcCtx.AdminService.PushApplicant(l.ctx, &hr_admin_service.PushApplicantReq{ 30 | ApplicantId: req.ApplicantId, 31 | ApplicantTimeId: req.ApplicantTimeId, 32 | RoomId: req.RoomId, 33 | AdminId: common.GetUserInfo(l.ctx).Id, 34 | }) 35 | if err != nil { 36 | return err 37 | } 38 | 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/room/setmyroomlogic.go: -------------------------------------------------------------------------------- 1 | package room 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type SetMyRoomLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewSetMyRoomLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetMyRoomLogic { 21 | return &SetMyRoomLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *SetMyRoomLogic) SetMyRoom(req *types.SetMyRoomReq) error { 29 | _, err := l.svcCtx.AdminService.SetMyRoom(l.ctx, &hr_admin_service.SetMyRoomReq{ 30 | AdminId: common.GetUserInfo(l.ctx).Id, 31 | RoomId: req.RoomId, 32 | }) 33 | if err != nil { 34 | return err 35 | } 36 | 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/room/setroomcommentlogic.go: -------------------------------------------------------------------------------- 1 | package room 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type SetRoomCommentLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewSetRoomCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetRoomCommentLogic { 21 | return &SetRoomCommentLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *SetRoomCommentLogic) SetRoomComment(req *types.SetRoomCommentReq) error { 29 | _, err := l.svcCtx.AdminService.SetRoomComment(l.ctx, &hr_admin_service.SetRoomCommentReq{ 30 | RoomId: req.RoomId, 31 | Comment: req.Comment, 32 | AdminId: common.GetUserInfo(l.ctx).Id, 33 | Type: req.Type, 34 | }) 35 | if err != nil { 36 | return err 37 | } 38 | 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/room/setroomgrouplogic.go: -------------------------------------------------------------------------------- 1 | package room 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type SetRoomGroupLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewSetRoomGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetRoomGroupLogic { 21 | return &SetRoomGroupLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *SetRoomGroupLogic) SetRoomGroup(req *types.SetRoomGroupReq) error { 29 | _, err := l.svcCtx.AdminService.SetRoomGroup(l.ctx, &hr_admin_service.SetRoomGroupReq{ 30 | RoomId: req.RoomId, 31 | Group: req.Group, 32 | AdminId: common.GetUserInfo(l.ctx).Id, 33 | }) 34 | if err != nil { 35 | return err 36 | } 37 | 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/room/setroomstatuslogic.go: -------------------------------------------------------------------------------- 1 | package room 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type SetRoomStatusLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewSetRoomStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetRoomStatusLogic { 21 | return &SetRoomStatusLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *SetRoomStatusLogic) SetRoomStatus(req *types.SetRoomStatusReq) error { 29 | _, err := l.svcCtx.AdminService.SetRoomStatus(l.ctx, &hr_admin_service.SetRoomStatusReq{ 30 | RoomId: req.RoomId, 31 | Status: req.Status, 32 | AdminId: common.GetUserInfo(l.ctx).Id, 33 | }) 34 | if err != nil { 35 | return err 36 | } 37 | 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/scores/deletescorelogic.go: -------------------------------------------------------------------------------- 1 | package scores 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type DeleteScoreLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewDeleteScoreLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteScoreLogic { 21 | return &DeleteScoreLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *DeleteScoreLogic) DeleteScore(req *types.DeleteScoreReq) (resp *types.Score, err error) { 29 | _, err = l.svcCtx.AdminService.DeleteScore(l.ctx, &hr_admin_service.DeleteScoreReq{ 30 | ApplicantId: req.Id, 31 | Group: req.Group, 32 | AdminId: common.GetUserInfo(l.ctx).Id, 33 | }) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | return &types.Score{}, nil 39 | } 40 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/scores/getranklogic.go: -------------------------------------------------------------------------------- 1 | package scores 2 | 3 | import ( 4 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 5 | "context" 6 | 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type GetRankLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewGetRankLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRankLogic { 20 | return &GetRankLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *GetRankLogic) GetRank(req *types.GetRankReq) (resp *types.GetRankResp, err error) { 28 | rankResp, err := l.svcCtx.AdminService.GetRank(l.ctx, &hr_admin_service.GetRankReq{ 29 | ApplicantId: req.Id, 30 | Group: req.Group, 31 | }) 32 | if err != nil { 33 | return nil, err 34 | } 35 | 36 | return &types.GetRankResp{ 37 | Rank: rankResp.Rank, 38 | Total: rankResp.Total, 39 | }, nil 40 | } 41 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/sms/getapplicantsmslogic.go: -------------------------------------------------------------------------------- 1 | package sms 2 | 3 | import ( 4 | "HR_Go/hr-admin-api/internal/logic" 5 | "HR_Go/hr-admin-api/internal/svc" 6 | "HR_Go/hr-admin-api/internal/types" 7 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 8 | "context" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type GetApplicantSmsLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewGetApplicantSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetApplicantSmsLogic { 20 | return &GetApplicantSmsLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *GetApplicantSmsLogic) GetApplicantSms(req *types.GetApplicantSmsReq) (resp *types.GetApplicantSmsResp, err error) { 28 | smsResp, err := l.svcCtx.AdminService.GetApplicantSms(l.ctx, &hr_admin_service.GetApplicantSmsReq{ 29 | Typ: req.Type, 30 | Page: req.Page, 31 | PageSize: req.PageSize, 32 | }) 33 | if err != nil { 34 | return nil, err 35 | } 36 | 37 | return &types.GetApplicantSmsResp{ 38 | ApplicantSms: logic.ApplicantSmsGrpcToApi(smsResp.ApplicantSms), 39 | Total: smsResp.Total, 40 | }, nil 41 | } 42 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/sms/gethistorysmslogic.go: -------------------------------------------------------------------------------- 1 | package sms 2 | 3 | import ( 4 | "HR_Go/hr-admin-api/internal/logic" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type GetHistorySmsLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewGetHistorySmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetHistorySmsLogic { 21 | return &GetHistorySmsLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *GetHistorySmsLogic) GetHistorySms(req *types.GetHistorySmsReq) (resp *types.GetHistorySmsResp, err error) { 29 | smsResp, err := l.svcCtx.AdminService.GetHistorySms(l.ctx, &hr_admin_service.ApplicantIdReq{ApplicantId: req.ApplicantId}) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | return &types.GetHistorySmsResp{ 35 | HistorySms: logic.HistorySmsGrpcToApi(smsResp.HistorySms), 36 | }, nil 37 | } 38 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/sms/getsmsconfiglogic.go: -------------------------------------------------------------------------------- 1 | package sms 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type GetSmsConfigLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewGetSmsConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSmsConfigLogic { 21 | return &GetSmsConfigLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *GetSmsConfigLogic) GetSmsConfig() (resp *types.GetSmsConfigResp, err error) { 29 | configResp, err := l.svcCtx.AdminService.GetSmsConfig(l.ctx, &hr_admin_service.AdminIdReq{AdminId: common.GetUserInfo(l.ctx).Id}) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | return &types.GetSmsConfigResp{ 35 | Types: configResp.Types, 36 | Alerts: configResp.Alerts, 37 | }, nil 38 | } 39 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/sms/receivesmslogic.go: -------------------------------------------------------------------------------- 1 | package sms 2 | 3 | import ( 4 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 5 | "context" 6 | 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type ReceiveSmsLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewReceiveSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ReceiveSmsLogic { 20 | return &ReceiveSmsLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *ReceiveSmsLogic) ReceiveSms(req *types.ReceiveSmsReq) (resp *types.ReceiveSmsResp, err error) { 28 | smsResp, err := l.svcCtx.AdminService.ReceiveSms(l.ctx, &hr_admin_service.ReceiveSmsReq{ 29 | Phone: req.Phone, 30 | Content: req.Content, 31 | }) 32 | if err != nil { 33 | return &types.ReceiveSmsResp{Code: 1}, nil 34 | } 35 | 36 | return &types.ReceiveSmsResp{ 37 | Code: smsResp.Code, 38 | }, nil 39 | } 40 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/sms/sendsmslogic.go: -------------------------------------------------------------------------------- 1 | package sms 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type SendSmsLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLogic { 21 | return &SendSmsLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *SendSmsLogic) SendSms(req *types.SendSmsReq) error { 29 | _, err := l.svcCtx.AdminService.SendSms(l.ctx, &hr_admin_service.SendSmsReq{ 30 | AdminId: common.GetUserInfo(l.ctx).Id, 31 | Typ: req.Typ, 32 | ApplicantIds: req.ApplicanrIds, 33 | }) 34 | if err != nil { 35 | return err 36 | } 37 | 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/statistics/getclasslogic.go: -------------------------------------------------------------------------------- 1 | package statistics 2 | 3 | import ( 4 | "HR_Go/hr-admin-api/internal/logic" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type GetClassLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewGetClassLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClassLogic { 21 | return &GetClassLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *GetClassLogic) GetClass(req *types.ClassReq) (resp *types.ClassResp, err error) { 29 | classify, err := l.svcCtx.AdminService.GetStatisticsClassify(l.ctx, &hr_admin_service.GetStatisticsClassifyReq{ 30 | Group: req.Group, 31 | Key: req.Key, 32 | }) 33 | if err != nil { 34 | return nil, err 35 | } 36 | 37 | return &types.ClassResp{ 38 | Class: logic.ClassGrpcToApi(classify.Class), 39 | }, nil 40 | } 41 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/statistics/getdailynewlogic.go: -------------------------------------------------------------------------------- 1 | package statistics 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | "github.com/samber/lo" 8 | 9 | "HR_Go/hr-admin-api/internal/svc" 10 | "HR_Go/hr-admin-api/internal/types" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type GetDailyNewLogic struct { 16 | logx.Logger 17 | ctx context.Context 18 | svcCtx *svc.ServiceContext 19 | } 20 | 21 | func NewGetDailyNewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDailyNewLogic { 22 | return &GetDailyNewLogic{ 23 | Logger: logx.WithContext(ctx), 24 | ctx: ctx, 25 | svcCtx: svcCtx, 26 | } 27 | } 28 | 29 | func (l *GetDailyNewLogic) GetDailyNew() (resp *types.DailyNewResp, err error) { 30 | dailyNew, err := l.svcCtx.AdminService.GetStatisticsDailyNew(l.ctx, &hr_admin_service.AdminIdReq{AdminId: common.GetUserInfo(l.ctx).Id}) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.DailyNewResp{ 36 | Applicants: lo.Map(dailyNew.Applicants, func(item *hr_admin_service.StatisticsDaily, index int) types.DailyNewApplicant { 37 | return types.DailyNewApplicant{ 38 | Date: item.Date, 39 | Counts: item.Count, 40 | } 41 | }), 42 | }, nil 43 | } 44 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/timeconfig/posttimeconfiglogic.go: -------------------------------------------------------------------------------- 1 | package timeconfig 2 | 3 | import ( 4 | "HR_Go/hr-admin-api/internal/logic" 5 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "HR_Go/hr-admin-api/internal/svc" 9 | "HR_Go/hr-admin-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type PostTimeConfigLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewPostTimeConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostTimeConfigLogic { 21 | return &PostTimeConfigLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *PostTimeConfigLogic) PostTimeConfig(req *types.PostTimeConfigReq) (resp *types.PostTimeConfigResp, err error) { 29 | timeConfigResp, err := l.svcCtx.AdminService.PostTimeConfig(l.ctx, &hr_admin_service.PostTimeConfigReq{ 30 | TimeConfigs: logic.TimeConfigApiToGrpc(req.TimeConfigs), 31 | }) 32 | if err != nil { 33 | return nil, err 34 | } 35 | 36 | return &types.PostTimeConfigResp{ 37 | TimeConfigs: logic.TimeConfigGrpcToApi(timeConfigResp.TimeConfigs), 38 | }, nil 39 | } 40 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/times/cleartimelogic.go: -------------------------------------------------------------------------------- 1 | package times 2 | 3 | import ( 4 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 5 | "context" 6 | 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type ClearTimeLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewClearTimeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClearTimeLogic { 20 | return &ClearTimeLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *ClearTimeLogic) ClearTime(req *types.ClearTimeReq) error { 28 | _, err := l.svcCtx.AdminService.ClearTimes(l.ctx, &hr_admin_service.ClearTimesReq{Group: req.Groups}) 29 | if err != nil { 30 | return err 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/times/getexportlogic.go: -------------------------------------------------------------------------------- 1 | package times 2 | 3 | import ( 4 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 5 | "context" 6 | 7 | "HR_Go/hr-admin-api/internal/svc" 8 | "HR_Go/hr-admin-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type GetExportLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewGetExportLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExportLogic { 20 | return &GetExportLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *GetExportLogic) GetExport(req *types.GetExportReq) ([]byte, error) { 28 | timesResp, err := l.svcCtx.AdminService.ExportTimes(l.ctx, &hr_admin_service.ExportTimesReq{Groups: req.Groups}) 29 | if err != nil { 30 | return nil, err 31 | } 32 | 33 | return timesResp.File, nil 34 | } 35 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/times/getstatisticslogic.go: -------------------------------------------------------------------------------- 1 | package times 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/hr-admin-api/internal/logic" 6 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 7 | "context" 8 | 9 | "HR_Go/hr-admin-api/internal/svc" 10 | "HR_Go/hr-admin-api/internal/types" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type GetStatisticsLogic struct { 16 | logx.Logger 17 | ctx context.Context 18 | svcCtx *svc.ServiceContext 19 | } 20 | 21 | func NewGetStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetStatisticsLogic { 22 | return &GetStatisticsLogic{ 23 | Logger: logx.WithContext(ctx), 24 | ctx: ctx, 25 | svcCtx: svcCtx, 26 | } 27 | } 28 | 29 | func (l *GetStatisticsLogic) GetStatistics() (resp *types.GetStatisticsResp, err error) { 30 | statisticsResp, err := l.svcCtx.AdminService.GetTimesStatistics(l.ctx, &hr_admin_service.AdminIdReq{AdminId: common.GetUserInfo(l.ctx).Id}) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.GetStatisticsResp{ 36 | Times: logic.TimeStatisticsGrpcToApi(statisticsResp.Times), 37 | }, nil 38 | } 39 | -------------------------------------------------------------------------------- /hr-admin-api/internal/logic/times/postuploadlogic.go: -------------------------------------------------------------------------------- 1 | package times 2 | 3 | import ( 4 | "HR_Go/hr-admin-api/internal/svc" 5 | "HR_Go/hr-admin-api/internal/types" 6 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 7 | "context" 8 | "github.com/samber/lo" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type PostUploadLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewPostUploadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostUploadLogic { 20 | return &PostUploadLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *PostUploadLogic) PostUpload(req *types.PostUploadReq) error { 28 | _, err := l.svcCtx.AdminService.UploadTimes(l.ctx, &hr_admin_service.UploadTimesReq{ 29 | Groups: req.Groups, 30 | Data: lo.Map(req.Data, func(item map[string]string, index int) *hr_admin_service.TimeItem { 31 | return &hr_admin_service.TimeItem{ 32 | Data: item, 33 | } 34 | }), 35 | }) 36 | if err != nil { 37 | return err 38 | } 39 | 40 | return nil 41 | } 42 | -------------------------------------------------------------------------------- /hr-admin-api/internal/svc/servicecontext.go: -------------------------------------------------------------------------------- 1 | package svc 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/hr-admin-api/internal/config" 6 | hr_admin_service "HR_Go/hr-admin-service/pb/hr-admin-service" 7 | "github.com/zeromicro/go-zero/core/logx" 8 | "github.com/zeromicro/go-zero/zrpc" 9 | "os" 10 | ) 11 | 12 | type ServiceContext struct { 13 | Common common.Config 14 | Config config.Config 15 | AdminService hr_admin_service.HrServiceClient 16 | } 17 | 18 | func NewServiceContext(c config.Config) *ServiceContext { 19 | client := zrpc.MustNewClient(zrpc.RpcClientConf{ 20 | Etcd: c.Etcd, 21 | }) 22 | commonConf, err := common.GetConfig("../common/config.yaml") 23 | if err != nil { 24 | logx.Error("common config load error", err) 25 | os.Exit(1) 26 | return nil 27 | } 28 | return &ServiceContext{ 29 | Common: commonConf, 30 | Config: c, 31 | AdminService: hr_admin_service.NewHrServiceClient(client.Conn()), 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /hr-admin-service/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.20-alpine AS builder 2 | 3 | LABEL stage=gobuilder 4 | 5 | ENV CGO_ENABLED 0 6 | ENV GOPROXY https://goproxy.cn,direct 7 | RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories 8 | 9 | RUN apk update --no-cache && apk add --no-cache tzdata 10 | 11 | WORKDIR /build 12 | 13 | ADD go.mod . 14 | ADD go.sum . 15 | RUN go mod download 16 | COPY . . 17 | WORKDIR /build/hr-admin-service 18 | RUN go build -ldflags="-s -w" -o /app/hr-admin-service . 19 | 20 | 21 | FROM scratch 22 | 23 | COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt 24 | COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai 25 | ENV TZ Asia/Shanghai 26 | 27 | WORKDIR /app 28 | COPY --from=builder /app/hr-admin-service /app/hr-admin-service 29 | 30 | CMD ["./hr-admin-service", "-f", "etc/config.yaml"] 31 | -------------------------------------------------------------------------------- /hr-admin-service/etc/admin.yaml: -------------------------------------------------------------------------------- 1 | Name: admin.rpc 2 | ListenOn: 0.0.0.0:8091 3 | Etcd: 4 | Hosts: 5 | - 127.0.0.1:2379 6 | Key: admin.rpc 7 | DataSource: "root:123456@(localhost:3306)/hr?charset=utf8mb4&parseTime=True&loc=Local" 8 | SmsBaoConfig: 9 | SendUrl: "https://api.smsbao.com/sms" 10 | Debug: false 11 | UserName: "" 12 | Password: "" 13 | -------------------------------------------------------------------------------- /hr-admin-service/internal/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "HR_Go/common/sms" 5 | "github.com/zeromicro/go-zero/zrpc" 6 | ) 7 | 8 | type Config struct { 9 | zrpc.RpcServerConf 10 | DataSource string 11 | SmsBaoConfig sms.SmsBaoConfig 12 | } 13 | -------------------------------------------------------------------------------- /hr-admin-service/internal/cronjob/main.go: -------------------------------------------------------------------------------- 1 | package cronjob 2 | 3 | import ( 4 | "HR_Go/hr-admin-service/internal/svc" 5 | "github.com/robfig/cron/v3" 6 | ) 7 | 8 | type BaseJob struct { 9 | Name string 10 | SvcCtx *svc.ServiceContext 11 | } 12 | 13 | func NewBaseJob(name string, svcCtx *svc.ServiceContext) *BaseJob { 14 | return &BaseJob{ 15 | Name: name, 16 | SvcCtx: svcCtx, 17 | } 18 | } 19 | 20 | func (t *BaseJob) Run() { 21 | } 22 | 23 | func InitCronJob(svcCtx *svc.ServiceContext, c *cron.Cron) { 24 | _, _ = c.AddJob("@every 1m", &SendSmsJob{BaseJob: *NewBaseJob("SendSms", svcCtx)}) 25 | } 26 | -------------------------------------------------------------------------------- /hr-admin-service/internal/cronjob/testjob.go: -------------------------------------------------------------------------------- 1 | package cronjob 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | type TestJob struct { 9 | BaseJob 10 | } 11 | 12 | func (t *TestJob) Run() { 13 | fmt.Println(time.Now().Format(time.DateTime) + ": --- test cronjob ---") 14 | } 15 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/adminloginlogic_test.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/hr-admin-service/pb/hr-admin-service" 5 | "testing" 6 | ) 7 | 8 | func TestAdminLoginLogic_AdminLogin(t *testing.T) { 9 | ctx, svcCtx := GetCtxAndSvcCtxForTest() 10 | logic := NewAdminLoginLogic(ctx, svcCtx) 11 | 12 | resp, err := logic.AdminLogin(&hr_admin_service.AdminLoginReq{ 13 | Code: "TYloe9WmXFmtKK129Tg2ZYuBUp8sK95g", 14 | }) 15 | if err != nil { 16 | return 17 | } 18 | 19 | t.Logf("resp: %+v", resp) 20 | } 21 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/adminlogoutlogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | 6 | "HR_Go/hr-admin-service/internal/svc" 7 | "HR_Go/hr-admin-service/pb/hr-admin-service" 8 | 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type AdminLogoutLogic struct { 13 | ctx context.Context 14 | svcCtx *svc.ServiceContext 15 | logx.Logger 16 | } 17 | 18 | func NewAdminLogoutLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminLogoutLogic { 19 | return &AdminLogoutLogic{ 20 | ctx: ctx, 21 | svcCtx: svcCtx, 22 | Logger: logx.WithContext(ctx), 23 | } 24 | } 25 | 26 | func (l *AdminLogoutLogic) AdminLogout(in *hr_admin_service.AdminIdReq) (*hr_admin_service.StatusResp, error) { 27 | return &hr_admin_service.StatusResp{ 28 | Ok: true, 29 | }, nil 30 | } 31 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/cleartimeslogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | 6 | "HR_Go/hr-admin-service/internal/svc" 7 | "HR_Go/hr-admin-service/pb/hr-admin-service" 8 | 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type ClearTimesLogic struct { 13 | ctx context.Context 14 | svcCtx *svc.ServiceContext 15 | logx.Logger 16 | } 17 | 18 | func NewClearTimesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClearTimesLogic { 19 | return &ClearTimesLogic{ 20 | ctx: ctx, 21 | svcCtx: svcCtx, 22 | Logger: logx.WithContext(ctx), 23 | } 24 | } 25 | 26 | func (l *ClearTimesLogic) ClearTimes(in *hr_admin_service.ClearTimesReq) (*hr_admin_service.StatusResp, error) { 27 | t := l.svcCtx.Query.Time 28 | for _, g := range in.Group { 29 | _, _ = t.WithContext(l.ctx).Where(t.Group_.Eq(g)).Delete() 30 | } 31 | 32 | return &hr_admin_service.StatusResp{ 33 | Ok: true, 34 | }, nil 35 | } 36 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/common_test.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/hr-admin-service/internal/config" 5 | "HR_Go/hr-admin-service/internal/svc" 6 | "context" 7 | "encoding/json" 8 | "fmt" 9 | "strings" 10 | "testing" 11 | ) 12 | 13 | func GetCtxAndSvcCtxForTest() (context.Context, *svc.ServiceContext) { 14 | c := config.Config{ 15 | DataSource: "root:123456@(localhost:3306)/hr?charset=utf8mb4&parseTime=True&loc=Local", 16 | } 17 | return context.Background(), svc.NewServiceContext4Test(c) 18 | } 19 | 20 | func TestExportApplicants(t *testing.T) { 21 | ctx, svcCtx := GetCtxAndSvcCtxForTest() 22 | 23 | a := svcCtx.Query.Applicant 24 | find, err := a.WithContext(ctx).Find() 25 | if err != nil { 26 | return 27 | } 28 | for _, applicant := range find { 29 | form := applicant.Form 30 | var formMap map[string]interface{} 31 | _ = json.Unmarshal([]byte(form), &formMap) 32 | var intro = "" 33 | if formMap["self_intro"] != nil { 34 | intro = formMap["self_intro"].(string) 35 | intro = strings.ReplaceAll(intro, "\n", "") 36 | } 37 | fmt.Printf("%d\t%s\t%s\n", applicant.ID, applicant.Name, intro) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/createquestionlogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/dal/model" 6 | "HR_Go/hr-admin-service/internal/svc" 7 | "HR_Go/hr-admin-service/pb/hr-admin-service" 8 | "context" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type CreateQuestionLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewCreateQuestionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateQuestionLogic { 20 | return &CreateQuestionLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *CreateQuestionLogic) CreateQuestion(in *hr_admin_service.CreateQuestionReq) (*hr_admin_service.CreateQuestionResp, error) { 28 | q := l.svcCtx.Query.Question 29 | m := &model.Question{ 30 | Question: in.Question, 31 | Group_: in.Group, 32 | } 33 | err := q.WithContext(l.ctx).Create(m) 34 | if err != nil { 35 | return nil, common.GrpcErrorInternal(err) 36 | } 37 | 38 | return &hr_admin_service.CreateQuestionResp{ 39 | Question: &hr_admin_service.Question{ 40 | Id: m.ID, 41 | Group: m.Group_, 42 | Question: m.Question, 43 | }, 44 | }, nil 45 | } 46 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/deleteapplicantlogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "context" 6 | 7 | "HR_Go/hr-admin-service/internal/svc" 8 | "HR_Go/hr-admin-service/pb/hr-admin-service" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteApplicantLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewDeleteApplicantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteApplicantLogic { 20 | return &DeleteApplicantLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *DeleteApplicantLogic) DeleteApplicant(in *hr_admin_service.ApplicantIdReq) (*hr_admin_service.StatusResp, error) { 28 | a := l.svcCtx.Query.Applicant 29 | _, err := a.WithContext(l.ctx).Where(a.ID.Eq(in.ApplicantId)).Delete() 30 | if err != nil { 31 | return nil, common.GrpcErrorInternal(err) 32 | } 33 | 34 | return &hr_admin_service.StatusResp{ 35 | Ok: true, 36 | }, nil 37 | } 38 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/deleteevaluationlogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | 6 | "HR_Go/hr-admin-service/internal/svc" 7 | "HR_Go/hr-admin-service/pb/hr-admin-service" 8 | 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type DeleteEvaluationLogic struct { 13 | ctx context.Context 14 | svcCtx *svc.ServiceContext 15 | logx.Logger 16 | } 17 | 18 | func NewDeleteEvaluationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteEvaluationLogic { 19 | return &DeleteEvaluationLogic{ 20 | ctx: ctx, 21 | svcCtx: svcCtx, 22 | Logger: logx.WithContext(ctx), 23 | } 24 | } 25 | 26 | func (l *DeleteEvaluationLogic) DeleteEvaluation(in *hr_admin_service.DeleteEvaluationReq) (*hr_admin_service.StatusResp, error) { 27 | es := l.svcCtx.Query.EvaluationStandard 28 | _, err := es.WithContext(l.ctx).Where(es.ID.Eq(in.EvaluationId)).Delete() 29 | if err != nil { 30 | return nil, err 31 | } 32 | 33 | return &hr_admin_service.StatusResp{ 34 | Ok: true, 35 | }, nil 36 | } 37 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/deletequestionlogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "context" 6 | 7 | "HR_Go/hr-admin-service/internal/svc" 8 | "HR_Go/hr-admin-service/pb/hr-admin-service" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteQuestionLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewDeleteQuestionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteQuestionLogic { 20 | return &DeleteQuestionLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *DeleteQuestionLogic) DeleteQuestion(in *hr_admin_service.DeleteQuestionReq) (*hr_admin_service.StatusResp, error) { 28 | q := l.svcCtx.Query.Question 29 | _, err := q.WithContext(l.ctx).Where(q.ID.Eq(in.QuestionId)).Delete() 30 | if err != nil { 31 | return nil, common.GrpcErrorNotFound(err) 32 | } 33 | 34 | return &hr_admin_service.StatusResp{ 35 | Ok: true, 36 | }, nil 37 | } 38 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/deleteremarklogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "context" 6 | 7 | "HR_Go/hr-admin-service/internal/svc" 8 | "HR_Go/hr-admin-service/pb/hr-admin-service" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteRemarkLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewDeleteRemarkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteRemarkLogic { 20 | return &DeleteRemarkLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *DeleteRemarkLogic) DeleteRemark(in *hr_admin_service.DeleteRemarkReq) (*hr_admin_service.StatusResp, error) { 28 | r := l.svcCtx.Query.Remark 29 | _, err := r.WithContext(l.ctx).Where(r.ApplicantID.Eq(in.ApplicantId), r.AdminID.Eq(in.AdminId)).Delete() 30 | if err != nil { 31 | return &hr_admin_service.StatusResp{Ok: false}, common.GrpcErrorInternal(err) 32 | } 33 | 34 | return &hr_admin_service.StatusResp{Ok: true}, nil 35 | } 36 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/deletescorelogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "context" 6 | 7 | "HR_Go/hr-admin-service/internal/svc" 8 | "HR_Go/hr-admin-service/pb/hr-admin-service" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteScoreLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewDeleteScoreLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteScoreLogic { 20 | return &DeleteScoreLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *DeleteScoreLogic) DeleteScore(in *hr_admin_service.DeleteScoreReq) (*hr_admin_service.StatusResp, error) { 28 | s := l.svcCtx.Query.Score 29 | _, err := s.WithContext(l.ctx).Where(s.ApplicantID.Eq(in.ApplicantId), s.AdminID.Eq(in.AdminId), s.Group_.Eq(in.Group)).Delete() 30 | if err != nil { 31 | return &hr_admin_service.StatusResp{ 32 | Ok: false, 33 | }, common.GrpcErrorNotFound(err) 34 | } 35 | 36 | return &hr_admin_service.StatusResp{ 37 | Ok: true, 38 | }, nil 39 | } 40 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/getconfiglogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | 6 | "HR_Go/hr-admin-service/internal/svc" 7 | "HR_Go/hr-admin-service/pb/hr-admin-service" 8 | 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type GetConfigLogic struct { 13 | ctx context.Context 14 | svcCtx *svc.ServiceContext 15 | logx.Logger 16 | } 17 | 18 | func NewGetConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetConfigLogic { 19 | return &GetConfigLogic{ 20 | ctx: ctx, 21 | svcCtx: svcCtx, 22 | Logger: logx.WithContext(ctx), 23 | } 24 | } 25 | 26 | func (l *GetConfigLogic) GetConfig(in *hr_admin_service.GetConfigReq) (*hr_admin_service.GetConfigResp, error) { 27 | c := l.svcCtx.Query.Configuration 28 | config, err := c.WithContext(l.ctx).Where(c.Key.Eq(in.Key)).First() 29 | if err != nil { 30 | return &hr_admin_service.GetConfigResp{ 31 | Key: config.Key, 32 | Value: "", 33 | }, nil 34 | } 35 | 36 | return &hr_admin_service.GetConfigResp{ 37 | Key: config.Key, 38 | Value: config.Value, 39 | }, nil 40 | } 41 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/getfrontendconfiglogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | 6 | "HR_Go/hr-admin-service/internal/svc" 7 | "HR_Go/hr-admin-service/pb/hr-admin-service" 8 | 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type GetFrontendConfigLogic struct { 13 | ctx context.Context 14 | svcCtx *svc.ServiceContext 15 | logx.Logger 16 | } 17 | 18 | func NewGetFrontendConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFrontendConfigLogic { 19 | return &GetFrontendConfigLogic{ 20 | ctx: ctx, 21 | svcCtx: svcCtx, 22 | Logger: logx.WithContext(ctx), 23 | } 24 | } 25 | 26 | func (l *GetFrontendConfigLogic) GetFrontendConfig(in *hr_admin_service.AdminIdReq) (*hr_admin_service.GetFrontendConfigResp, error) { 27 | common := l.svcCtx.Common 28 | 29 | return &hr_admin_service.GetFrontendConfigResp{ 30 | ClientId: common.OAuth.ClientId, 31 | RedirectUri: common.OAuth.RedirectUrl, 32 | AdminUri: common.Url.AdminUrl, 33 | WechatUri: common.Url.WechatUrl, 34 | BaseUri: common.Url.BaseUrl, 35 | Debug: common.Debug, 36 | }, nil 37 | } 38 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/getoauthconfiglogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | 6 | "HR_Go/hr-admin-service/internal/svc" 7 | "HR_Go/hr-admin-service/pb/hr-admin-service" 8 | 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type GetOAuthConfigLogic struct { 13 | ctx context.Context 14 | svcCtx *svc.ServiceContext 15 | logx.Logger 16 | } 17 | 18 | func NewGetOAuthConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOAuthConfigLogic { 19 | return &GetOAuthConfigLogic{ 20 | ctx: ctx, 21 | svcCtx: svcCtx, 22 | Logger: logx.WithContext(ctx), 23 | } 24 | } 25 | 26 | func (l *GetOAuthConfigLogic) GetOAuthConfig(in *hr_admin_service.AdminIdReq) (*hr_admin_service.GetOAuthConfigResp, error) { 27 | common := l.svcCtx.Common 28 | 29 | return &hr_admin_service.GetOAuthConfigResp{ 30 | ClientId: common.OAuth.ClientId, 31 | ClientSecret: common.OAuth.ClientSecret, 32 | AdminUri: common.Url.AdminUrl, 33 | WechatUri: common.Url.WechatUrl, 34 | RedirectUri: common.OAuth.RedirectUrl, 35 | }, nil 36 | } 37 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/getquestionslogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/dal/model" 5 | "context" 6 | "github.com/samber/lo" 7 | 8 | "HR_Go/hr-admin-service/internal/svc" 9 | "HR_Go/hr-admin-service/pb/hr-admin-service" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type GetQuestionsLogic struct { 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | logx.Logger 18 | } 19 | 20 | func NewGetQuestionsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetQuestionsLogic { 21 | return &GetQuestionsLogic{ 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | Logger: logx.WithContext(ctx), 25 | } 26 | } 27 | 28 | func (l *GetQuestionsLogic) GetQuestions(in *hr_admin_service.GetQuestionsReq) (*hr_admin_service.GetQuestionsResp, error) { 29 | q := l.svcCtx.Query.Question 30 | questions, err := q.WithContext(l.ctx).Where(q.Group_.Eq(in.Group)).Find() 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &hr_admin_service.GetQuestionsResp{ 36 | Questions: lo.Map(questions, func(item *model.Question, index int) *hr_admin_service.Question { 37 | return &hr_admin_service.Question{ 38 | Id: item.ID, 39 | Group: item.Group_, 40 | Question: item.Question, 41 | } 42 | }), 43 | }, nil 44 | } 45 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/getremarklogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "context" 6 | 7 | "HR_Go/hr-admin-service/internal/svc" 8 | "HR_Go/hr-admin-service/pb/hr-admin-service" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type GetRemarkLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewGetRemarkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRemarkLogic { 20 | return &GetRemarkLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *GetRemarkLogic) GetRemark(in *hr_admin_service.GetRemarkReq) (*hr_admin_service.GetRemarkResp, error) { 28 | r := l.svcCtx.Query.Remark 29 | remark, err := r.WithContext(l.ctx).Where(r.ApplicantID.Eq(in.ApplicantId), r.AdminID.Eq(in.AdminId)).First() 30 | if err != nil { 31 | return nil, common.GrpcErrorNotFound(err) 32 | } 33 | 34 | return &hr_admin_service.GetRemarkResp{ 35 | ApplicantId: remark.ApplicantID, 36 | AdminId: remark.AdminID, 37 | Remark: remark.Remark, 38 | }, nil 39 | } 40 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/getsmsconfiglogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/common/sms" 6 | "HR_Go/hr-admin-service/internal/svc" 7 | "HR_Go/hr-admin-service/pb/hr-admin-service" 8 | "context" 9 | "github.com/samber/lo" 10 | "github.com/zeromicro/go-zero/core/logx" 11 | "time" 12 | ) 13 | 14 | type GetSmsConfigLogic struct { 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | logx.Logger 18 | } 19 | 20 | func NewGetSmsConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSmsConfigLogic { 21 | return &GetSmsConfigLogic{ 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | Logger: logx.WithContext(ctx), 25 | } 26 | } 27 | 28 | func (l *GetSmsConfigLogic) GetSmsConfig(in *hr_admin_service.AdminIdReq) (*hr_admin_service.GetSmsConfigResp, error) { 29 | tc := l.svcCtx.Query.TimeConfig 30 | pubResStTime, _ := tc.WithContext(l.ctx).Where(tc.Key.Eq(common.PublishResultStart)).First() 31 | 32 | return &hr_admin_service.GetSmsConfigResp{ 33 | Types: sms.Types, 34 | Alerts: lo.Map(sms.Types, func(item string, index int) string { 35 | switch item { 36 | case "录取结果": 37 | if time.Now().Before(pubResStTime.Value) { 38 | return "公开录取结果的时间没有到。" 39 | } 40 | } 41 | return "" 42 | }), 43 | }, nil 44 | } 45 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/getsmsserviceconfiglogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/hr-admin-service/internal/svc" 5 | "HR_Go/hr-admin-service/pb/hr-admin-service" 6 | "context" 7 | 8 | "github.com/zeromicro/go-zero/core/logx" 9 | ) 10 | 11 | const ( 12 | SmsServiceEnabled = "SmsServiceEnabled" 13 | ) 14 | 15 | type GetSmsServiceConfigLogic struct { 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | logx.Logger 19 | } 20 | 21 | func NewGetSmsServiceConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSmsServiceConfigLogic { 22 | return &GetSmsServiceConfigLogic{ 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | Logger: logx.WithContext(ctx), 26 | } 27 | } 28 | 29 | func (l *GetSmsServiceConfigLogic) GetSmsServiceConfig(in *hr_admin_service.AdminIdReq) (*hr_admin_service.GetSmsServiceConfigResp, error) { 30 | enabled := GetConfigOrDefault(l.ctx, l.svcCtx, SmsServiceEnabled, "0") 31 | smsBaoConfig := l.svcCtx.Config.SmsBaoConfig 32 | 33 | return &hr_admin_service.GetSmsServiceConfigResp{ 34 | Debug: smsBaoConfig.Debug, 35 | Enabled: enabled == "1", 36 | SendUrl: smsBaoConfig.SendUrl, 37 | UserName: smsBaoConfig.Username, 38 | }, nil 39 | } 40 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/getstatisticsdailynewlogic_test.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestGetStatisticsDailyNewLogic_GetStatisticsDailyNew(t *testing.T) { 9 | timeCountMap := make(map[string]int) 10 | timeCountMap["2023-8-8"]++ 11 | fmt.Printf("%+v", timeCountMap) 12 | } 13 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/pinglogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "HR_Go/hr-admin-service/internal/svc" 8 | "HR_Go/hr-admin-service/pb/hr-admin-service" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type PingLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic { 20 | return &PingLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *PingLogic) Ping(in *hr_admin_service.PingRequest) (*hr_admin_service.PingResponse, error) { 28 | fmt.Printf("Ping = %s\n", in.Ping) 29 | return &hr_admin_service.PingResponse{Pong: "pong"}, nil 30 | } 31 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/postremarklogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/dal/model" 6 | "HR_Go/hr-admin-service/internal/svc" 7 | "HR_Go/hr-admin-service/pb/hr-admin-service" 8 | "context" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type PostRemarkLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewPostRemarkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostRemarkLogic { 20 | return &PostRemarkLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *PostRemarkLogic) PostRemark(in *hr_admin_service.PostRemarkReq) (*hr_admin_service.PostRemarkResp, error) { 28 | r := l.svcCtx.Query.Remark 29 | err := r.WithContext(l.ctx).Where(r.ApplicantID.Eq(in.ApplicantId), r.AdminID.Eq(in.AdminId)).Save(&model.Remark{ 30 | AdminID: in.AdminId, 31 | ApplicantID: in.ApplicantId, 32 | Remark: in.Remark, 33 | }) 34 | if err != nil { 35 | return nil, common.GrpcErrorInternal(err) 36 | } 37 | 38 | return &hr_admin_service.PostRemarkResp{ 39 | ApplicantId: in.ApplicantId, 40 | AdminId: in.AdminId, 41 | Remark: in.Remark, 42 | }, nil 43 | } 44 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/receivesmslogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/dal/model" 5 | "HR_Go/hr-admin-service/internal/svc" 6 | "HR_Go/hr-admin-service/pb/hr-admin-service" 7 | "context" 8 | 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type ReceiveSmsLogic struct { 13 | ctx context.Context 14 | svcCtx *svc.ServiceContext 15 | logx.Logger 16 | } 17 | 18 | func NewReceiveSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ReceiveSmsLogic { 19 | return &ReceiveSmsLogic{ 20 | ctx: ctx, 21 | svcCtx: svcCtx, 22 | Logger: logx.WithContext(ctx), 23 | } 24 | } 25 | 26 | func (l *ReceiveSmsLogic) ReceiveSms(in *hr_admin_service.ReceiveSmsReq) (*hr_admin_service.ReceiveSmsResp, error) { 27 | rs := l.svcCtx.Query.ReceiveSm 28 | 29 | m := &model.ReceiveSm{ 30 | Phone: in.Phone, 31 | Content: in.Content, 32 | } 33 | err := rs.WithContext(l.ctx).Create(m) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | return &hr_admin_service.ReceiveSmsResp{ 39 | Code: 0, 40 | }, nil 41 | } 42 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/setapplicanttimeextendlogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "context" 6 | 7 | "HR_Go/hr-admin-service/internal/svc" 8 | "HR_Go/hr-admin-service/pb/hr-admin-service" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type SetApplicantTimeExtendLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewSetApplicantTimeExtendLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetApplicantTimeExtendLogic { 20 | return &SetApplicantTimeExtendLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *SetApplicantTimeExtendLogic) SetApplicantTimeExtend(in *hr_admin_service.SetApplicantTimeExtendReq) (*hr_admin_service.StatusResp, error) { 28 | at := l.svcCtx.Query.ApplicantTime 29 | _, err := at.WithContext(l.ctx).Where(at.ApplicantID.Eq(in.ApplicantId), at.Group_.Eq(in.Group)).UpdateColumn(at.Extend, in.Extend) 30 | if err != nil { 31 | return nil, common.GrpcErrorInternal(err) 32 | } 33 | 34 | return &hr_admin_service.StatusResp{ 35 | Ok: true, 36 | }, nil 37 | } 38 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/setdefaultstandardlogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "context" 6 | 7 | "HR_Go/hr-admin-service/internal/svc" 8 | "HR_Go/hr-admin-service/pb/hr-admin-service" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type SetDefaultStandardLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewSetDefaultStandardLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetDefaultStandardLogic { 20 | return &SetDefaultStandardLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *SetDefaultStandardLogic) SetDefaultStandard(in *hr_admin_service.SetDefaultStandardReq) (*hr_admin_service.StatusResp, error) { 28 | a := l.svcCtx.Query.Admin 29 | _, err := a.WithContext(l.ctx).Where(a.ID.Eq(in.AdminId)).UpdateColumn(a.DefaultStandardID, in.StandardId) 30 | if err != nil { 31 | return nil, common.GrpcErrorInternal(err) 32 | } 33 | 34 | return &hr_admin_service.StatusResp{ 35 | Ok: true, 36 | }, nil 37 | } 38 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/setmyroomlogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | 6 | "HR_Go/hr-admin-service/internal/svc" 7 | "HR_Go/hr-admin-service/pb/hr-admin-service" 8 | 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type SetMyRoomLogic struct { 13 | ctx context.Context 14 | svcCtx *svc.ServiceContext 15 | logx.Logger 16 | } 17 | 18 | func NewSetMyRoomLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetMyRoomLogic { 19 | return &SetMyRoomLogic{ 20 | ctx: ctx, 21 | svcCtx: svcCtx, 22 | Logger: logx.WithContext(ctx), 23 | } 24 | } 25 | 26 | func (l *SetMyRoomLogic) SetMyRoom(in *hr_admin_service.SetMyRoomReq) (*hr_admin_service.StatusResp, error) { 27 | a := l.svcCtx.Query.Admin 28 | _, err := a.WithContext(l.ctx).Where(a.ID.Eq(in.AdminId)).UpdateColumn(a.RoomID, in.RoomId) 29 | if err != nil { 30 | return nil, err 31 | } 32 | 33 | return &hr_admin_service.StatusResp{ 34 | Ok: true, 35 | }, nil 36 | } 37 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/setroomcommentlogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "HR_Go/hr-admin-service/internal/svc" 8 | "HR_Go/hr-admin-service/pb/hr-admin-service" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type SetRoomCommentLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewSetRoomCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetRoomCommentLogic { 20 | return &SetRoomCommentLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *SetRoomCommentLogic) SetRoomComment(in *hr_admin_service.SetRoomCommentReq) (*hr_admin_service.StatusResp, error) { 28 | r := l.svcCtx.Query.Room 29 | 30 | var err error 31 | if in.Type == InterviewerComment { 32 | _, err = r.WithContext(l.ctx).Where(r.ID.Eq(in.RoomId)).UpdateColumn(r.InterviewerComment, in.Comment) 33 | } else if in.Type == ReceiverComment { 34 | _, err = r.WithContext(l.ctx).Where(r.ID.Eq(in.RoomId)).UpdateColumn(r.ReceiverComment, in.Comment) 35 | } else { 36 | err = fmt.Errorf("invalid type") 37 | } 38 | if err != nil { 39 | return nil, err 40 | } 41 | 42 | return &hr_admin_service.StatusResp{ 43 | Ok: true, 44 | }, nil 45 | } 46 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/setroomgrouplogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | "HR_Go/hr-admin-service/internal/svc" 8 | "HR_Go/hr-admin-service/pb/hr-admin-service" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type SetRoomGroupLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewSetRoomGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetRoomGroupLogic { 20 | return &SetRoomGroupLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *SetRoomGroupLogic) SetRoomGroup(in *hr_admin_service.SetRoomGroupReq) (*hr_admin_service.StatusResp, error) { 28 | r := l.svcCtx.Query.Room 29 | _, err := r.WithContext(l.ctx).Where(r.ID.Eq(in.RoomId)).Updates(map[string]interface{}{ 30 | "group_label": in.Group, 31 | "status_updated_at": time.Now(), 32 | "updated_by": in.AdminId, 33 | }) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | return &hr_admin_service.StatusResp{ 39 | Ok: true, 40 | }, nil 41 | } 42 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/setroomstatuslogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | "HR_Go/hr-admin-service/internal/svc" 8 | "HR_Go/hr-admin-service/pb/hr-admin-service" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type SetRoomStatusLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewSetRoomStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetRoomStatusLogic { 20 | return &SetRoomStatusLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *SetRoomStatusLogic) SetRoomStatus(in *hr_admin_service.SetRoomStatusReq) (*hr_admin_service.StatusResp, error) { 28 | r := l.svcCtx.Query.Room 29 | _, err := r.WithContext(l.ctx).Where(r.ID.Eq(in.RoomId)).Updates(map[string]interface{}{ 30 | "status": in.Status, 31 | "status_updated_at": time.Now(), 32 | "applicant_time_id": 0, 33 | "updated_by": in.AdminId, 34 | }) 35 | if err != nil { 36 | return nil, err 37 | } 38 | 39 | return &hr_admin_service.StatusResp{ 40 | Ok: true, 41 | }, nil 42 | } 43 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/updateconfiglogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/dal/model" 5 | "HR_Go/hr-admin-service/internal/svc" 6 | "HR_Go/hr-admin-service/pb/hr-admin-service" 7 | "context" 8 | 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type UpdateConfigLogic struct { 13 | ctx context.Context 14 | svcCtx *svc.ServiceContext 15 | logx.Logger 16 | } 17 | 18 | func NewUpdateConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateConfigLogic { 19 | return &UpdateConfigLogic{ 20 | ctx: ctx, 21 | svcCtx: svcCtx, 22 | Logger: logx.WithContext(ctx), 23 | } 24 | } 25 | 26 | func (l *UpdateConfigLogic) UpdateConfig(in *hr_admin_service.UpdateConfigReq) (*hr_admin_service.UpdateConfigResp, error) { 27 | c := l.svcCtx.Query.Configuration 28 | err := c.WithContext(l.ctx).Where(c.Key.Eq(in.Key)).Save(&model.Configuration{ 29 | Key: in.Key, 30 | Value: in.Value, 31 | }) 32 | if err != nil { 33 | return nil, err 34 | } 35 | 36 | return &hr_admin_service.UpdateConfigResp{ 37 | Key: in.Key, 38 | Value: in.Value, 39 | }, nil 40 | } 41 | -------------------------------------------------------------------------------- /hr-admin-service/internal/logic/updatequestionlogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/dal/model" 6 | "HR_Go/hr-admin-service/internal/svc" 7 | "HR_Go/hr-admin-service/pb/hr-admin-service" 8 | "context" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type UpdateQuestionLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewUpdateQuestionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateQuestionLogic { 20 | return &UpdateQuestionLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *UpdateQuestionLogic) UpdateQuestion(in *hr_admin_service.UpdateQuestionReq) (*hr_admin_service.UpdateQuestionResp, error) { 28 | q := l.svcCtx.Query.Question 29 | err := q.WithContext(l.ctx).Where(q.ID.Eq(in.Question.Id)).Save(&model.Question{ 30 | ID: in.Question.Id, 31 | Question: in.Question.Question, 32 | Group_: in.Question.Group, 33 | }) 34 | if err != nil { 35 | return nil, common.GrpcErrorInternal(err) 36 | } 37 | 38 | return &hr_admin_service.UpdateQuestionResp{ 39 | Question: in.Question, 40 | }, nil 41 | } 42 | -------------------------------------------------------------------------------- /hr-api/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.20-alpine AS builder 2 | 3 | LABEL stage=gobuilder 4 | 5 | ENV CGO_ENABLED 0 6 | ENV GOPROXY https://goproxy.cn,direct 7 | RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories 8 | 9 | RUN apk update --no-cache && apk add --no-cache tzdata 10 | 11 | WORKDIR /build 12 | 13 | ADD go.mod . 14 | ADD go.sum . 15 | RUN go mod download 16 | COPY . . 17 | WORKDIR /build/hr-api 18 | RUN go build -ldflags="-s -w" -o /app/hr-api . 19 | 20 | 21 | FROM scratch 22 | 23 | COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt 24 | COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai 25 | ENV TZ Asia/Shanghai 26 | 27 | WORKDIR /app 28 | COPY --from=builder /app/hr-api /app/hr-api 29 | 30 | CMD ["./hr-api", "-f", "etc/config.yaml"] 31 | -------------------------------------------------------------------------------- /hr-api/api/announce.api: -------------------------------------------------------------------------------- 1 | syntax = "v1" 2 | 3 | info( 4 | title: "Human Resource" 5 | desc: "华南虎面试系统" 6 | author: "22-信息-常霆钰" 7 | email: "1067088037@qq.com" 8 | version: "v1" 9 | ) 10 | 11 | type ( 12 | GetAnnounceStatusReq { 13 | Status string `path:"status"` 14 | } 15 | 16 | GetAnnounceStatusResp { 17 | Id int64 `json:"id"` 18 | Status string `json:"status"` 19 | Body string `json:"body"` 20 | } 21 | ) 22 | 23 | @server( 24 | prefix: /api/announce 25 | group: announce 26 | jwt: Auth 27 | ) 28 | service hr { 29 | @doc "获取发布状态" 30 | @handler GetAnnounceStatus 31 | get /:status (GetAnnounceStatusReq) returns (GetAnnounceStatusResp) 32 | } -------------------------------------------------------------------------------- /hr-api/api/form.api: -------------------------------------------------------------------------------- 1 | syntax = "v1" 2 | 3 | info( 4 | title: "Human Resource" 5 | desc: "华南虎面试系统" 6 | author: "22-信息-常霆钰" 7 | email: "1067088037@qq.com" 8 | version: "v1" 9 | ) 10 | 11 | type ( 12 | IntentConfig { 13 | Min int32 `json:"min"` 14 | Max int32 `json:"max"` 15 | Parallel bool `json:"parallel"` 16 | } 17 | 18 | FormItem { 19 | Id int64 `json:"id"` 20 | Name string `json:"name"` 21 | Key string `json:"key"` 22 | Type string `json:"type"` 23 | Required int32 `json:"required"` 24 | Options []string `json:"options"` 25 | Regexp string `json:"regexp"` 26 | MaxLength int32 `json:"max_length"` 27 | } 28 | 29 | GetFormIntentResq { 30 | Intent IntentConfig `json:"intent"` 31 | } 32 | 33 | GetFormGroupsResq { 34 | Groups []string `json:"groups"` 35 | } 36 | 37 | GetFormResq { 38 | Form []FormItem `json:"form"` 39 | } 40 | ) 41 | 42 | @server( 43 | prefix: /api/form 44 | group: form 45 | // 不需要鉴权 46 | ) 47 | service hr { 48 | @doc "获取表单意向" 49 | @handler GetFormIntent 50 | get /intent returns (GetFormIntentResq) 51 | 52 | @doc "获取表单分组" 53 | @handler GetFormGroups 54 | get /groups returns (GetFormGroupsResq) 55 | 56 | @doc "获取表单格式" 57 | @handler GetForm 58 | get /get returns (GetFormResq) 59 | } -------------------------------------------------------------------------------- /hr-api/api/timeconfig.api: -------------------------------------------------------------------------------- 1 | syntax = "v1" 2 | 3 | info( 4 | title: "Human Resource" 5 | desc: "华南虎面试系统" 6 | author: "22-信息-常霆钰" 7 | email: "1067088037@qq.com" 8 | version: "v1" 9 | ) 10 | 11 | type ( 12 | TimeConfigItem { 13 | Key string `json:"key"` 14 | Value string `json:"value"` 15 | } 16 | 17 | GetTimeConfigResp { 18 | TimeConfigs []TimeConfigItem `json:"timeConfigs"` 19 | } 20 | ) 21 | 22 | @server( 23 | prefix: /api/time-config 24 | group: timeconfig 25 | // 不需要鉴权 26 | ) 27 | service hr { 28 | @doc "获取时间配置" 29 | @handler GetTimeConfig 30 | get / returns (GetTimeConfigResp) 31 | } -------------------------------------------------------------------------------- /hr-api/etc/hr.yaml: -------------------------------------------------------------------------------- 1 | Name: hr 2 | Host: 0.0.0.0 3 | Port: 8888 4 | Etcd: 5 | Hosts: 6 | - 127.0.0.1:2379 7 | Key: hr.rpc 8 | Auth: 9 | AccessSecret: "12345678.debug" 10 | AccessExpire: 28800 11 | -------------------------------------------------------------------------------- /hr-api/hr.api: -------------------------------------------------------------------------------- 1 | syntax = "v1" 2 | 3 | info( 4 | title: "Human Resource" 5 | desc: "华南虎面试系统" 6 | author: "22-信息-常霆钰" 7 | email: "1067088037@qq.com" 8 | version: "v1" 9 | ) 10 | 11 | import "api/announce.api" 12 | import "api/exam.api" 13 | import "api/form.api" 14 | import "api/joinus.api" 15 | import "api/timeconfig.api" 16 | 17 | type PingResp { 18 | Ping string `json:"ping"` 19 | } 20 | 21 | @server( 22 | prefix : /api 23 | ) 24 | service hr { 25 | @doc "Ping" 26 | @handler Ping 27 | get /ping returns (PingResp) 28 | } -------------------------------------------------------------------------------- /hr-api/hr.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "net/http" 7 | 8 | "HR_Go/hr-api/internal/config" 9 | "HR_Go/hr-api/internal/handler" 10 | "HR_Go/hr-api/internal/svc" 11 | 12 | "github.com/zeromicro/go-zero/core/conf" 13 | "github.com/zeromicro/go-zero/rest" 14 | ) 15 | 16 | var configFile = flag.String("f", "etc/hr.yaml", "the config file") 17 | 18 | func main() { 19 | flag.Parse() 20 | 21 | var c config.Config 22 | conf.MustLoad(*configFile, &c) 23 | 24 | server := rest.MustNewServer(c.RestConf, rest.WithUnauthorizedCallback(unauthorizedCallback)) 25 | defer server.Stop() 26 | 27 | ctx := svc.NewServiceContext(c) 28 | handler.RegisterHandlers(server, ctx) 29 | 30 | fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) 31 | server.Start() 32 | } 33 | 34 | func unauthorizedCallback(w http.ResponseWriter, r *http.Request, err error) { 35 | w.WriteHeader(http.StatusUnauthorized) 36 | _, err = w.Write([]byte(err.Error())) 37 | if err != nil { 38 | return 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /hr-api/internal/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "HR_Go/common" 5 | "github.com/zeromicro/go-zero/core/discov" 6 | "github.com/zeromicro/go-zero/rest" 7 | ) 8 | 9 | type Config struct { 10 | rest.RestConf 11 | Auth common.Auth 12 | Etcd discov.EtcdConf 13 | } 14 | -------------------------------------------------------------------------------- /hr-api/internal/handler/announce/getannouncestatushandler.go: -------------------------------------------------------------------------------- 1 | package announce 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/announce" 7 | "HR_Go/hr-api/internal/svc" 8 | "HR_Go/hr-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetAnnounceStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetAnnounceStatusReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := announce.NewGetAnnounceStatusLogic(r.Context(), svcCtx) 21 | resp, err := l.GetAnnounceStatus(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-api/internal/handler/exam/getexamhandler.go: -------------------------------------------------------------------------------- 1 | package exam 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/exam" 7 | "HR_Go/hr-api/internal/svc" 8 | "HR_Go/hr-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetExamHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetExamReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := exam.NewGetExamLogic(r.Context(), svcCtx) 21 | resp, err := l.GetExam(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-api/internal/handler/exam/getguidehandler.go: -------------------------------------------------------------------------------- 1 | package exam 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/exam" 7 | "HR_Go/hr-api/internal/svc" 8 | "HR_Go/hr-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetGuideHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetGuideReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := exam.NewGetGuideLogic(r.Context(), svcCtx) 21 | resp, err := l.GetGuide(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-api/internal/handler/exam/setexamhandler.go: -------------------------------------------------------------------------------- 1 | package exam 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/exam" 7 | "HR_Go/hr-api/internal/svc" 8 | "HR_Go/hr-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func SetExamHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.SetExamReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := exam.NewSetExamLogic(r.Context(), svcCtx) 21 | resp, err := l.SetExam(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-api/internal/handler/form/getformgroupshandler.go: -------------------------------------------------------------------------------- 1 | package form 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/form" 7 | "HR_Go/hr-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetFormGroupsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := form.NewGetFormGroupsLogic(r.Context(), svcCtx) 14 | resp, err := l.GetFormGroups() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-api/internal/handler/form/getformhandler.go: -------------------------------------------------------------------------------- 1 | package form 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/form" 7 | "HR_Go/hr-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetFormHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := form.NewGetFormLogic(r.Context(), svcCtx) 14 | resp, err := l.GetForm() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-api/internal/handler/form/getformintenthandler.go: -------------------------------------------------------------------------------- 1 | package form 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/form" 7 | "HR_Go/hr-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetFormIntentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := form.NewGetFormIntentLogic(r.Context(), svcCtx) 14 | resp, err := l.GetFormIntent() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-api/internal/handler/joinus/getcanapplyhandler.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/joinus" 7 | "HR_Go/hr-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetCanApplyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := joinus.NewGetCanApplyLogic(r.Context(), svcCtx) 14 | resp, err := l.GetCanApply() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-api/internal/handler/joinus/getcanselecthandler.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/joinus" 7 | "HR_Go/hr-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetCanSelectHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := joinus.NewGetCanSelectLogic(r.Context(), svcCtx) 14 | resp, err := l.GetCanSelect() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-api/internal/handler/joinus/getformhandler.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/joinus" 7 | "HR_Go/hr-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetFormHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := joinus.NewGetFormLogic(r.Context(), svcCtx) 14 | resp, err := l.GetForm() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-api/internal/handler/joinus/getintentshandler.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/joinus" 7 | "HR_Go/hr-api/internal/svc" 8 | "HR_Go/hr-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetIntentsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetIntentsReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := joinus.NewGetIntentsLogic(r.Context(), svcCtx) 21 | resp, err := l.GetIntents(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-api/internal/handler/joinus/getresulthandler.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/joinus" 7 | "HR_Go/hr-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetResultHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := joinus.NewGetResultLogic(r.Context(), svcCtx) 14 | resp, err := l.GetResult() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-api/internal/handler/joinus/getreviewhandler.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/joinus" 7 | "HR_Go/hr-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetReviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := joinus.NewGetReviewLogic(r.Context(), svcCtx) 14 | resp, err := l.GetReview() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-api/internal/handler/joinus/getstephandler.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/joinus" 7 | "HR_Go/hr-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetStepHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := joinus.NewGetStepLogic(r.Context(), svcCtx) 14 | resp, err := l.GetStep() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-api/internal/handler/joinus/gettimehandler.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/joinus" 7 | "HR_Go/hr-api/internal/svc" 8 | "HR_Go/hr-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func GetTimeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.GetTimeReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := joinus.NewGetTimeLogic(r.Context(), svcCtx) 21 | resp, err := l.GetTime(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-api/internal/handler/joinus/getwechathandler.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/joinus" 7 | "HR_Go/hr-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetWechatHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := joinus.NewGetWechatLogic(r.Context(), svcCtx) 14 | resp, err := l.GetWechat() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-api/internal/handler/joinus/loginhandler.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/joinus" 7 | "HR_Go/hr-api/internal/svc" 8 | "HR_Go/hr-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func LoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.LoginReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := joinus.NewLoginLogic(r.Context(), svcCtx) 21 | resp, err := l.Login(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-api/internal/handler/joinus/postapplyhandler.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/joinus" 7 | "HR_Go/hr-api/internal/svc" 8 | "HR_Go/hr-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func PostApplyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.PostApplyReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := joinus.NewPostApplyLogic(r.Context(), svcCtx) 21 | resp, err := l.PostApply(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-api/internal/handler/joinus/selecttimehandler.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/joinus" 7 | "HR_Go/hr-api/internal/svc" 8 | "HR_Go/hr-api/internal/types" 9 | "github.com/zeromicro/go-zero/rest/httpx" 10 | ) 11 | 12 | func SelectTimeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | var req types.SelectTimeReq 15 | if err := httpx.Parse(r, &req); err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | return 18 | } 19 | 20 | l := joinus.NewSelectTimeLogic(r.Context(), svcCtx) 21 | resp, err := l.SelectTime(&req) 22 | if err != nil { 23 | httpx.ErrorCtx(r.Context(), w, err) 24 | } else { 25 | httpx.OkJsonCtx(r.Context(), w, resp) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hr-api/internal/handler/pinghandler.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic" 7 | "HR_Go/hr-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func PingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := logic.NewPingLogic(r.Context(), svcCtx) 14 | resp, err := l.Ping() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-api/internal/handler/timeconfig/gettimeconfighandler.go: -------------------------------------------------------------------------------- 1 | package timeconfig 2 | 3 | import ( 4 | "net/http" 5 | 6 | "HR_Go/hr-api/internal/logic/timeconfig" 7 | "HR_Go/hr-api/internal/svc" 8 | "github.com/zeromicro/go-zero/rest/httpx" 9 | ) 10 | 11 | func GetTimeConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | l := timeconfig.NewGetTimeConfigLogic(r.Context(), svcCtx) 14 | resp, err := l.GetTimeConfig() 15 | if err != nil { 16 | httpx.ErrorCtx(r.Context(), w, err) 17 | } else { 18 | httpx.OkJsonCtx(r.Context(), w, resp) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hr-api/internal/logic/announce/getannouncestatuslogic.go: -------------------------------------------------------------------------------- 1 | package announce 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_service "HR_Go/hr-service/pb/hr-service" 6 | "context" 7 | 8 | "HR_Go/hr-api/internal/svc" 9 | "HR_Go/hr-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type GetAnnounceStatusLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewGetAnnounceStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAnnounceStatusLogic { 21 | return &GetAnnounceStatusLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *GetAnnounceStatusLogic) GetAnnounceStatus(req *types.GetAnnounceStatusReq) (resp *types.GetAnnounceStatusResp, err error) { 29 | status, err := l.svcCtx.HrService.GetAnnounceStatus(l.ctx, &hr_service.GetAnnounceStatusReq{ 30 | ApplicantId: common.GetUserInfo(l.ctx).Id, 31 | Status: req.Status, 32 | }) 33 | if err != nil { 34 | return nil, err 35 | } 36 | 37 | return &types.GetAnnounceStatusResp{ 38 | Id: status.Id, 39 | Status: status.Status, 40 | Body: status.Body, 41 | }, nil 42 | } 43 | -------------------------------------------------------------------------------- /hr-api/internal/logic/exam/getexamlogic.go: -------------------------------------------------------------------------------- 1 | package exam 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_service "HR_Go/hr-service/pb/hr-service" 6 | "context" 7 | "github.com/samber/lo" 8 | 9 | "HR_Go/hr-api/internal/svc" 10 | "HR_Go/hr-api/internal/types" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type GetExamLogic struct { 16 | logx.Logger 17 | ctx context.Context 18 | svcCtx *svc.ServiceContext 19 | } 20 | 21 | func NewGetExamLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExamLogic { 22 | return &GetExamLogic{ 23 | Logger: logx.WithContext(ctx), 24 | ctx: ctx, 25 | svcCtx: svcCtx, 26 | } 27 | } 28 | 29 | func (l *GetExamLogic) GetExam(req *types.GetExamReq) (resp *types.GetExamResp, err error) { 30 | exam, err := l.svcCtx.HrService.GetExam(l.ctx, &hr_service.GetExamReq{ 31 | ApplicantId: common.GetUserInfo(l.ctx).Id, 32 | Group: req.Group, 33 | }) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | return &types.GetExamResp{ 39 | ApplicantId: exam.ApplicantId, 40 | Questions: common.NotNullList(lo.Map(exam.Questions, func(item *hr_service.Question, _ int) types.Question { 41 | return types.Question{ 42 | Id: item.Id, 43 | Question: item.Question, 44 | Answer: item.Answer, 45 | } 46 | })), 47 | }, nil 48 | } 49 | -------------------------------------------------------------------------------- /hr-api/internal/logic/exam/getguidelogic.go: -------------------------------------------------------------------------------- 1 | package exam 2 | 3 | import ( 4 | "HR_Go/hr-service/hrservice" 5 | "context" 6 | 7 | "HR_Go/hr-api/internal/svc" 8 | "HR_Go/hr-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type GetGuideLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewGetGuideLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetGuideLogic { 20 | return &GetGuideLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *GetGuideLogic) GetGuide(req *types.GetGuideReq) (resp *types.GetGuideResp, err error) { 28 | guide, err := l.svcCtx.HrService.GetGuide(l.ctx, &hrservice.GetGuideReq{ 29 | Group: req.Group, 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.GetGuideResp{ 36 | Guide: guide.Guide, 37 | }, nil 38 | } 39 | -------------------------------------------------------------------------------- /hr-api/internal/logic/form/getformgroupslogic.go: -------------------------------------------------------------------------------- 1 | package form 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/hr-api/internal/svc" 6 | "HR_Go/hr-api/internal/types" 7 | "HR_Go/hr-service/hrservice" 8 | "context" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type GetFormGroupsLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewGetFormGroupsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFormGroupsLogic { 20 | return &GetFormGroupsLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *GetFormGroupsLogic) GetFormGroups() (resp *types.GetFormGroupsResq, err error) { 28 | groups, err := l.svcCtx.HrService.GetFormGroups(l.ctx, &hrservice.ApplicantIdReq{ 29 | ApplicantId: 0, 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.GetFormGroupsResq{ 36 | Groups: common.NotNullList(groups.Groups), 37 | }, nil 38 | } 39 | -------------------------------------------------------------------------------- /hr-api/internal/logic/form/getformintentlogic.go: -------------------------------------------------------------------------------- 1 | package form 2 | 3 | import ( 4 | "HR_Go/hr-service/hrservice" 5 | "context" 6 | 7 | "HR_Go/hr-api/internal/svc" 8 | "HR_Go/hr-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type GetFormIntentLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewGetFormIntentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFormIntentLogic { 20 | return &GetFormIntentLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *GetFormIntentLogic) GetFormIntent() (resp *types.GetFormIntentResq, err error) { 28 | intentResp, err := l.svcCtx.HrService.GetFormIntent(l.ctx, &hrservice.ApplicantIdReq{ 29 | ApplicantId: 0, 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.GetFormIntentResq{ 36 | Intent: types.IntentConfig{ 37 | Min: intentResp.Min, 38 | Max: intentResp.Max, 39 | Parallel: intentResp.Parallel, 40 | }, 41 | }, nil 42 | } 43 | -------------------------------------------------------------------------------- /hr-api/internal/logic/joinus/getcanapplylogic.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "HR_Go/hr-service/hrservice" 5 | "context" 6 | 7 | "HR_Go/hr-api/internal/svc" 8 | "HR_Go/hr-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type GetCanApplyLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewGetCanApplyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCanApplyLogic { 20 | return &GetCanApplyLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *GetCanApplyLogic) GetCanApply() (resp *types.CanApplyResp, err error) { 28 | able, err := l.svcCtx.HrService.GetCanJoin(l.ctx, &hrservice.GetCanJoinReq{ 29 | Key: "can-apply", 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.CanApplyResp{ 36 | Status: able.Status, 37 | Start: able.Start, 38 | End: able.End, 39 | }, nil 40 | } 41 | -------------------------------------------------------------------------------- /hr-api/internal/logic/joinus/getcanselectlogic.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "HR_Go/hr-service/hrservice" 5 | "context" 6 | 7 | "HR_Go/hr-api/internal/svc" 8 | "HR_Go/hr-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type GetCanSelectLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewGetCanSelectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCanSelectLogic { 20 | return &GetCanSelectLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *GetCanSelectLogic) GetCanSelect() (resp *types.CanSelectResp, err error) { 28 | able, err := l.svcCtx.HrService.GetCanJoin(l.ctx, &hrservice.GetCanJoinReq{ 29 | Key: "can-select", 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.CanSelectResp{ 36 | Status: able.Status, 37 | Start: able.Start, 38 | End: able.End, 39 | }, nil 40 | } 41 | -------------------------------------------------------------------------------- /hr-api/internal/logic/joinus/getreviewlogic.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/hr-api/internal/svc" 6 | "HR_Go/hr-api/internal/types" 7 | hr_service "HR_Go/hr-service/pb/hr-service" 8 | "context" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type GetReviewLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewGetReviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetReviewLogic { 20 | return &GetReviewLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *GetReviewLogic) GetReview() (resp *types.GetReviewResp, err error) { 28 | id := common.GetUserInfo(l.ctx).Id 29 | reviewResp, err := l.svcCtx.HrService.GetReview(l.ctx, &hr_service.ApplicantIdReq{ApplicantId: id}) 30 | if err != nil { 31 | logx.Errorf("获取面试回顾失败: %s", err) 32 | return nil, nil 33 | } 34 | 35 | return &types.GetReviewResp{ 36 | Text: reviewResp.Text, 37 | }, nil 38 | } 39 | -------------------------------------------------------------------------------- /hr-api/internal/logic/joinus/getsteplogic.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_service "HR_Go/hr-service/pb/hr-service" 6 | "context" 7 | 8 | "HR_Go/hr-api/internal/svc" 9 | "HR_Go/hr-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type GetStepLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewGetStepLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetStepLogic { 21 | return &GetStepLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *GetStepLogic) GetStep() (resp *types.GetStepResp, err error) { 29 | step, err := l.svcCtx.HrService.GetMyStep(l.ctx, &hr_service.ApplicantIdReq{ 30 | ApplicantId: common.GetUserInfo(l.ctx).Id, 31 | }) 32 | if err != nil { 33 | return nil, err 34 | } 35 | 36 | return &types.GetStepResp{ 37 | Step: step.Step, 38 | }, nil 39 | } 40 | -------------------------------------------------------------------------------- /hr-api/internal/logic/joinus/postapplylogic.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_service "HR_Go/hr-service/pb/hr-service" 6 | "context" 7 | 8 | "HR_Go/hr-api/internal/svc" 9 | "HR_Go/hr-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type PostApplyLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewPostApplyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostApplyLogic { 21 | return &PostApplyLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *PostApplyLogic) PostApply(req *types.PostApplyReq) (resp *types.PostApplyResp, err error) { 29 | apply, err := l.svcCtx.HrService.PostApply(l.ctx, &hr_service.PostApplyReq{ 30 | ApplicantId: common.GetUserInfo(l.ctx).Id, 31 | Name: req.Name, 32 | Gender: req.Gender, 33 | Phone: req.Phone, 34 | Intents: req.Intents, 35 | Parallel: req.Parallel, 36 | Form: req.Form, 37 | }) 38 | if err != nil { 39 | return nil, err 40 | } 41 | 42 | return &types.PostApplyResp{ 43 | Id: apply.Id, 44 | }, nil 45 | } 46 | -------------------------------------------------------------------------------- /hr-api/internal/logic/joinus/selecttimelogic.go: -------------------------------------------------------------------------------- 1 | package joinus 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_service "HR_Go/hr-service/pb/hr-service" 6 | "context" 7 | 8 | "HR_Go/hr-api/internal/svc" 9 | "HR_Go/hr-api/internal/types" 10 | 11 | "github.com/zeromicro/go-zero/core/logx" 12 | ) 13 | 14 | type SelectTimeLogic struct { 15 | logx.Logger 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | } 19 | 20 | func NewSelectTimeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SelectTimeLogic { 21 | return &SelectTimeLogic{ 22 | Logger: logx.WithContext(ctx), 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | } 26 | } 27 | 28 | func (l *SelectTimeLogic) SelectTime(req *types.SelectTimeReq) (resp *types.SelectTimeResp, err error) { 29 | time, err := l.svcCtx.HrService.SelectTime(l.ctx, &hr_service.SelectTimeReq{ 30 | ApplicantId: common.GetUserInfo(l.ctx).Id, 31 | TimeId: req.TimeId, 32 | Group: req.Group, 33 | }) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | return &types.SelectTimeResp{ 39 | Time: types.SelectTime{ 40 | ApplicantId: time.ApplicantId, 41 | Group: time.Group, 42 | TimeId: time.TimeId, 43 | }, 44 | }, nil 45 | } 46 | -------------------------------------------------------------------------------- /hr-api/internal/logic/pinglogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | hr_service "HR_Go/hr-service/pb/hr-service" 5 | "context" 6 | 7 | "HR_Go/hr-api/internal/svc" 8 | "HR_Go/hr-api/internal/types" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type PingLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic { 20 | return &PingLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *PingLogic) Ping() (resp *types.PingResp, err error) { 28 | response, err := l.svcCtx.HrService.Ping(l.ctx, &hr_service.PingRequest{Ping: "ping"}) 29 | if err != nil { 30 | return nil, err 31 | } 32 | return &types.PingResp{Ping: response.Pong}, nil 33 | } 34 | -------------------------------------------------------------------------------- /hr-api/internal/logic/timeconfig/gettimeconfiglogic.go: -------------------------------------------------------------------------------- 1 | package timeconfig 2 | 3 | import ( 4 | "HR_Go/common" 5 | hr_service "HR_Go/hr-service/pb/hr-service" 6 | "context" 7 | "github.com/samber/lo" 8 | 9 | "HR_Go/hr-api/internal/svc" 10 | "HR_Go/hr-api/internal/types" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type GetTimeConfigLogic struct { 16 | logx.Logger 17 | ctx context.Context 18 | svcCtx *svc.ServiceContext 19 | } 20 | 21 | func NewGetTimeConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTimeConfigLogic { 22 | return &GetTimeConfigLogic{ 23 | Logger: logx.WithContext(ctx), 24 | ctx: ctx, 25 | svcCtx: svcCtx, 26 | } 27 | } 28 | 29 | func (l *GetTimeConfigLogic) GetTimeConfig() (resp *types.GetTimeConfigResp, err error) { 30 | timeConfig, err := l.svcCtx.HrService.GetTimeConfig(l.ctx, &hr_service.ApplicantIdReq{ 31 | ApplicantId: common.GetUserInfo(l.ctx).Id, 32 | }) 33 | if err != nil { 34 | return nil, err 35 | } 36 | 37 | return &types.GetTimeConfigResp{ 38 | TimeConfigs: lo.Map(timeConfig.TimeConfigs, func(item *hr_service.TimeConfig, index int) types.TimeConfigItem { 39 | return types.TimeConfigItem{ 40 | Key: item.Key, 41 | Value: item.Value, 42 | } 43 | }), 44 | }, nil 45 | } 46 | -------------------------------------------------------------------------------- /hr-api/internal/svc/servicecontext.go: -------------------------------------------------------------------------------- 1 | package svc 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/hr-api/internal/config" 6 | hr_service "HR_Go/hr-service/pb/hr-service" 7 | "github.com/zeromicro/go-zero/core/logx" 8 | "github.com/zeromicro/go-zero/zrpc" 9 | "os" 10 | ) 11 | 12 | type ServiceContext struct { 13 | Common common.Config 14 | Config config.Config 15 | HrService hr_service.HrServiceClient 16 | } 17 | 18 | func NewServiceContext(c config.Config) *ServiceContext { 19 | client := zrpc.MustNewClient(zrpc.RpcClientConf{ 20 | Etcd: c.Etcd, 21 | }) 22 | commonConf, err := common.GetConfig("../common/config.yaml") 23 | if err != nil { 24 | logx.Error("common config load error", err) 25 | os.Exit(1) 26 | return nil 27 | } 28 | return &ServiceContext{ 29 | Common: commonConf, 30 | Config: c, 31 | HrService: hr_service.NewHrServiceClient(client.Conn()), 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /hr-service/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.20-alpine AS builder 2 | 3 | LABEL stage=gobuilder 4 | 5 | ENV CGO_ENABLED 0 6 | ENV GOPROXY https://goproxy.cn,direct 7 | RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories 8 | 9 | RUN apk update --no-cache && apk add --no-cache tzdata 10 | 11 | WORKDIR /build 12 | 13 | ADD go.mod . 14 | ADD go.sum . 15 | RUN go mod download 16 | COPY . . 17 | WORKDIR /build/hr-service 18 | RUN go build -ldflags="-s -w" -o /app/hr-service . 19 | 20 | 21 | FROM scratch 22 | 23 | COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt 24 | COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai 25 | ENV TZ Asia/Shanghai 26 | 27 | WORKDIR /app 28 | COPY --from=builder /app/hr-service /app/hr-service 29 | 30 | CMD ["./hr-service", "-f", "etc/config.yaml"] 31 | -------------------------------------------------------------------------------- /hr-service/etc/hr.yaml: -------------------------------------------------------------------------------- 1 | Name: hr.rpc 2 | ListenOn: 0.0.0.0:8090 3 | Etcd: 4 | Hosts: 5 | - 127.0.0.1:2379 6 | Key: hr.rpc 7 | AdminServiceKey: admin.rpc 8 | DataSource: "root:123456@(localhost:3306)/hr?charset=utf8mb4&parseTime=True&loc=Local" 9 | -------------------------------------------------------------------------------- /hr-service/hr.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | 7 | "HR_Go/hr-service/internal/config" 8 | "HR_Go/hr-service/internal/server" 9 | "HR_Go/hr-service/internal/svc" 10 | "HR_Go/hr-service/pb/hr-service" 11 | 12 | "github.com/zeromicro/go-zero/core/conf" 13 | "github.com/zeromicro/go-zero/core/service" 14 | "github.com/zeromicro/go-zero/zrpc" 15 | "google.golang.org/grpc" 16 | "google.golang.org/grpc/reflection" 17 | ) 18 | 19 | var configFile = flag.String("f", "etc/hr.yaml", "the config file") 20 | 21 | func main() { 22 | flag.Parse() 23 | 24 | var c config.Config 25 | conf.MustLoad(*configFile, &c) 26 | ctx := svc.NewServiceContext(c) 27 | 28 | s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { 29 | hr_service.RegisterHrServiceServer(grpcServer, server.NewHrServiceServer(ctx)) 30 | 31 | if c.Mode == service.DevMode || c.Mode == service.TestMode { 32 | reflection.Register(grpcServer) 33 | } 34 | }) 35 | defer s.Stop() 36 | 37 | fmt.Printf("Starting rpc server at %s...\n", c.ListenOn) 38 | s.Start() 39 | } 40 | -------------------------------------------------------------------------------- /hr-service/internal/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import "github.com/zeromicro/go-zero/zrpc" 4 | 5 | type Config struct { 6 | zrpc.RpcServerConf 7 | DataSource string 8 | AdminServiceKey string 9 | } 10 | -------------------------------------------------------------------------------- /hr-service/internal/logic/common.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/hr-service/internal/svc" 5 | hr_service "HR_Go/hr-service/pb/hr-service" 6 | "context" 7 | ) 8 | 9 | type Profile struct { 10 | OpenId string `json:"openid"` 11 | Nickname string `json:"nickname"` 12 | Sex int `json:"sex"` 13 | Language string `json:"language"` 14 | City string `json:"city"` 15 | Province string `json:"province"` 16 | Country string `json:"country"` 17 | HeadImgURL string `json:"headimgurl"` 18 | Privilege []string `json:"privilege"` 19 | } 20 | 21 | func GetTimeAndApplicantTime(ctx context.Context, svcCtx *svc.ServiceContext, applicantId int64) []*hr_service.TimeItem { 22 | db := svcCtx.Db 23 | var result []*hr_service.TimeItem 24 | err := db.WithContext(ctx).Table("applicant_times as at"). 25 | Select("at.id as applicant_id, t.id, t.group, date(t.time) as date, time(t.time) as time, t.rank, t.location, t.total_cnt, t.grade, t.campus, t.meeting_id"). 26 | Joins("left join times as t on t.id = at.time_id and t.deleted_at is null"). 27 | Where("at.deleted_at is null"). 28 | Where("at.applicant_id = ?", applicantId). 29 | Scan(&result).Error 30 | if err != nil { 31 | return nil 32 | } 33 | 34 | return result 35 | } 36 | -------------------------------------------------------------------------------- /hr-service/internal/logic/common_test.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/hr-service/internal/config" 5 | "HR_Go/hr-service/internal/svc" 6 | "context" 7 | ) 8 | 9 | func GetCtxAndSvcCtxForTest() (context.Context, *svc.ServiceContext) { 10 | c := config.Config{ 11 | DataSource: "root:123456@(localhost:3306)/hr?charset=utf8mb4&parseTime=True&loc=Local", 12 | } 13 | return context.Background(), svc.NewServiceContext4Test(c) 14 | } 15 | -------------------------------------------------------------------------------- /hr-service/internal/logic/getannouncestatuslogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/hr-service/internal/svc" 6 | "HR_Go/hr-service/pb/hr-service" 7 | "context" 8 | 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type GetAnnounceStatusLogic struct { 13 | ctx context.Context 14 | svcCtx *svc.ServiceContext 15 | logx.Logger 16 | } 17 | 18 | func NewGetAnnounceStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAnnounceStatusLogic { 19 | return &GetAnnounceStatusLogic{ 20 | ctx: ctx, 21 | svcCtx: svcCtx, 22 | Logger: logx.WithContext(ctx), 23 | } 24 | } 25 | 26 | func (l *GetAnnounceStatusLogic) GetAnnounceStatus(in *hr_service.GetAnnounceStatusReq) (*hr_service.GetAnnounceStatusResp, error) { 27 | ac := l.svcCtx.Query.AnnounceConfig 28 | first, err := ac.WithContext(l.ctx).Where(ac.Status.Eq(in.Status)).First() 29 | if err != nil { 30 | return nil, common.GrpcErrorNotFound(err) 31 | } 32 | 33 | return &hr_service.GetAnnounceStatusResp{ 34 | Id: first.ID, 35 | Status: first.Status, 36 | Body: first.Body, 37 | }, nil 38 | } 39 | -------------------------------------------------------------------------------- /hr-service/internal/logic/getannouncestatuslogic_test.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/dal/model" 6 | hr_service "HR_Go/hr-service/pb/hr-service" 7 | "github.com/stretchr/testify/assert" 8 | "testing" 9 | ) 10 | 11 | func TestGetAnnounceStatusLogic_GetAnnounceStatus(t *testing.T) { 12 | ctx, svcCtx := GetCtxAndSvcCtxForTest() 13 | logic := NewGetAnnounceStatusLogic(ctx, svcCtx) 14 | 15 | ac := svcCtx.Query.AnnounceConfig 16 | m := &model.AnnounceConfig{ 17 | Status: common.HaveNotAppliedForm, 18 | Body: "您还没有提交报名表。", 19 | } 20 | err := ac.WithContext(ctx).Create(m) 21 | if err != nil { 22 | t.Fail() 23 | } 24 | 25 | status, err := logic.GetAnnounceStatus(&hr_service.GetAnnounceStatusReq{ 26 | Status: common.HaveNotAppliedForm, 27 | }) 28 | if err != nil { 29 | t.Fail() 30 | } 31 | assert.Equal(t, "您还没有提交报名表。", status.Body) 32 | 33 | _, err = ac.WithContext(ctx).Delete(m) 34 | } 35 | -------------------------------------------------------------------------------- /hr-service/internal/logic/getexamlogic_test.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/dal/model" 5 | hr_service "HR_Go/hr-service/pb/hr-service" 6 | "fmt" 7 | "github.com/stretchr/testify/assert" 8 | "math/rand" 9 | "testing" 10 | ) 11 | 12 | func TestGetExamLogic_GetExam(t *testing.T) { 13 | ctx, svcCtx := GetCtxAndSvcCtxForTest() 14 | logic := NewGetExamLogic(ctx, svcCtx) 15 | 16 | applicantID := rand.Int63() 17 | 18 | q := &model.Question{ 19 | Question: "为什么", 20 | Group_: "测试", 21 | } 22 | _ = svcCtx.Query.Question.WithContext(ctx).Create(q) 23 | 24 | aq := &model.ApplicantQuestion{ 25 | ApplicantID: applicantID, 26 | QuestionID: q.ID, 27 | Answer: "A", 28 | } 29 | _ = svcCtx.Query.ApplicantQuestion.WithContext(ctx).Create(aq) 30 | 31 | resp, err := logic.GetExam(&hr_service.GetExamReq{ 32 | ApplicantId: applicantID, 33 | Group: "测试", 34 | }) 35 | if err != nil { 36 | t.Fail() 37 | println(err) 38 | } 39 | 40 | assert.Equal(t, "为什么", resp.Questions[0].Question) 41 | assert.Equal(t, "A", resp.Questions[0].Answer) 42 | fmt.Printf("%+v\n", resp) 43 | 44 | _, _ = svcCtx.Query.Question.WithContext(ctx).Delete(q) 45 | _, _ = svcCtx.Query.ApplicantQuestion.WithContext(ctx).Delete(aq) 46 | } 47 | -------------------------------------------------------------------------------- /hr-service/internal/logic/getformgroupslogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | 6 | "HR_Go/hr-service/internal/svc" 7 | "HR_Go/hr-service/pb/hr-service" 8 | 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type GetFormGroupsLogic struct { 13 | ctx context.Context 14 | svcCtx *svc.ServiceContext 15 | logx.Logger 16 | } 17 | 18 | func NewGetFormGroupsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFormGroupsLogic { 19 | return &GetFormGroupsLogic{ 20 | ctx: ctx, 21 | svcCtx: svcCtx, 22 | Logger: logx.WithContext(ctx), 23 | } 24 | } 25 | 26 | func (l *GetFormGroupsLogic) GetFormGroups(in *hr_service.ApplicantIdReq) (*hr_service.GetFormGroupsResp, error) { 27 | return &hr_service.GetFormGroupsResp{ 28 | Groups: l.svcCtx.Common.Groups, 29 | }, nil 30 | } 31 | -------------------------------------------------------------------------------- /hr-service/internal/logic/getformintentlogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | 6 | "HR_Go/hr-service/internal/svc" 7 | "HR_Go/hr-service/pb/hr-service" 8 | 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type GetFormIntentLogic struct { 13 | ctx context.Context 14 | svcCtx *svc.ServiceContext 15 | logx.Logger 16 | } 17 | 18 | func NewGetFormIntentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFormIntentLogic { 19 | return &GetFormIntentLogic{ 20 | ctx: ctx, 21 | svcCtx: svcCtx, 22 | Logger: logx.WithContext(ctx), 23 | } 24 | } 25 | 26 | func (l *GetFormIntentLogic) GetFormIntent(in *hr_service.ApplicantIdReq) (*hr_service.GetFormIntentResp, error) { 27 | intents := l.svcCtx.Common.Intents 28 | return &hr_service.GetFormIntentResp{ 29 | Min: intents.Min, 30 | Max: intents.Max, 31 | Parallel: intents.Parallel, 32 | }, nil 33 | } 34 | -------------------------------------------------------------------------------- /hr-service/internal/logic/getguidelogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | 6 | "HR_Go/hr-service/internal/svc" 7 | "HR_Go/hr-service/pb/hr-service" 8 | 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type GetGuideLogic struct { 13 | ctx context.Context 14 | svcCtx *svc.ServiceContext 15 | logx.Logger 16 | } 17 | 18 | func NewGetGuideLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetGuideLogic { 19 | return &GetGuideLogic{ 20 | ctx: ctx, 21 | svcCtx: svcCtx, 22 | Logger: logx.WithContext(ctx), 23 | } 24 | } 25 | 26 | func (l *GetGuideLogic) GetGuide(in *hr_service.GetGuideReq) (*hr_service.GetGuideResp, error) { 27 | g := l.svcCtx.Query.Guide 28 | 29 | guide, err := g.WithContext(l.ctx).Where(g.Group_.Eq(in.Group)).First() 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | return &hr_service.GetGuideResp{ 35 | Guide: guide.Guide, 36 | }, nil 37 | } 38 | -------------------------------------------------------------------------------- /hr-service/internal/logic/getreviewlogic_test.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | hr_service "HR_Go/hr-service/pb/hr-service" 5 | "fmt" 6 | "testing" 7 | ) 8 | 9 | func TestNewGetReviewLogic(t *testing.T) { 10 | ctx, svcCtx := GetCtxAndSvcCtxForTest() 11 | logic := NewGetReviewLogic(ctx, svcCtx) 12 | 13 | applicantId := int64(351) 14 | review, err := logic.GetReview(&hr_service.ApplicantIdReq{ApplicantId: applicantId}) 15 | if err != nil { 16 | return 17 | } 18 | 19 | fmt.Println(review.Text) 20 | } 21 | -------------------------------------------------------------------------------- /hr-service/internal/logic/gettimeconfiglogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "HR_Go/dal/model" 6 | "context" 7 | "github.com/samber/lo" 8 | "time" 9 | 10 | "HR_Go/hr-service/internal/svc" 11 | "HR_Go/hr-service/pb/hr-service" 12 | 13 | "github.com/zeromicro/go-zero/core/logx" 14 | ) 15 | 16 | type GetTimeConfigLogic struct { 17 | ctx context.Context 18 | svcCtx *svc.ServiceContext 19 | logx.Logger 20 | } 21 | 22 | func NewGetTimeConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTimeConfigLogic { 23 | return &GetTimeConfigLogic{ 24 | ctx: ctx, 25 | svcCtx: svcCtx, 26 | Logger: logx.WithContext(ctx), 27 | } 28 | } 29 | 30 | func (l *GetTimeConfigLogic) GetTimeConfig(in *hr_service.ApplicantIdReq) (*hr_service.GetTimeConfigResp, error) { 31 | tc := l.svcCtx.Query.TimeConfig 32 | 33 | timeConfigs, err := tc.WithContext(l.ctx).Find() 34 | if err != nil { 35 | return nil, common.GrpcErrorNotFound(err) 36 | } 37 | 38 | return &hr_service.GetTimeConfigResp{ 39 | TimeConfigs: common.NotNullList(lo.Map(timeConfigs, func(item *model.TimeConfig, _ int) *hr_service.TimeConfig { 40 | return &hr_service.TimeConfig{ 41 | Key: item.Key, 42 | Value: item.Value.Format(time.DateTime), 43 | } 44 | })), 45 | }, nil 46 | } 47 | -------------------------------------------------------------------------------- /hr-service/internal/logic/loginlogic_test.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | hr_service "HR_Go/hr-service/pb/hr-service" 5 | "testing" 6 | ) 7 | 8 | func TestLoginLogic_Login(t *testing.T) { 9 | ctx, svcCtx := GetCtxAndSvcCtxForTest() 10 | logic := NewLoginLogic(ctx, svcCtx) 11 | 12 | _, err := logic.Login(&hr_service.LoginReq{ 13 | Token: "", 14 | }) 15 | if err != nil { 16 | return 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /hr-service/internal/logic/migrate_test.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/common" 5 | "testing" 6 | ) 7 | 8 | func TestAutoMigrate(t *testing.T) { 9 | _, svcCtx := GetCtxAndSvcCtxForTest() 10 | db := svcCtx.Db 11 | 12 | // 实际上创建 ServiceContext 时已经自动迁移了 13 | err := common.AutoMigrate(db) 14 | if err != nil { 15 | t.Error("gorm auto migrate error", err) 16 | return 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /hr-service/internal/logic/pinglogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "HR_Go/hr-service/internal/svc" 8 | "HR_Go/hr-service/pb/hr-service" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type PingLogic struct { 14 | ctx context.Context 15 | svcCtx *svc.ServiceContext 16 | logx.Logger 17 | } 18 | 19 | func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic { 20 | return &PingLogic{ 21 | ctx: ctx, 22 | svcCtx: svcCtx, 23 | Logger: logx.WithContext(ctx), 24 | } 25 | } 26 | 27 | func (l *PingLogic) Ping(in *hr_service.PingRequest) (*hr_service.PingResponse, error) { 28 | fmt.Printf("Ping = %s\n", in.Ping) 29 | return &hr_service.PingResponse{Pong: "pong"}, nil 30 | } 31 | -------------------------------------------------------------------------------- /hr-service/internal/logic/postexamlogic.go: -------------------------------------------------------------------------------- 1 | package logic 2 | 3 | import ( 4 | "HR_Go/dal/model" 5 | "HR_Go/hr-service/internal/svc" 6 | "HR_Go/hr-service/pb/hr-service" 7 | "context" 8 | "github.com/samber/lo" 9 | "github.com/zeromicro/go-zero/core/logx" 10 | ) 11 | 12 | type PostExamLogic struct { 13 | ctx context.Context 14 | svcCtx *svc.ServiceContext 15 | logx.Logger 16 | } 17 | 18 | func NewPostExamLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostExamLogic { 19 | return &PostExamLogic{ 20 | ctx: ctx, 21 | svcCtx: svcCtx, 22 | Logger: logx.WithContext(ctx), 23 | } 24 | } 25 | 26 | func (l *PostExamLogic) PostExam(in *hr_service.PostExamReq) (*hr_service.PostExamResp, error) { 27 | aq := l.svcCtx.Query.ApplicantQuestion 28 | 29 | lo.Map(in.Answers, func(item *hr_service.Answer, _ int) *hr_service.Question { 30 | m := &model.ApplicantQuestion{ 31 | ApplicantID: in.ApplicantId, 32 | QuestionID: item.QuestionId, 33 | Answer: item.Answer, 34 | } 35 | 36 | err := aq.WithContext(l.ctx).Where(aq.ID.Eq(item.QuestionId), aq.ApplicantID.Eq(in.ApplicantId)).Save(m) 37 | if err != nil { 38 | return nil 39 | } 40 | 41 | return nil 42 | }) 43 | 44 | return &hr_service.PostExamResp{ 45 | ApplicantId: in.ApplicantId, 46 | Questions: nil, 47 | }, nil 48 | } 49 | -------------------------------------------------------------------------------- /unittest/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | mysql: 5 | container_name: mysql 6 | image: mysql:8.0 # amd64 7 | # image: arm64v8/mysql:8.0 # arm64 8 | restart: always 9 | command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci 10 | environment: 11 | - MYSQL_ROOT_PASSWORD=123456 12 | - TZ=Asia/Shanghai 13 | ports: 14 | - "3306:3306" 15 | volumes: 16 | - ./mysql/:/var/lib/mysql 17 | nginx: 18 | container_name: nginx 19 | image: nginx 20 | restart: always 21 | volumes: 22 | - ./nginx-conf.d/:/etc/nginx/conf.d/ 23 | ports: 24 | - "8000:80" 25 | etcd: 26 | container_name: etcd 27 | image: bitnami/etcd:3.5 28 | restart: always 29 | environment: 30 | - ALLOW_NONE_AUTHENTICATION=yes 31 | - ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379 32 | ports: 33 | - "2379:2379" 34 | - "2380:2380" 35 | -------------------------------------------------------------------------------- /unittest/nginx-conf.d/hr.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | 4 | location /api/admin { 5 | proxy_pass http://host.docker.internal:8889; 6 | } 7 | 8 | location /api { 9 | proxy_pass http://host.docker.internal:8888; 10 | } 11 | } --------------------------------------------------------------------------------