forked from team-bibim/Broccoli-BE
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
104 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class ExerConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'Exer' |
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
class Exercise(models.Model): | ||
exercise_id = models.IntegerField(primary_key=True) | ||
usebody_id = models.ForeignKey('Usebody', on_delete=models.CASCADE, max_length=11) | ||
exerciseName_English= models.CharField(max_length=50, blank=True, null=True) | ||
exerciseName_Korean = models.CharField(max_length=50, blank=True, null=True) | ||
equipment_name = models.CharField(max_length=50, blank=True, null=True) | ||
videolink = models.CharField(max_length=150, blank=True, null=True) | ||
|
||
class Meta: | ||
managed = False | ||
db_table = 'exercise' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from rest_framework import serializers | ||
from .models import Exercise | ||
|
||
class ExerciseDetailSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Exercise | ||
fields = ['exerciseName_English', 'exerciseName_Korean', 'equipment_name', 'videolink'] | ||
|
||
class ExerciseSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Exercise | ||
fields = ['usebody_id', 'exerciseName_English', 'exerciseName_Korean'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.urls import path | ||
from . import views | ||
|
||
urlpatterns = [ | ||
path('', views.ExerciseSearchAPIView.as_view()), | ||
path('<int:pk>/', views.ExerciseDetailAPIView.as_view()), | ||
path('body/<int:pk>/', views.ExerciseBodyAPIiew.as_view()), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from rest_framework.views import APIView | ||
from rest_framework.response import Response | ||
|
||
from Exer.models import Exercise | ||
from Exer.serializers import ExerciseSerializer | ||
from Exer.serializers import ExerciseDetailSerializer | ||
from django.shortcuts import get_object_or_404 | ||
|
||
|
||
#03-01 부위별 운동 간단 조회 | ||
#usebody의 id 대신 name이 나오게 하려면 model을 수정해야 할 것으로 보임 | ||
class ExerciseBodyAPIiew(APIView): | ||
def get_object(self,pk): | ||
return Exercise.objects.filter(usebody_id=pk) | ||
|
||
def get(self,request,pk): | ||
exercise = self.get_object(pk) | ||
serializer = ExerciseSerializer(exercise) | ||
return Response(serializer.data) | ||
|
||
|
||
#03-02 운동 상세 조회 | ||
class ExerciseDetailAPIView(APIView): | ||
def get_object(self, pk): | ||
return get_object_or_404(Exercise, pk=pk) | ||
|
||
def get(self, request,pk): | ||
exercise = self.get_object(pk) | ||
serializer = ExerciseDetailSerializer(exercise) | ||
return Response(serializer.data) | ||
|
||
#03-03 운동 검색 | ||
class ExerciseSearchAPIView(APIView): | ||
def post(self,request): | ||
data = request.data | ||
|
||
exercise = Exercise.objects.filter(exerciseName_Korean=data) | ||
serializer = ExerciseSerializer(exercise) | ||
|
||
if serializer.is_valid(): | ||
return Response(serializer.data) | ||
return Response(serializer.errors) | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters