|
|
@@ -173,6 +173,9 @@ func AddLevelTask(c *gin.Context) { |
|
|
|
if req.TaskTypeLevelId != "" { |
|
|
|
task.TaskTypeLevelId = utils.StrToInt(req.TaskTypeLevelId) |
|
|
|
} |
|
|
|
if req.ActiveDays != "" { |
|
|
|
task.ActiveDays = utils.StrToInt(req.ActiveDays) |
|
|
|
} |
|
|
|
|
|
|
|
taskDb := implement.NewUserLevelTaskDb(db.Db) |
|
|
|
taskID, err := taskDb.UserLevelTaskInsert(&task) |
|
|
@@ -200,12 +203,13 @@ func UpdateLevelTask(c *gin.Context) { |
|
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var forceColumns []string |
|
|
|
task := &model.UserLevelTask{ |
|
|
|
Id: utils.StrToInt(req.TaskID), |
|
|
|
} |
|
|
|
if req.IsMustTask != "" { |
|
|
|
task.IsMustTask = utils.StrToInt(req.IsMustTask) |
|
|
|
forceColumns = append(forceColumns, "is_must_task") |
|
|
|
} |
|
|
|
if req.TaskType != "" { |
|
|
|
task.TaskType = utils.StrToInt(req.TaskType) |
|
|
@@ -219,9 +223,12 @@ func UpdateLevelTask(c *gin.Context) { |
|
|
|
if req.TaskTypeLevelId != "" { |
|
|
|
task.TaskTypeLevelId = utils.StrToInt(req.TaskTypeLevelId) |
|
|
|
} |
|
|
|
if req.ActiveDays != "" { |
|
|
|
task.ActiveDays = utils.StrToInt(req.ActiveDays) |
|
|
|
} |
|
|
|
|
|
|
|
taskDb := implement.NewUserLevelTaskDb(db.Db) |
|
|
|
affected, err := taskDb.UserLevelTaskUpdate(task) |
|
|
|
affected, err := taskDb.UserLevelTaskUpdate(task, forceColumns...) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
@@ -246,7 +253,7 @@ func UpdateLevel(c *gin.Context) { |
|
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var forceColumns []string |
|
|
|
level := &model.UserLevel{ |
|
|
|
Id: utils.StrToInt(req.LevelID), |
|
|
|
LevelName: req.LevelName, |
|
|
@@ -255,17 +262,24 @@ func UpdateLevel(c *gin.Context) { |
|
|
|
} |
|
|
|
if req.LevelWeight != "" { |
|
|
|
level.LevelWeight = utils.StrToInt(req.LevelWeight) |
|
|
|
forceColumns = append(forceColumns, "level_weight") |
|
|
|
} |
|
|
|
if req.IsUse == "0" || req.IsUse == "1" { |
|
|
|
level.LevelWeight = utils.StrToInt(req.IsUse) |
|
|
|
forceColumns = append(forceColumns, "is_use") |
|
|
|
} |
|
|
|
if req.AutoUpdate == "0" || req.AutoUpdate == "1" { |
|
|
|
level.AutoUpdate = utils.StrToInt(req.AutoUpdate) |
|
|
|
forceColumns = append(forceColumns, "auto_update") |
|
|
|
} |
|
|
|
forceColumns := []string{"level_weight", "is_use"} |
|
|
|
|
|
|
|
levelDb := implement.NewUserLevelDb(db.Db) |
|
|
|
affected, err := levelDb.UserLevelUpdate(req.LevelID, level, forceColumns...) |
|
|
|
if err != nil { |
|
|
|
if err.Error() == "no columns found to be updated" { |
|
|
|
e.OutSuc(c, affected, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|