diff --git a/app/db/db_card.go b/app/db/db_card.go new file mode 100644 index 0000000..15f60a6 --- /dev/null +++ b/app/db/db_card.go @@ -0,0 +1,28 @@ +package db + +import ( + "applet/app/db/model" + "applet/app/utils" + "xorm.io/xorm" +) + +func GetCard(eg *xorm.Engine, arg map[string]string) *[]model.CommunityTeamCard { + var data []model.CommunityTeamCard + sess := eg.Where("1=1") + limit := utils.StrToInt(arg["size"]) + start := (utils.StrToInt(arg["p"]) - 1) * limit + err := sess.OrderBy("sort desc,id desc").Limit(limit, start).Find(&data) + if err != nil { + return nil + } + return &data +} +func GetCardDetail(eg *xorm.Engine, arg map[string]string) *model.CommunityTeamCard { + var data model.CommunityTeamCard + sess := eg.Where("id=?", arg["id"]) + get, err := sess.Get(&data) + if err != nil || get == false { + return nil + } + return &data +} diff --git a/app/db/model/community_team_card.go b/app/db/model/community_team_card.go new file mode 100644 index 0000000..05aa9b7 --- /dev/null +++ b/app/db/model/community_team_card.go @@ -0,0 +1,12 @@ +package model + +type CommunityTeamCard struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Title string `json:"title" xorm:"VARCHAR(255)"` + Sort int `json:"sort" xorm:"INT(11)"` + IsUse int `json:"is_use" xorm:"default 1 INT(1)"` + Img string `json:"img" xorm:"VARCHAR(255)"` + Content string `json:"content" xorm:"TEXT"` + FirstTip string `json:"first_tip" xorm:"VARCHAR(255)"` + SecondTip string `json:"second_tip" xorm:"VARCHAR(255)"` +} diff --git a/app/hdl/hdl_store.go b/app/hdl/hdl_store.go index 505feaf..2783e4d 100644 --- a/app/hdl/hdl_store.go +++ b/app/hdl/hdl_store.go @@ -96,9 +96,27 @@ func BankStore(c *gin.Context) { func BankActivity(c *gin.Context) { svc.BankActivity(c) } +func BankCard(c *gin.Context) { + svc.BankCard(c) +} +func BankCardDetail(c *gin.Context) { + svc.BankCardDetail(c) +} func BankNotice(c *gin.Context) { svc.BankNotice(c) } +func BankUserInfo(c *gin.Context) { + user := svc.GetUser(c) + res := map[string]string{ + "head_img": user.Profile.AvatarUrl, + "nickname": user.Info.Nickname, + "phone": user.Info.Phone, + "level_name": user.Level.LevelName, + "amount": svc.GetCommissionPrec(c, user.Profile.FinValid, "2", "1"), + } + e.OutSuc(c, res, nil) + return +} func NewStoreCate(c *gin.Context) { var res = []map[string]string{ {"name": "全部店铺", "value": ""}, diff --git a/app/router/router.go b/app/router/router.go index 6bccafb..5e06180 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -150,6 +150,8 @@ func routeCommunityTeam(r *gin.RouterGroup) { r.POST("/bank/store/list", hdl.BankStore) r.POST("/bank/store/activity", hdl.BankActivity) r.POST("/bank/store/notice", hdl.BankNotice) + r.POST("/bank/card", hdl.BankCard) + r.POST("/bank/card/detail", hdl.BankCardDetail) r.GET("/new/store/cate", hdl.NewStoreCate) r.POST("/new/store/list", hdl.NewStore) @@ -162,6 +164,7 @@ func routeCommunityTeam(r *gin.RouterGroup) { r.GET("/user", hdl.User) // 用户授权后调用的接口 r.Use(mw.AuthJWT) + r.GET("/bank/user/info", hdl.BankUserInfo) r.POST("/coupon/receive", hdl.CouponReceive) r.POST("/store/addLike", hdl.StoreAddLike) r.POST("/store/cancelLike", hdl.StoreCancelLike) diff --git a/app/svc/svc_store.go b/app/svc/svc_store.go index f35a944..2ef09cd 100644 --- a/app/svc/svc_store.go +++ b/app/svc/svc_store.go @@ -267,6 +267,65 @@ func BankActivity(c *gin.Context) { e.OutSuc(c, list, nil) return } +func BankCardDetail(c *gin.Context) { + var arg map[string]string + if err := c.ShouldBindJSON(&arg); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err) + return + } + detail := db.GetCardDetail(MasterDb(c), arg) + if detail == nil { + e.OutErr(c, 400, e.NewErr(400, "记录不存在")) + return + } + tmp := map[string]string{ + "id": utils.IntToStr(detail.Id), + "title": detail.Title, + "first_tip": detail.FirstTip, + "second_tip": detail.SecondTip, + "time_str": "", + "content": detail.Content, + "type": "0", + } + if tmp["time_str"] != "" { + tmp["type"] = "1" + } + if detail.IsUse == 0 { + tmp["type"] = "2" + } + e.OutSuc(c, tmp, nil) + return +} +func BankCard(c *gin.Context) { + var arg map[string]string + if err := c.ShouldBindJSON(&arg); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err) + return + } + list := make([]map[string]string, 0) + data := db.GetCard(MasterDb(c), arg) + if data != nil { + for _, v := range *data { + tmp := map[string]string{ + "id": utils.IntToStr(v.Id), + "title": v.Title, + "first_tip": v.FirstTip, + "second_tip": v.SecondTip, + "time_str": "", + "type": "0", + } + if tmp["time_str"] != "" { + tmp["type"] = "1" + } + if v.IsUse == 0 { + tmp["type"] = "2" + } + list = append(list, tmp) + } + } + e.OutSuc(c, list, nil) + return +} func NewStore(c *gin.Context) { var arg map[string]string if err := c.ShouldBindJSON(&arg); err != nil {