package logic import ( "errors" "micro-document/api/emailAlerts" "micro-document/internel/dao" util "micro-document/pkg/utils" "github.com/jinzhu/copier" ) type emailAlertsLogic struct{} var EmailAlertsLogic = new(emailAlertsLogic) func (emailAlertsLogic) EmailAlertsSubmit(req *emailAlerts.EmailAlertsSubmitReq) (result *emailAlerts.EmailAlertsSubmitResp, err error) { result = &emailAlerts.EmailAlertsSubmitResp{} if req.FirstName == "" { return nil, errors.New("FirstName is null") } if req.LastName == "" { return nil, errors.New("LastName is null") } if req.Email == "" { return nil, errors.New("Email is null") } if req.Company == "" { return nil, errors.New("Company is null") } if req.Phone == "" { return nil, errors.New("Phone is null") } err = dao.EmailAlertsDao.Submit(req) if err != nil { result.Msg = err.Error() return nil, err } result.Msg = "新增邮件提醒成功" return } func (emailAlertsLogic) GetEmailInformationList(req *emailAlerts.GetEmailInformationListReq) (result *emailAlerts.GetEmailInformationListResp, err error) { result = &emailAlerts.GetEmailInformationListResp{} data, total, err := dao.EmailAlertsDao.GetEmailInformationList(req) if err != nil { return nil, errors.New("查询邮件提醒失败") } result.Total = int32(total) if err = copier.CopyWithOption(&result.Data, &data, util.CopierProtoOptions); err != nil { return nil, errors.New("复制邮件提醒失败") } return }