From de4bcd1dead50b05f716bc5718be5540bdb96783 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期日, 28 四月 2024 17:23:29 +0800
Subject: [PATCH] fix
---
api/v1/test/supplier.go | 92 ++++++++++++++++++++++++++++++++++++----------
1 files changed, 72 insertions(+), 20 deletions(-)
diff --git a/api/v1/test/supplier.go b/api/v1/test/supplier.go
index 6884436..6a2b489 100644
--- a/api/v1/test/supplier.go
+++ b/api/v1/test/supplier.go
@@ -1,15 +1,16 @@
package test
import (
- "github.com/flipped-aurora/gin-vue-admin/server/global"
- "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
- "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
- "github.com/flipped-aurora/gin-vue-admin/server/model/test"
- testReq "github.com/flipped-aurora/gin-vue-admin/server/model/test/request"
- "github.com/flipped-aurora/gin-vue-admin/server/service"
- "github.com/flipped-aurora/gin-vue-admin/server/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
+ "gorm.io/gorm"
+ "srm/global"
+ "srm/model/common/request"
+ "srm/model/common/response"
+ "srm/model/test"
+ testReq "srm/model/test/request"
+ "srm/service"
+ "srm/utils"
)
type SupplierApi struct {
@@ -25,7 +26,7 @@
// @Produce application/json
// @Param data body test.Supplier true "鍒涘缓Supplier"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}"
-// @Router /api/s/createSupplier [post]
+// @Router /s/createSupplier [post]
func (sApi *SupplierApi) CreateSupplier(c *gin.Context) {
var s test.Supplier
err := c.ShouldBindJSON(&s)
@@ -33,12 +34,9 @@
response.FailWithMessage(err.Error(), c)
return
}
- verify := utils.Rules{
- "Name": {utils.NotEmpty()},
- "ResponsiblePersonId": {utils.NotEmpty()},
- }
- if err := utils.Verify(s, verify); err != nil {
- response.FailWithMessage(err.Error(), c)
+ _, err = sService.GetSupplierByNumber(s.Number)
+ if err != gorm.ErrRecordNotFound {
+ response.FailWithMessage("缂栧彿閲嶅", c)
return
}
if err := sService.CreateSupplier(&s); err != nil {
@@ -57,7 +55,7 @@
// @Produce application/json
// @Param data body test.Supplier true "鍒犻櫎Supplier"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"鍒犻櫎鎴愬姛"}"
-// @Router /api/s/deleteSupplier [delete]
+// @Router /s/deleteSupplier [delete]
func (sApi *SupplierApi) DeleteSupplier(c *gin.Context) {
var s test.Supplier
err := c.ShouldBindJSON(&s)
@@ -81,7 +79,7 @@
// @Produce application/json
// @Param data body request.IdsReq true "鎵归噺鍒犻櫎Supplier"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"鎵归噺鍒犻櫎鎴愬姛"}"
-// @Router /api/s/deleteSupplierByIds [delete]
+// @Router /s/deleteSupplierByIds [delete]
func (sApi *SupplierApi) DeleteSupplierByIds(c *gin.Context) {
var IDS request.IdsReq
err := c.ShouldBindJSON(&IDS)
@@ -105,7 +103,7 @@
// @Produce application/json
// @Param data body test.Supplier true "鏇存柊Supplier"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"鏇存柊鎴愬姛"}"
-// @Router /api/s/updateSupplier [put]
+// @Router /s/updateSupplier [put]
func (sApi *SupplierApi) UpdateSupplier(c *gin.Context) {
var s test.Supplier
err := c.ShouldBindJSON(&s)
@@ -137,7 +135,7 @@
// @Produce application/json
// @Param data query test.Supplier true "鐢╥d鏌ヨSupplier"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"鏌ヨ鎴愬姛"}"
-// @Router /api/s/findSupplier [get]
+// @Router /s/findSupplier [get]
func (sApi *SupplierApi) FindSupplier(c *gin.Context) {
var s test.Supplier
err := c.ShouldBindQuery(&s)
@@ -153,6 +151,29 @@
}
}
+// GetSupplierByNumber 鐢ㄧ紪鐮佹煡璇upplier
+// @Tags Supplier
+// @Summary 鐢ㄧ紪鐮佹煡璇upplier
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param number path string true "渚涘簲鍟嗙紪鐮�"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"鏌ヨ鎴愬姛"}"
+// @Router /s/getSupplierByNumber/{number} [get]
+func (sApi *SupplierApi) GetSupplierByNumber(c *gin.Context) {
+ number := c.Param("number")
+ if number == "" {
+ response.FailWithMessage("缂栫爜鍙傛暟涓嶈兘涓虹┖", c)
+ return
+ }
+ if res, err := sService.GetSupplierByNumber(number); err != nil {
+ global.GVA_LOG.Error("鏌ヨ澶辫触!", zap.Error(err))
+ response.FailWithMessage("鏌ヨ澶辫触", c)
+ } else {
+ response.OkWithData(gin.H{"res": res}, c)
+ }
+}
+
// GetSupplierList 鍒嗛〉鑾峰彇Supplier鍒楄〃
// @Tags Supplier
// @Summary 鍒嗛〉鑾峰彇Supplier鍒楄〃
@@ -161,7 +182,7 @@
// @Produce application/json
// @Param data query testReq.SupplierSearch true "鍒嗛〉鑾峰彇Supplier鍒楄〃"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}"
-// @Router /api/s/getSupplierList [get]
+// @Router /s/getSupplierList [get]
func (sApi *SupplierApi) GetSupplierList(c *gin.Context) {
var pageInfo testReq.SupplierSearch
err := c.ShouldBindQuery(&pageInfo)
@@ -190,7 +211,7 @@
// @Produce application/json
// @Param data body testReq.SupplierStatus true "淇敼Supplier鐘舵��"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"淇敼鎴愬姛"}"
-// @Router /api/s/changeSupplierStatus [post]
+// @Router /s/changeSupplierStatus [post]
func (sApi *SupplierApi) ChangeSupplierStatus(c *gin.Context) {
var params testReq.SupplierStatus
err := c.ShouldBindJSON(¶ms)
@@ -205,3 +226,34 @@
response.OkWithMessage("淇敼鎴愬姛", c)
}
}
+
+// GetSupplierProductList 鑾峰彇渚涘簲鍟嗘彁渚涗骇鍝佸垪琛�
+// @Tags Supplier
+// @Summary 鑾峰彇渚涘簲鍟嗘彁渚涗骇鍝佸垪琛�
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data query testReq.SupplierProduct true "鑾峰彇渚涘簲鍟嗘彁渚涗骇鍝佸垪琛�"
+// @Param Authorization header string true "token"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}"
+// @Router /s/getSupplierProductList [get]
+func (sApi *SupplierApi) GetSupplierProductList(c *gin.Context) {
+ var params testReq.SupplierProduct
+ err := c.ShouldBindQuery(¶ms)
+ if err != nil {
+ response.FailWithMessage(err.Error(), c)
+ return
+ }
+ list, total, err := sService.GetSupplierProduct(params)
+ if err != nil {
+ global.GVA_LOG.Error("鑾峰彇澶辫触!", zap.Error(err))
+ response.FailWithMessage("鑾峰彇澶辫触", c)
+ return
+ }
+ response.OkWithDetailed(response.PageResult{
+ List: list,
+ Total: total,
+ Page: params.Page,
+ PageSize: params.PageSize,
+ }, "鑾峰彇鎴愬姛", c)
+}
--
Gitblit v1.8.0