func (p *Login) createNewSession(login *entity.Login, tx *sql.Tx, ctx *df.Context) *entity.Session { uuid := uuid.New() session := entity.CreateSession() session.SetUuid(uuid) session.SetLoginId(df.CreateNullInt64(login.GetId())) bhv.SessionBhv_I.Insert(session, tx, ctx) return session }
func ConvFromWebData( arg interface{}, colInfo *df.ColumnInfo, argType string) interface{} { goType := colInfo.GoType if argType == goType { return arg } switch goType { case "sql.NullString": switch argType { case "string": return df.CreateNullString(arg.(string)) } case "int64": switch argType { case "string": cv, err := strconv.ParseInt(arg.(string), 10, 64) if err != nil { panic("int64に変換出来ません:" + arg.(string)) } return cv case "float64": return int64(arg.(float64)) } case "sql.NullInt64": switch argType { case "string": cv, err := strconv.ParseInt(arg.(string), 10, 64) if err != nil { panic("int64に変換出来ません:" + arg.(string)) } return df.CreateNullInt64(cv) case "float64": return df.CreateNullInt64(int64(arg.(float64))) } case "float64": switch argType { case "string": cv, err := strconv.ParseFloat(arg.(string), 64) if err != nil { panic("float64に変換出来ません:" + arg.(string)) } return cv case "float64": return arg.(float64) } case "sql.NullFloat64": switch argType { case "string": cv, err := strconv.ParseFloat(arg.(string), 64) if err != nil { panic("float64に変換出来ません:" + arg.(string)) } return df.CreateNullFloat64(cv) case "float64": return df.CreateNullFloat64(arg.(float64)) } case "sql.NullBool": switch argType { case "string": cv, err := strconv.ParseBool(arg.(string)) if err != nil { panic("Booleanに変換出来ません:" + arg.(string)) } return df.CreateNullBool(cv) case "bool": return df.CreateNullBool(arg.(bool)) } case "df.Numeric": switch argType { case "string": cv, err := df.CreateNumeric(arg.(string)) if err != nil { panic("Numericに変換出来ません:" + arg.(string)) } return cv } case "df.NullNumeric": switch argType { case "string": cv, err := df.CreateNullNumeric(arg.(string)) if err != nil { panic("Numericに変換出来ません:" + arg.(string)) } return cv } case "time.Time": switch argType { case "string": res, err := time.Parse(df.DISP_SQL_DEFAULT_TIME_FORMAT, arg.(string)) if err != nil { panic("Timeに変換出来ません。:" + arg.(string)) } return res } case "df.Date": switch argType { case "string": res, err := time.Parse(df.DISP_SQL_DEFAULT_DATE_FORMAT, arg.(string)) if err != nil { panic("Timeに変換出来ません。:" + arg.(string)) } return df.CreateDate(res) } case "df.Timestamp": switch argType { case "string": args := arg.(string) parse := df.DISP_SQL_DEFAULT_TIMESTAMP_FORMAT if len(args) == len(df.DISP_SQL_DEFAULT_DATE_FORMAT) { parse = df.DISP_SQL_DEFAULT_DATE_FORMAT } res, err := time.Parse(parse, args) if err != nil { panic("Timestampに変換出来ません。:" + args) } return df.CreateTimestamp(res) } case "pq.NullTime": switch argType { case "string": res, err := time.Parse(df.DISP_SQL_DEFAULT_TIME_FORMAT, arg.(string)) if err != nil { panic("Timeに変換出来ません。:" + arg.(string)) } return df.CreateNullTime(res) } case "df.NullDate": switch argType { case "string": res, err := time.Parse(df.DISP_SQL_DEFAULT_DATE_FORMAT, arg.(string)) if err != nil { panic("Timeに変換出来ません。:" + arg.(string)) } return df.CreateNullDate(res) } case "df.NullTimestamp": switch argType { case "string": args := arg.(string) parse := df.DISP_SQL_DEFAULT_TIMESTAMP_FORMAT if len(args) == len(df.DISP_SQL_DEFAULT_DATE_FORMAT) { parse = df.DISP_SQL_DEFAULT_DATE_FORMAT } res, err := time.Parse(parse, args) if err != nil { panic("Timestampに変換出来ません。:" + args) } return df.CreateNullTimestamp(res) } } if argType != goType { panic("この組み合わせは規定されていません。 argType:" + argType + " goType:" + goType) } return arg }