package router

import (
	"demo/data/dao/manage"
	"demo/data/domain"
	"demo/share"
	"fmt"
	"github.com/gin-gonic/gin"
	"github.com/mitchellh/mapstructure"
	"github.com/spf13/cast"
	"strings"
	"time"
	"unicode"
)

func UtilStructToMap(m map[string]interface{}) map[string]interface{} {
	res := make(map[string]interface{})
	for s := range m {
		result := ""
		for i, r := range s {
			if unicode.IsUpper(r) && i > 0 {
				result += "_"
			}
			result += strings.ToLower(string(r))
		}
		res[result] = m[s]
	}
	return res
}

func DateToString(date time.Time) string {
	return date.Format("2006-01-02 15:04:05")
}

func BaseArticleRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/article", GetBaseArticleById)
	PushRouter(BaseArticleGroup, "POST", "/article/list", GetBaseArticleList)
	PushRouter(BaseArticleGroup, "POST", "/article/in", GetBaseArticleListInId)
	PushRouter(BaseArticleGroup, "POST", "/article", SaveBaseArticle)
	PushRouter(BaseArticleGroup, "PUT", "/article", UpdateBaseArticle)
	PushRouter(BaseArticleGroup, "DELETE", "/article", DeleteBaseArticle)
}

func BaseArticleTagRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/articleTag", GetBaseArticleTagById)
	PushRouter(BaseArticleGroup, "POST", "/articleTag/list", GetBaseArticleTagList)
	PushRouter(BaseArticleGroup, "POST", "/articleTag/in", GetBaseArticleTagListInId)
	PushRouter(BaseArticleGroup, "POST", "/articleTag", SaveBaseArticleTag)
	PushRouter(BaseArticleGroup, "PUT", "/articleTag", UpdateBaseArticleTag)
	PushRouter(BaseArticleGroup, "DELETE", "/articleTag", DeleteBaseArticleTag)
}

func BaseArticleTopicRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/articleTopic", GetBaseArticleTopicById)
	PushRouter(BaseArticleGroup, "POST", "/articleTopic/list", GetBaseArticleTopicList)
	PushRouter(BaseArticleGroup, "POST", "/articleTopic/in", GetBaseArticleTopicListInId)
	PushRouter(BaseArticleGroup, "POST", "/articleTopic", SaveBaseArticleTopic)
	PushRouter(BaseArticleGroup, "PUT", "/articleTopic", UpdateBaseArticleTopic)
	PushRouter(BaseArticleGroup, "DELETE", "/articleTopic", DeleteBaseArticleTopic)
}

func BaseBackAuthorityRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/backAuthority", GetBaseBackAuthorityById)
	PushRouter(BaseArticleGroup, "POST", "/backAuthority/list", GetBaseBackAuthorityList)
	PushRouter(BaseArticleGroup, "POST", "/backAuthority/in", GetBaseBackAuthorityListInId)
	PushRouter(BaseArticleGroup, "POST", "/backAuthority", SaveBaseBackAuthority)
	PushRouter(BaseArticleGroup, "PUT", "/backAuthority", UpdateBaseBackAuthority)
	PushRouter(BaseArticleGroup, "DELETE", "/backAuthority", DeleteBaseBackAuthority)
}

func BaseBackMenuRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/backMenu", GetBaseBackMenuById)
	PushRouter(BaseArticleGroup, "POST", "/backMenu/list", GetBaseBackMenuList)
	PushRouter(BaseArticleGroup, "POST", "/backMenu/in", GetBaseBackMenuListInId)
	PushRouter(BaseArticleGroup, "POST", "/backMenu", SaveBaseBackMenu)
	PushRouter(BaseArticleGroup, "PUT", "/backMenu", UpdateBaseBackMenu)
	PushRouter(BaseArticleGroup, "DELETE", "/backMenu", DeleteBaseBackMenu)
}

func BaseBackRoleRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/backRole", GetBaseBackRoleById)
	PushRouter(BaseArticleGroup, "POST", "/backRole/list", GetBaseBackRoleList)
	PushRouter(BaseArticleGroup, "POST", "/backRole/in", GetBaseBackRoleListInId)
	PushRouter(BaseArticleGroup, "POST", "/backRole", SaveBaseBackRole)
	PushRouter(BaseArticleGroup, "PUT", "/backRole", UpdateBaseBackRole)
	PushRouter(BaseArticleGroup, "DELETE", "/backRole", DeleteBaseBackRole)
}

func BaseBackRoleAuthorityRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/backRoleAuthority", GetBaseBackRoleAuthorityById)
	PushRouter(BaseArticleGroup, "POST", "/backRoleAuthority/list", GetBaseBackRoleAuthorityList)
	PushRouter(BaseArticleGroup, "POST", "/backRoleAuthority/in", GetBaseBackRoleAuthorityListInId)
	PushRouter(BaseArticleGroup, "POST", "/backRoleAuthority", SaveBaseBackRoleAuthority)
	PushRouter(BaseArticleGroup, "PUT", "/backRoleAuthority", UpdateBaseBackRoleAuthority)
	PushRouter(BaseArticleGroup, "DELETE", "/backRoleAuthority", DeleteBaseBackRoleAuthority)
}

func BaseBackRoleMenuRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/backRoleMenu", GetBaseBackRoleMenuById)
	PushRouter(BaseArticleGroup, "POST", "/backRoleMenu/list", GetBaseBackRoleMenuList)
	PushRouter(BaseArticleGroup, "POST", "/backRoleMenu/in", GetBaseBackRoleMenuListInId)
	PushRouter(BaseArticleGroup, "POST", "/backRoleMenu", SaveBaseBackRoleMenu)
	PushRouter(BaseArticleGroup, "PUT", "/backRoleMenu", UpdateBaseBackRoleMenu)
	PushRouter(BaseArticleGroup, "DELETE", "/backRoleMenu", DeleteBaseBackRoleMenu)
}

func BaseGenTableRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/genTable", GetBaseGenTableById)
	PushRouter(BaseArticleGroup, "POST", "/genTable/list", GetBaseGenTableList)
	PushRouter(BaseArticleGroup, "POST", "/genTable/in", GetBaseGenTableListInId)
	PushRouter(BaseArticleGroup, "POST", "/genTable", SaveBaseGenTable)
	PushRouter(BaseArticleGroup, "PUT", "/genTable", UpdateBaseGenTable)
	PushRouter(BaseArticleGroup, "DELETE", "/genTable", DeleteBaseGenTable)
}

func BaseGenTableColumnRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/genTableColumn", GetBaseGenTableColumnById)
	PushRouter(BaseArticleGroup, "POST", "/genTableColumn/list", GetBaseGenTableColumnList)
	PushRouter(BaseArticleGroup, "POST", "/genTableColumn/in", GetBaseGenTableColumnListInId)
	PushRouter(BaseArticleGroup, "POST", "/genTableColumn", SaveBaseGenTableColumn)
	PushRouter(BaseArticleGroup, "PUT", "/genTableColumn", UpdateBaseGenTableColumn)
	PushRouter(BaseArticleGroup, "DELETE", "/genTableColumn", DeleteBaseGenTableColumn)
}

func BaseGoodsRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/goods", GetBaseGoodsById)
	PushRouter(BaseArticleGroup, "POST", "/goods/list", GetBaseGoodsList)
	PushRouter(BaseArticleGroup, "POST", "/goods/in", GetBaseGoodsListInId)
	PushRouter(BaseArticleGroup, "POST", "/goods", SaveBaseGoods)
	PushRouter(BaseArticleGroup, "PUT", "/goods", UpdateBaseGoods)
	PushRouter(BaseArticleGroup, "DELETE", "/goods", DeleteBaseGoods)
}

func BaseGoodsCommodityAreaRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/goodsCommodityArea", GetBaseGoodsCommodityAreaById)
	PushRouter(BaseArticleGroup, "POST", "/goodsCommodityArea/list", GetBaseGoodsCommodityAreaList)
	PushRouter(BaseArticleGroup, "POST", "/goodsCommodityArea/in", GetBaseGoodsCommodityAreaListInId)
	PushRouter(BaseArticleGroup, "POST", "/goodsCommodityArea", SaveBaseGoodsCommodityArea)
	PushRouter(BaseArticleGroup, "PUT", "/goodsCommodityArea", UpdateBaseGoodsCommodityArea)
	PushRouter(BaseArticleGroup, "DELETE", "/goodsCommodityArea", DeleteBaseGoodsCommodityArea)
}

func BaseGoodsCouponRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/goodsCoupon", GetBaseGoodsCouponById)
	PushRouter(BaseArticleGroup, "POST", "/goodsCoupon/list", GetBaseGoodsCouponList)
	PushRouter(BaseArticleGroup, "POST", "/goodsCoupon/in", GetBaseGoodsCouponListInId)
	PushRouter(BaseArticleGroup, "POST", "/goodsCoupon", SaveBaseGoodsCoupon)
	PushRouter(BaseArticleGroup, "PUT", "/goodsCoupon", UpdateBaseGoodsCoupon)
	PushRouter(BaseArticleGroup, "DELETE", "/goodsCoupon", DeleteBaseGoodsCoupon)
}

func BaseGoodsCouponUserRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/goodsCouponUser", GetBaseGoodsCouponUserById)
	PushRouter(BaseArticleGroup, "POST", "/goodsCouponUser/list", GetBaseGoodsCouponUserList)
	PushRouter(BaseArticleGroup, "POST", "/goodsCouponUser/in", GetBaseGoodsCouponUserListInId)
	PushRouter(BaseArticleGroup, "POST", "/goodsCouponUser", SaveBaseGoodsCouponUser)
	PushRouter(BaseArticleGroup, "PUT", "/goodsCouponUser", UpdateBaseGoodsCouponUser)
	PushRouter(BaseArticleGroup, "DELETE", "/goodsCouponUser", DeleteBaseGoodsCouponUser)
}

func BaseGoodsIntroductionRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/goodsIntroduction", GetBaseGoodsIntroductionById)
	PushRouter(BaseArticleGroup, "POST", "/goodsIntroduction/list", GetBaseGoodsIntroductionList)
	PushRouter(BaseArticleGroup, "POST", "/goodsIntroduction/in", GetBaseGoodsIntroductionListInId)
	PushRouter(BaseArticleGroup, "POST", "/goodsIntroduction", SaveBaseGoodsIntroduction)
	PushRouter(BaseArticleGroup, "PUT", "/goodsIntroduction", UpdateBaseGoodsIntroduction)
	PushRouter(BaseArticleGroup, "DELETE", "/goodsIntroduction", DeleteBaseGoodsIntroduction)
}

func BaseGoodsOrderRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/goodsOrder", GetBaseGoodsOrderById)
	PushRouter(BaseArticleGroup, "POST", "/goodsOrder/list", GetBaseGoodsOrderList)
	PushRouter(BaseArticleGroup, "POST", "/goodsOrder/in", GetBaseGoodsOrderListInId)
	PushRouter(BaseArticleGroup, "POST", "/goodsOrder", SaveBaseGoodsOrder)
	PushRouter(BaseArticleGroup, "PUT", "/goodsOrder", UpdateBaseGoodsOrder)
	PushRouter(BaseArticleGroup, "DELETE", "/goodsOrder", DeleteBaseGoodsOrder)
}

func BaseGoodsSkuRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/goodsSku", GetBaseGoodsSkuById)
	PushRouter(BaseArticleGroup, "POST", "/goodsSku/list", GetBaseGoodsSkuList)
	PushRouter(BaseArticleGroup, "POST", "/goodsSku/in", GetBaseGoodsSkuListInId)
	PushRouter(BaseArticleGroup, "POST", "/goodsSku", SaveBaseGoodsSku)
	PushRouter(BaseArticleGroup, "PUT", "/goodsSku", UpdateBaseGoodsSku)
	PushRouter(BaseArticleGroup, "DELETE", "/goodsSku", DeleteBaseGoodsSku)
}

func BaseGoodsSkuCardRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/goodsSkuCard", GetBaseGoodsSkuCardById)
	PushRouter(BaseArticleGroup, "POST", "/goodsSkuCard/list", GetBaseGoodsSkuCardList)
	PushRouter(BaseArticleGroup, "POST", "/goodsSkuCard/in", GetBaseGoodsSkuCardListInId)
	PushRouter(BaseArticleGroup, "POST", "/goodsSkuCard", SaveBaseGoodsSkuCard)
	PushRouter(BaseArticleGroup, "PUT", "/goodsSkuCard", UpdateBaseGoodsSkuCard)
	PushRouter(BaseArticleGroup, "DELETE", "/goodsSkuCard", DeleteBaseGoodsSkuCard)
}

func BaseGoodsTagRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/goodsTag", GetBaseGoodsTagById)
	PushRouter(BaseArticleGroup, "POST", "/goodsTag/list", GetBaseGoodsTagList)
	PushRouter(BaseArticleGroup, "POST", "/goodsTag/in", GetBaseGoodsTagListInId)
	PushRouter(BaseArticleGroup, "POST", "/goodsTag", SaveBaseGoodsTag)
	PushRouter(BaseArticleGroup, "PUT", "/goodsTag", UpdateBaseGoodsTag)
	PushRouter(BaseArticleGroup, "DELETE", "/goodsTag", DeleteBaseGoodsTag)
}

func BaseGoodsTypeRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/goodsType", GetBaseGoodsTypeById)
	PushRouter(BaseArticleGroup, "POST", "/goodsType/list", GetBaseGoodsTypeList)
	PushRouter(BaseArticleGroup, "POST", "/goodsType/in", GetBaseGoodsTypeListInId)
	PushRouter(BaseArticleGroup, "POST", "/goodsType", SaveBaseGoodsType)
	PushRouter(BaseArticleGroup, "PUT", "/goodsType", UpdateBaseGoodsType)
	PushRouter(BaseArticleGroup, "DELETE", "/goodsType", DeleteBaseGoodsType)
}

func BaseUserRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/user", GetBaseUserById)
	PushRouter(BaseArticleGroup, "POST", "/user/list", GetBaseUserList)
	PushRouter(BaseArticleGroup, "POST", "/user/in", GetBaseUserListInId)
	PushRouter(BaseArticleGroup, "POST", "/user", SaveBaseUser)
	PushRouter(BaseArticleGroup, "PUT", "/user", UpdateBaseUser)
	PushRouter(BaseArticleGroup, "DELETE", "/user", DeleteBaseUser)
}

func BaseUserWalletRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/userWallet", GetBaseUserWalletById)
	PushRouter(BaseArticleGroup, "POST", "/userWallet/list", GetBaseUserWalletList)
	PushRouter(BaseArticleGroup, "POST", "/userWallet/in", GetBaseUserWalletListInId)
	PushRouter(BaseArticleGroup, "POST", "/userWallet", SaveBaseUserWallet)
	PushRouter(BaseArticleGroup, "PUT", "/userWallet", UpdateBaseUserWallet)
	PushRouter(BaseArticleGroup, "DELETE", "/userWallet", DeleteBaseUserWallet)
}

func BaseDictDataRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/dictData", GetBaseDictDataById)
	PushRouter(BaseArticleGroup, "POST", "/dictData/list", GetBaseDictDataList)
	PushRouter(BaseArticleGroup, "POST", "/dictData/in", GetBaseDictDataListInId)
	PushRouter(BaseArticleGroup, "POST", "/dictData", SaveBaseDictData)
	PushRouter(BaseArticleGroup, "PUT", "/dictData", UpdateBaseDictData)
	PushRouter(BaseArticleGroup, "DELETE", "/dictData", DeleteBaseDictData)
}

func BaseDictTypeRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/dictType", GetBaseDictTypeById)
	PushRouter(BaseArticleGroup, "POST", "/dictType/list", GetBaseDictTypeList)
	PushRouter(BaseArticleGroup, "POST", "/dictType/in", GetBaseDictTypeListInId)
	PushRouter(BaseArticleGroup, "POST", "/dictType", SaveBaseDictType)
	PushRouter(BaseArticleGroup, "PUT", "/dictType", UpdateBaseDictType)
	PushRouter(BaseArticleGroup, "DELETE", "/dictType", DeleteBaseDictType)
}

func BaseShopTopicRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/shopTopic", GetBaseShopTopicById)
	PushRouter(BaseArticleGroup, "POST", "/shopTopic/list", GetBaseShopTopicList)
	PushRouter(BaseArticleGroup, "POST", "/shopTopic/in", GetBaseShopTopicListInId)
	PushRouter(BaseArticleGroup, "POST", "/shopTopic", SaveBaseShopTopic)
	PushRouter(BaseArticleGroup, "PUT", "/shopTopic", UpdateBaseShopTopic)
	PushRouter(BaseArticleGroup, "DELETE", "/shopTopic", DeleteBaseShopTopic)
}

func BaseShopAdviceCarouselRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/shopAdviceCarousel", GetBaseShopAdviceCarouselById)
	PushRouter(BaseArticleGroup, "POST", "/shopAdviceCarousel/list", GetBaseShopAdviceCarouselList)
	PushRouter(BaseArticleGroup, "POST", "/shopAdviceCarousel/in", GetBaseShopAdviceCarouselListInId)
	PushRouter(BaseArticleGroup, "POST", "/shopAdviceCarousel", SaveBaseShopAdviceCarousel)
	PushRouter(BaseArticleGroup, "PUT", "/shopAdviceCarousel", UpdateBaseShopAdviceCarousel)
	PushRouter(BaseArticleGroup, "DELETE", "/shopAdviceCarousel", DeleteBaseShopAdviceCarousel)
}

func BaseShopTopicSkuRouter(group *gin.RouterGroup) {
	BaseArticleGroup := group.Group("/back/base")
	PushRouter(BaseArticleGroup, "GET", "/shopTopicSku", GetBaseShopTopicSkuById)
	PushRouter(BaseArticleGroup, "POST", "/shopTopicSku/list", GetBaseShopTopicSkuList)
	PushRouter(BaseArticleGroup, "POST", "/shopTopicSku/in", GetBaseShopTopicSkuListInId)
	PushRouter(BaseArticleGroup, "POST", "/shopTopicSku", SaveBaseShopTopicSku)
	PushRouter(BaseArticleGroup, "PUT", "/shopTopicSku", UpdateBaseShopTopicSku)
	PushRouter(BaseArticleGroup, "DELETE", "/shopTopicSku", DeleteBaseShopTopicSku)
}

// ================Article 文章==============================
func GetBaseArticleById(c *gin.Context) {
	id := c.Query("id")
	article, err := manage.GetArticleById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(article))
	return
}

func GetBaseArticleList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	article := domain.ArticleQuery{}
	err := mapstructure.Decode(param, &article)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2ArticleList(article, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseArticleListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetArticleListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseArticle(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	articleParam, _ := data("article")
	article := domain.Article{}
	err := mapstructure.Decode(articleParam, &article)
	article.CreateBy = fmt.Sprint(GetUserIdByToken(c))
	article.CreateTime = time.Now()
	saveArticle, err := manage.SaveArticle(&article)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveArticle))
}

func UpdateBaseArticle(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	article, _ := data("article")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(article))
	toMap["create_by"] = nil
	toMap["create_time"] = nil
	toMap["update_by"] = fmt.Sprint(GetUserIdByToken(c))
	toMap["update_time"] = DateToString(time.Now())
	setArticle, b, err := manage.SetArticle(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setArticle))
}

func DeleteBaseArticle(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteArticle(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================ArticleTag 文章标签==============================
func GetBaseArticleTagById(c *gin.Context) {
	id := c.Query("id")
	articleTag, err := manage.GetArticleTagById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(articleTag))
	return
}

func GetBaseArticleTagList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	articleTag := domain.ArticleTagQuery{}
	err := mapstructure.Decode(param, &articleTag)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2ArticleTagList(articleTag, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseArticleTagListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetArticleTagListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseArticleTag(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	articleTagParam, _ := data("articleTag")
	articleTag := domain.ArticleTag{}
	err := mapstructure.Decode(articleTagParam, &articleTag)

	saveArticleTag, err := manage.SaveArticleTag(&articleTag)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveArticleTag))
}

func UpdateBaseArticleTag(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	articleTag, _ := data("articleTag")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(articleTag))

	setArticleTag, b, err := manage.SetArticleTag(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setArticleTag))
}

func DeleteBaseArticleTag(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteArticleTag(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================ArticleTopic 文章主题==============================
func GetBaseArticleTopicById(c *gin.Context) {
	id := c.Query("id")
	articleTopic, err := manage.GetArticleTopicById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(articleTopic))
	return
}

func GetBaseArticleTopicList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	articleTopic := domain.ArticleTopicQuery{}
	err := mapstructure.Decode(param, &articleTopic)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2ArticleTopicList(articleTopic, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseArticleTopicListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetArticleTopicListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseArticleTopic(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	articleTopicParam, _ := data("articleTopic")
	articleTopic := domain.ArticleTopic{}
	err := mapstructure.Decode(articleTopicParam, &articleTopic)

	saveArticleTopic, err := manage.SaveArticleTopic(&articleTopic)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveArticleTopic))
}

func UpdateBaseArticleTopic(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	articleTopic, _ := data("articleTopic")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(articleTopic))

	setArticleTopic, b, err := manage.SetArticleTopic(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setArticleTopic))
}

func DeleteBaseArticleTopic(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteArticleTopic(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================BackAuthority 后台权限校验==============================
func GetBaseBackAuthorityById(c *gin.Context) {
	id := c.Query("id")
	backAuthority, err := manage.GetBackAuthorityById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(backAuthority))
	return
}

func GetBaseBackAuthorityList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	backAuthority := domain.BackAuthorityQuery{}
	err := mapstructure.Decode(param, &backAuthority)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2BackAuthorityList(backAuthority, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseBackAuthorityListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetBackAuthorityListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseBackAuthority(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	backAuthorityParam, _ := data("backAuthority")
	backAuthority := domain.BackAuthority{}
	err := mapstructure.Decode(backAuthorityParam, &backAuthority)

	backAuthority.CreateTime = time.Now()
	saveBackAuthority, err := manage.SaveBackAuthority(&backAuthority)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveBackAuthority))
}

func UpdateBaseBackAuthority(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	backAuthority, _ := data("backAuthority")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(backAuthority))

	toMap["create_time"] = nil

	setBackAuthority, b, err := manage.SetBackAuthority(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setBackAuthority))
}

func DeleteBaseBackAuthority(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteBackAuthority(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================BackMenu 后台菜单==============================
func GetBaseBackMenuById(c *gin.Context) {
	id := c.Query("id")
	backMenu, err := manage.GetBackMenuById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(backMenu))
	return
}

func GetBaseBackMenuList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	backMenu := domain.BackMenuQuery{}
	err := mapstructure.Decode(param, &backMenu)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2BackMenuList(backMenu, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseBackMenuListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetBackMenuListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseBackMenu(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	backMenuParam, _ := data("backMenu")
	backMenu := domain.BackMenu{}
	err := mapstructure.Decode(backMenuParam, &backMenu)

	saveBackMenu, err := manage.SaveBackMenu(&backMenu)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveBackMenu))
}

func UpdateBaseBackMenu(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	backMenu, _ := data("backMenu")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(backMenu))

	setBackMenu, b, err := manage.SetBackMenu(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setBackMenu))
}

func DeleteBaseBackMenu(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteBackMenu(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================BackRole 后台角色==============================
func GetBaseBackRoleById(c *gin.Context) {
	id := c.Query("id")
	backRole, err := manage.GetBackRoleById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(backRole))
	return
}

func GetBaseBackRoleList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	backRole := domain.BackRoleQuery{}
	err := mapstructure.Decode(param, &backRole)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2BackRoleList(backRole, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseBackRoleListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetBackRoleListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseBackRole(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	backRoleParam, _ := data("backRole")
	backRole := domain.BackRole{}
	err := mapstructure.Decode(backRoleParam, &backRole)

	saveBackRole, err := manage.SaveBackRole(&backRole)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveBackRole))
}

func UpdateBaseBackRole(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	backRole, _ := data("backRole")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(backRole))

	setBackRole, b, err := manage.SetBackRole(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setBackRole))
}

func DeleteBaseBackRole(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteBackRole(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================BackRoleAuthority 后台角色权限表==============================
func GetBaseBackRoleAuthorityById(c *gin.Context) {
	id := c.Query("id")
	backRoleAuthority, err := manage.GetBackRoleAuthorityById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(backRoleAuthority))
	return
}

func GetBaseBackRoleAuthorityList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	backRoleAuthority := domain.BackRoleAuthorityQuery{}
	err := mapstructure.Decode(param, &backRoleAuthority)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2BackRoleAuthorityList(backRoleAuthority, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseBackRoleAuthorityListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetBackRoleAuthorityListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseBackRoleAuthority(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	backRoleAuthorityParam, _ := data("backRoleAuthority")
	backRoleAuthority := domain.BackRoleAuthority{}
	err := mapstructure.Decode(backRoleAuthorityParam, &backRoleAuthority)

	saveBackRoleAuthority, err := manage.SaveBackRoleAuthority(&backRoleAuthority)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveBackRoleAuthority))
}

func UpdateBaseBackRoleAuthority(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	backRoleAuthority, _ := data("backRoleAuthority")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(backRoleAuthority))

	setBackRoleAuthority, b, err := manage.SetBackRoleAuthority(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setBackRoleAuthority))
}

func DeleteBaseBackRoleAuthority(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteBackRoleAuthority(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================BackRoleMenu 后台角色菜单表==============================
func GetBaseBackRoleMenuById(c *gin.Context) {
	id := c.Query("id")
	backRoleMenu, err := manage.GetBackRoleMenuById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(backRoleMenu))
	return
}

func GetBaseBackRoleMenuList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	backRoleMenu := domain.BackRoleMenuQuery{}
	err := mapstructure.Decode(param, &backRoleMenu)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2BackRoleMenuList(backRoleMenu, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseBackRoleMenuListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetBackRoleMenuListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseBackRoleMenu(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	backRoleMenuParam, _ := data("backRoleMenu")
	backRoleMenu := domain.BackRoleMenu{}
	err := mapstructure.Decode(backRoleMenuParam, &backRoleMenu)

	saveBackRoleMenu, err := manage.SaveBackRoleMenu(&backRoleMenu)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveBackRoleMenu))
}

func UpdateBaseBackRoleMenu(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	backRoleMenu, _ := data("backRoleMenu")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(backRoleMenu))

	setBackRoleMenu, b, err := manage.SetBackRoleMenu(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setBackRoleMenu))
}

func DeleteBaseBackRoleMenu(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteBackRoleMenu(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================GenTable ==============================
func GetBaseGenTableById(c *gin.Context) {
	id := c.Query("id")
	genTable, err := manage.GetGenTableById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(genTable))
	return
}

func GetBaseGenTableList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	genTable := domain.GenTableQuery{}
	err := mapstructure.Decode(param, &genTable)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2GenTableList(genTable, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseGenTableListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetGenTableListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseGenTable(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	genTableParam, _ := data("genTable")
	genTable := domain.GenTable{}
	err := mapstructure.Decode(genTableParam, &genTable)

	saveGenTable, err := manage.SaveGenTable(&genTable)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveGenTable))
}

func UpdateBaseGenTable(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	genTable, _ := data("genTable")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(genTable))

	setGenTable, b, err := manage.SetGenTable(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setGenTable))
}

func DeleteBaseGenTable(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteGenTable(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================GenTableColumn ==============================
func GetBaseGenTableColumnById(c *gin.Context) {
	id := c.Query("id")
	genTableColumn, err := manage.GetGenTableColumnById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(genTableColumn))
	return
}

func GetBaseGenTableColumnList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	genTableColumn := domain.GenTableColumnQuery{}
	err := mapstructure.Decode(param, &genTableColumn)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2GenTableColumnList(genTableColumn, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseGenTableColumnListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetGenTableColumnListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseGenTableColumn(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	genTableColumnParam, _ := data("genTableColumn")
	genTableColumn := domain.GenTableColumn{}
	err := mapstructure.Decode(genTableColumnParam, &genTableColumn)

	saveGenTableColumn, err := manage.SaveGenTableColumn(&genTableColumn)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveGenTableColumn))
}

func UpdateBaseGenTableColumn(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	genTableColumn, _ := data("genTableColumn")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(genTableColumn))

	setGenTableColumn, b, err := manage.SetGenTableColumn(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setGenTableColumn))
}

func DeleteBaseGenTableColumn(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteGenTableColumn(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================Goods 商品表==============================
func GetBaseGoodsById(c *gin.Context) {
	id := c.Query("id")
	goods, err := manage.GetGoodsById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(goods))
	return
}

func GetBaseGoodsList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	goods := domain.GoodsQuery{}
	err := mapstructure.Decode(param, &goods)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2GoodsList(goods, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseGoodsListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetGoodsListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseGoods(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsParam, _ := data("goods")
	goods := domain.Goods{}
	err := mapstructure.Decode(goodsParam, &goods)

	saveGoods, err := manage.SaveGoods(&goods)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveGoods))
}

func UpdateBaseGoods(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goods, _ := data("goods")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(goods))

	setGoods, b, err := manage.SetGoods(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setGoods))
}

func DeleteBaseGoods(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteGoods(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================GoodsCommodityArea 商品属性==============================
func GetBaseGoodsCommodityAreaById(c *gin.Context) {
	id := c.Query("id")
	goodsCommodityArea, err := manage.GetGoodsCommodityAreaById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(goodsCommodityArea))
	return
}

func GetBaseGoodsCommodityAreaList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	goodsCommodityArea := domain.GoodsCommodityAreaQuery{}
	err := mapstructure.Decode(param, &goodsCommodityArea)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2GoodsCommodityAreaList(goodsCommodityArea, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseGoodsCommodityAreaListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetGoodsCommodityAreaListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseGoodsCommodityArea(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsCommodityAreaParam, _ := data("goodsCommodityArea")
	goodsCommodityArea := domain.GoodsCommodityArea{}
	err := mapstructure.Decode(goodsCommodityAreaParam, &goodsCommodityArea)

	saveGoodsCommodityArea, err := manage.SaveGoodsCommodityArea(&goodsCommodityArea)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveGoodsCommodityArea))
}

func UpdateBaseGoodsCommodityArea(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsCommodityArea, _ := data("goodsCommodityArea")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(goodsCommodityArea))

	setGoodsCommodityArea, b, err := manage.SetGoodsCommodityArea(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setGoodsCommodityArea))
}

func DeleteBaseGoodsCommodityArea(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteGoodsCommodityArea(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================GoodsCoupon 优惠券==============================
func GetBaseGoodsCouponById(c *gin.Context) {
	id := c.Query("id")
	goodsCoupon, err := manage.GetGoodsCouponById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(goodsCoupon))
	return
}

func GetBaseGoodsCouponList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	goodsCoupon := domain.GoodsCouponQuery{}
	err := mapstructure.Decode(param, &goodsCoupon)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2GoodsCouponList(goodsCoupon, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseGoodsCouponListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetGoodsCouponListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseGoodsCoupon(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsCouponParam, _ := data("goodsCoupon")
	goodsCoupon := domain.GoodsCoupon{}
	err := mapstructure.Decode(goodsCouponParam, &goodsCoupon)

	saveGoodsCoupon, err := manage.SaveGoodsCoupon(&goodsCoupon)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveGoodsCoupon))
}

func UpdateBaseGoodsCoupon(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsCoupon, _ := data("goodsCoupon")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(goodsCoupon))

	setGoodsCoupon, b, err := manage.SetGoodsCoupon(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setGoodsCoupon))
}

func DeleteBaseGoodsCoupon(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteGoodsCoupon(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================GoodsCouponUser 优惠券领取==============================
func GetBaseGoodsCouponUserById(c *gin.Context) {
	id := c.Query("id")
	goodsCouponUser, err := manage.GetGoodsCouponUserById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(goodsCouponUser))
	return
}

func GetBaseGoodsCouponUserList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	goodsCouponUser := domain.GoodsCouponUserQuery{}
	err := mapstructure.Decode(param, &goodsCouponUser)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2GoodsCouponUserList(goodsCouponUser, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseGoodsCouponUserListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetGoodsCouponUserListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseGoodsCouponUser(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsCouponUserParam, _ := data("goodsCouponUser")
	goodsCouponUser := domain.GoodsCouponUser{}
	err := mapstructure.Decode(goodsCouponUserParam, &goodsCouponUser)

	saveGoodsCouponUser, err := manage.SaveGoodsCouponUser(&goodsCouponUser)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveGoodsCouponUser))
}

func UpdateBaseGoodsCouponUser(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsCouponUser, _ := data("goodsCouponUser")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(goodsCouponUser))

	setGoodsCouponUser, b, err := manage.SetGoodsCouponUser(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setGoodsCouponUser))
}

func DeleteBaseGoodsCouponUser(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteGoodsCouponUser(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================GoodsIntroduction 商品介绍==============================
func GetBaseGoodsIntroductionById(c *gin.Context) {
	id := c.Query("id")
	goodsIntroduction, err := manage.GetGoodsIntroductionById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(goodsIntroduction))
	return
}

func GetBaseGoodsIntroductionList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	goodsIntroduction := domain.GoodsIntroductionQuery{}
	err := mapstructure.Decode(param, &goodsIntroduction)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2GoodsIntroductionList(goodsIntroduction, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseGoodsIntroductionListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetGoodsIntroductionListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseGoodsIntroduction(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsIntroductionParam, _ := data("goodsIntroduction")
	goodsIntroduction := domain.GoodsIntroduction{}
	err := mapstructure.Decode(goodsIntroductionParam, &goodsIntroduction)
	goodsIntroduction.CreateBy = fmt.Sprint(GetUserIdByToken(c))
	goodsIntroduction.CreateTime = time.Now()
	saveGoodsIntroduction, err := manage.SaveGoodsIntroduction(&goodsIntroduction)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveGoodsIntroduction))
}

func UpdateBaseGoodsIntroduction(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsIntroduction, _ := data("goodsIntroduction")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(goodsIntroduction))
	toMap["create_by"] = nil
	toMap["create_time"] = nil
	toMap["update_by"] = fmt.Sprint(GetUserIdByToken(c))
	toMap["update_time"] = DateToString(time.Now())
	setGoodsIntroduction, b, err := manage.SetGoodsIntroduction(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setGoodsIntroduction))
}

func DeleteBaseGoodsIntroduction(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteGoodsIntroduction(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================GoodsOrder 商品订单==============================
func GetBaseGoodsOrderById(c *gin.Context) {
	id := c.Query("id")
	goodsOrder, err := manage.GetGoodsOrderById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(goodsOrder))
	return
}

func GetBaseGoodsOrderList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	goodsOrder := domain.GoodsOrderQuery{}
	err := mapstructure.Decode(param, &goodsOrder)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2GoodsOrderList(goodsOrder, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseGoodsOrderListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetGoodsOrderListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseGoodsOrder(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsOrderParam, _ := data("goodsOrder")
	goodsOrder := domain.GoodsOrder{}
	err := mapstructure.Decode(goodsOrderParam, &goodsOrder)
	goodsOrder.CreateBy = (GetUserIdByToken(c))
	goodsOrder.CreateTime = time.Now()
	saveGoodsOrder, err := manage.SaveGoodsOrder(&goodsOrder)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveGoodsOrder))
}

func UpdateBaseGoodsOrder(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsOrder, _ := data("goodsOrder")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(goodsOrder))
	toMap["create_by"] = nil
	toMap["create_time"] = nil

	setGoodsOrder, b, err := manage.SetGoodsOrder(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setGoodsOrder))
}

func DeleteBaseGoodsOrder(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteGoodsOrder(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================GoodsSku 商品规格==============================
func GetBaseGoodsSkuById(c *gin.Context) {
	id := c.Query("id")
	goodsSku, err := manage.GetGoodsSkuById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(goodsSku))
	return
}

func GetBaseGoodsSkuList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	goodsSku := domain.GoodsSkuQuery{}
	err := mapstructure.Decode(param, &goodsSku)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2GoodsSkuList(goodsSku, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseGoodsSkuListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetGoodsSkuListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseGoodsSku(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsSkuParam, _ := data("goodsSku")
	goodsSku := domain.GoodsSku{}
	err := mapstructure.Decode(goodsSkuParam, &goodsSku)
	goodsSku.CreateBy = fmt.Sprint(GetUserIdByToken(c))
	goodsSku.CreateTime = time.Now()
	saveGoodsSku, err := manage.SaveGoodsSku(&goodsSku)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveGoodsSku))
}

func UpdateBaseGoodsSku(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsSku, _ := data("goodsSku")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(goodsSku))
	toMap["create_by"] = nil
	toMap["create_time"] = nil

	setGoodsSku, b, err := manage.SetGoodsSku(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setGoodsSku))
}

func DeleteBaseGoodsSku(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteGoodsSku(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================GoodsSkuCard 商品卡号==============================
func GetBaseGoodsSkuCardById(c *gin.Context) {
	id := c.Query("id")
	goodsSkuCard, err := manage.GetGoodsSkuCardById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(goodsSkuCard))
	return
}

func GetBaseGoodsSkuCardList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	goodsSkuCard := domain.GoodsSkuCardQuery{}
	err := mapstructure.Decode(param, &goodsSkuCard)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2GoodsSkuCardList(goodsSkuCard, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseGoodsSkuCardListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetGoodsSkuCardListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseGoodsSkuCard(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsSkuCardParam, _ := data("goodsSkuCard")
	goodsSkuCard := domain.GoodsSkuCard{}
	err := mapstructure.Decode(goodsSkuCardParam, &goodsSkuCard)

	saveGoodsSkuCard, err := manage.SaveGoodsSkuCard(&goodsSkuCard)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveGoodsSkuCard))
}

func UpdateBaseGoodsSkuCard(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsSkuCard, _ := data("goodsSkuCard")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(goodsSkuCard))

	setGoodsSkuCard, b, err := manage.SetGoodsSkuCard(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setGoodsSkuCard))
}

func DeleteBaseGoodsSkuCard(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteGoodsSkuCard(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================GoodsTag 商品标签==============================
func GetBaseGoodsTagById(c *gin.Context) {
	id := c.Query("id")
	goodsTag, err := manage.GetGoodsTagById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(goodsTag))
	return
}

func GetBaseGoodsTagList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	goodsTag := domain.GoodsTagQuery{}
	err := mapstructure.Decode(param, &goodsTag)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2GoodsTagList(goodsTag, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseGoodsTagListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetGoodsTagListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseGoodsTag(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsTagParam, _ := data("goodsTag")
	goodsTag := domain.GoodsTag{}
	err := mapstructure.Decode(goodsTagParam, &goodsTag)

	saveGoodsTag, err := manage.SaveGoodsTag(&goodsTag)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveGoodsTag))
}

func UpdateBaseGoodsTag(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsTag, _ := data("goodsTag")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(goodsTag))

	setGoodsTag, b, err := manage.SetGoodsTag(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setGoodsTag))
}

func DeleteBaseGoodsTag(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteGoodsTag(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================GoodsType 商品分类==============================
func GetBaseGoodsTypeById(c *gin.Context) {
	id := c.Query("id")
	goodsType, err := manage.GetGoodsTypeById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(goodsType))
	return
}

func GetBaseGoodsTypeList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	goodsType := domain.GoodsTypeQuery{}
	err := mapstructure.Decode(param, &goodsType)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2GoodsTypeList(goodsType, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseGoodsTypeListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetGoodsTypeListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseGoodsType(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsTypeParam, _ := data("goodsType")
	goodsType := domain.GoodsType{}
	err := mapstructure.Decode(goodsTypeParam, &goodsType)

	goodsType.CreateTime = time.Now()
	saveGoodsType, err := manage.SaveGoodsType(&goodsType)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveGoodsType))
}

func UpdateBaseGoodsType(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	goodsType, _ := data("goodsType")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(goodsType))

	toMap["create_time"] = nil

	setGoodsType, b, err := manage.SetGoodsType(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setGoodsType))
}

func DeleteBaseGoodsType(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteGoodsType(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================User 用户表==============================
func GetBaseUserById(c *gin.Context) {
	id := c.Query("id")
	user, err := manage.GetUserById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(user))
	return
}

func GetBaseUserList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	user := domain.UserQuery{}
	err := mapstructure.Decode(param, &user)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2UserList(user, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseUserListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetUserListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseUser(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	userParam, _ := data("user")
	user := domain.User{}
	err := mapstructure.Decode(userParam, &user)

	saveUser, err := manage.SaveUser(&user)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveUser))
}

func UpdateBaseUser(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	user, _ := data("user")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(user))

	setUser, b, err := manage.SetUser(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setUser))
}

func DeleteBaseUser(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteUser(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================UserWallet 用户钱包==============================
func GetBaseUserWalletById(c *gin.Context) {
	id := c.Query("id")
	userWallet, err := manage.GetUserWalletById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(userWallet))
	return
}

func GetBaseUserWalletList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	userWallet := domain.UserWalletQuery{}
	err := mapstructure.Decode(param, &userWallet)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2UserWalletList(userWallet, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseUserWalletListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetUserWalletListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseUserWallet(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	userWalletParam, _ := data("userWallet")
	userWallet := domain.UserWallet{}
	err := mapstructure.Decode(userWalletParam, &userWallet)

	saveUserWallet, err := manage.SaveUserWallet(&userWallet)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveUserWallet))
}

func UpdateBaseUserWallet(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	userWallet, _ := data("userWallet")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(userWallet))

	setUserWallet, b, err := manage.SetUserWallet(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setUserWallet))
}

func DeleteBaseUserWallet(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteUserWallet(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================DictData 字典数据==============================
func GetBaseDictDataById(c *gin.Context) {
	id := c.Query("id")
	dictData, err := manage.GetDictDataById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(dictData))
	return
}

func GetBaseDictDataList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	dictData := domain.DictDataQuery{}
	err := mapstructure.Decode(param, &dictData)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2DictDataList(dictData, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseDictDataListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetDictDataListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseDictData(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	dictDataParam, _ := data("dictData")
	dictData := domain.DictData{}
	err := mapstructure.Decode(dictDataParam, &dictData)

	saveDictData, err := manage.SaveDictData(&dictData)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveDictData))
}

func UpdateBaseDictData(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	dictData, _ := data("dictData")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(dictData))

	setDictData, b, err := manage.SetDictData(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setDictData))
}

func DeleteBaseDictData(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteDictData(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================DictType 字典类型==============================
func GetBaseDictTypeById(c *gin.Context) {
	id := c.Query("id")
	dictType, err := manage.GetDictTypeById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(dictType))
	return
}

func GetBaseDictTypeList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	dictType := domain.DictTypeQuery{}
	err := mapstructure.Decode(param, &dictType)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2DictTypeList(dictType, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseDictTypeListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetDictTypeListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseDictType(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	dictTypeParam, _ := data("dictType")
	dictType := domain.DictType{}
	err := mapstructure.Decode(dictTypeParam, &dictType)

	saveDictType, err := manage.SaveDictType(&dictType)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveDictType))
}

func UpdateBaseDictType(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	dictType, _ := data("dictType")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(dictType))

	setDictType, b, err := manage.SetDictType(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setDictType))
}

func DeleteBaseDictType(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteDictType(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================ShopTopic 商品主题==============================
func GetBaseShopTopicById(c *gin.Context) {
	id := c.Query("id")
	shopTopic, err := manage.GetShopTopicById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(shopTopic))
	return
}

func GetBaseShopTopicList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	shopTopic := domain.ShopTopicQuery{}
	err := mapstructure.Decode(param, &shopTopic)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2ShopTopicList(shopTopic, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseShopTopicListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetShopTopicListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseShopTopic(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	shopTopicParam, _ := data("shopTopic")
	shopTopic := domain.ShopTopic{}
	err := mapstructure.Decode(shopTopicParam, &shopTopic)

	saveShopTopic, err := manage.SaveShopTopic(&shopTopic)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveShopTopic))
}

func UpdateBaseShopTopic(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	shopTopic, _ := data("shopTopic")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(shopTopic))

	setShopTopic, b, err := manage.SetShopTopic(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setShopTopic))
}

func DeleteBaseShopTopic(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteShopTopic(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================ShopAdviceCarousel 商城广告==============================
func GetBaseShopAdviceCarouselById(c *gin.Context) {
	id := c.Query("id")
	shopAdviceCarousel, err := manage.GetShopAdviceCarouselById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(shopAdviceCarousel))
	return
}

func GetBaseShopAdviceCarouselList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	shopAdviceCarousel := domain.ShopAdviceCarouselQuery{}
	err := mapstructure.Decode(param, &shopAdviceCarousel)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2ShopAdviceCarouselList(shopAdviceCarousel, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseShopAdviceCarouselListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetShopAdviceCarouselListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseShopAdviceCarousel(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	shopAdviceCarouselParam, _ := data("shopAdviceCarousel")
	shopAdviceCarousel := domain.ShopAdviceCarousel{}
	err := mapstructure.Decode(shopAdviceCarouselParam, &shopAdviceCarousel)
	shopAdviceCarousel.CreateBy = fmt.Sprint(GetUserIdByToken(c))
	shopAdviceCarousel.CreateTime = time.Now()
	saveShopAdviceCarousel, err := manage.SaveShopAdviceCarousel(&shopAdviceCarousel)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveShopAdviceCarousel))
}

func UpdateBaseShopAdviceCarousel(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	shopAdviceCarousel, _ := data("shopAdviceCarousel")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(shopAdviceCarousel))
	toMap["create_by"] = nil
	toMap["create_time"] = nil
	toMap["update_by"] = fmt.Sprint(GetUserIdByToken(c))
	toMap["update_time"] = DateToString(time.Now())
	setShopAdviceCarousel, b, err := manage.SetShopAdviceCarousel(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setShopAdviceCarousel))
}

func DeleteBaseShopAdviceCarousel(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteShopAdviceCarousel(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}

// ================ShopTopicSku 商城主题商品==============================
func GetBaseShopTopicSkuById(c *gin.Context) {
	id := c.Query("id")
	shopTopicSku, err := manage.GetShopTopicSkuById(cast.ToInt64(id))
	if err != nil {
		c.JSON(200, CreateResultError(500, "用户查询不存在"))
		return
	}
	c.JSON(200, CreateResultData(shopTopicSku))
	return
}

func GetBaseShopTopicSkuList(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	param, _ := data("param")
	pageNum, _ := data("pageNum")
	pageSize, _ := data("pageSize")
	shopTopicSku := domain.ShopTopicSkuQuery{}
	err := mapstructure.Decode(param, &shopTopicSku)
	if err != nil {
		c.JSON(200, CreateResultError(500, "json转换错误"))
		return
	}
	list, err := manage.Get2ShopTopicSkuList(shopTopicSku, cast.ToInt(pageNum), cast.ToInt(pageSize))
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func GetBaseShopTopicSkuListInId(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	idsString, _ := data("ids")
	var ids []int64
	err := mapstructure.Decode([]byte(cast.ToString(idsString)), &ids)
	list, err := manage.GetShopTopicSkuListInId(ids)
	if err != nil {
		c.JSON(200, CreateResultError(500, "查询错误"))
		return
	}
	c.JSON(200, CreateResultData(list))
}

func SaveBaseShopTopicSku(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	shopTopicSkuParam, _ := data("shopTopicSku")
	shopTopicSku := domain.ShopTopicSku{}
	err := mapstructure.Decode(shopTopicSkuParam, &shopTopicSku)

	saveShopTopicSku, err := manage.SaveShopTopicSku(&shopTopicSku)
	if err != nil {
		c.JSON(200, CreateResultError(500, "保存错误"))
		return
	}
	c.JSON(200, CreateResultData(saveShopTopicSku))
}

func UpdateBaseShopTopicSku(c *gin.Context) {
	data := share.GetJsonAnyParam(c)
	shopTopicSku, _ := data("shopTopicSku")
	id, _ := data("id")
	toMap := UtilStructToMap(cast.ToStringMap(shopTopicSku))

	setShopTopicSku, b, err := manage.SetShopTopicSku(toMap, cast.ToInt64(id))
	if err != nil || !b {
		c.JSON(200, CreateResultError(500, "修改错误"))
		return
	}
	c.JSON(200, CreateResultData(setShopTopicSku))
}

func DeleteBaseShopTopicSku(c *gin.Context) {
	id := c.Query("id")
	res := manage.DeleteShopTopicSku(cast.ToInt64(id))
	if !res {
		c.JSON(200, CreateResultError(500, "删除错误"))
		return
	}
	c.JSON(200, CreateResult())
}
