Exemplo n.º 1
0
func GetLoginFromSession(session *entity.Session, tx *sql.Tx) *entity.Login {
	cb := cb.CreateLoginCB()
	cb.Query().SetId_Equal(session.GetLoginId().Int64)
	cb.Query().SetDelFlag_Equal(0)
	res, err := bhv.LoginBhv_I.SelectList(cb, tx)
	if err != nil {
		panic("Login Select Error:" + err.Error())
	}
	if res.AllRecordCount != 1 {
		panic("Login Not Found")
	}
	return (res.List.Get(0)).(*entity.Login)
}
Exemplo n.º 2
0
func (p *Login) getDelFlagMaxValue(entityx *entity.Login) int64 {
	cb := cb.CreateLoginCB()
	cb.Query().SetLoginId_Equal(entityx.GetLoginId())
	cb.Query().AddOrderBy_DelFlag_Desc()
	cb.FetchFirst(1)
	res, err := bhv.LoginBhv_I.SelectList(cb, p.tx)
	if err != nil {
		panic(err.Error())
	}
	if res.AllRecordCount == 1 {
		return (res.List.Get(0)).(*entity.Login).GetDelFlag()
	}
	panic("DelFlag Max not found")
	return 1
}
Exemplo n.º 3
0
func (p *Login) getLoginFromLoginId(json map[string]interface{}, tx *sql.Tx) *entity.Login {

	cb := cb.CreateLoginCB()
	loginId := json["loginId"]
	if loginId == nil {
		return nil
	}
	cb.Query().SetLoginId_Equal((loginId).(string))
	cb.Query().SetDelFlag_Equal(0)
	res, err2 := bhv.LoginBhv_I.SelectList(cb, tx)

	if err2 != nil {
		panic(err2.Error())
	}
	if res.AllRecordCount == 1 {
		return (res.List.Get(0)).(*entity.Login)
	}
	return nil
}
Exemplo n.º 4
0
func GetSessionFromRequestCookie(c *gin.Context, tx *sql.Tx) *entity.Session {
	cookie, err := c.Request.Cookie("uuid")
	if err != nil {
		return nil
	}
	uuid := cookie.Value
	uuid = uuid
	cb := cb.CreateSessionCB()
	cb.Query().SetUuid_Equal(uuid)
	cb.Query().SetDelFlag_Equal(0)
	res, err2 := bhv.SessionBhv_I.SelectList(cb, tx)
	if err2 != nil {
		panic("Session Select Error:" + err2.Error())
	}
	if res.AllRecordCount != 1 {
		return nil
	}
	return (res.List.Get(0)).(*entity.Session)
}