|
|
@@ -6,7 +6,6 @@ import ( |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
"code.gitea.io/gitea/routers/response" |
|
|
|
"code.gitea.io/gitea/services/admin/operate_log" |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"strings" |
|
|
|
) |
|
|
@@ -36,8 +35,7 @@ func UpdateSpecUnitPrice(doerId int64, specId int64, unitPrice int) *response.Bi |
|
|
|
} |
|
|
|
|
|
|
|
if oldSpec.UnitPrice != unitPrice { |
|
|
|
newSpec, _ := models.GetResourceSpecification(&models.ResourceSpecification{ID: specId}) |
|
|
|
AddSpecOperateLog(doerId, "edit", newSpec, oldSpec, fmt.Sprintf("修改单价从%d积分到%d积分", oldSpec.UnitPrice, newSpec.UnitPrice)) |
|
|
|
AddSpecOperateLog(doerId, "edit", operate_log.NewLogValues().Add("unitPrice", unitPrice), operate_log.NewLogValues().Add("unitPrice", oldSpec.UnitPrice), specId, fmt.Sprintf("修改资源规格单价从%d积分到%d积分", oldSpec.UnitPrice, unitPrice)) |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |
|
|
@@ -149,8 +147,9 @@ func ResourceSpecOnShelf(doerId int64, id int64, unitPrice int) *response.BizErr |
|
|
|
return response.NewBizError(err) |
|
|
|
} |
|
|
|
if spec.UnitPrice != unitPrice { |
|
|
|
newSpec, _ := models.GetResourceSpecification(&models.ResourceSpecification{ID: id}) |
|
|
|
AddSpecOperateLog(doerId, "on-shelf", newSpec, spec, fmt.Sprintf("修改单价从%d积分到%d积分", spec.UnitPrice, newSpec.UnitPrice)) |
|
|
|
AddSpecOperateLog(doerId, "on-shelf", operate_log.NewLogValues().Add("UnitPrice", unitPrice), operate_log.NewLogValues().Add("UnitPrice", spec.UnitPrice), id, fmt.Sprintf("定价上架资源规格,单价为%d", unitPrice)) |
|
|
|
} else { |
|
|
|
AddSpecOperateLog(doerId, "on-shelf", nil, nil, id, "上架资源规格") |
|
|
|
} |
|
|
|
return nil |
|
|
|
|
|
|
@@ -160,20 +159,27 @@ func ResourceSpecOffShelf(doerId int64, id int64) *response.BizError { |
|
|
|
if err != nil { |
|
|
|
return response.NewBizError(err) |
|
|
|
} |
|
|
|
AddSpecOperateLog(doerId, "off-shelf", nil, nil, id, "下架资源规格") |
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func AddSpecOperateLog(doerId int64, operateType string, newSpec, oldSpec *models.ResourceSpecification, comment string) { |
|
|
|
newJson, _ := json.Marshal(newSpec) |
|
|
|
oldJson, _ := json.Marshal(oldSpec) |
|
|
|
func AddSpecOperateLog(doerId int64, operateType string, newValue, oldValue *models.LogValues, specId int64, comment string) { |
|
|
|
var newString = "" |
|
|
|
var oldString = "" |
|
|
|
if newValue != nil { |
|
|
|
newString = newValue.JsonString() |
|
|
|
} |
|
|
|
if oldValue != nil { |
|
|
|
oldString = oldValue.JsonString() |
|
|
|
} |
|
|
|
operate_log.Log(models.AdminOperateLog{ |
|
|
|
BizType: "SpecOperate", |
|
|
|
OperateType: operateType, |
|
|
|
OldValue: string(newJson), |
|
|
|
NewValue: string(oldJson), |
|
|
|
RelatedId: fmt.Sprint(newSpec.ID), |
|
|
|
Comment: comment, |
|
|
|
OldValue: oldString, |
|
|
|
NewValue: newString, |
|
|
|
RelatedId: fmt.Sprint(specId), |
|
|
|
CreatedBy: doerId, |
|
|
|
Comment: comment, |
|
|
|
}) |
|
|
|
} |