def post(self): type = self.get_argument('type',default='unsolved') if type == '10060':#点赞 acid = self.get_argument('acid',default='null') m_phone = self.get_argument('phone',default='null') try: ifActivity = self.db.query(Activity).filter(Activity.Acid == acid).one() try: Aclike = self.db.query(Favorite).filter(Favorite.Facid == acid,Favorite.Futel == m_phone).one() if Aclike.Fvalid == 1: self.retjson['code']='10062' self.retjson['contents']='已经点过赞!不能重复点赞' elif Aclike.Fvalid == 0: Aclike.Fvalid = 1 ifActivity.AclikeN += 1 self.db.commit() self.retjson['code'] = '10061' self.retjson['contents']='点赞成功' except Exception,e: print e newaclike = Favorite ( Futel = m_phone, Facid=acid, Fvalid = 1 ) self.db.merge(newaclike) ifActivity.AclikeN += 1 self.db.commit() self.retjson['code']='10061' self.retjson['contents']='点赞成功!' except Exception,e: print e self.retjson['code']='10062' self.retjson['contents']='该活动不存在'
def post(self): type = self.get_argument('type', default='null') u_id = self.get_argument('uid', default='null') auth_key = self.get_argument('authkey', default='null') ufunc = Userinfo.Ufuncs.Ufuncs() if ufunc.judge_user_valid(u_id, auth_key): if type == '12002': #收藏动态 trendid = self.get_argument('trendid', default='none') try: exsit = self.db.query(Trend).filter( Trend.Tid == trendid).one() print exsit.Tid if exsit: try: #判断是否已经有这行(即用户之前有没有操作过) once_favorite = self.db.query(Favorite).filter( Favorite.Fuid == u_id, Favorite.Ftypeid == trendid, Favorite.Ftype == 3).one() print '哈哈哈' print once_favorite.Fvalid if once_favorite.Fvalid == 0: #以前收藏过但取消了 once_favorite.Fvalid = 1 #重新收藏 exsit.TlikeN += 1 self.db.commit() self.retjson['code'] = '12021' self.retjson['contents'] = '收藏成功' else: self.retjson['code'] = '12022' self.retjson['contents'] = '已经收藏过' except Exception, e: #之前没有这行,没有收藏过 print e new_favorite = Favorite(Fuid=u_id, Ftype=3, Ftypeid=trendid, Fvalid=1) self.db.merge(new_favorite) try: exsit.TlikeN += 1 self.db.commit() self.retjson['code'] = '12021' self.retjson['contents'] = '收藏成功' except Exception, e: print e self.retjson['contents'] = r'操作数据库失败' except Exception, e: print e self.retjson['code'] = '12023' self.retjson['contents'] = '该动态不存在'
def post(self): type = self.get_argument('type') user_id = self.get_argument('uid') u_auth_key = self.get_argument('authkey') ufuncs = Userinfo.Ufuncs.Ufuncs() if ufuncs.judge_user_valid(user_id, u_auth_key): if type == '10501': # 收藏约拍 typeid = self.get_argument('typeid') try: exist = self.db.query(Appointment).filter( Appointment.APid == typeid).one() # 约拍是否存在 if exist: # 该约拍存在 if exist.APvalid == 1: # 该约拍还有效 try: # 判断用户曾经是否对改约拍进行过收藏动作, once_favorite = self.db.query(Favorite).filter( Favorite.Fuid == user_id, Favorite.Ftypeid == typeid, Favorite.Ftype == 1).one() if once_favorite: # 已有这项,不知是否有效 if once_favorite.Fvalid == 0: # 曾经收藏过,但是现在取消了 once_favorite.Fvalid = 1 self.db.commit() self.retjson['code'] = '10520' self.retjson['contents'] = "收藏成功" else: # 用户已收藏 self.retjson['code'] = '10527' self.retjson[ 'contents'] = "该约拍已在用户收藏夹中" except Exception, e: # 未收藏过 favorite = Favorite( Fuid=user_id, Ftype=1, # 1为约拍 Ftypeid=typeid, Fvalid=1) self.db.merge(favorite) try: self.db.commit() self.retjson['code'] = '10520' self.retjson['contents'] = r'收藏成功' except Exception, e: # todo 基本码待定 print e self.retjson['contents'] = r'数据库操作失败,请重试' else: self.retjson['code'] = '10525' self.retjson['contents'] = r'该约拍已过期'
Favorite.Ftypeid == typeid, Favorite.Ftype == 2).one() if once_favorite: # 已有这项,不知是否有效 if once_favorite.Fvalid == 0: # 曾经收藏过,但是现在取消了 once_favorite.Fvalid = 1 self.db.commit() self.retjson['code'] = '10520' self.retjson['contents'] = "收藏成功" else: # 用户已收藏 self.retjson['code'] = '10527' self.retjson['contents'] = "该活动已在用户收藏夹中" except Exception, e: # 未收藏过 favorite = Favorite( Fuid=user_id, Ftype=2, # 1为约拍 Ftypeid=typeid, Fvalid=1 ) self.db.merge(favorite) try: self.db.commit() self.retjson['code'] = '10520' self.retjson['contents'] = r'收藏成功' except Exception, e: # todo 基本码待定 print e self.retjson['contents'] = r'数据库操作失败,请重试' else: self.retjson['code'] = '10525' self.retjson['contents'] = r'该活动已过期' except Exception, e: