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.
27 lines
547 B
27 lines
547 B
package handler
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"laic-backend/common"
|
|
)
|
|
|
|
// parseID 解析路径参数 :id 为 int64
|
|
func parseID(c *gin.Context) (int64, *common.BusiError) {
|
|
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
|
if err != nil || id <= 0 {
|
|
return 0, common.ErrParam
|
|
}
|
|
return id, nil
|
|
}
|
|
|
|
// parseStringID 解析路径参数 :id 为字符串(如任务 ID)
|
|
func parseStringID(c *gin.Context) (string, *common.BusiError) {
|
|
id := c.Param("id")
|
|
if id == "" {
|
|
return "", common.ErrParam
|
|
}
|
|
return id, nil
|
|
}
|
|
|