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