|
- package controller
-
- import (
- "github.com/QuantumNous/new-api/common"
- "github.com/QuantumNous/new-api/model"
-
- "github.com/gin-gonic/gin"
- )
-
- // ReorderVendors 批量更新供应商排序
- func ReorderVendors(c *gin.Context) {
- var req struct {
- Items []struct {
- Id int `json:"id"`
- SortOrder int `json:"sort_order"`
- } `json:"items"`
- }
- if err := c.ShouldBindJSON(&req); err != nil {
- common.ApiError(c, err)
- return
- }
- if len(req.Items) == 0 {
- common.ApiErrorMsg(c, "items 不能为空")
- return
- }
- if err := model.ReorderVendors(req.Items); err != nil {
- common.ApiError(c, err)
- return
- }
- common.ApiSuccess(c, nil)
- }
-
- // ReorderModels 批量更新模型排序
- func ReorderModels(c *gin.Context) {
- var req struct {
- Items []struct {
- Id int `json:"id"`
- SortOrder int `json:"sort_order"`
- } `json:"items"`
- }
- if err := c.ShouldBindJSON(&req); err != nil {
- common.ApiError(c, err)
- return
- }
- if len(req.Items) == 0 {
- common.ApiErrorMsg(c, "items 不能为空")
- return
- }
- if err := model.ReorderModels(req.Items); err != nil {
- common.ApiError(c, err)
- return
- }
- model.RefreshPricing()
- common.ApiSuccess(c, nil)
- }
|