72 lines
2.0 KiB
Go
72 lines
2.0 KiB
Go
package decision
|
||
|
||
import (
|
||
"errors"
|
||
"github.com/gin-gonic/gin"
|
||
model "go-admin/app/admin/models"
|
||
"go-admin/logger"
|
||
"go-admin/tools"
|
||
"go-admin/tools/app"
|
||
"net/http"
|
||
)
|
||
|
||
// ErpDecisionReport 进销存报表
|
||
// @Summary 进销存报表
|
||
// @Tags 决策中心,V1.4.0
|
||
// @Produce json
|
||
// @Accept json
|
||
// @Param request body models.ErpDecisionReportReq true "进销存报表模型"
|
||
// @Success 200 {object} models.ErpDecisionReportResp
|
||
// @Router /api/v1/decision/report [post]
|
||
func ErpDecisionReport(c *gin.Context) {
|
||
req := new(model.ErpDecisionReportReq)
|
||
if err := c.ShouldBindJSON(&req); err != nil {
|
||
logger.Error("ShouldBindJSON err:", logger.Field("err", err))
|
||
app.Error(c, http.StatusBadRequest, errors.New("para err"), "参数错误"+err.Error())
|
||
return
|
||
}
|
||
|
||
resp, err := req.DecisionReportList(c)
|
||
if err != nil {
|
||
//logger.Error("erp commodity list err:", err)
|
||
app.Error(c, http.StatusInternalServerError, err, "查询失败:"+err.Error())
|
||
return
|
||
}
|
||
|
||
app.OK(c, resp, "OK")
|
||
return
|
||
}
|
||
|
||
// ErpStoreSalesData 门店销售对比
|
||
// @Summary 门店销售对比
|
||
// @Tags 决策中心,V1.4.0
|
||
// @Produce json
|
||
// @Accept json
|
||
// @Param request body models.ErpStoreSalesDataReq true "门店销售对比数据模型"
|
||
// @Success 200 {object} models.ErpStoreSalesDataResp
|
||
// @Router /api/v1/decision/store_sales_report [post]
|
||
func ErpStoreSalesData(c *gin.Context) {
|
||
var req = new(model.ErpStoreSalesDataReq)
|
||
if err := c.ShouldBindJSON(&req); err != nil {
|
||
logger.Error("ShouldBindJSON err:", logger.Field("err", err))
|
||
app.Error(c, http.StatusBadRequest, err, "参数错误:"+err.Error())
|
||
return
|
||
}
|
||
|
||
err := tools.Validate(req) //必填参数校验
|
||
if err != nil {
|
||
app.Error(c, http.StatusBadRequest, err, err.Error())
|
||
return
|
||
}
|
||
|
||
resp, err := model.QueryStoreSalesData(req, c)
|
||
if err != nil {
|
||
logger.Error("QueryStoreSalesData err:", logger.Field("err", err))
|
||
app.Error(c, http.StatusInternalServerError, err, "查询失败:"+err.Error())
|
||
return
|
||
}
|
||
|
||
app.OK(c, resp, "")
|
||
return
|
||
}
|