|
- package endpoints
-
- import (
- "context"
- "github.com/go-kit/kit/endpoint"
- "job_risk_third/internal/proto"
- "job_risk_third/internal/services"
- )
-
- type JobRiskThirdEndpoint struct {
- PushFeatureDealEndpoint endpoint.Endpoint
- PushUserInfoEndpoint endpoint.Endpoint
- PushFeatureInfoEndpoint endpoint.Endpoint
- HealthCheckEndpoint endpoint.Endpoint
- }
-
- // MakeHealthCheckEndpoint 创建健康检查Endpoint
- func MakeHealthCheckEndpoint(svc services.JobRiskThirdServices) endpoint.Endpoint {
- return func(ctx context.Context, request interface{}) (response interface{}, err error) {
- status := svc.HealthCheck()
- return proto.HealthResponse{Status: status}, nil
- }
- }
-
- //MakePushFeatureDealEndpoint 接收风险特征处置结果Endpoint
- func MakePushFeatureDealEndpoint(svc services.JobRiskThirdServices) endpoint.Endpoint {
- return func(ctx context.Context, request interface{}) (response interface{}, err error) {
- req := request.(proto.PushFeatureDealRequest)
- err = svc.PushFeatureDeal(req)
- if err != nil {
- return proto.BaseResponse{
- RespCode: 500,
- RespMsg: "接收风险特征处置结果失败",
- }, err
- }
- return proto.BaseResponse{
- RespCode: 200,
- RespMsg: "成功",
- }, err
- }
- }
-
- //MakePushUserInfoEndpoint 获取用户信息接口
- func MakePushUserInfoEndpoint(svc services.JobRiskThirdServices) endpoint.Endpoint {
- return func(ctx context.Context, request interface{}) (response interface{}, err error) {
- req := request.(proto.PushUserInfoRequest)
- err = svc.PushUserInfo(req)
- if err != nil {
- return proto.BaseResponse{
- RespCode: 500,
- RespMsg: "获取用户信息失败",
- }, err
- }
- return proto.BaseResponse{
- RespCode: 200,
- RespMsg: "成功",
- }, err
- }
- }
-
- //MakePushFeatureInfoEndpoint 推送的风险结果信息
- func MakePushFeatureInfoEndpoint(svc services.JobRiskThirdServices) endpoint.Endpoint {
- return func(ctx context.Context, request interface{}) (response interface{}, err error) {
- req := request.(proto.PushFeatureInfoRequest)
- err = svc.PushFeatureInfo(req)
- if err != nil {
- return proto.BaseResponse{
- RespCode: 500,
- RespMsg: "推送风险结果信息失败",
- }, err
- }
- return proto.BaseResponse{
- RespCode: 200,
- RespMsg: "成功",
- }, err
- }
- }
|