def RoleQuery(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) orgsign = acntHandle.orgcode.code rolecode = allParams["rolecode"] roleHandle = PaperRoles.objects.filter(code=rolecode).first() dataSets = PaperRoleFunc.objects.filter(rcode=roleHandle) # 返回数据 rtnList = [] for index, oneOrg in enumerate(dataSets): oneDict = {} oneDict['code'] = oneOrg.fcode_id oneDict['flag'] = oneOrg.flag rtnList.append(oneDict) # 返回登录结果 lResut = json.dumps(rtnList) return HttpResponse(lResut)
def RoleDele(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) roleHandle = PaperRoles.objects.filter( code=allParams["rolecode"]).first() if not roleHandle: LoggerHandle.writeLogDevelope("角色不存在", request) loginResut = json.dumps({ "ErrorInfo": "角色不存在", "ErrorId": 20006, "Result": {} }) return HttpResponse(loginResut) roleHandle.state = 2 try: roleHandle.save() except: LoggerHandle.writeLogDevelope("数据写入失败", request) loginResut = json.dumps({ "ErrorInfo": "数据写入失败", "ErrorId": 20007, "Result": {} }) return HttpResponse(loginResut) # 返回登录结果 loginResut = json.dumps({ "ErrorInfo": "操作成功", "ErrorId": 200, "Result": None }) return HttpResponse(loginResut)
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
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)
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)
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)
def AccountList(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 # orgsign = allParams["orgsign"] orgsign = acntHandle.orgcode.code orgcode = None try: orgcode = allParams["orgcode"] except: pass orgList = [] if orgcode: orgList.append(PaperOrgs.objects.filter(code=orgcode).first()) else: 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) acns = acns.filter(~Q(type=1)) for oneAcnt in acns: accountList.append(oneAcnt) # 排序 accountList.sort(lambda p1, p2: cmp(p1.id, p2.id)) limit = int(allParams["limit"]) pageIndex = int(allParams["page"]) fliterStr = None try: fliterStr = allParams["fliterstring"] except: pass dataSets = [] # 数据刷选 for index, oneAccount in enumerate(accountList): if fliterStr and len(fliterStr) > 0: if fliterStr not in oneAccount.alias and fliterStr not in oneAccount.account and fliterStr not in oneAccount.workno: continue dataSets.append(oneAccount) # 返回数据 rtnList = [] for index, oneAccount in enumerate(dataSets): if index < limit * (pageIndex - 1) or index >= limit * pageIndex: continue oneOrgDict = {} oneOrgDict['id'] = oneAccount.id oneOrgDict['code'] = oneAccount.code oneOrgDict['account'] = oneAccount.workno oneOrgDict['name'] = oneAccount.alias oneOrgDict['phone'] = oneAccount.account oneOrgDict['type'] = oneAccount.type if oneAccount.type == 0: oneOrgDict['typename'] = "普通账号" elif oneAccount.type == 2: oneOrgDict['typename'] = "PAD账号" else: oneOrgDict['typename'] = "未知" oneOrgDict['regdate'] = oneAccount.regdate oneOrgDict['orgcode'] = oneAccount.orgcode_id oneOrgDict['orgname'] = oneAccount.orgcode.name rtnList.append(oneOrgDict) dictRtn = {} dictRtn["code"] = 0 dictRtn["msg"] = "success" dictRtn["count"] = len(dataSets) dictRtn["data"] = rtnList # 返回登录结果 lResut = json.dumps(dictRtn) return HttpResponse(lResut)
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)
def AccountQuery(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) # # 查询单位数据 # orgHandle = PaperOrgs.objects.filter(code=allParams["orgsign"]).first() # if not orgHandle: # LoggerHandle.writeLogDevelope("单位数据不存在", request) # loginResut = json.dumps({"ErrorInfo": "单位数据不存在", "ErrorId": 20007, "Result": {}}) # return HttpResponse(loginResut) oneAccount = PaperAccount.objects.filter( code=allParams["code"], workno=allParams["account"]).first() if not oneAccount: LoggerHandle.writeLogDevelope("账户数据不存在", request) loginResut = json.dumps({ "ErrorInfo": "账户数据不存在", "ErrorId": 20007, "Result": {} }) return HttpResponse(loginResut) oneOrgDict = {} oneOrgDict['id'] = oneAccount.id oneOrgDict['code'] = oneAccount.code oneOrgDict['account'] = oneAccount.workno oneOrgDict['name'] = oneAccount.alias oneOrgDict['phone'] = oneAccount.account oneOrgDict['type'] = oneAccount.type oneOrgDict['regdate'] = oneAccount.regdate oneOrgDict['orgcode'] = oneAccount.orgcode_id # 返回登录结果 lResut = json.dumps(oneOrgDict) return HttpResponse(lResut)
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)
def QueryOrg(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 = 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": 20007, "Result": {} }) return HttpResponse(loginResut) orgManageAccount = PaperAccount.objects.filter(orgcode=orgHandle, type=1).first() # 返回单位数据 rtnData = {} rtnData["code"] = orgHandle.code rtnData["name"] = orgHandle.name rtnData["contactname"] = orgHandle.contactname rtnData["contactphone"] = orgHandle.contactphone rtnData["regdate"] = orgHandle.regdate rtnData["state"] = orgHandle.state rtnData["logo"] = orgHandle.logo # rtnData["signstr"] = orgHandle.signstr rtnData["parentcode"] = orgHandle.parentcode_id # rtnData["type"] = orgHandle.type # rtnData["terminalcount"] = orgHandle.terminalcount # rtnData["storagesize"] =orgHandle.storagesize if not orgManageAccount: rtnData["maccount"] = "noset" rtnData["mpassword"] = "******" else: rtnData["maccount"] = orgManageAccount.workno rtnData["mpassword"] = orgManageAccount.password # 返回登录结果 loginResut = json.dumps({ "ErrorInfo": "操作成功", "ErrorId": 200, "Result": rtnData }) return HttpResponse(loginResut)
def GoodsQuery(request, cmd): ''' 商品查询 :param request: :return: ''' LoggerHandle.writeLogDevelope("收到商品查询指令%s" % cmd.encode('utf-8'), request) LoggerHandle.writeLog("%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) acntHandle = PaperAccount.objects.filter( account=allParams["logincode"]).first() # userOrg, acntHandle = OrgTree.getUserOrg(allParams["logincode"], allParams["orgsign"]) if not acntHandle or not acntHandle.orgcode: LoggerHandle.writeLogDevelope("用户单位数据异常", request) loginResut = json.dumps({ "ErrorInfo": "用户单位数据异常", "ErrorId": 20008, "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) # 检查当前账户是否具有权限 # ownerOrgHandel = PaperOrgs.objects.filter(code = allParams["orgsign"]).first() if not acntHandle.orgcode: LoggerHandle.writeLogDevelope("归属单位数据异常", request) loginResut = json.dumps({ "ErrorInfo": "归属单位数据异常", "ErrorId": 20006, "Result": {} }) return HttpResponse(loginResut) # 检查logioncode是否为权力机构 goodsHandles = PaperGoods.objects.filter(code=allParams["code"]) devHandle = goodsHandles.filter(~Q(state=0)).first() # 检查当前账号是否具有当前权限 if not devHandle: LoggerHandle.writeLogDevelope("当前商品数据异常", request) loginResut = json.dumps({ "ErrorInfo": "当前商品数据异常", "ErrorId": 20001, "Result": {} }) return HttpResponse(loginResut) oneOrgDict = {} oneOrgDict['goodsname'] = devHandle.name oneOrgDict['goodsprice'] = devHandle.price oneOrgDict['orgcode'] = devHandle.orgcode.code oneOrgDict[ 'previewimage'] = "/static/GoodsImage/%s.jpg" % allParams["code"] # 返回登录结果 lResut = json.dumps(oneOrgDict) return HttpResponse(lResut)