本文整理汇总了Golang中go2o/src/core/domain/interface/member.ValueMember.Usr方法的典型用法代码示例。如果您正苦于以下问题:Golang ValueMember.Usr方法的具体用法?Golang ValueMember.Usr怎么用?Golang ValueMember.Usr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类go2o/src/core/domain/interface/member.ValueMember
的用法示例。
在下文中一共展示了ValueMember.Usr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetValue
// 设置值
func (this *Member) SetValue(v *member.ValueMember) error {
v.Usr = this._value.Usr
if err := this.validate(v); err != nil {
return err
}
this._value.Address = v.Address
this._value.Birthday = v.Birthday
this._value.Qq = v.Qq
this._value.Email = v.Email
this._value.LastLoginTime = v.LastLoginTime
this._value.Phone = v.Phone
this._value.Pwd = v.Pwd
this._value.Name = v.Name
this._value.Sex = v.Sex
this._value.RegFrom = v.RegFrom
if v.Avatar != "" {
this._value.Avatar = v.Avatar
}
if len(this._value.InvitationCode) == 0 {
this._value.InvitationCode = v.InvitationCode
}
if len(v.TradePwd) == 0 {
this._value.TradePwd = v.TradePwd
}
if len(this._value.Qq) != 0 && len(this._value.Email) != 0 &&
len(this._value.Birthday) != 0 && len(this._value.Address) != 0 &&
len(this._value.Phone) != 0 && len(this._value.Avatar) != 0 &&
this._value.Sex != 0 {
this.notifyOnProfileComplete()
}
return nil
}
示例2: validate
func (this *Member) validate(v *member.ValueMember) error {
v.Usr = strings.ToLower(strings.TrimSpace(v.Usr)) // 小写并删除空格
v.Name = strings.TrimSpace(v.Name)
v.Email = strings.ToLower(strings.TrimSpace(v.Email))
v.Phone = strings.TrimSpace(v.Phone)
if len([]rune(v.Usr)) < 6 {
return member.ErrUserLength
}
if !userRegex.MatchString(v.Usr) {
return member.ErrUserValidErr
}
if this.GetAggregateRootId() != 0 && len([]rune(v.Name)) < 2 {
return member.ErrPersonName
}
if len(v.Email) != 0 && !emailRegex.MatchString(v.Email) {
return member.ErrEmailValidErr
}
if len(v.Phone) != 0 && !phoneRegex.MatchString(v.Phone) {
return member.ErrPhoneValidErr
}
if len(v.Qq) != 0 && !qqRegex.MatchString(v.Qq) {
return member.ErrQqValidErr
}
return nil
}
示例3: Register
// 注册
func (this *MemberC) Register(ctx *web.Context) {
if this.BaseC.Requesting(ctx) {
r := ctx.Request
var result dto.MessageResult
var err error
var partnerId int = this.GetPartnerId(ctx)
var invMemberId int // 邀请人
var usr string = r.FormValue("usr")
var pwd string = r.FormValue("pwd")
var phone string = r.FormValue("phone")
var registerFrom string = r.FormValue("reg_from") // 注册来源
var invitationCode string = r.FormValue("invitation_code") // 推荐码
var regIp string
if i := strings.Index(r.RemoteAddr, ":"); i != -1 {
regIp = r.RemoteAddr[:i]
}
if err = dps.PartnerService.CheckRegisterMode(partnerId, invitationCode); err != nil {
result.Message = err.Error()
ctx.Response.JsonOutput(result)
return
}
//fmt.Println(usr, pwd, "REGFROM:", registerFrom, "INVICODE:", invitationCode)
// 检验
if len(invitationCode) != 0 {
invMemberId = dps.MemberService.GetMemberIdByInvitationCode(invitationCode)
if invMemberId == 0 {
result.Message = "1011:推荐码错误"
ctx.Response.JsonOutput(result)
return
}
}
var member member.ValueMember
member.Usr = usr
member.Pwd = domain.MemberSha1Pwd(pwd)
member.RegIp = regIp
member.Phone = phone
member.RegFrom = registerFrom
memberId, err := dps.MemberService.SaveMember(&member)
if err == nil {
result.Result = true
err = dps.MemberService.SaveRelation(memberId, "-", invMemberId, partnerId)
}
if err != nil {
result.Message = err.Error()
}
ctx.Response.JsonOutput(result)
}
}