新建
This commit is contained in:
parent
aeb7379028
commit
f1d87954bf
@ -1 +1,16 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"exhibition-register/pb/exhibition"
|
||||
"exhibition-register/pkg/msg"
|
||||
)
|
||||
|
||||
func (e *ExhibitionProvider) CheckPhone(_ context.Context, req *exhibition.RegisterInfo) (res *exhibition.CheckPhoneResp, err error) {
|
||||
res = new(exhibition.CheckPhoneResp)
|
||||
if res, err = e.registerLogic.CheckPhone(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res.Msg = msg.Success
|
||||
return
|
||||
}
|
||||
|
23
internal/dao/register.go
Normal file
23
internal/dao/register.go
Normal file
@ -0,0 +1,23 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"exhibition-register/internal/model"
|
||||
"exhibition-register/pkg/app"
|
||||
"exhibition-register/pkg/msg"
|
||||
"go.uber.org/zap"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func CheckByPhone(phone string) (record *model.RegisterRecord, err error) {
|
||||
res := app.ModuleClients.ExhibitionRegister.Where("phone_num=?", phone).First(record)
|
||||
if res.Error != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
zap.L().Error("Register err CheckByPhone", zap.Error(err))
|
||||
err = errors.New(msg.ErrorSelect)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
@ -1,7 +1,47 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"exhibition-register/internal/dao"
|
||||
"exhibition-register/pb/exhibition"
|
||||
)
|
||||
|
||||
type IRegister interface {
|
||||
CheckPhone(in *exhibition.RegisterInfo) (out *exhibition.CheckPhoneResp, err error)
|
||||
}
|
||||
|
||||
func NewRegister() IRegister {
|
||||
return &Register{}
|
||||
}
|
||||
|
||||
type Register struct {
|
||||
}
|
||||
|
||||
// CheckPhone 通过手机号检索 存在的就返回数据
|
||||
func (r *Register) CheckPhone(in *exhibition.RegisterInfo) (out *exhibition.CheckPhoneResp, err error) {
|
||||
out = &exhibition.CheckPhoneResp{}
|
||||
record, err := dao.CheckByPhone(in.PhoneNum)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if record == nil {
|
||||
out.IsExist = false
|
||||
return out, nil
|
||||
}
|
||||
data := &exhibition.RegisterInfo{
|
||||
Id: int32(record.ID),
|
||||
Uuid: record.UUID,
|
||||
ArtistName: record.ArtistName,
|
||||
Gender: record.Gender,
|
||||
PhoneNum: record.PhoneNum,
|
||||
IdCard: record.IdCard,
|
||||
Address: record.Address,
|
||||
IdCardPhoto: record.IdCardPhoto,
|
||||
ArtistPhoto: record.ArtistPhoto,
|
||||
CreatedAt: record.CreatedAt.String(),
|
||||
UpdatedAt: record.UpdatedAt.String(),
|
||||
}
|
||||
out.Data = data
|
||||
out.IsExist = true
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
@ -71,52 +71,4 @@ const (
|
||||
|
||||
const (
|
||||
ErrOperate = "操作错误"
|
||||
|
||||
ErrCreateUser = "创建用户失败"
|
||||
ErrUpdateUser = "更新用户失败"
|
||||
ErrGetUserInfo = "查询用户信息失败"
|
||||
ErrGetUserInfoExam = "查询答题用户信息失败"
|
||||
ErrUserNotRegister = "用户未注册"
|
||||
ErrVerifyUser = "校验用户信息失败"
|
||||
ErrUserHad = "当前用户信息已存在"
|
||||
|
||||
ErrCreateExam = "创建考试失败"
|
||||
ErrUpdateExam = "更新考试失败"
|
||||
ErrGetExamInfoData = "查询考试信息失败"
|
||||
ErrGetExamInfoCount = "查询考试信息失败"
|
||||
ErrGetExamInfoNoParams = "查询考试信息条件错误"
|
||||
ErUpdateExamStatus = "更新考试状态错误"
|
||||
|
||||
ErrCreateTrain = "创建培训失败"
|
||||
ErrUpdateTrain = "更新培训失败"
|
||||
ErrGetTrainInfoData = "查询培训信息失败"
|
||||
ErrGetTrainInfoCount = "查询培训信息失败"
|
||||
ErrGetTrainInfoNoParams = "查询培训信息条件错误"
|
||||
|
||||
ErrCreateQuestion = "创建题目失败"
|
||||
ErrUpdateQuestion = "更新题目失败"
|
||||
ErrQuestionInUse = "题目正在被使用,无法修改"
|
||||
ErrGetQuestionInfoData = "查询题目信息失败"
|
||||
ErrGetQuestionInfoCount = "查询题目信息失败"
|
||||
|
||||
ErrCreateGift = "创建礼品失败"
|
||||
ErrUpdateGift = "更新礼品失败"
|
||||
ErrGetGiftInfoData = "查询礼品信息失败"
|
||||
ErrGetGiftInfoCount = "查询礼品信息失败"
|
||||
|
||||
ErrCreateUserHis = "创建考试成绩失败"
|
||||
ErrQueryUserHis = "查询考试成绩失败"
|
||||
ErrQueryAnswerScore = "查询答案分值失败"
|
||||
ErrQueryAnswer = "查询答案失败"
|
||||
ErrCreateUserAnswerHis = "创建作答记录失败"
|
||||
ErrCreateUserTrainHis = "创建培训记录失败"
|
||||
ErrUpdateUserTrainHis = "更新培训记录失败"
|
||||
ErrCreateUserGiftHis = "创建礼品记录失败"
|
||||
ErrUpdateUserGiftHis = "更新礼品状态失败"
|
||||
ErrCheckAnswer = "答案核对失败"
|
||||
ErrUpdateUserHis = "更新考试成绩失败"
|
||||
ErrUpdateParticipantNum = "更新参与人数失败"
|
||||
ErrUpdateParticipantPassNum = "更新通过人数失败"
|
||||
ErrQueryVideo = "查询视频信息失败"
|
||||
ErrQueryUserAnswerHis = "查询答题记录失败"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user