func (p *CommonColumnAutoSetupperImpl) DoHandleCommonColumnOfUpdateIfNeeds(
	entity *df.Entity, context *df.Context) {
	tempUpdateDatetime := df.CreateTimestamp(time.Now())
	if &tempUpdateDatetime != nil {
		df.SetEntityValue(entity, "updateDatetime", tempUpdateDatetime)
	}
	tempUpdateUser := context.Get("User")
	if &tempUpdateUser != nil {
		df.SetEntityValue(entity, "updateUser", tempUpdateUser)
	}
	tempUpdateProcess := context.Get("Process")
	if &tempUpdateProcess != nil {
		df.SetEntityValue(entity, "updateProcess", tempUpdateProcess)
	}
}
Пример #2
0
func MapToEntity(rmap map[string]interface{}, entity *df.Entity, table string, update bool) {
	meta := df.DBMetaProvider_I.TableDbNameInstanceMap[table]
	for propertyName := range rmap {
		colInfo := (*meta).GetColumnInfoByPropertyName(propertyName)
		if colInfo == nil {
			continue
		}
		value := rmap[propertyName]
		if value == nil {
			continue
		}
		argType := df.GetType(value)
		if argType == "string" {
			svalue := value.(string)
			if svalue == "" {
				EntitySetNull(entity, propertyName, colInfo, update)
				continue
			}
		}
		df.SetEntityValue(entity, propertyName,
			ConvFromWebData(value, colInfo, argType))
	}
}
Пример #3
0
func EntitySetNull(
	entity *df.Entity, propertyName string, colInfo *df.ColumnInfo, update bool) {
	switch colInfo.GoType {
	case "string":
		df.SetEntityValue(entity, propertyName, "")
	case "sql.NullString":
		df.SetEntityValue(entity, propertyName, new(sql.NullString))
	case "pq.NullTime":
		nt := new(pq.NullTime)
		nt.Valid = false
		df.SetEntityValue(entity, propertyName, nt)
	case "df.NullDate":
		df.SetEntityValue(entity, propertyName, new(df.NullDate))
	case "df.NullTimestamp":
		df.SetEntityValue(entity, propertyName, new(df.NullTimestamp))
	case "df.NullNumeric":
		df.SetEntityValue(entity, propertyName, new(df.NullNumeric))
	case "df.MysqlNullDate":
		df.SetEntityValue(entity, propertyName, new(df.MysqlNullDate))
	case "df.MysqlNullTime":
		df.SetEntityValue(entity, propertyName, new(df.MysqlNullTime))
	case "df.MysqlNullTimestamp":
		df.SetEntityValue(entity, propertyName, new(df.MysqlNullTimestamp))
	case "sql.NullInt64":
		df.SetEntityValue(entity, propertyName, new(sql.NullInt64))
	case "sql.NullFloat64":
		df.SetEntityValue(entity, propertyName, new(sql.NullFloat64))
	case "sql.NullBool":
		df.SetEntityValue(entity, propertyName, new(sql.NullBool))
	default:
		if update {
			panic("必須項目未入力です。 項目名:" + propertyName)
		}
	}
}