Explorar el Código

update

master
shenjiachi hace 1 semana
padre
commit
492a5e7ef7
Se han modificado 4 ficheros con 133 adiciones y 2 borrados
  1. +106
    -0
      app/hdl/institutional_management/egg_energy/hdl_basic.go
  2. +22
    -0
      app/md/institutional_management/egg_energy/md_basic.go
  3. +3
    -0
      app/router/router.go
  4. +2
    -2
      go.mod

+ 106
- 0
app/hdl/institutional_management/egg_energy/hdl_basic.go Ver fichero

@@ -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 蛋蛋能量


+ 22
- 0
app/md/institutional_management/egg_energy/md_basic.go Ver fichero

@@ -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"` // 会员等级名称


+ 3
- 0
app/router/router.go Ver fichero

@@ -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)


+ 2
- 2
go.mod Ver fichero

@@ -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


Cargando…
Cancelar
Guardar