Esempio n. 1
0
 def get(self, request, *args, **kwargs):
     """查询用户的申请状态"""
     try:
         user_id = request.GET.get("user_id", None)
         if user_id:
             user_list = apply_repo.get_applicants_team(user_id=user_id)
             status_list = [
                 user_status.to_dict() for user_status in user_list
             ]
             result = general_message(200,
                                      "success",
                                      "查询成功",
                                      list=status_list)
             return Response(result, status=result["code"])
         else:
             user_list = apply_repo.get_applicants_team(
                 user_id=self.user.user_id)
             status_list = [
                 user_status.to_dict() for user_status in user_list
             ]
             result = general_message(200,
                                      "success",
                                      "查询成功",
                                      list=status_list)
     except Exception as e:
         logger.exception(e)
         result = error_message(e.message)
     return Response(result, status=result["code"])
Esempio n. 2
0
 def get(self, request, *args, **kwargs):
     """查看指定用户加入的团队的状态"""
     user_id = request.GET.get("user_id", None)
     if user_id:
         apply_user = apply_repo.get_applicants_team(user_id=user_id)
         team_list = [team.to_dict() for team in apply_user]
         result = general_message(200, "success", "查询成功", list=team_list)
     else:
         apply_user = apply_repo.get_applicants_team(user_id=self.user.user_id)
         team_list = [team.to_dict() for team in apply_user]
         result = general_message(200, "success", "查询成功", list=team_list)
     return Response(result, status=result["code"])
Esempio n. 3
0
    def get(self, request, *args, **kwargs):
        """指定用户可以加入哪些团队"""
        try:
            tenants = team_repo.get_tenants_by_user_id(
                user_id=self.user.user_id)
            team_names = tenants.values("tenant_name")
            team_name_list = [
                t_name.get("tenant_name") for t_name in team_names
            ]

            user_id = request.GET.get("user_id", None)
            if user_id:
                enterprise_id = user_repo.get_by_user_id(
                    user_id=user_id).enterprise_id
                team_list = team_repo.get_teams_by_enterprise_id(enterprise_id)
                apply_team = apply_repo.get_applicants_team(user_id=user_id)
            else:
                enterprise_id = user_repo.get_by_user_id(
                    user_id=self.user.user_id).enterprise_id
                team_list = team_repo.get_teams_by_enterprise_id(enterprise_id)
                apply_team = apply_repo.get_applicants_team(
                    user_id=self.user.user_id)
            applied_team = [
                team_repo.get_team_by_team_name(team_name=team_name) for
                team_name in [team_name.team_name for team_name in apply_team]
            ]
            join_list = []
            for join_team in team_list:
                if join_team not in applied_team and join_team.tenant_name not in team_name_list:
                    join_list.append(join_team)
            join_list = [{
                "team_name": j_team.tenant_name,
                "team_alias": j_team.tenant_alias,
                "team_id": j_team.tenant_id
            } for j_team in join_list]
            result = general_message(200, "success", "查询成功", list=join_list)
        except Exception as e:
            logger.exception(e)
            result = error_message(e.message)
        return Response(result, status=result["code"])