Browse Source

no message

xingzai 2 years ago
parent
commit
4099b0d1f8
3 changed files with 66 additions and 0 deletions
  1. 49 0
      controllers/activity_special.go
  2. 8 0
      models/activity_special_trip.go
  3. 9 0
      routers/commentsRouter.go

+ 49 - 0
controllers/activity_special.go

@@ -595,3 +595,52 @@ func (this *ActivitySpecialCoAntroller) SpecialTripAdd() {
 	br.Msg = "操作成功"
 	br.Data = resp
 }
+
+// @Title 取消报名
+// @Description 取消报名
+// @Param	request	body models.ActivityIdRep true "type json string"
+// @Success Ret=200 {object} models.SignupStatus
+// @router /trip/cancel [post]
+func (this *ActivitySpecialCoAntroller) Tripcancel() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	var req models.ActivityIdRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	activityId := req.ActivityId
+	activityInfo, errInfo := models.GetCygxActivitySpecialDetailById(uid, activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+	err = models.CancelActivitySpecialTrip(uid, activityInfo)
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "CancelActivitySpecialTrip,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "会议提醒已取消"
+}

+ 8 - 0
models/activity_special_trip.go

@@ -70,3 +70,11 @@ func AddCygxActivitySpecialTrip(item *CygxActivitySpecialTrip) (err error) {
 	_, err = o.Insert(item)
 	return
 }
+
+//取消
+func CancelActivitySpecialTrip(uid int, item *CygxActivitySpecialDetail) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE  FROM cygx_activity_special_trip   WHERE user_id=?  AND activity_id=? `
+	_, err = o.Raw(sql, uid, item.ActivityId).Exec()
+	return
+}

+ 9 - 0
routers/commentsRouter.go

@@ -250,6 +250,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySpecialCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySpecialCoAntroller"],
+        beego.ControllerComments{
+            Method: "Tripcancel",
+            Router: `/trip/cancel`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:AdviceController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:AdviceController"],
         beego.ControllerComments{
             Method: "ApplyApprove",