From 82c058c91daed212fd9b3807dca9ca80217ce738 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期三, 30 八月 2023 20:25:01 +0800
Subject: [PATCH] fix
---
service/test/supplier.go | 36 ++++++++++++++++++++++++++++++------
1 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/service/test/supplier.go b/service/test/supplier.go
index 915190c..4ce559f 100644
--- a/service/test/supplier.go
+++ b/service/test/supplier.go
@@ -1,10 +1,10 @@
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/test"
- testReq "github.com/flipped-aurora/gin-vue-admin/server/model/test/request"
+ "srm/global"
+ "srm/model/common/request"
+ "srm/model/test"
+ testReq "srm/model/test/request"
)
type SupplierService struct {
@@ -34,7 +34,7 @@
// UpdateSupplier 鏇存柊Supplier璁板綍
// Author [piexlmax](https://github.com/piexlmax)
func (sService *SupplierService) UpdateSupplier(s test.Supplier) (err error) {
- err = global.GVA_DB.Save(&s).Error
+ err = global.GVA_DB.Updates(&s).Error
return err
}
@@ -60,11 +60,35 @@
if info.Name != "" {
db = db.Where("name LIKE ?", "%"+info.Name+"%")
}
+ if info.Number != "" {
+ db = db.Where("number LIKE ?", "%"+info.Number+"%")
+ }
+ if info.SupplierType != "" {
+ db = db.Where("supplier_type LIKE ?", "%"+info.SupplierType+"%")
+ }
+ if info.Industry != "" {
+ db = db.Where("industry LIKE ?", "%"+info.Industry+"%")
+ }
+ if info.Contact != "" {
+ db = db.Where("contact LIKE ?", "%"+info.Contact+"%")
+ }
+ if info.Phone != "" {
+ db = db.Where("phone LIKE ?", "%"+info.Phone+"%")
+ }
+ if info.CreatedAt != nil {
+ db = db.Where("created_at = ?", info.CreatedAt)
+ }
err = db.Count(&total).Error
if err != nil {
return
}
- err = db.Limit(limit).Offset(offset).Find(&ss).Error
+ err = db.Debug().Limit(limit).Offset(offset).Preload("Contract").Find(&ss).Error
return ss, total, err
}
+
+// ChangeStatus Change supplier status
+func (sService *SupplierService) ChangeStatus(id uint, status int) (err error) {
+ err = global.GVA_DB.Model(&test.Supplier{}).Where("id = ?", id).Update("status", status).Error
+ return err
+}
--
Gitblit v1.8.0