Beispiel #1
0
class UAVApprovalAgree(Resource):
    def __init__(self):
        self.dao = ApprovalDao()
        self.userDao = UserDAO()

    def post(self):
        if (request.data != ""):
            data = json.loads(request.data)
            token = data['token']
            user = self.userDao.verify_token(token, '')

            approvaldict = data['approval']
            approval = Approval()
            approval.apply_person = approvaldict[0]['apply_person']
            approval.approval_team = approvaldict[0]['approval_team']
            approval.device_ver = approvaldict[0]['device_ver']
            approval.device_number = approvaldict[0]['device_number']
            approval.battery_ver = approvaldict[0]['battery_ver']
            approval.battery_number = approvaldict[0]['battery_number']
            approval.pad_ver = approvaldict[0]['pad_ver']
            approval.pad_number = approvaldict[0]['pad_number']
            approval.approval_person = user.user_id
            if (not user):
                return make_response(
                    jsonify({
                        'error': '用户不存在或登录过期',
                        'errorcode': 10000000
                    }), 400)
            if user == 1010301:
                return make_response(
                    jsonify({
                        'error': '登录过期',
                        'errorcode': user
                    }), 400)
            if user == 1010302:
                return make_response(
                    jsonify({
                        'error': '用户验证错误',
                        'errorcode': user
                    }), 400)
            rs = self.dao.approval_aggree(user, approval)
            if rs == 2080401:
                return make_response(
                    jsonify({
                        'error': '没有权限进行审批',
                        'errorcode': 2080401
                    }), 401)
            if rs == 1:
                return make_response(jsonify({'success': '审批通过'}), 200)
        else:
            return make_response(
                jsonify({
                    'error': '输入参数有误',
                    'errorcode': 10000000
                }), 401)

    def get(self):
        return self.post()
Beispiel #2
0
class UAVApprovalList(Resource):
    def __init__(self):
        self.dao = ApprovalDao()
        self.userDao = UserDAO()

    def post(self):
        if (request.data != ""):
            data = json.loads(request.data)
            token = data['token']
            user = self.userDao.verify_token(token, '')
            if (not user):
                return make_response(
                    jsonify({
                        'error': '用户不存在或登录过期',
                        'errorcode': 10000000
                    }), 400)
            if user == 1010301:
                return make_response(
                    jsonify({
                        'error': '登录过期',
                        'errorcode': user
                    }), 400)
            if user == 1010302:
                return make_response(
                    jsonify({
                        'error': '用户验证错误',
                        'errorcode': user
                    }), 400)

            rs = self.dao.approval_query(user)
            if rs == None:
                return make_response(
                    jsonify({
                        'error': '查询申请失败',
                        'errorcode': 10000000
                    }), 401)
            else:
                return rs
        else:
            return make_response(
                jsonify({
                    'error': '传入参数错误',
                    'errorcode': 10000000
                }), 401)

    def get(self):
        return self.post()
class UAVApprovalList(Resource):
    def __init__(self):
        self.dao = ApprovalDao()
        self.userDao = UserDAO()

    def post(self):
        if (request.data != ""):
            data = json.loads(request.data)
            token = data['token']
            user = self.userDao.verify_token(token, '')
            if (not user):
                 return make_response(jsonify({'error': 'Unauthorized access'}), 401)

            rs=self.dao.approval_query(user)
            if rs==None:
                return make_response(jsonify({'error': 'Unauthorized access'}), 401)
            else:
                return rs
        else:
            return  make_response(jsonify({'error': 'Unauthorized access'}), 401)

    def get(self):
        return self.post()
Beispiel #4
0
 def __init__(self):
     self.dao = ApprovalDao()
     self.userDao = UserDAO()
Beispiel #5
0
class UAVApprovalAdd(Resource):
    def __init__(self):
        self.dao = ApprovalDao()
        self.userDao = UserDAO()

    def post(self):
        if (request.data != ""):
            data = json.loads(request.data)
            token = data['token']
            approvaldict = data['approval']
            approval = Approval()
            approval.apply_person = approvaldict[0]['apply_person']
            approval.approval_person = approvaldict[0]['approval_person']
            approval.approval_team = approvaldict[0]['approval_team']
            approval.device_ver = approvaldict[0]['device_ver']
            approval.device_number = approvaldict[0]['device_number']
            approval.battery_ver = approvaldict[0]['battery_ver']
            approval.battery_number = approvaldict[0]['battery_number']
            approval.pad_ver = approvaldict[0]['pad_ver']
            approval.pad_number = approvaldict[0]['pad_number']
            #approval.approval_reason = approvaldict[0]['reason']
            #approval.approval_desc = approvaldict[0]['desc']
            approval.approval_status = 0

            user = self.userDao.verify_token(token, '')
            if (not user):
                return make_response(
                    jsonify({
                        'error': '用户不存在或登录过期',
                        'errorcode': 10000000
                    }), 400)
            if user == 1010301:
                return make_response(
                    jsonify({
                        'error': '登录过期',
                        'errorcode': user
                    }), 400)
            if user == 1010302:
                return make_response(
                    jsonify({
                        'error': '用户验证错误',
                        'errorcode': user
                    }), 400)

            rs = self.dao.approval_add(user, approval)
            if rs == 1:
                return make_response(
                    jsonify({
                        'success': '借调申请提交成功',
                        'errorcode': 10000000
                    }), 200)
            elif rs == 2080601:
                return make_response(
                    jsonify({
                        'error': '批准人不存在',
                        'errorcode': rs
                    }), 401)
            elif rs == 2080602 or rs == 2080603:
                #批准人不存在
                return make_response(
                    jsonify({
                        'error': '批准人无批准权限',
                        'errorcode': rs
                    }), 501)
        else:
            return make_response(
                jsonify({
                    'error': '输入参数错误',
                    'errorcode': 10000000
                }), 401)

    def get(self):
        return self.post()