Esempio n. 1
0
    def RoleModi(request, cmd):
        '''
        角色修改
        :param request:
        :return:
        '''
        LoggerHandle.writeLogDevelope("添加角色%s" % cmd.encode('utf-8'), request)

        # 提取参数
        getParams = UtilHelper.UtilHelper.getGetParams(request)
        postParams = UtilHelper.UtilHelper.getPostParams(request)

        allParams = dict(getParams.items() + postParams.items())
        LoggerHandle.writeLogDevelope("指令GET参数" + str(getParams), request)
        LoggerHandle.writeLogDevelope("指令POST参数" + str(postParams), request)

        # 验证参数完整性
        paramCompleteness, info = ParamCheckHelper.ParamCheckHelper.getParamModule(
            cmd).checkParamComplete(allParams)

        if paramCompleteness:
            LoggerHandle.writeLogDevelope("参数完整,符合要求", request)
        else:
            LoggerHandle.writeLogDevelope("参数不完整,缺少:" + info, request)
            loginResut = json.dumps({
                "ErrorInfo": "参数不足,缺少:" + info,
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # # 参数验签
        # verifyResult = VerifyHelper.VerifyHelper.verifyParam(allParams)
        # if verifyResult:
        #     LoggerHandle.writeLogDevelope("参数验签成功", request)
        # else:
        #     LoggerHandle.writeLogDevelope("参数验签失败", request)
        #     loginResut = json.dumps({"ErrorInfo": "参数验签失败", "ErrorId": 20002, "Result": {}})
        #     return HttpResponse(loginResut)

        # 检查logioncode是否为权力机构
        acntHandle = PaperAccount.objects.filter(
            account=allParams["logincode"]).first()

        # 检查当前账号是否具有当前权限
        if not acntHandle:
            LoggerHandle.writeLogDevelope("当前账号数据异常", request)
            loginResut = json.dumps({
                "ErrorInfo": "当前账号数据异常",
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 检查当前账户是否具有权限
        resultPrivilegeSign = PrivilegeHelper.funcPrivCheck(cmd, acntHandle)
        if not resultPrivilegeSign:
            LoggerHandle.writeLogDevelope("权限受限", request)
            loginResut = json.dumps({
                "ErrorInfo": "权限受限",
                "ErrorId": 20006,
                "Result": {}
            })
            return HttpResponse(loginResut)

        rolecode = allParams["rolecode"]
        roleHandle = PaperRoles.objects.filter(code=rolecode).first()
        if not roleHandle:
            LoggerHandle.writeLogDevelope("角色数据异常", request)
            loginResut = json.dumps({
                "ErrorInfo": "角色数据异常",
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        orgCode = acntHandle.orgcode.code
        # 生成权限数据
        commitDataList = []

        name = None
        roleUpdate = False
        try:
            name = allParams["name"]
            roleHandle.name = name
            roleUpdate = True
        except:
            pass

        info = None
        try:
            info = allParams["info"]
            roleHandle.content = info
            roleUpdate = True
        except:
            pass

        if roleUpdate:
            commitDataList.append(CommitData(roleHandle, 0))

        funcs = None
        try:
            funcs = allParams["funcs"]
            commitDataList.append(
                CommitData(PaperRoleFunc.objects.filter(rcode=roleHandle), 1))

            funcLists = funcs.split(',')
            for oneFun in funcLists:
                funInfo = oneFun.split(":")
                if len(funInfo) != 2:
                    continue

                newRelate = PaperRoleFunc()
                newRelate.fcode = PaperFunctions.objects.filter(
                    code=funInfo[0]).first()
                newRelate.rcode = roleHandle
                newRelate.flag = funInfo[1]
                newRelate.code = uuid.uuid1().__str__().replace("-", "")
                commitDataList.append(CommitData(newRelate, 0))
        except:
            pass

        # 事务提交
        try:
            result = DBHelper.commitCustomDataByTranslate(commitDataList)

            if not result:
                loginResut = json.dumps({
                    "ErrorInfo": "数据库操作失败",
                    "ErrorId": 99999,
                    "Result": None
                })
                return HttpResponse(loginResut)
        except Exception, ex:
            loginResut = json.dumps({
                "ErrorInfo": "数据库操作失败",
                "ErrorId": 99999,
                "Result": None
            })
            return HttpResponse(loginResut)
Esempio n. 2
0
    def RoleAdd(request, cmd):
        '''
        添加角色
        :param request:
        :return:
        '''
        LoggerHandle.writeLogDevelope("添加角色%s" % cmd.encode('utf-8'), request)

        # 提取参数
        getParams = UtilHelper.UtilHelper.getGetParams(request)
        postParams = UtilHelper.UtilHelper.getPostParams(request)

        allParams = dict(getParams.items() + postParams.items())
        LoggerHandle.writeLogDevelope("指令GET参数" + str(getParams), request)
        LoggerHandle.writeLogDevelope("指令POST参数" + str(postParams), request)

        # 验证参数完整性
        paramCompleteness, info = ParamCheckHelper.ParamCheckHelper.getParamModule(
            cmd).checkParamComplete(allParams)

        if paramCompleteness:
            LoggerHandle.writeLogDevelope("参数完整,符合要求", request)
        else:
            LoggerHandle.writeLogDevelope("参数不完整,缺少:" + info, request)
            loginResut = json.dumps({
                "ErrorInfo": "参数不足,缺少:" + info,
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # # 参数验签
        # verifyResult = VerifyHelper.VerifyHelper.verifyParam(allParams)
        # if verifyResult:
        #     LoggerHandle.writeLogDevelope("参数验签成功", request)
        # else:
        #     LoggerHandle.writeLogDevelope("参数验签失败", request)
        #     loginResut = json.dumps({"ErrorInfo": "参数验签失败", "ErrorId": 20002, "Result": {}})
        #     return HttpResponse(loginResut)

        # 检查logioncode是否为权力机构
        # acntHandle = SmartAccount.objects.filter(account = allParams["logincode"]).first()

        userOrg, acntHandle = OrgTree.getUserOrg(allParams["logincode"])
        if not userOrg:
            LoggerHandle.writeLogDevelope("用户单位数据异常", request)
            loginResut = json.dumps({
                "ErrorInfo": "用户单位数据异常",
                "ErrorId": 20008,
                "Result": {}
            })
            return HttpResponse(loginResut)

        if not acntHandle:
            LoggerHandle.writeLogDevelope("当前账号数据异常", request)
            loginResut = json.dumps({
                "ErrorInfo": "当前账号数据异常",
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 检查当前账户是否具有权限
        resultPrivilegeSign = PrivilegeHelper.funcPrivCheck(cmd, acntHandle)
        if not resultPrivilegeSign:
            LoggerHandle.writeLogDevelope("权限受限", request)
            loginResut = json.dumps({
                "ErrorInfo": "权限受限",
                "ErrorId": 20006,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 增加角色数据
        # RoleName
        # OrgSign
        # Funcs
        # Info
        # LoginCode
        # TimeStamp
        # SIGN
        # 验证单位信息
        # orgHandle = PaperOrgs.objects.filter(code = allParams["orgsign"]).first()
        #
        # if not orgHandle:
        #     LoggerHandle.writeLogDevelope("传入的单位数据异常", request)
        #     loginResut = json.dumps({"ErrorInfo": "传入的单位数据异常", "ErrorId": 20007, "Result": {}})
        #     return HttpResponse(loginResut)

        commitDataList = []

        newRole = PaperRoles()
        newRole.code = uuid.uuid1().__str__().replace("-", "")
        newRole.orgcode = userOrg
        newRole.name = allParams["name"]
        newRole.state = 1
        newRole.content = ""
        commitDataList.append(CommitData(newRole, 0))

        # 处理角色所包含的功能
        try:
            funcString = allParams["funcs"]

            funcList = funcString.split(",")
            for oneFunc in funcList:
                newRoleFunc = PaperRoleFunc()
                newRoleFunc.code = uuid.uuid1().__str__().replace("-", "")
                newRoleFunc.rcode = newRole
                newRoleFunc.fcode = PaperFunctions.objects.filter(
                    code=oneFunc).first()
                commitDataList.append(CommitData(newRoleFunc, 0))
                pass
        except Exception, ex:
            pass
Esempio n. 3
0
    def AccountAdd(request, cmd):
        '''
        超级登录指令
        :param request:
        :return:
        '''
        LoggerHandle.writeLogDevelope("执行添加账户指令%s" % cmd.encode('utf-8'),
                                      request)

        # 提取参数
        getParams = UtilHelper.UtilHelper.getGetParams(request)
        postParams = UtilHelper.UtilHelper.getPostParams(request)

        allParams = dict(getParams.items() + postParams.items())
        LoggerHandle.writeLogDevelope("指令GET参数" + str(getParams), request)
        LoggerHandle.writeLogDevelope("指令POST参数" + str(postParams), request)

        # 验证参数完整性
        paramCompleteness, info = ParamCheckHelper.ParamCheckHelper.getParamModule(
            cmd).checkParamComplete(allParams)

        if paramCompleteness:
            LoggerHandle.writeLogDevelope("参数完整,符合要求", request)
        else:
            LoggerHandle.writeLogDevelope("参数不完整,缺少:" + info, request)
            loginResut = json.dumps({
                "ErrorInfo": "参数不足,缺少:" + info,
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # # 参数验签
        # verifyResult = VerifyHelper.VerifyHelper.verifyParam(allParams)
        # if verifyResult:
        #     LoggerHandle.writeLogDevelope("参数验签成功", request)
        # else:
        #     LoggerHandle.writeLogDevelope("参数验签失败", request)
        #     loginResut = json.dumps({"ErrorInfo": "参数验签失败", "ErrorId": 20002, "Result": {}})
        #     return HttpResponse(loginResut)

        # 检查logioncode是否为权力机构
        acntHandle = PaperAccount.objects.filter(
            account=allParams["logincode"]).first()

        # 检查当前账号是否具有当前权限
        if not acntHandle:
            LoggerHandle.writeLogDevelope("当前账号数据异常", request)
            loginResut = json.dumps({
                "ErrorInfo": "当前账号数据异常",
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 检查当前账户是否具有权限
        resultPrivilegeSign = PrivilegeHelper.funcPrivCheck(cmd, acntHandle)
        if not resultPrivilegeSign:
            LoggerHandle.writeLogDevelope("权限受限", request)
            loginResut = json.dumps({
                "ErrorInfo": "权限受限",
                "ErrorId": 20006,
                "Result": {}
            })
            return HttpResponse(loginResut)

        orgS = None
        orgList = []
        orgsign = acntHandle.orgcode.code
        # orgsign = allParams["orgsign"]
        orgList = OrgTree.getOrgTreeObjects(
            PaperOrgs.objects.filter(code=orgsign).first())
        orgList.append(PaperOrgs.objects.filter(code=orgsign).first())

        accountList = []
        for oneOrg in orgList:
            acns = PaperAccount.objects.filter(orgcode=oneOrg, state=1)
            for oneAcnt in acns:
                accountList.append(oneAcnt)

        #  检查账户是否重复
        for oneActTemp in accountList:
            if oneActTemp.workno == allParams["account"]:
                LoggerHandle.writeLogDevelope("登陆账号重复", request)
                loginResut = json.dumps({
                    "ErrorInfo": "登陆账号重复",
                    "ErrorId": 20007,
                    "Result": {}
                })
                return HttpResponse(loginResut)

            continue

        orgsign = allParams["orgsign"]
        Name = allParams["name"]
        Account = allParams["account"]  #工号
        Password = allParams["password"]
        Phone = allParams["phone"]  # 手机号码
        OrgCode = allParams["orgcode"]
        accounttype = int(allParams["accounttype"])
        LoginCode = allParams["logincode"]

        orgHandle = PaperOrgs.objects.filter(code=OrgCode).first()

        newAccount = PaperAccount()
        newAccount.alias = Name
        newAccount.orgcode = orgHandle
        newAccount.code = uuid.uuid1().__str__().replace("-", "")
        newAccount.type = accounttype
        newAccount.state = 1

        # 登陆账号
        newAccount.account = Phone
        newAccount.mobile = Phone
        newAccount.workno = Account
        newAccount.password = Password
        newAccount.regdate = time.strftime("%Y-%m-%d", time.localtime())
        commitDataList = []
        commitDataList.append(CommitData(newAccount, 0))

        # 事务提交
        try:
            result = DBHelper.commitCustomDataByTranslate(commitDataList)

            if not result:
                loginResut = json.dumps({
                    "ErrorInfo": "数据库操作失败",
                    "ErrorId": 99999,
                    "Result": None
                })
                return HttpResponse(loginResut)
        except Exception, ex:
            loginResut = json.dumps({
                "ErrorInfo": "数据库操作失败",
                "ErrorId": 99999,
                "Result": None
            })
            return HttpResponse(loginResut)
Esempio n. 4
0
    def SetUserPswd(request, cmd):
        '''
         复制节目
         :param request:
         :return:
         '''
        LoggerHandle.writeLogDevelope("密码重置%s" % cmd.encode('utf-8'), request)

        # 提取参数
        getParams = UtilHelper.UtilHelper.getGetParams(request)
        postParams = UtilHelper.UtilHelper.getPostParams(request)

        allParams = dict(getParams.items() + postParams.items())
        LoggerHandle.writeLogDevelope("指令GET参数" + str(getParams), request)
        LoggerHandle.writeLogDevelope("指令POST参数" + str(postParams), request)

        # 验证参数完整性
        paramCompleteness, info = ParamCheckHelper.ParamCheckHelper.getParamModule(
            cmd).checkParamComplete(allParams)

        if paramCompleteness:
            LoggerHandle.writeLogDevelope("参数完整,符合要求", request)
        else:
            LoggerHandle.writeLogDevelope("参数不完整,缺少:" + info, request)
            loginResut = json.dumps({
                "ErrorInfo": "参数不足,缺少:" + info,
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # # 参数验签
        # verifyResult = VerifyHelper.VerifyHelper.verifyParam(allParams)
        # if verifyResult:
        #     LoggerHandle.writeLogDevelope("参数验签成功", request)
        # else:
        #     LoggerHandle.writeLogDevelope("参数验签失败", request)
        #     loginResut = json.dumps({"ErrorInfo": "参数验签失败", "ErrorId": 20002, "Result": {}})
        #     return HttpResponse(loginResut)

        # 检查logioncode是否为权力机构
        acntHandle = PaperAccount.objects.filter(
            account=allParams["logincode"]).first()

        # 检查当前账号是否具有当前权限
        if not acntHandle:
            LoggerHandle.writeLogDevelope("当前账号数据异常", request)
            loginResut = json.dumps({
                "ErrorInfo": "当前账号数据异常",
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # orgHandel = PaperOrgs.objects.filter(code=allParams["orgsign"]).first()
        # if not orgHandel:
        #     LoggerHandle.writeLogDevelope("客户单位数据异常", request)
        #     loginResut = json.dumps({"ErrorInfo": "客户单位数据异常", "ErrorId": 20008, "Result": {}})
        #     return HttpResponse(loginResut)

        userOrg, userHandle = OrgTree.getUserOrg(allParams["logincode"])
        if not userOrg:
            LoggerHandle.writeLogDevelope("用户单位数据异常", request)
            loginResut = json.dumps({
                "ErrorInfo": "用户单位数据异常",
                "ErrorId": 20008,
                "Result": {}
            })
            return HttpResponse(loginResut)

        if not userHandle:
            LoggerHandle.writeLogDevelope("当前账号数据异常", request)
            loginResut = json.dumps({
                "ErrorInfo": "当前账号数据异常",
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 检查当前账户是否具有权限
        resultPrivilegeSign = PrivilegeHelper.funcPrivCheck(cmd, userHandle)
        if not resultPrivilegeSign:
            LoggerHandle.writeLogDevelope("权限受限", request)
            loginResut = json.dumps({
                "ErrorInfo": "权限受限",
                "ErrorId": 20006,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 查询账号信息
        accountModi = PaperAccount.objects.filter(
            code=allParams["acode"]).first()
        if not accountModi:
            LoggerHandle.writeLogDevelope("待修改的账号不存在", request)
            loginResut = json.dumps({
                "ErrorInfo": "待修改的账号不存在",
                "ErrorId": 20007,
                "Result": {}
            })
            return HttpResponse(loginResut)

        accountModi.password = allParams["password"]
        commitDataList = []
        commitDataList.append(CommitData(accountModi, 0))

        # 事务提交
        try:
            result = DBHelper.commitCustomDataByTranslate(commitDataList)

            if not result:
                loginResut = json.dumps({
                    "ErrorInfo": "数据库操作失败",
                    "ErrorId": 99999,
                    "Result": None
                })
                return HttpResponse(loginResut)
        except Exception, ex:
            loginResut = json.dumps({
                "ErrorInfo": "数据库操作失败",
                "ErrorId": 99999,
                "Result": None
            })
            return HttpResponse(loginResut)
Esempio n. 5
0
    def AccountDele(request, cmd):
        LoggerHandle.writeLogDevelope("删除账户指令%s" % cmd.encode('utf-8'),
                                      request)

        # 提取参数
        getParams = UtilHelper.UtilHelper.getGetParams(request)
        postParams = UtilHelper.UtilHelper.getPostParams(request)

        allParams = dict(getParams.items() + postParams.items())
        LoggerHandle.writeLogDevelope("指令GET参数" + str(getParams), request)
        LoggerHandle.writeLogDevelope("指令POST参数" + str(postParams), request)

        # 验证参数完整性
        paramCompleteness, info = ParamCheckHelper.ParamCheckHelper.getParamModule(
            cmd).checkParamComplete(allParams)

        if paramCompleteness:
            LoggerHandle.writeLogDevelope("参数完整,符合要求", request)
        else:
            LoggerHandle.writeLogDevelope("参数不完整,缺少:" + info, request)
            loginResut = json.dumps({
                "ErrorInfo": "参数不足,缺少:" + info,
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # # 参数验签
        # verifyResult = VerifyHelper.VerifyHelper.verifyParam(allParams)
        # if verifyResult:
        #     LoggerHandle.writeLogDevelope("参数验签成功", request)
        # else:
        #     LoggerHandle.writeLogDevelope("参数验签失败", request)
        #     loginResut = json.dumps({"ErrorInfo": "参数验签失败", "ErrorId": 20002, "Result": {}})
        #     return HttpResponse(loginResut)

        # 检查logioncode是否为权力机构
        acntHandle = PaperAccount.objects.filter(
            account=allParams["logincode"]).first()

        # 检查当前账号是否具有当前权限
        if not acntHandle:
            LoggerHandle.writeLogDevelope("当前账号数据异常", request)
            loginResut = json.dumps({
                "ErrorInfo": "当前账号数据异常",
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 检查当前账户是否具有权限
        resultPrivilegeSign = PrivilegeHelper.funcPrivCheck(cmd, acntHandle)
        if not resultPrivilegeSign:
            LoggerHandle.writeLogDevelope("权限受限", request)
            loginResut = json.dumps({
                "ErrorInfo": "权限受限",
                "ErrorId": 20006,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 查询单位数据
        if not acntHandle.orgcode:
            LoggerHandle.writeLogDevelope("单位数据不存在", request)
            loginResut = json.dumps({
                "ErrorInfo": "单位数据不存在",
                "ErrorId": 20007,
                "Result": {}
            })
            return HttpResponse(loginResut)

        accountHandle = PaperAccount.objects.filter(
            code=allParams["code"], workno=allParams["account"]).first()

        accountHandle.state = 2
        # 提交变更
        commitDataList = []
        commitDataList.append(CommitData(accountHandle, 0))

        # 事务提交
        try:
            result = DBHelper.commitCustomDataByTranslate(commitDataList)

            if not result:
                loginResut = json.dumps({
                    "ErrorInfo": "数据库操作失败",
                    "ErrorId": 99999,
                    "Result": None
                })
                return HttpResponse(loginResut)
        except Exception, ex:
            loginResut = json.dumps({
                "ErrorInfo": "数据库操作失败",
                "ErrorId": 99999,
                "Result": None
            })
            return HttpResponse(loginResut)
Esempio n. 6
0
    def SetUserRoles(request, cmd):
        '''
        账户修改
        :param request:
        :return:
        '''
        LoggerHandle.writeLogDevelope("账户修改指令%s" % cmd.encode('utf-8'),
                                      request)

        # 提取参数
        getParams = UtilHelper.UtilHelper.getGetParams(request)
        postParams = UtilHelper.UtilHelper.getPostParams(request)

        allParams = dict(getParams.items() + postParams.items())
        LoggerHandle.writeLogDevelope("指令GET参数" + str(getParams), request)
        LoggerHandle.writeLogDevelope("指令POST参数" + str(postParams), request)

        # 验证参数完整性
        paramCompleteness, info = ParamCheckHelper.ParamCheckHelper.getParamModule(
            cmd).checkParamComplete(allParams)

        if paramCompleteness:
            LoggerHandle.writeLogDevelope("参数完整,符合要求", request)
        else:
            LoggerHandle.writeLogDevelope("参数不完整,缺少:" + info, request)
            loginResut = json.dumps({
                "ErrorInfo": "参数不足,缺少:" + info,
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # # 参数验签
        # verifyResult = VerifyHelper.VerifyHelper.verifyParam(allParams)
        # if verifyResult:
        #     LoggerHandle.writeLogDevelope("参数验签成功", request)
        # else:
        #     LoggerHandle.writeLogDevelope("参数验签失败", request)
        #     loginResut = json.dumps({"ErrorInfo": "参数验签失败", "ErrorId": 20002, "Result": {}})
        #     return HttpResponse(loginResut)

        # 检查logioncode是否为权力机构
        acntHandle = PaperAccount.objects.filter(
            account=allParams["logincode"]).first()

        # 检查当前账号是否具有当前权限
        if not acntHandle:
            LoggerHandle.writeLogDevelope("当前账号数据异常", request)
            loginResut = json.dumps({
                "ErrorInfo": "当前账号数据异常",
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 检查当前账户是否具有权限
        resultPrivilegeSign = PrivilegeHelper.funcPrivCheck(cmd, acntHandle)
        if not resultPrivilegeSign:
            LoggerHandle.writeLogDevelope("权限受限", request)
            loginResut = json.dumps({
                "ErrorInfo": "权限受限",
                "ErrorId": 20006,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # # 检查单位是否存在
        # orgHandle = PaperOrgs.objects.filter(code = allParams["orgsign"]).first()
        # if not orgHandle:
        #     LoggerHandle.writeLogDevelope("单位不存在", request)
        #     loginResut = json.dumps({"ErrorInfo": "单位不存在", "ErrorId": 20006, "Result": {}})
        #     return HttpResponse(loginResut)

        # 检查账户是否存在
        accountHandle = PaperAccount.objects.filter(code=allParams["usercode"],
                                                    state=1).first()
        if not accountHandle:
            LoggerHandle.writeLogDevelope("账户数据异常", request)
            loginResut = json.dumps({
                "ErrorInfo": "账户数据异常",
                "ErrorId": 20006,
                "Result": {}
            })
            return HttpResponse(loginResut)

        roles = allParams["rolecodes"].split(",")

        # 提交变更
        commitDataList = []

        commitDataList.append(
            CommitData(PaperUserRole.objects.filter(acode=accountHandle), 1))
        for oneRoleCode in roles:
            if not oneRoleCode or oneRoleCode == "" or oneRoleCode == "null":
                continue
            newMap = PaperUserRole()
            newMap.rcode = PaperRoles.objects.filter(code=oneRoleCode).first()
            newMap.code = uuid.uuid1().__str__().replace("-", "")
            newMap.acode = accountHandle
            commitDataList.append(CommitData(newMap, 0))

        # 事务提交
        try:
            result = DBHelper.commitCustomDataByTranslate(commitDataList)

            if not result:
                loginResut = json.dumps({
                    "ErrorInfo": "数据库操作失败",
                    "ErrorId": 99999,
                    "Result": None
                })
                return HttpResponse(loginResut)
        except Exception, ex:
            loginResut = json.dumps({
                "ErrorInfo": "数据库操作失败",
                "ErrorId": 99999,
                "Result": None
            })
            return HttpResponse(loginResut)
Esempio n. 7
0
    def OrgAddOrg(request, cmd):
        '''
        超级登录指令
        :param request:
        :return:
        '''
        LoggerHandle.writeLogDevelope("单位添加指令%s" % cmd.encode('utf-8'),
                                      request)

        # 提取参数
        getParams = UtilHelper.UtilHelper.getGetParams(request)
        postParams = UtilHelper.UtilHelper.getPostParams(request)

        allParams = dict(getParams.items() + postParams.items())
        LoggerHandle.writeLogDevelope("指令GET参数" + str(getParams), request)
        LoggerHandle.writeLogDevelope("指令POST参数" + str(postParams), request)

        # 验证参数完整性
        paramCompleteness, info = ParamCheckHelper.ParamCheckHelper.getParamModule(
            cmd).checkParamComplete(allParams)

        if paramCompleteness:
            LoggerHandle.writeLogDevelope("参数完整,符合要求", request)
        else:
            LoggerHandle.writeLogDevelope("参数不完整,缺少:" + info, request)
            loginResut = json.dumps({
                "ErrorInfo": "参数不足,缺少:" + info,
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # # 参数验签
        # verifyResult = VerifyHelper.VerifyHelper.verifyParam(allParams)
        # if verifyResult:
        #     LoggerHandle.writeLogDevelope("参数验签成功", request)
        # else:
        #     LoggerHandle.writeLogDevelope("参数验签失败", request)
        #     loginResut = json.dumps({"ErrorInfo": "参数验签失败", "ErrorId": 20002, "Result": {}})
        #     return HttpResponse(loginResut)

        # 检查logioncode是否为权力机构
        acntHandle = PaperAccount.objects.filter(
            account=allParams["logincode"]).first()

        # 检查当前账号是否具有当前权限
        if not acntHandle:
            LoggerHandle.writeLogDevelope("当前账号数据异常", request)
            loginResut = json.dumps({
                "ErrorInfo": "当前账号数据异常",
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # # 检查当前账户是否具有权限
        # resultPrivilegeSign = PrivilegeHelper.PrivilegeHelper.funcPrivCheck(cmd, acntHandle)
        # if not resultPrivilegeSign:
        #     LoggerHandle.writeLogDevelope("权限受限", request)
        #     loginResut = json.dumps({"ErrorInfo": "权限受限", "ErrorId": 20006, "Result": {}})
        #     return HttpResponse(loginResut)

        # 创建单位数据
        newOrg = PaperOrgs()
        newOrg.code = uuid.uuid1().__str__().replace("-", "")

        if not allParams.has_key("parentcode"):
            newOrg.parentcode = None
        else:
            # 从检查父亲单位的合法性
            parentCode = allParams["parentcode"]
            if not parentCode and len(parentCode) > 0:
                parentExist, parentHandle = PrivilegeHelper.checkOrgExist(
                    allParams["parentcode"])
                if not parentExist:
                    LoggerHandle.writeLogDevelope("设定的父亲机构不存在", request)
                    loginResut = json.dumps({
                        "ErrorInfo": "设定的父亲机构不存在",
                        "ErrorId": 30002,
                        "Result": {}
                    })
                    return HttpResponse(loginResut)
                else:
                    newOrg.parentcode = parentHandle
            else:
                newOrg.parentcode = None

        newOrg.name = allParams["name"]
        newOrg.contactname = allParams["conname"]
        newOrg.contactphone = allParams["conphone"]
        newOrg.parentcode = PaperOrgs.objects.filter(
            code=allParams["parentcode"]).first()
        newOrg.regdate = time.strftime("%Y-%m-%d", time.localtime(time.time()))
        newOrg.signstr = newOrg.code
        newOrg.state = 1
        newOrg.type = 1
        newOrg.logo = "%s.png" % newOrg.code

        # 提交变更
        commitDataList = []
        commitDataList.append(CommitData(newOrg, 0))

        # 事务提交
        try:
            result = DBHelper.commitCustomDataByTranslate(commitDataList)

            if not result:
                loginResut = json.dumps({
                    "ErrorInfo": "数据库操作失败",
                    "ErrorId": 99999,
                    "Result": None
                })
                return HttpResponse(loginResut)
        except Exception, ex:
            loginResut = json.dumps({
                "ErrorInfo": "数据库操作失败",
                "ErrorId": 99999,
                "Result": None
            })
            return HttpResponse(loginResut)
Esempio n. 8
0
    def OrgModi(request, cmd):
        '''
        修改单位基础信息
        :param request:
        :param cmd:
        :return:
        '''
        LoggerHandle.writeLogDevelope("单位修改指令%s" % cmd.encode('utf-8'),
                                      request)

        # 提取参数
        getParams = UtilHelper.UtilHelper.getGetParams(request)
        postParams = UtilHelper.UtilHelper.getPostParams(request)

        allParams = dict(getParams.items() + postParams.items())
        LoggerHandle.writeLogDevelope("指令GET参数" + str(getParams), request)
        LoggerHandle.writeLogDevelope("指令POST参数" + str(postParams), request)

        # 验证参数完整性
        paramCompleteness, info = ParamCheckHelper.ParamCheckHelper.getParamModule(
            cmd).checkParamComplete(allParams)

        if paramCompleteness:
            LoggerHandle.writeLogDevelope("参数完整,符合要求", request)
        else:
            LoggerHandle.writeLogDevelope("参数不完整,缺少:" + info, request)
            loginResut = json.dumps({
                "ErrorInfo": "参数不足,缺少:" + info,
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 参数验签
        verifyResult = VerifyHelper.VerifyHelper.verifyParam(allParams)
        if verifyResult:
            LoggerHandle.writeLogDevelope("参数验签成功", request)
        else:
            LoggerHandle.writeLogDevelope("参数验签失败", request)
            loginResut = json.dumps({
                "ErrorInfo": "参数验签失败",
                "ErrorId": 20002,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 检查logioncode是否为权力机构
        acntHandle = SmartAccount.objects.filter(
            workno=allParams["logincode"]).first()

        # 检查当前账号是否具有当前权限
        if not acntHandle:
            LoggerHandle.writeLogDevelope("当前账号数据异常", request)
            loginResut = json.dumps({
                "ErrorInfo": "当前账号数据异常",
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 检查当前账户是否具有权限
        resultPrivilegeSign = PrivilegeHelper.PrivilegeHelper.funcPrivCheck(
            cmd, acntHandle)
        if not resultPrivilegeSign:
            LoggerHandle.writeLogDevelope("权限受限", request)
            loginResut = json.dumps({
                "ErrorInfo": "权限受限",
                "ErrorId": 20006,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 查询单位数据
        orgHandle = SmartOrganization.objects.filter(
            code=allParams["orgsign"]).first()
        if not orgHandle:
            LoggerHandle.writeLogDevelope("单位数据不存在", request)
            loginResut = json.dumps({
                "ErrorInfo": "单位数据不存在",
                "ErrorId": 20007,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # orgHandle.code = uuid.uuid1().__str__().replace("-", "")
        # Name
        # Address
        # ConName
        # ConPhone

        orgHandle.name = allParams["name"]
        orgHandle.contactname = allParams["conname"]
        orgHandle.contactphone = allParams["conphone"]

        # 提交变更
        commitDataList = []
        commitDataList.append(CommitData(orgHandle, 0))

        # 事务提交
        try:
            result = DBHelper.commitCustomDataByTranslate(commitDataList)

            if not result:
                loginResut = json.dumps({
                    "ErrorInfo": "数据库操作失败",
                    "ErrorId": 99999,
                    "Result": None
                })
                return HttpResponse(loginResut)
        except Exception, ex:
            loginResut = json.dumps({
                "ErrorInfo": "数据库操作失败",
                "ErrorId": 99999,
                "Result": None
            })
            return HttpResponse(loginResut)
Esempio n. 9
0
    def OrgConfig(request, cmd):
        '''
        配置单位授权信息
        :param request:
        :param cmd:
        :return:
        '''
        LoggerHandle.writeLogDevelope("单位配置指令%s" % cmd.encode('utf-8'),
                                      request)

        # 提取参数
        getParams = UtilHelper.UtilHelper.getGetParams(request)
        postParams = UtilHelper.UtilHelper.getPostParams(request)

        allParams = dict(getParams.items() + postParams.items())
        LoggerHandle.writeLogDevelope("指令GET参数" + str(getParams), request)
        LoggerHandle.writeLogDevelope("指令POST参数" + str(postParams), request)

        # 验证参数完整性
        paramCompleteness, info = ParamCheckHelper.ParamCheckHelper.getParamModule(
            cmd).checkParamComplete(allParams)

        if paramCompleteness:
            LoggerHandle.writeLogDevelope("参数完整,符合要求", request)
        else:
            LoggerHandle.writeLogDevelope("参数不完整,缺少:" + info, request)
            loginResut = json.dumps({
                "ErrorInfo": "参数不足,缺少:" + info,
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 参数验签
        verifyResult = VerifyHelper.VerifyHelper.verifyParam(allParams)
        if verifyResult:
            LoggerHandle.writeLogDevelope("参数验签成功", request)
        else:
            LoggerHandle.writeLogDevelope("参数验签失败", request)
            loginResut = json.dumps({
                "ErrorInfo": "参数验签失败",
                "ErrorId": 20002,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 检查logioncode是否为权力机构
        acntHandle = SmartAccount.objects.filter(
            workno=allParams["logincode"]).first()

        # 检查当前账号是否具有当前权限
        if not acntHandle:
            LoggerHandle.writeLogDevelope("当前账号数据异常", request)
            loginResut = json.dumps({
                "ErrorInfo": "当前账号数据异常",
                "ErrorId": 20001,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 检查当前账户是否具有权限
        resultPrivilegeSign = PrivilegeHelper.PrivilegeHelper.funcPrivCheck(
            cmd, acntHandle)
        if not resultPrivilegeSign:
            LoggerHandle.writeLogDevelope("权限受限", request)
            loginResut = json.dumps({
                "ErrorInfo": "权限受限",
                "ErrorId": 20006,
                "Result": {}
            })
            return HttpResponse(loginResut)

        # 查询单位数据
        orgHandle = SmartOrganization.objects.filter(
            code=allParams["orgsign"]).first()
        if not orgHandle:
            LoggerHandle.writeLogDevelope("单位数据不存在", request)
            loginResut = json.dumps({
                "ErrorInfo": "单位数据不存在",
                "ErrorId": 20007,
                "Result": {}
            })
            return HttpResponse(loginResut)

        type = int(allParams["type"])

        if type == 1:
            orgHandle.terminalcount = F('terminalcount') + int(
                allParams["terminalcount"])
            orgHandle.storagesize = F('storagesize') + int(
                allParams["storagesize"])
        else:
            orgHandle.terminalcount = int(allParams["terminalcount"])
            orgHandle.storagesize = int(allParams["storagesize"])

        terminalChangeSize = int(allParams["terminalcount"])

        # 提交变更
        commitDataList = []
        commitDataList.append(CommitData(orgHandle, 0))

        if type == 2:
            pass

        for index in range(terminalChangeSize):
            pass

        # 事务提交
        try:
            result = DBHelper.commitCustomDataByTranslate(commitDataList)

            if not result:
                loginResut = json.dumps({
                    "ErrorInfo": "数据库操作失败",
                    "ErrorId": 99999,
                    "Result": None
                })
                return HttpResponse(loginResut)
        except Exception, ex:
            loginResut = json.dumps({
                "ErrorInfo": "数据库操作失败",
                "ErrorId": 99999,
                "Result": None
            })
            return HttpResponse(loginResut)