本文整理汇总了Golang中go2o/src/core/domain/interface/member.ValueMember.RegFrom方法的典型用法代码示例。如果您正苦于以下问题:Golang ValueMember.RegFrom方法的具体用法?Golang ValueMember.RegFrom怎么用?Golang ValueMember.RegFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类go2o/src/core/domain/interface/member.ValueMember
的用法示例。
在下文中一共展示了ValueMember.RegFrom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RegisterMember
func (this *Partner) RegisterMember(m *jsv.Args, r *jsv.Result) error {
var err error
e := member.ValueMember{}
if err = jsv.UnmarshalMap((*m)["json"], &e); err != nil {
return err
}
var cardId string
var tgId int
var partnerId int
cardId = (*m)["card_id"].(string)
tgId, _ = strconv.Atoi((*m)["tg_id"].(string))
partnerId, _ = strconv.Atoi((*m)["partner_id"].(string))
//如果卡片ID为空时,自动生成
if cardId == "" {
cardId = time.Now().Format("200601021504")
}
e.RegFrom = "WEB"
e.Pwd = domain.MemberSha1Pwd(e.Pwd)
id, err := dps.MemberService.SaveMember(&e)
if err == nil {
dps.MemberService.SaveRelation(id, cardId, tgId, partnerId)
r.Result = true
return nil
}
return err
}
示例2: create
// 创建会员
func (this *Member) create(m *member.ValueMember) (int, error) {
if this.UsrIsExist() {
return -1, errors.New("用户名已经被使用")
}
t := time.Now().Unix()
m.State = 1
m.RegTime = t
m.LastLoginTime = t
m.Level = 1
m.Exp = 1
m.Avatar = "resource/no_avatar.gif"
m.Birthday = "1970-01-01"
m.DynamicToken = m.Pwd
m.Exp = 0
if len(m.RegFrom) == 0 {
m.RegFrom = "API-INTERNAL"
}
// 如果昵称为空,则跟用户名相同
if len(m.Name) == 0 {
m.Name = m.Usr
}
m.InvitationCode = this.generateInvitationCode() // 创建一个邀请码
id, err := this._rep.SaveMember(m)
if id != 0 {
this._value.Id = id
}
return id, err
}
示例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)
}
}