package logic import ( "fusenapi/utils/auth" "fusenapi/utils/basic" "context" "fusenapi/server/home-user-auth/internal/svc" "fusenapi/server/home-user-auth/internal/types" "github.com/zeromicro/go-zero/core/logx" ) type UserContactServiceLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewUserContactServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserContactServiceLogic { return &UserContactServiceLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } func (l *UserContactServiceLogic) UserContactService(req *types.RequestContactService, userinfo *auth.UserInfo) (resp *basic.Response) { // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) // userinfo 传入值时, 一定不为null // if !userinfo.IsUser() { // return resp.SetStatus(basic.CodeUnAuth) // } // cs := gmodel.FsContactService{ // UserId: &userinfo.UserId, // } // collect.LoadJsonTag(&cs, &req) // switch req.Type { // case "order": // _, err := l.svcCtx.AllModels.FsOrder.FindOneAndCreateServiceContact(l.ctx, userinfo.UserId, req.RelationID, &cs) // if err != nil { // if err == gorm.ErrRecordNotFound { // return resp.SetStatus(basic.CodeOrderNotFoundErr) // } // return resp.SetStatus(basic.CodeDbSqlErr) // } // case "cloud": // _, err := l.svcCtx.AllModels.FsCloudPickUp.GetCloudPickUpByIDAndUserID(l.ctx, userinfo.UserId, req.RelationID, &cs) // if err != nil { // if err == gorm.ErrRecordNotFound { // return resp.SetStatus(basic.CodeCloudOrderNotFoundErr) // } // return resp.SetStatus(basic.CodeDbSqlErr) // } // return // default: // return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "type is unknown") // } return resp.SetStatus(basic.CodeOK) }