常用类型及数据操作方法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
774 B

3 years ago
  1. package helper
  2. import (
  3. "strings"
  4. )
  5. /**
  6. * 处理传递的参数
  7. * @param param
  8. * @return
  9. * 2020/05/15
  10. * gz
  11. */
  12. func ParamsString(param string) string {
  13. if strings.Contains(param, " ") {
  14. return ""
  15. }
  16. return param
  17. }
  18. /**
  19. * 根据第几页计算从第几行开始
  20. * @param pageNum 第几页
  21. * @param pageSize 每页几行
  22. * @return from,offset 开始行数偏移量
  23. * 2020/05/15
  24. * gz
  25. */
  26. func GetPage(pageNum, pageSize interface{}) (string, string) {
  27. var from string
  28. var offset int = ToInt(pageSize)
  29. var pageNumInt, pageSizeInt int = ToInt(pageNum), ToInt(pageSize)
  30. if pageNumInt < 1 {
  31. pageNumInt = 1
  32. }
  33. if pageSizeInt < 1 {
  34. offset = 10
  35. pageSizeInt = 10
  36. }
  37. from = ToString((pageNumInt - 1) * pageSizeInt)
  38. return from, ToString(offset)
  39. }