1
0

url.go 448 B

1234567891011121314151617181920212223242526
  1. package pkg
  2. import (
  3. "strings"
  4. "github.com/gin-gonic/gin"
  5. )
  6. //获取URL中批量id并解析
  7. func IdsStrToIdsIntGroup(key string, c *gin.Context) []int {
  8. return IdsStrToIdsIntGroupStr(c.Param(key))
  9. }
  10. type Ids struct {
  11. Ids []int
  12. }
  13. func IdsStrToIdsIntGroupStr(keys string) []int {
  14. IDS := make([]int, 0)
  15. ids := strings.Split(keys, ",")
  16. for i := 0; i < len(ids); i++ {
  17. ID, _ := StringToInt(ids[i])
  18. IDS = append(IDS, ID)
  19. }
  20. return IDS
  21. }