From 0e106357c3995772275e425dddc929955719e474 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Thu, 5 Dec 2024 12:11:02 +0800 Subject: [PATCH] add egg point partition coefficient management --- ...nt_partition_coefficient_management_dao.go | 11 +++++ ...tition_coefficient_management_implement.go | 49 +++++++++++++++++++ ..._point_partition_coefficient_management.go | 10 ++++ 3 files changed, 70 insertions(+) create mode 100644 src/dao/egg_point_partition_coefficient_management_dao.go create mode 100644 src/implement/egg_point_partition_coefficient_management_implement.go create mode 100644 src/model/egg_point_partition_coefficient_management.go diff --git a/src/dao/egg_point_partition_coefficient_management_dao.go b/src/dao/egg_point_partition_coefficient_management_dao.go new file mode 100644 index 0000000..aef9bcb --- /dev/null +++ b/src/dao/egg_point_partition_coefficient_management_dao.go @@ -0,0 +1,11 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type EggPointPartitionCoefficientManagementDao interface { + //TODO:: You can add specific method definitions here + EggPointPartitionCoefficientManagementGetAll() (*[]model.EggPointPartitionCoefficientManagement, error) + EggPointPartitionCoefficientManagementBatchInsert(m []model.EggPointPartitionCoefficientManagement) (int64, error) + EggPointPartitionCoefficientManagementDel(id string) (int64, error) + EggPointPartitionCoefficientManagementUpdate(id string, m *model.EggPointPartitionCoefficientManagement, columns ...string) (int64, error) +} diff --git a/src/implement/egg_point_partition_coefficient_management_implement.go b/src/implement/egg_point_partition_coefficient_management_implement.go new file mode 100644 index 0000000..d1e8f0c --- /dev/null +++ b/src/implement/egg_point_partition_coefficient_management_implement.go @@ -0,0 +1,49 @@ +package implement + +import ( + "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" + "xorm.io/xorm" +) + +func NewEggPointPartitionCoefficientManagementDb(engine *xorm.Engine) dao.EggPointPartitionCoefficientManagementDao { + return &EggPointPartitionCoefficientManagementDb{Db: engine} +} + +type EggPointPartitionCoefficientManagementDb struct { + Db *xorm.Engine +} + +func (e EggPointPartitionCoefficientManagementDb) EggPointPartitionCoefficientManagementGetAll() (*[]model.EggPointPartitionCoefficientManagement, error) { + var m []model.EggPointPartitionCoefficientManagement + err := e.Db.Asc("start_score").Find(&m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err.Error()) + } + return &m, err +} + +func (e EggPointPartitionCoefficientManagementDb) EggPointPartitionCoefficientManagementBatchInsert(m []model.EggPointPartitionCoefficientManagement) (int64, error) { + affect, err := e.Db.Insert(m) + if err != nil { + return 0, zhios_order_relate_logx.Error(err.Error()) + } + return affect, nil +} + +func (e EggPointPartitionCoefficientManagementDb) EggPointPartitionCoefficientManagementDel(id string) (int64, error) { + affect, err := e.Db.Where("id = ?", id).Delete(model.EggPointPartitionCoefficientManagement{}) + if err != nil { + return 0, zhios_order_relate_logx.Error(err.Error()) + } + return affect, nil +} + +func (e EggPointPartitionCoefficientManagementDb) EggPointPartitionCoefficientManagementUpdate(id string, m *model.EggPointPartitionCoefficientManagement, columns ...string) (int64, error) { + affected, err := e.Db.Where("id =?", id).Cols(columns...).Update(m) + if err != nil { + return 0, err + } + return affected, nil +} diff --git a/src/model/egg_point_partition_coefficient_management.go b/src/model/egg_point_partition_coefficient_management.go new file mode 100644 index 0000000..66e909f --- /dev/null +++ b/src/model/egg_point_partition_coefficient_management.go @@ -0,0 +1,10 @@ +package model + +type EggPointPartitionCoefficientManagement struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + StartScore string `json:"start_score" xorm:"not null comment('起始分值') DECIMAL(10,2)"` + EndScore string `json:"end_score" xorm:"not null comment('截止分值') DECIMAL(10,2)"` + Coefficient string `json:"coefficient" xorm:"not null comment('系数') DECIMAL(10,2)"` + CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"` +}