rewrite giant thing
This commit is contained in:
@@ -9,60 +9,48 @@ import (
|
||||
|
||||
type MapfixUpdate datastore.OptionalMap
|
||||
|
||||
func NewMapfixUpdate(
|
||||
display_name string, display_name_ok bool,
|
||||
creator string, creator_ok bool,
|
||||
game_id uint32, game_id_ok bool,
|
||||
submitter uint64, submitter_ok bool,
|
||||
asset_id uint64, asset_id_ok bool,
|
||||
asset_version uint64, asset_version_ok bool,
|
||||
validated_asset_id uint64, validated_asset_id_ok bool,
|
||||
validated_asset_version uint64, validated_asset_version_ok bool,
|
||||
completed bool, completed_ok bool,
|
||||
target_asset_id uint64, target_asset_id_ok bool,
|
||||
status_id model.MapfixStatus, status_id_ok bool,
|
||||
description string, description_ok bool,
|
||||
) MapfixUpdate {
|
||||
func NewMapfixUpdate() MapfixUpdate {
|
||||
update := datastore.Optional()
|
||||
if display_name_ok {
|
||||
update.Add("display_name", display_name)
|
||||
}
|
||||
if creator_ok {
|
||||
update.Add("creator", creator)
|
||||
}
|
||||
if game_id_ok {
|
||||
update.Add("game_id", game_id)
|
||||
}
|
||||
if submitter_ok {
|
||||
update.Add("submitter", submitter)
|
||||
}
|
||||
if asset_id_ok {
|
||||
update.Add("asset_id", asset_id)
|
||||
}
|
||||
if asset_version_ok {
|
||||
update.Add("asset_version", asset_version)
|
||||
}
|
||||
if validated_asset_id_ok {
|
||||
update.Add("validated_asset_id", validated_asset_id)
|
||||
}
|
||||
if validated_asset_version_ok {
|
||||
update.Add("validated_asset_version", validated_asset_version)
|
||||
}
|
||||
if completed_ok {
|
||||
update.Add("completed", completed)
|
||||
}
|
||||
if target_asset_id_ok {
|
||||
update.Add("target_asset_id", target_asset_id)
|
||||
}
|
||||
if status_id_ok {
|
||||
update.Add("status_id", status_id)
|
||||
}
|
||||
if description_ok {
|
||||
update.Add("description", description)
|
||||
}
|
||||
return MapfixUpdate(update)
|
||||
}
|
||||
|
||||
func (update MapfixUpdate) SetDisplayName(display_name string) {
|
||||
datastore.OptionalMap(update).Add("display_name", display_name)
|
||||
}
|
||||
func (update MapfixUpdate) SetCreator(creator string) {
|
||||
datastore.OptionalMap(update).Add("creator", creator)
|
||||
}
|
||||
func (update MapfixUpdate) SetGameID(game_id uint32) {
|
||||
datastore.OptionalMap(update).Add("game_id", game_id)
|
||||
}
|
||||
func (update MapfixUpdate) SetSubmitter(submitter uint64) {
|
||||
datastore.OptionalMap(update).Add("submitter", submitter)
|
||||
}
|
||||
func (update MapfixUpdate) SetAssetID(asset_id uint64) {
|
||||
datastore.OptionalMap(update).Add("asset_id", asset_id)
|
||||
}
|
||||
func (update MapfixUpdate) SetAssetVersion(asset_version uint64) {
|
||||
datastore.OptionalMap(update).Add("asset_version", asset_version)
|
||||
}
|
||||
func (update MapfixUpdate) SetValidatedAssetID(validated_asset_id uint64) {
|
||||
datastore.OptionalMap(update).Add("validated_asset_id", validated_asset_id)
|
||||
}
|
||||
func (update MapfixUpdate) SetValidatedAssetVersion(validated_asset_version uint64) {
|
||||
datastore.OptionalMap(update).Add("validated_asset_version", validated_asset_version)
|
||||
}
|
||||
func (update MapfixUpdate) SetCompleted(completed bool) {
|
||||
datastore.OptionalMap(update).Add("completed", completed)
|
||||
}
|
||||
func (update MapfixUpdate) SetTargetAssetID(target_asset_id uint64) {
|
||||
datastore.OptionalMap(update).Add("target_asset_id", target_asset_id)
|
||||
}
|
||||
func (update MapfixUpdate) SetStatusID(status_id model.MapfixStatus) {
|
||||
datastore.OptionalMap(update).Add("status_id", status_id)
|
||||
}
|
||||
func (update MapfixUpdate) SetDescription(description string) {
|
||||
datastore.OptionalMap(update).Add("description", description)
|
||||
}
|
||||
|
||||
type MapfixFilter datastore.OptionalMap
|
||||
|
||||
func NewMapfixFilter(
|
||||
@@ -99,12 +87,6 @@ func NewMapfixFilter(
|
||||
return MapfixFilter(filter)
|
||||
}
|
||||
|
||||
func NewMapfixFilterCompleted() MapfixFilter {
|
||||
filter := datastore.Optional()
|
||||
filter.Add("completed", true)
|
||||
return MapfixFilter(filter)
|
||||
}
|
||||
|
||||
func (svc *Service) CreateMapfix(ctx context.Context, script model.Mapfix) (model.Mapfix, error) {
|
||||
return svc.db.Mapfixes().Create(ctx, script)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user