def get(self, request, *args, **kwargs): serializer = InterfaceGroupIDSerializer(data=request.query_params) if not serializer.is_valid(): retdata = BaseResponse(code=0, msg='error') if serializer.errors.get('ai_skill_group_id'): if serializer.errors['ai_skill_group_id'][ 0].code == 'required': retdata.error_msg = '技能接口分组ID是必须的' else: retdata.error_msg = '技能接口分组ID不合法,为6-20位字母、数字或下划线' return Response(retdata.result) has_ai_skill_gourp = AISkillGroup.objects.filter( user=request.user, ai_skill_group_id=serializer.validated_data['ai_skill_group_id'] ).first() retdata = BaseResponse(code=1, msg='success') if not has_ai_skill_gourp: retdata.success_msg = '技能接口分组不存在,可创建' retdata.data = 0 else: retdata.success_msg = '技能接口分组已存在' retdata.data = 1 return Response(retdata.result)
def get(self, request, *args, **kwargs): serializer = FaceIDSerializer(data=request.query_params) if not serializer.is_valid(): retdata = BaseResponse(code=0, msg='error') if serializer.errors.get('face_id'): if serializer.errors['face_id'][0].code == 'required': retdata.error_msg = '人脸ID是必须的' else: retdata.error_msg = '人脸ID不合法,为6-20位字母、数字或下划线' return Response(retdata.result) has_face = Face.objects.filter( user=request.user, face_id=serializer.validated_data['face_id']) retdata = BaseResponse(code=1, msg='successs') if not has_face: retdata.success_msg = '人脸不存在,可创建' retdata.data = 0 else: retdata.success_msg = '人脸已存在' retdata.data = 1 return Response(retdata.result)