87 lines
2.5 KiB
Go
87 lines
2.5 KiB
Go
package controller
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"exhibition-register/pb/exhibition"
|
|
"exhibition-register/pkg/msg"
|
|
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func (e *ExhibitionProvider) CheckPhone(_ context.Context, req *exhibition.RegisterInfo) (rep *exhibition.CheckPhoneResp, err error) {
|
|
if rep, err = e.registerLogic.CheckByPhone(req); err != nil {
|
|
return nil, err
|
|
}
|
|
rep.Msg = msg.Success
|
|
return rep, nil
|
|
}
|
|
|
|
func (e *ExhibitionProvider) CheckIdCard(_ context.Context, req *exhibition.RegisterInfo) (rep *exhibition.CheckIdCardResp, err error) {
|
|
if rep, err = e.registerLogic.CheckIdCard(req); err != nil {
|
|
return rep, err
|
|
}
|
|
rep.Msg = msg.Success
|
|
return rep, nil
|
|
}
|
|
|
|
func (e *ExhibitionProvider) SaveRegisterRecord(_ context.Context, req *exhibition.RegisterInfo) (rep *exhibition.SaveRegisterRecordResp, err error) {
|
|
if rep, err = e.registerLogic.SaveRegisterRecord(req); err != nil {
|
|
return nil, err
|
|
}
|
|
rep.Msg = msg.Success
|
|
return rep, nil
|
|
}
|
|
|
|
func (e *ExhibitionProvider) RegisterRecordList(_ context.Context, req *exhibition.RecordListReq) (rep *exhibition.RecordListResp, err error) {
|
|
if rep, err = e.registerLogic.RegisterRecordList(req); err != nil {
|
|
return nil, err
|
|
}
|
|
rep.Msg = msg.Success
|
|
rep.Page = req.Page
|
|
rep.PageSize = req.PageSize
|
|
return rep, nil
|
|
}
|
|
|
|
func (e *ExhibitionProvider) ExportRegisterRecord(_ context.Context, req *exhibition.ExportRecordReq) (rep *exhibition.ExportRecordResp, err error) {
|
|
if rep, err = e.registerLogic.FindAllRecord(); err != nil {
|
|
return nil, err
|
|
}
|
|
rep.Msg = msg.Success
|
|
return rep, nil
|
|
}
|
|
func (e *ExhibitionProvider) ImportInfoByExcel(_ context.Context, req *exhibition.RegisterInfo) (rep *exhibition.SaveRegisterRecordResp, err error) {
|
|
if info, err := e.registerLogic.GetRecordByName(req); err != nil {
|
|
return nil, err
|
|
} else {
|
|
req.Uuid = info.Uuid
|
|
}
|
|
if rep, err = e.registerLogic.UpdateRegisterRecord(req); err != nil {
|
|
return nil, err
|
|
}
|
|
rep.Msg = msg.Success
|
|
return rep, nil
|
|
}
|
|
|
|
// 新增评选号校验方法
|
|
func (e *ExhibitionProvider) CheckRatingNo(ctx context.Context, req *exhibition.CheckRatingNoReq) (*exhibition.CheckRatingNoResp, error) {
|
|
resp := &exhibition.CheckRatingNoResp{}
|
|
|
|
// 参数校验
|
|
if req.RatingNo == "" {
|
|
resp.Msg = "评选号不能为空"
|
|
return resp, nil
|
|
}
|
|
|
|
// 调用logic层校验逻辑
|
|
exist, err := e.registerLogic.CheckRatingNoExists(req)
|
|
if err != nil {
|
|
zap.L().Error("评选号校验失败", zap.String("ratingNo", req.RatingNo), zap.Error(err))
|
|
return nil, errors.New(msg.ErrorSelect)
|
|
}
|
|
|
|
resp.IsExist = exist
|
|
resp.Msg = msg.Success
|
|
return resp, nil
|
|
}
|