Browse Source

push origin master

master
黄梓健 5 years ago
parent
commit
53cacea218
  1. 5
      controllers/author.go
  2. 4
      controllers/client/activity.go
  3. 2
      controllers/client/auction.go
  4. 2
      controllers/client/barrage.go
  5. 4
      controllers/client/bully_screen.go
  6. 4
      controllers/client/invite_envelope.go
  7. 5
      controllers/client/login.go
  8. 82
      controllers/client/login_test.go
  9. 2
      controllers/client/order_entry.go
  10. 2
      controllers/client/reward.go
  11. 5
      controllers/client/shake_red_envelope.go
  12. 4
      controllers/client/upper_wall.go
  13. 2
      controllers/client/vote.go
  14. 4
      controllers/pc/sign.go
  15. 7
      utils/define/define.go

5
controllers/author.go

@ -41,11 +41,6 @@ func (t *AuthorCtl) MustGetUID() int64 {
return t.claims.AccountId
}
// token 应该携带某个主活动i
func (t *AuthorCtl) MustGetActivityId() int64 {
return t.MustGetInt64("activity_id")
}
func (t *AuthorCtl) MustGetCustomerId() int64 {
if t.claims.CustomerId == 0 {
return t.MustGetInt64("customer_id")

4
controllers/client/activity.go

@ -19,7 +19,7 @@ type ActivityCtl struct {
}
func (t *ActivityCtl) ModuleStatus() {
activityId := t.MustGetActivityId()
activityId := t.MustGetInt64("activity_id")
moduleName := t.MustGet("module_name")
exist, err := activity_service.ExistModuleByActivityId(activityId, moduleName)
t.CheckErr(err)
@ -30,7 +30,7 @@ func (t *ActivityCtl) ModuleStatus() {
// 某个模块的活动状态
func (t *ActivityCtl) ModuleCurrent() {
activityId := t.MustGetActivityId()
activityId := t.MustGetInt64("activity_id")
moduleName := t.MustGet("module_name")
uid := t.MustGetUID()

2
controllers/client/auction.go

@ -168,7 +168,7 @@ func (t *AuctionCtl) ExistRecord() {
// 已经竞拍到了
func (t *AuctionCtl) UserAuctions() {
uid := t.MustGetUID()
activityId := t.MustGetActivityId()
activityId := t.MustGetInt64("activity_id")
records, err := auction_service.GetUserAuctions(activityId, uid)
t.CheckErr(err)

2
controllers/client/barrage.go

@ -21,7 +21,7 @@ type BarrageCtl struct {
func (t *BarrageCtl) Send() {
uid := t.MustGetUID()
customerId := t.MustGetCustomerId()
activityId := t.MustGetActivityId()
activityId := t.MustGetInt64("activity_id")
content := t.MustGet("content")
//检查内容是否包含敏感

4
controllers/client/bully_screen.go

@ -21,7 +21,7 @@ type BullyScreenCtl struct {
//用户霸屏
// todo: 支付接口
func (t *BullyScreenCtl) PaScreen() {
activityId := t.MustGetActivityId()
activityId := t.MustGetInt64("activity_id")
uid := t.MustGetUID()
content := t.MustGet("content")
second := t.MustGetDouble("second")
@ -87,7 +87,7 @@ func (t *BullyScreenCtl) PaScreen() {
// 审核列表 [未审核,未通过,已通过]
func (t *BullyScreenCtl) List() {
uid := t.MustGetUID()
activityId := t.MustGetActivityId()
activityId := t.MustGetInt64("activity_id")
bss := new(models.BullyScreenServer)
exist, err := bss.GetByActivityId(activityId)

4
controllers/client/invite_envelope.go

@ -25,7 +25,7 @@ type InvitationLetterCtl struct {
// @Router /Client/InviteEnvelopeCtl/invite [post]
func (t *InvitationLetterCtl) Invite() {
uid := t.MustGetUID()
activityId := t.MustGetActivityId()
activityId := t.MustGetInt64("activity_id")
invitationId := t.MustGetInt64("invitation_id")
answer := t.MustGet("answer")
@ -65,7 +65,7 @@ func (t *InvitationLetterCtl) Invite() {
// @Failure 405 {string} string "用户不存在"
// @Router /Client/InviteEnvelopeCtl/setting [get]
func (t *InvitationLetterCtl) Setting() {
activityId := t.MustGetActivityId()
activityId := t.MustGetInt64("activity_id")
uid := t.MustGetUID()
activity := new(models.Activity)

5
controllers/client/login.go

@ -158,7 +158,7 @@ func (t *UserCtl) WxLogin() {
realSignExist, err := new(models.RealSignHistory).Check(user.Id, activity.Id, activity.RehearsalId)
t.CheckErr(err)
jwtToken, err := jwt.GenJwtToken(define.TYPE_USER, user.Id, customer.Id, customer.Pid, area.Id, activityId)
jwtToken, err := jwt.GenJwtToken(define.TYPE_H5USER, user.Id, customer.Id, customer.Pid, area.Id, activityId)
t.CheckErr(err)
t.SetSession(define.TOKEN, jwtToken)
@ -206,7 +206,6 @@ func (t *UserCtl) Login() {
if token.AccessToken == "" || token.OpenId == "" {
t.ERROR("code无效", code.MSG_ERR)
}
//info, err := wx.GetUserInfo(token.AccessToken, token.OpenId)
info, err := wechat.GetUserInfo(token)
t.CheckErr(err)
exist, err := user.GetUserByOpenid(info.OpenId)
@ -234,7 +233,7 @@ func (t *UserCtl) Login() {
t.CheckErr(err)
}
jwtToken, err := jwt.GenJwtToken(define.TYPE_USER, user.Id, 0, 0, 0, 0)
jwtToken, err := jwt.GenJwtToken(define.TYPE_LIVEUSER, user.Id, 0, 0, 0, 0)
t.CheckErr(err)
t.SetSession(define.TOKEN, jwtToken)

82
controllers/client/login_test.go

@ -1,82 +0,0 @@
package client
import (
"github.com/ouxuanserver/osmanthuswine/src/core"
. "github.com/smartystreets/goconvey/convey"
"hudongzhuanjia/libs/jwt"
"hudongzhuanjia/models"
"hudongzhuanjia/test"
"hudongzhuanjia/utils/code"
"hudongzhuanjia/utils/define"
"net/http"
"testing"
)
func TestEntryLogin(t *testing.T) {
type Data struct {
People *models.OrderEntryPerson `json:"people"`
}
type Result struct {
core.ResponseData
Data Data `json:"data"`
}
conf := test.GetConfig()
Convey("测试录入人员登录", t, func() {
path := test.ApiUrl("PcClient/Client/UserCtl/entryLogin")
// 正确登录
param := map[string]interface{}{
"account": conf.EntryAccount,
"password": conf.EntryPwd,
"activity_id": conf.ActivityId,
}
resp, err := test.Api("").Get(path, param) // 并不需要token
So(err, ShouldBeNil) // 检测是否请求出错
So(resp.StatusCode(), ShouldEqual, http.StatusOK) // 检测请求连接是否正确
res := new(Result)
err = resp.Json(res)
So(err, ShouldBeNil) // 检测json 解析是否正确
So(res.Code, ShouldEqual, 0) // 返回code是否为0
So(res.Data.People, ShouldNotBeNil, nil) // 检测返回数据是否为空
So(res.Data.People.ActivityId, ShouldEqual, conf.ActivityId)
So(res.Data.People.Account, ShouldEqual, conf.EntryAccount)
So(res.Data.People.Password, ShouldEqual, conf.EntryPwd)
So(res.Data.People.Token, ShouldNotBeEmpty)
// 校验token
claims, err := jwt.ParseAccessToken(res.Data.People.Token)
So(err, ShouldNotBeNil)
So(claims.ActivityId, ShouldEqual, conf.ActivityId)
So(claims.AccountType, ShouldEqual, define.TYPE_ENTRY)
// 登录失败的场景
// 录入人员不存在
param = map[string]interface{}{
"account": "tommy",
"password": conf.EntryPwd,
"activity_id": conf.ActivityId,
}
resp, err = test.Api("").Get(path)
So(err, ShouldBeNil)
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
res = new(Result)
err = resp.Json(res)
So(err, ShouldBeNil)
So(res.Code, ShouldEqual, code.MSG_ENTRYPEOPLE_NOT_EXIST)
// 互动不存在
param = map[string]interface{}{
"account": conf.EntryAccount,
"password": conf.EntryPwd,
"activity_id": 0,
}
resp, err = test.Api("").Get(path)
So(err, ShouldBeNil)
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
res = new(Result)
err = resp.Json(res)
So(err, ShouldBeNil)
So(res.Code, ShouldEqual, code.MSG_ACTIVITY_NOT_EXIST)
// done
})
}

2
controllers/client/order_entry.go

@ -21,7 +21,7 @@ type OrderEntryCtl struct {
// 商品 == > 用户查看所有商品
func (t *OrderEntryCtl) List() {
uid := t.MustGetUID()
activityId := t.MustGetActivityId()
activityId := t.MustGetInt64("activity_id")
goods := make([]*models.CustomerGoods, 0)
err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId).
Asc("created_at").Find(&goods)

2
controllers/client/reward.go

@ -84,7 +84,7 @@ type RWListResult struct {
func (t *RewardCtl) List() {
uid := t.MustGetUID()
activityId := t.MustGetActivityId()
activityId := t.MustGetInt64("activity_id")
rs := new(models.RewardServer)
exist, err := rs.GetByActivityId(activityId)

5
controllers/client/shake_red_envelope.go

@ -84,12 +84,11 @@ func (t *ShakeRedEnvelopeCtl) Shake() {
t.CheckErr(err)
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在")
record.IsDraw = 0
// 记录红包 ---> 非彩排才能
if activity.RehearsalId == 0 {
res, err := pay_service.SendRedPack("欧轩互动", user.Openid, fmt.Sprintf("感谢您参加%s", activity.Name),
"", rule.Model, "摇得越快抢得越多", int(record.Amount * 100), 1, 1)
"", rule.Model, "摇得越快抢得越多", int(record.Amount*100), 1, 1)
t.CheckErr(err)
record.MchBillno = res.MchBillno
record.Reason = fmt.Sprintf("%s:%s", res.ErrCode, res.ErrCodeDes)
@ -120,7 +119,7 @@ func (t *ShakeRedEnvelopeCtl) Shake() {
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
go ws_send_service.SendShakeRedEnvelope(fmt.Sprintf("%d", activity.Id),
define.TYPE_USER, userId, map[string]interface{}{
define.TYPE_H5USER, userId, map[string]interface{}{
"customer_id": customer.Id,
"user_id": user.Id,
"type": "shake_rb",

4
controllers/client/upper_wall.go

@ -18,7 +18,7 @@ type UpperWallCtl struct {
// todo: 支付接口
func (t *UpperWallCtl) Send() {
uid := t.MustGetUID()
activityId := t.MustGetActivityId()
activityId := t.MustGetInt64("activity_id")
category := t.MustGetInt("category")
content, _ := t.Get("content")
img, _ := t.Get("img")
@ -67,7 +67,7 @@ type UWListResult struct {
}
func (t *UpperWallCtl) List() {
activityId := t.MustGetActivityId()
activityId := t.MustGetInt64("activity_id")
uid := t.MustGetUID()
activity := new(models.Activity)

2
controllers/client/vote.go

@ -95,7 +95,7 @@ func (t *VoteCtl) List() {
func (t *VoteCtl) Detail() {
voteActivityId := t.MustGetInt64("vote_activity_id")
uid := t.MustGetUID()
activityId := t.MustGetActivityId()
activityId := t.MustGetInt64("activity_id")
activity := new(models.Activity)
exist, err := models.GetById(activity, activityId)

4
controllers/pc/sign.go

@ -67,7 +67,7 @@ type SignResult struct {
//处理签到信息
func (t *SignCtl) SignInfo() {
aid := t.MustGetActivityId()
aid := t.MustGetInt64("activity_id")
//activityId := t.MustGetInt64("activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
@ -90,7 +90,7 @@ func (t *SignCtl) SignInfo() {
// 实名签到信息
func (t *SignCtl) RealSignInfo() {
aid := t.MustGetActivityId()
aid := t.MustGetInt64("activity_id")
rid := t.MustGetInt64("rehearsal_id")
results, err := models.GetRealSignHistories(aid, rid)
t.CheckErr(err)

7
utils/define/define.go

@ -79,7 +79,8 @@ const (
)
const (
TYPE_USER = "user"
TYPE_CUSTOMER = "customer"
TYPE_ENTRY = "entry"
TYPE_H5USER = "h5user"
TYPE_LIVEUSER = "live_user"
TYPE_CUSTOMER = "customer"
TYPE_ENTRYPEOPLE = "entry_people"
)
Loading…
Cancel
Save