Example #1
0
 def get_pool_by_user(self, username):
     user = userDao.get_user_by_username(username)
     print("get my")
     return [
         PoolListConverter().toVO(i)
         for i in self.pool_dao.get_pool_by_user(user.id)
     ]
Example #2
0
 def recruit_someone(self, username, userID):
     user = userDao.get_user_by_username(username)
     ## 先通过userID 得到 postsID
     print(userID)
     posts = self.posts_dao.get_posts_by_user(userID)[0]
     self.recruit_dao.get_recruit(user.id, posts.id)
     return self.recruit_dao.insert(RecruitModel(user.id, posts.id, False))
Example #3
0
 def get_my(self, username):
     user = userDao.get_user_by_username(username)
     posts = self.posts_dao.get_my(user.id)
     return [
         PostsListConverter().toVO(
             i, self.user_info_dao.get_user_info(i.userID, True))
         for i in posts
     ]
Example #4
0
 def get_activity_by_user(self, username):
     user = userDao.get_user_by_username(username)
     if not user:
         raise NotFoundException
     return [
         ActivityListConverter().toVO(i)
         for i in self.activity_dao.get_activity_by_user(user.id)
     ]
Example #5
0
 def post(self, id):
     username = JwtUtil.JwtUtil.get_token_username(
         request.headers.get("token"))
     user = userDao.get_user_by_username(username)
     result = poolJoinDao.getPoolJoin(user.id, id)
     if result:
         return None, 200
     else:
         return None, 404
Example #6
0
 def check_register(self, username, pID):
     print(str(pID) + " " + str(username))
     user = userDao.get_user_by_username(username)
     print(str(pID) + " " + str(user.id))
     result = self.pool_join_dao.getPoolJoin(user.id, pID)
     print(result)
     if not result:
         raise NotFoundException
     return result
Example #7
0
 def love_some_one(self, uID, username, poolID):
     """还是要看是不是已经关注过了,在这个互选池中"""
     """ todo: 还要做异性的检查... """
     user = userDao.get_user_by_username(username)
     try:
         self.love_relation_dao.get_relation(user.id, uID, poolID)
     except AlreadyExists:
         raise AlreadyExists
     self.love_relation_dao.insert(LoveRelationModel(user.id, uID, poolID))
Example #8
0
 def join_pool(self, pID, username):
     """ 先检查有没有参加过 """
     print(str(pID) + " " + str(username))
     user = userDao.get_user_by_username(username)
     result = self.pool_join_dao.getPoolJoin(user.id, pID)
     print(result)
     if result:
         raise AlreadyExists
     self.pool_join_dao.insert(PoolJoinModel(pID, user.id))
Example #9
0
 def join_activity(self, username, activity_id):
     """还要检查是不是已经报名了"""
     user = userDao.get_user_by_username(username)
     if not user:
         raise NotFoundException
     join = self.activity_join_dao.getActivityJoin(user.id, activity_id)
     if join:
         raise AlreadyExists
     return self.activity_join_dao.insert(
         ActivityJoinModel(user.id, activity_id))
Example #10
0
 def add_user_info(self, user_info: UserInfoVO, username):
     user = userDao.get_user_by_username(username)
     user_info.id = user.id
     ### 如果存在先删除
     try:
         userInfo = self.user_info_dao.get_user_info(user.id, False)
         print(userInfo)
         self.user_info_dao.delete(userInfo)
     except NotFoundException:
         pass
     self.user_info_dao.insert(UserInfoConverter().toModel(user_info))
Example #11
0
 def leave_activity(self, username, activity_id):
     """还要检查是不是已经报名了"""
     print(username, activity_id)
     user = userDao.get_user_by_username(username)
     if not user:
         print("not found user")
         raise NotFoundException
     join = self.activity_join_dao.getActivityJoin(user.id, activity_id)
     if not join:
         print("not found join")
         raise NotFoundException
     return self.activity_join_dao.delete(join)
Example #12
0
 def check_register(self, username, activity_id):
     """还要检查是不是已经报名了"""
     print(username, activity_id)
     user = userDao.get_user_by_username(username)
     if not user:
         print("not found user")
         raise NotFoundException
     join = self.activity_join_dao.getActivityJoin(user.id, activity_id)
     if not join:
         print("not found join")
         raise NotFoundException
     else:
         return join
Example #13
0
 def add_posts(self, username, endTime):
     user = userDao.get_user_by_username(username)
     reuslt = self.posts_dao.get_posts_by_user(user.id)
     if reuslt:
         raise AlreadyExists
     return self.posts_dao.insert(PostsModel(user.id, endTime))
Example #14
0
 def get_true_love(self, username, pool_id):
     user = userDao.get_user_by_username(username)
     return self.love_relation_dao.get_true_love(user.id, pool_id)
Example #15
0
 def get_love(self, username, pool_id):
     user = userDao.get_user_by_username(username)
     return [
         UserListConverter().toVO(i)
         for i in self.love_relation_dao.get_your_love(user.id, pool_id)
     ]