You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.6 KiB
88 lines
2.6 KiB
package client
|
|
|
|
import (
|
|
"github.com/ouxuanserver/osmanthuswine/src/core"
|
|
"hudongzhuanjia/controllers"
|
|
"hudongzhuanjia/models"
|
|
"hudongzhuanjia/utils/code"
|
|
"time"
|
|
)
|
|
|
|
type InvitationLetterCtl struct {
|
|
controllers.AuthorCtl
|
|
}
|
|
|
|
// InviteEnvelope doc
|
|
// @Summary InviteEnvelope
|
|
// @Description 填写要求信息
|
|
// @Tags invite envelope
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param activity_id query int true "邀请函内容"
|
|
// @Success 0 {string} string "success"
|
|
// @Failure 404 {string} string "参数不存在"
|
|
// @Failure 405 {string} string "用户不存在"
|
|
// @Router /Client/InviteEnvelopeCtl/invite [post]
|
|
func (t *InvitationLetterCtl) Invite() {
|
|
uid := t.MustGetUID()
|
|
activityId := t.MustGetInt64("activity_id")
|
|
invitationId := t.MustGetInt64("invitation_id")
|
|
answer := t.MustGet("answer")
|
|
|
|
activity := new(models.Activity)
|
|
exist, err := models.GetById(activity, activityId)
|
|
t.CheckErr(err)
|
|
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
|
|
|
|
letter := new(models.InvitationLetter)
|
|
exist, err = letter.GetByUserIdAndActivityId(uid, activityId, activity.RehearsalId)
|
|
t.CheckErr(err)
|
|
t.Assert(!exist, code.MSG_INVITE_LETTER_EXIST, "您已经接受过邀请")
|
|
|
|
letter.UserId = uid
|
|
letter.ActivityId = activityId
|
|
letter.InvitationId = invitationId
|
|
letter.RehearsalId = activity.RehearsalId
|
|
letter.ExtraData = answer
|
|
letter.IsDelete = false
|
|
letter.CreatedAt = time.Now()
|
|
letter.UpdatedAt = time.Now()
|
|
_, err = core.GetXormAuto().InsertOne(letter)
|
|
t.CheckErr(err)
|
|
|
|
t.STRING("success")
|
|
}
|
|
|
|
// InviteEnvelope doc
|
|
// @Summary InviteEnvelope
|
|
// @Description get invite envelope setting
|
|
// @Tags invite envelope
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param activity_id query int true "Activity ID"
|
|
// @Success 0 {object} models.Invitation
|
|
// @Failure 404 {string} string "参数不存在"
|
|
// @Failure 405 {string} string "用户不存在"
|
|
// @Router /Client/InviteEnvelopeCtl/setting [get]
|
|
func (t *InvitationLetterCtl) Setting() {
|
|
activityId := t.MustGetInt64("activity_id")
|
|
uid := t.MustGetUID()
|
|
|
|
activity := new(models.Activity)
|
|
exist, err := models.GetById(activity, activityId)
|
|
t.CheckErr(err)
|
|
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
|
|
|
|
letter := new(models.InvitationLetter)
|
|
exist, err = letter.GetByUserIdAndActivityId(uid, activityId, activity.RehearsalId)
|
|
t.CheckErr(err)
|
|
t.Assert(!exist, code.MSG_INVITE_LETTER_EXIST, "您已经接受过邀请")
|
|
|
|
invitation := new(models.Invitation)
|
|
exist, err = invitation.GetInvitationByActivityId(activityId)
|
|
t.CheckErr(err)
|
|
t.Assert(exist, code.MSG_INVITE_SETTING_NOT_EXIST, "邀请函设置不存在")
|
|
t.JSON(map[string]interface{}{
|
|
"setting": invitation,
|
|
})
|
|
}
|