func (p *CommonColumnAutoSetupperImpl) DoHandleCommonColumnOfInsertIfNeeds(
	entity *df.Entity, context *df.Context) {
	tempRegisterDatetime := df.CreateTimestamp(time.Now())
	if &tempRegisterDatetime != nil {
		df.SetEntityValue(entity, "registerDatetime", tempRegisterDatetime)
	}
	tempRegisterUser := context.Get("User")
	if &tempRegisterUser != nil {
		df.SetEntityValue(entity, "registerUser", tempRegisterUser)
	}
	tempRegisterProcess := context.Get("Process")
	if &tempRegisterProcess != nil {
		df.SetEntityValue(entity, "registerProcess", tempRegisterProcess)
	}
	tempUpdateDatetime := df.GetEntityValue(entity, "registerDatetime")
	if &tempUpdateDatetime != nil {
		df.SetEntityValue(entity, "updateDatetime", tempUpdateDatetime)
	}
	tempUpdateUser := df.GetEntityValue(entity, "registerUser")
	if &tempUpdateUser != nil {
		df.SetEntityValue(entity, "updateUser", tempUpdateUser)
	}
	tempUpdateProcess := df.GetEntityValue(entity, "registerProcess")
	if &tempUpdateProcess != nil {
		df.SetEntityValue(entity, "updateProcess", tempUpdateProcess)
	}

}
Esempio n. 2
0
func ConvFromWebDataForInvoke(
	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 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 cv
		case "float64":
			return 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 cv
		case "float64":
			return arg.(float64)
		}
	case "sql.NullBool":
		switch argType {
		case "string":
			cv, err := strconv.ParseBool(arg.(string))
			if err != nil {
				panic("Booleanに変換出来ません:" + arg.(string))
			}
			return cv
		case "bool":
			return 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.CreateNumeric(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 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.CreateDate(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.CreateTimestamp(res)
		}
	}

	if argType != goType {
		panic("この組み合わせは規定されていません。 argType:" + argType + " goType:" + goType)
	}
	return arg
}