From 13782b799e92ff7d7e0cfe7367f09d9cf4f67b35 Mon Sep 17 00:00:00 2001 From: eson <474420502@qq.com> Date: Tue, 9 Apr 2024 23:50:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/killara_customer_logic.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/model/killara_customer_logic.go b/model/killara_customer_logic.go index d09c090..bb5bbed 100644 --- a/model/killara_customer_logic.go +++ b/model/killara_customer_logic.go @@ -7,6 +7,14 @@ import ( "github.com/jmoiron/sqlx" ) +const ( + /** + * 禁止A仓交易,1:是;2:否 + */ + Disable_A_No = 2 + Type_2 = 2 +) + type KillaraCustomerModel struct { // fields ... db *sqlx.DB @@ -21,3 +29,21 @@ func (m *KillaraCustomerModel) Find(ctx context.Context) (result []*KillaraCusto } return customer, nil } + +func (m *KillaraCustomerModel) InsertCustomer(data *KillaraCustomer) (int64, error) { + result, err := m.db.NamedExec(`INSERT INTO customer (type, realname, code, telephone, email, nickname, name, status, disable_a, parent_id) + VALUES (:type, :realname, :code, :telephone, :email, :nickname, :name, :status, :disable_a, :parent_id)`, data) + if err != nil { + return 0, err + } + id, err := result.LastInsertId() + return id, err +} + +func (m *KillaraCustomerModel) UpdateCustomer(id int64, data *KillaraCustomer) error { + _, err := m.db.NamedExec( + `UPDATE customer SET type=:type, realname=:realname, code=:code, telephone=:telephone, email=:email, nickname=:nickname, name=:name, status=:status, disable_a=:disable_a, parent_id=:parent_id WHERE customer_id=:customer_id`, + data, + ) + return err +}