Commit c8ae67fb authored by shajiaiming's avatar shajiaiming

fix

parent 5232ac11
...@@ -5,11 +5,13 @@ import ( ...@@ -5,11 +5,13 @@ import (
"bwallet/pkg/handler" "bwallet/pkg/handler"
"bwallet/pkg/util" "bwallet/pkg/util"
"bwallet/service/auth_service" "bwallet/service/auth_service"
"bwallet/service/coin_service"
"bwallet/service/recommend_coin_service" "bwallet/service/recommend_coin_service"
"bwallet/validate_service" "bwallet/validate_service"
"github.com/Unknwon/com" "github.com/Unknwon/com"
"github.com/astaxie/beego/validation" "github.com/astaxie/beego/validation"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"strconv"
"strings" "strings"
) )
...@@ -71,7 +73,56 @@ func AddRecommendCoin(c *gin.Context) { ...@@ -71,7 +73,56 @@ func AddRecommendCoin(c *gin.Context) {
} }
} }
token := c.Request.Header.Get("Token")
authService := auth_service.Auth{Token: token}
auth, _ := authService.GetUserInfo()
group := auth.Group
var platform_id int
platform_id = auth.PlatformId
if ("administrator" == group) {
if recommend_coin.PlatformId != 0 {
platform_id = recommend_coin.PlatformId
}
}
for _, id := range strings.Split(recommend_coin.Cid, ",") {
if id == "" {
continue
}
coin_id, err := strconv.Atoi(id)
if (nil != err) {
continue
}
coinService := coin_service.Coin{
Id: coin_id,
}
exists, err := coinService.ExistById()
if err != nil || !exists {
continue
}
existsRecommendCoinService := recommend_coin_service.RecommendCoin{
Cid: coin_id,
PlatformId: platform_id,
CategoryId: recommend_coin.CategoryId,
}
existsRecommendCoinService.DeleteByCondition()
recommendCoinService := recommend_coin_service.RecommendCoin{
Cid: coin_id,
Sort: recommend_coin.Sort,
PlatformId: platform_id,
CategoryId: recommend_coin.CategoryId,
}
recommendCoinService.Add()
}
handler.SendResponse(c, nil, nil)
//自定义验证 //自定义验证
/*
recommendCoinValidate := recommend_coin_service.RecommendCoin{ recommendCoinValidate := recommend_coin_service.RecommendCoin{
CategoryId: recommend_coin.CategoryId, CategoryId: recommend_coin.CategoryId,
PlatformId: recommend_coin.PlatformId, PlatformId: recommend_coin.PlatformId,
...@@ -113,6 +164,7 @@ func AddRecommendCoin(c *gin.Context) { ...@@ -113,6 +164,7 @@ func AddRecommendCoin(c *gin.Context) {
} }
handler.SendResponse(c, nil, nil) handler.SendResponse(c, nil, nil)
*/
} }
func EditRecommendCoin(c *gin.Context) { func EditRecommendCoin(c *gin.Context) {
......
package validate_service package validate_service
type RecommendCoin struct { type RecommendCoin struct {
Cid int `json:"cid" validate:"required"` Cid string `json:"cid" validate:"required"`
Sort int `json:"sort" validate:"required"` Sort int `json:"sort" validate:"required"`
PlatformId int `json:"platform_id" validate:"required"` PlatformId int `json:"platform_id" validate:"required"`
CategoryId uint8 `json:"category_id" validate:"required"` CategoryId uint8 `json:"category_id" validate:"required"`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment