From 492a5e7ef7ad42fc822eedfc2544e5214a3f177c Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Wed, 11 Dec 2024 11:57:24 +0800 Subject: [PATCH] update --- .../egg_energy/hdl_basic.go | 106 ++++++++++++++++++ .../egg_energy/md_basic.go | 22 ++++ app/router/router.go | 3 + go.mod | 4 +- 4 files changed, 133 insertions(+), 2 deletions(-) diff --git a/app/hdl/institutional_management/egg_energy/hdl_basic.go b/app/hdl/institutional_management/egg_energy/hdl_basic.go index c97b45b..b0fe73c 100644 --- a/app/hdl/institutional_management/egg_energy/hdl_basic.go +++ b/app/hdl/institutional_management/egg_energy/hdl_basic.go @@ -49,6 +49,112 @@ func GetVirtualCoinList(c *gin.Context) { } +// BatchAddVirtualCoins +// @Summary 制度中心-蛋蛋能量-批量新增币种 +// @Tags 蛋蛋能量 +// @Description 批量新增币种 +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Param req body md.BatchAddVirtualCoinsReq true "新增数据信息" +// @Success 200 {int} "新增数据数量" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/institutionalManagement/eggEnergy/batchAddVirtualCoins [POST] +func BatchAddVirtualCoins(c *gin.Context) { + var req *md.BatchAddVirtualCoinsReq + if err1 := c.ShouldBindJSON(&req); err1 != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error()) + return + } + now := time.Now() + coins := make([]model.VirtualCoin, len(req.List)) + for i, node := range req.List { + coins[i].Name = node.Name + coins[i].ExchangeRatio = node.ExchangeRatio + coins[i].IsUse = node.IsUse + coins[i].CreateAt = now.Format("2006-01-02 15:04:05") + coins[i].UpdateAt = now.Format("2006-01-02 15:04:05") + } + + coinDb := implement.NewVirtualCoinDb(db.Db) + affected, err := coinDb.VirtualCoinBatchAdd(coins) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + e.OutSuc(c, affected, nil) + return +} + +// UpdateVirtualCoin +// @Summary 制度中心-蛋蛋能量-更新币种信息 +// @Tags 蛋蛋能量 +// @Description 更新币种信息 +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Param req body md.UpdateVirtualCoinReq true "更新数据信息" +// @Success 200 {int} "更新数据数量" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/institutionalManagement/eggEnergy/updateVirtualCoin [POST] +func UpdateVirtualCoin(c *gin.Context) { + var req *md.UpdateVirtualCoinReq + if err1 := c.ShouldBindJSON(&req); err1 != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error()) + return + } + + coinDb := implement.NewVirtualCoinDb(db.Db) + coin, err := coinDb.VirtualCoinGetOneByParams(map[string]interface{}{ + "key": "id", + "value": req.Id, + }) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if coin == nil { + e.OutErr(c, e.ERR_NO_DATA, errors.New("该币种不存在")) + return + } + + m := model.VirtualCoin{ + Id: req.Id, + Name: req.Name, + ExchangeRatio: req.ExchangeRatio, + IsUse: req.IsUse, + } + forceColumns := []string{"is_use"} + affected, err := coinDb.VirtualCoinUpdate(&m, forceColumns...) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + e.OutSuc(c, affected, nil) +} + +// DeleteVirtualCoin +// @Summary 制度中心-蛋蛋能量-删除币种 +// @Tags 蛋蛋能量 +// @Description 删除币种 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Success 200 {int} "删除数据数量" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/institutionalManagement/eggEnergy/deleteVirtualCoin/{$id} [DELETE] +func DeleteVirtualCoin(c *gin.Context) { + id := c.Param("id") + + coinDb := implement.NewVirtualCoinDb(db.Db) + affected, err := coinDb.VirtualCoinDelete(id) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + e.OutSuc(c, affected, nil) +} + // GetEggEnergyBasic // @Summary 制度中心-蛋蛋能量-基础设置(获取) // @Tags 蛋蛋能量 diff --git a/app/md/institutional_management/egg_energy/md_basic.go b/app/md/institutional_management/egg_energy/md_basic.go index 0215d72..81908a9 100644 --- a/app/md/institutional_management/egg_energy/md_basic.go +++ b/app/md/institutional_management/egg_energy/md_basic.go @@ -69,6 +69,28 @@ type UpdateEggEnergyBasicReq struct { NewUserIncentiveRules md.NewUserRewardRules `json:"new_user_incentive_rules"` // 新用户奖励规则 // 新用户奖励规则 } +type AddVirtualCoinNode struct { + Name string `json:"name"` // 名称 + ExchangeRatio string `json:"exchange_ratio"` // 兑换比例(与金额) + IsUse int `json:"is_use" ` // 是否开启:0否 1是 +} + +type BatchAddVirtualCoinsReq struct { + List []AddVirtualCoinNode `json:"list"` // 新增的货币列表 +} + +type UpdateVirtualCoinReq struct { + Id int `json:"id"` + Name string `json:"name"` // 名称 + ExchangeRatio string `json:"exchange_ratio"` // 兑换比例(与金额) + IsUse int `json:"is_use"` // 是否开启:0否 1是 + +} + +type DeleteVirtualCoinReq struct { + Id int `json:"id"` +} + type VipEquitySettingNode struct { VipLevelID string `json:"vip_level_id"` // 会员等级ID VipLevelName string `json:"vip_level_name"` // 会员等级名称 diff --git a/app/router/router.go b/app/router/router.go index 5adb49b..1e12954 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -244,6 +244,9 @@ func rInstitutionalManagement(r *gin.RouterGroup) { //制度管理 rEggEnergy := r.Group("/eggEnergy") //蛋蛋能量 { rEggEnergy.GET("/getVirtualCoinList", egg_energy.GetVirtualCoinList) + rEggEnergy.POST("/batchAddVirtualCoins", egg_energy.BatchAddVirtualCoins) + rEggEnergy.POST("/updateVirtualCoin", egg_energy.UpdateVirtualCoin) + rEggEnergy.DELETE("/deleteVirtualCoin/:id", egg_energy.DeleteVirtualCoin) rEggEnergy.GET("/getBasic", egg_energy.GetEggEnergyBasic) rEggEnergy.POST("/updateBasic", egg_energy.UpdateEggEnergyBasic) rEggEnergy.GET("/getVipSetting", egg_energy.GetEggEnergyVipSetting) diff --git a/go.mod b/go.mod index 256f202..7b3d012 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module applet go 1.19 -// replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models +replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models //replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules @@ -33,7 +33,7 @@ require ( ) require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241210122203-4b6573d9eb25 + code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241211035630-d1cf0a9dd18b code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241205075006-9c0bf995c788 code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5