123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package routers
- import (
- "fmt"
- "github.com/astaxie/beego/logs"
- "github.com/gin-gonic/gin"
- "kpt.xdmy/apiserver/model"
- "kpt.xdmy/pkg/app"
- "kpt.xdmy/pkg/e"
- "strconv"
- )
- func GetStockList(c *gin.Context) {
- req := new(model.GetStockListReq)
- req.PastureId = c.Query("pastureId")
- req.DepartmentId = c.Query("departmentId")
- offsetStr := c.Query("offset")
- pagecountStr := c.Query("pagecount")
- req.StartDate = c.Query("startdate")
- req.EndDate = c.Query("enddate")
- req.Offset, _ = strconv.Atoi(offsetStr)
- req.Pagecount, _ = strconv.Atoi(pagecountStr)
- req.Offset = req.Offset - 1
- resp, err := svc.GetStockList(req)
- if err != nil {
- fmt.Println(err)
- c.JSON(500, map[string]interface{}{"code": 500, "data": "查询失败!", "msg": err})
- return
- }
- resp.Offset = req.Offset + 1
- resp.Pagecount = req.Pagecount
- c.JSON(200, map[string]interface{}{"code": 200, "data": resp, "msg": "ok"})
- }
- func StockExcel(c *gin.Context) {
- appG := app.Gin{C: c}
- data := svc.StockExcel(c)
- appG.Response(200, e.SUCCESS, data)
- }
- func DelStockList(c *gin.Context) {
- req := new(model.DelStockListReq)
- err := c.ShouldBind(&req)
- if err != nil {
- logs.Error(err)
- c.JSON(500, map[string]interface{}{"code": 500, "data": "参数有误!", "msg": err})
- return
- }
- var idList []string
- for _, id := range req.Id {
- idStr := strconv.Itoa(id)
- idList = append(idList, idStr)
- }
- err = svc.DelStockList(idList)
- if err != nil {
- logs.Error(err)
- c.JSON(500, map[string]interface{}{"code": 500, "data": "删除失败!", "msg": err})
- return
- }
- c.JSON(200, map[string]interface{}{"code": 200, "data": true, "msg": "ok"})
- }
|