update.go 944 B

123456789101112131415161718192021222324252627
  1. package my_chart_classify
  2. import (
  3. "fmt"
  4. "hongze/hongze_yb/global"
  5. "time"
  6. )
  7. // UpdateMyChartClassifySortByClassifyId 根据分类ID更新排序
  8. func UpdateMyChartClassifySortByClassifyId(adminId, classifyId, nowSort int, updateSort string) (err error) {
  9. sql := ` update my_chart_classify set sort = ` + updateSort + ` WHERE admin_id = ? and sort > ? `
  10. if classifyId > 0 {
  11. sql += ` or ( my_chart_classify_id > ` + fmt.Sprint(classifyId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
  12. }
  13. err = global.MYSQL["data"].Exec(sql, adminId, nowSort).Error
  14. return
  15. }
  16. // UpdateClassifySort 更新分类排序
  17. func UpdateClassifySort(adminId, classifyId, nowSort int, modifyTime time.Time) (err error) {
  18. err = global.MYSQL["data"].Model(MyChartClassify{}).Select("Sort", "ModifyTime").Where("admin_id = ? AND my_chart_classify_id = ?", adminId, classifyId).Updates(MyChartClassify{
  19. Sort: nowSort,
  20. ModifyTime: modifyTime,
  21. }).Error
  22. return
  23. }