Beispiel #1
0
 def put(self):
     # 取POST Form提交的数据
     alldata = self.getRequestData()
     inst = entity.Meun_ag_manage(self.db)
     #先删除所有
     inst.remove(alldata['menu_group_id'],table="system.menu_authority_relation_group",key='menu_group_id',delete=True)
     #再循环插入
     #if not alldata['items']:
     #    raise BaseError(801)
     ids=0
     for menu_item_id in alldata['items']:
         lstData = {
             'menu_group_id':alldata['menu_group_id'],
             'create_id':alldata['create_id'],           
             'create_time':time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time())),
             'menu_item_id':menu_item_id                
                         }            
         id = inst.save(lstData,table='system.menu_authority_relation_group')
         if id <= 0:
             raise BaseError(703)  #参数错误 
         ids+=1
     cur=self.db.getCursor()
     cur.execute("select name from SYSTEM.MENU_AUTHORITY_GROUP where id=%s"%alldata['menu_group_id'])
     rows = cur.fetchall()
     oc=rows[0][0]
     if not self.objUserInfo :
         raise BaseError(604)
     name = self.objUserInfo['name']
     #msg=Message(self.db)
     #msg.addMsg(alldata['hospital_code'], alldata['hospital_code'], "%s修改了一个菜单权限组的菜单权限:%s"%(name,oc))
     operation_log(self.db).addLog(alldata['create_id'],alldata['hospital_code'],'menus_aut_group_manage',"修改了一个菜单权限组的菜单权限:%s"%oc,alldata['menu_group_id'])    
     self.response(ids)  
 def put(self):
     # 取POST Form提交的数据
     alldata = self.getRequestData()
     inst = entity.Menuadmin(self.db)
     #先删除所有
     inst.remove(alldata['user_id'],
                 table="system.menu_authority_group_relation",
                 key='user_id',
                 delete=True)
     #再循环插入
     #if not alldata['groups']:
     #    raise BaseError(801)
     ids = 0
     for group_id in alldata['groups']:
         lstData = {
             'group_id':
             group_id,
             'create_time':
             time.strftime("%Y-%m-%d %H:%M:%S",
                           time.localtime(time.time())),
             'user_id':
             alldata['user_id'],
             'create_id':
             alldata['update_id']
         }
         id = inst.save(lstData,
                        table='system.menu_authority_group_relation')
         if id <= 0:
             raise BaseError(703)  #参数错误
         ids += 1
     operation_log(
         self.db).addLog(alldata['update_id'], alldata['hospital_code'],
                         'menus_aut_group_manage', "给用户授予菜单权限组",
                         alldata['user_id'])  #'menus_aut_user_group'
     self.response(ids)
Beispiel #3
0
 def delete(self):
     alldata = self.getRequestData()
     e = itemEntity.MenuItem(self.db)
     r = e.remove(alldata['id'], delete=True)
     operation_log(self.db).addLog(alldata['uid'], alldata['hospital_code'],
                                   'edit_menu_item', "删除菜单项", alldata['id'])
     self.response(r)
Beispiel #4
0
 def post(self):
     # 取POST Form提交的数据
     alldata = self.getRequestData()
     inst = entity.Menuadmin(self.db)
     user = self.objUserInfo['name']
     #先删除所有
     inst.remove(alldata['user_id'],table="system.menu_authority_relation",key='user_id',delete=True)
     #再循环插入
     #if not alldata['items']:
      #   raise BaseError(801)
     ids=0
     for menu_item_id in alldata['items']:
         lstData = {
             'menu_item_id':menu_item_id,
             'create_time':time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time())),           
             'user_id':alldata['user_id'],
             'create_id':alldata['create_id']
         }            
         id = inst.save(lstData,table='system.menu_authority_relation')
         if id <= 0:
             raise BaseError(703)  #参数错误 
         ids+=1
     cur=self.db.getCursor()
     cur.execute("select name from public.account where id=%s"%alldata['user_id'])
     rows = cur.fetchall()
     oc=rows[0][0]      
     operation_log(self.db).addLog(alldata['create_id'],alldata['hospital_code'],'menus_aut_user',"%s给用户%s授予菜单权限"%(user,oc),alldata['user_id'])
     #msg=Message(self.db)
     #msg.addMsg(alldata['hospital_code'], alldata['hospital_code'],"%s给用户%s授予菜单权限"%(user,oc))
     self.response(ids)    
Beispiel #5
0
    def put(self):
        # 取POST Form提交的数据
        alldata = self.getRequestData()
        inst = itemEntity.MenuItem(self.db)
        #先查看该菜单项类型是否存在
        id = alldata['id']
        cur = self.db.getCursor()
        cur.execute(
            "select id from system.menu_item where type=%s and menu_id=%s and id<>%s"
            % (alldata['type'], alldata['menu_id'], id))
        if cur.fetchall():
            raise BaseError(808)  #以存在

        rows = []
        lstData = {
            'menu_code': 'menu_code',
            'update_id': 'update_id',
            'update_time': 'update_time',
            'menu_id': 'menu_id',
            'type': 'type',
            'path': 'path'
        }
        data = {}
        for (k, v) in lstData.items():
            try:
                if k == 'menu_id' or k == 'type':
                    if alldata[v] == "" or alldata[v] is None:
                        raise BaseError(801)
                    data[k] = alldata[v]
                elif k == "update_time":
                    try:
                        data[k] = time.strftime("%Y-%m-%d %H:%M:%S",
                                                time.localtime(time.time()))
                    except Exception as ex:
                        print(ex)
                elif k == "update_id":
                    if alldata[v] is None:
                        pass
                    else:
                        data[k] = alldata[v]
                else:
                    data[k] = alldata[v]
            except:
                pass

        if data is None or data == {}:
            raise BaseError(801)  #参数错误
        id = inst.save(data, id, table='system.menu_item')
        if id <= 0:
            raise BaseError(703)  #参数错误
        operation_log(self.db).addLog(alldata['update_id'],
                                      alldata['hospital_code'],
                                      'edit_menu_item',
                                      "修改菜单项:" + alldata['menu_code'],
                                      alldata['id'])
        self.response(id)
Beispiel #6
0
 def delete(self):
     alldata = self.getRequestData()
     e = entity.Menuadmin(self.db)  
     r=e.remove(alldata['id'],delete=True)
     #删除下一级菜单
     e.remove(alldata['id'],key='parent_id',delete=True)
     if r<=0:
         raise BaseError(703)
     operation_log(self.db).addLog(alldata['uid'],alldata['hospital_code'],'edit_menu',"删除菜单",alldata['id'])
     self.response(r) 
Beispiel #7
0
 def delete(self):
     alldata = self.getRequestData()
     e = entity.Menuadmin(self.db)
     r = e.remove(alldata['id'], delete=True)
     #删除下一级菜单
     e.remove(alldata['id'], key='parent_id', delete=True)
     if r <= 0:
         raise BaseError(703)
     operation_log(self.db).addLog(alldata['uid'], alldata['hospital_code'],
                                   'edit_menu', "删除菜单", alldata['id'])
     self.response(r)
Beispiel #8
0
    def put(self):
        # 取POST Form提交的数据
        alldata = self.getRequestData()
        inst = entity.Menuadmin(self.db)
        #先查看code是否存在
        id = alldata['id']
        cur = self.db.getCursor()
        cur.execute("select id from system.menu where code='%s' and id<>%s" %
                    (alldata['code'], id))
        if cur.fetchall():
            raise BaseError(807)  #code以存在
        rows = []
        lstData = {
            'code': 'code',
            'name': 'name',
            'sort': 'sort',
            'tier': 'tier',
            'parent_id': 'parent_id',
            'parent_code': 'parent_code',
            'update_id': 'update_id',
            'update_time': 'update_time'
        }
        data = {}
        for (k, v) in lstData.items():
            try:
                if k == 'code' or k == 'name':
                    if alldata[v] == "" or alldata[v] is None:
                        raise BaseError(801)
                    data[k] = alldata[v]
                elif k == "update_time":
                    try:
                        data[k] = time.strftime("%Y-%m-%d %H:%M:%S",
                                                time.localtime(time.time()))
                    except Exception as ex:
                        print(ex)
                elif k == "update_id" or k == "parent_id" or k == "parent_code":
                    if alldata[v] is None:
                        pass
                    else:
                        data[k] = alldata[v]
                else:
                    data[k] = alldata[v]
            except:
                pass

        if data is None or data == {}:
            raise BaseError(801)  #参数错误
        id = inst.save(data, id, table='system.menu')
        if id <= 0:
            raise BaseError(703)  #参数错误
        operation_log(self.db).addLog(alldata['update_id'],
                                      alldata['hospital_code'], 'edit_menu',
                                      "修改菜单:" + alldata['name'], alldata['id'])
        self.response(id)
Beispiel #9
0
 def put(self):
     # 取POST Form提交的数据
     alldata = self.getRequestData()
     inst = entity.Menuadmin(self.db)
     #先查看code是否存在
     id=alldata['id']
     cur=self.db.getCursor()
     cur.execute("select id from system.menu where code='%s' and id<>%s"% (alldata['code'],id))
     if cur.fetchall():
         raise BaseError(807)  #code以存在        
     rows = []
     lstData = {
         'code':'code',
         'name':'name',           
         'sort':'sort',             
         'tier':'tier',               
         'parent_id':'parent_id',                   
         'parent_code':'parent_code',          
         'update_id':'update_id',
         'update_time':'update_time'
     }
     data = {}
     for (k, v) in lstData.items():
         try:
             if k == 'code' or k == 'name':
                 if alldata[v]=="" or alldata[v] is None:
                     raise BaseError(801)
                 data[k] = alldata[v]
             elif k=="update_time":
                 try:
                     data[k]=time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()))
                 except Exception as ex:
                     print(ex)
             elif k=="update_id" or k=="parent_id" or k=="parent_code":
                 if alldata[v] is None:
                     pass
                 else : 
                     data[k] = alldata[v]
             else :
                 data[k] = alldata[v]
         except:
             pass
     
     if data is None or data == {}:
         raise BaseError(801)  #参数错误
     id = inst.save(data,id, table='system.menu')
     if id <= 0:
         raise BaseError(703)  #参数错误 
     operation_log(self.db).addLog(alldata['update_id'],alldata['hospital_code'],'edit_menu',"修改菜单:"+alldata['name'],alldata['id'])
     self.response(id)    
Beispiel #10
0
 def put(self):
     # 取POST Form提交的数据
     alldata = self.getRequestData()
     inst = itemEntity.MenuItem(self.db)
     #先查看该菜单项类型是否存在
     id=alldata['id']
     cur=self.db.getCursor()
     cur.execute("select id from system.menu_item where type=%s and menu_id=%s and id<>%s"% (alldata['type'],alldata['menu_id'],id))
     if cur.fetchall():
         raise BaseError(808)  #以存在
     
     rows = []
     lstData = {
         'menu_code':'menu_code',         
         'update_id':'update_id',
         'update_time':'update_time',
         'menu_id':'menu_id',
         'type':'type',
         'path':'path'
     }
     data = {}
     for (k, v) in lstData.items():
         try:
             if k == 'menu_id' or k == 'type':
                 if alldata[v]=="" or alldata[v] is None:
                     raise BaseError(801)
                 data[k] = alldata[v]
             elif k=="update_time":
                 try:
                     data[k]=time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()))
                 except Exception as ex:
                     print(ex)   
             elif k=="update_id":
                 if alldata[v] is None:
                     pass
                 else : 
                     data[k] = alldata[v]                
             else :
                 data[k] = alldata[v]
         except:
             pass
     
     if data is None or data == {}:
         raise BaseError(801)  #参数错误
     id = inst.save(data,id,table='system.menu_item')
     if id <= 0:
         raise BaseError(703)  #参数错误 
     operation_log(self.db).addLog(alldata['update_id'],alldata['hospital_code'],'edit_menu_item',"修改菜单项:"+alldata['menu_code'],alldata['id'])
     self.response(id)    
Beispiel #11
0
 def put(self):
     # 取POST Form提交的数据
     alldata = self.getRequestData()
     inst = entity.Meun_ag_manage(self.db)
     #先删除所有
     inst.remove(alldata['menu_group_id'],
                 table="system.menu_authority_relation_group",
                 key='menu_group_id',
                 delete=True)
     #再循环插入
     #if not alldata['items']:
     #    raise BaseError(801)
     ids = 0
     for menu_item_id in alldata['items']:
         lstData = {
             'menu_group_id':
             alldata['menu_group_id'],
             'create_id':
             alldata['create_id'],
             'create_time':
             time.strftime("%Y-%m-%d %H:%M:%S",
                           time.localtime(time.time())),
             'menu_item_id':
             menu_item_id
         }
         id = inst.save(lstData,
                        table='system.menu_authority_relation_group')
         if id <= 0:
             raise BaseError(703)  #参数错误
         ids += 1
     cur = self.db.getCursor()
     cur.execute(
         "select name from SYSTEM.MENU_AUTHORITY_GROUP where id=%s" %
         alldata['menu_group_id'])
     rows = cur.fetchall()
     oc = rows[0][0]
     if not self.objUserInfo:
         raise BaseError(604)
     name = self.objUserInfo['name']
     #msg=Message(self.db)
     #msg.addMsg(alldata['hospital_code'], alldata['hospital_code'], "%s修改了一个菜单权限组的菜单权限:%s"%(name,oc))
     operation_log(self.db).addLog(alldata['create_id'],
                                   alldata['hospital_code'],
                                   'menus_aut_group_manage',
                                   "修改了一个菜单权限组的菜单权限:%s" % oc,
                                   alldata['menu_group_id'])
     self.response(ids)
Beispiel #12
0
 def delete(self):
     objdata = self.getRequestData()
     s = entity.Meun_ag_manage(self.db)
     cur=self.db.getCursor()
     cur.execute("select name from SYSTEM.MENU_AUTHORITY_GROUP where id=%s"%objdata['id'])
     rows = cur.fetchall() 
     oc=rows[0][0]
     r=s.remove(objdata['id'],delete=True)
     s.remove(objdata['id'],table="system.menu_authority_relation_group",key="menu_group_id",delete=True)
     s.remove(objdata['id'],table="system.menu_authority_group_relation",key="group_id",delete=True)
     if not self.objUserInfo :
         raise BaseError(604)
     name = self.objUserInfo['name']
     #msg=Message(self.db)
     #msg.addMsg(objdata['hospital_code'], objdata['hospital_code'], "%s删除了一个菜单权限组:%s"%(name,oc))
     operation_log(self.db).addLog(objdata['uid'],objdata['hospital_code'],'menus_aut_group_manage',"删除了一个菜单权限组:%s"%oc,objdata['id'])
     self.response(r)
Beispiel #13
0
 def post(self):
     # 取POST Form提交的数据
     objdata = self.getRequestData()
     s = entity.Meun_ag_manage(self.db)
     cur=self.db.getCursor()
     cur.execute("select count('id') from  system.menu_authority_group where name='%s' and hospital_code='%s'" %(objdata['name'],objdata['hospital_code']))
     rows = cur.fetchall()
     su=rows[0][0]
     if su:
         raise BaseError(891)
     lstData = {
         'create_id':'create_id',
         'name':'name',           
         'create_time':'create_time',
         'hospital_code':'hospital_code'
     }
     data = {}
     for (k, v) in lstData.items():
         try:
             if k == 'hospital_code' or k == 'name':
                 if objdata[v]=="" or objdata[v] is None:
                     raise BaseError(801)
                 data[k] = objdata[v]
             elif k=="create_time":
                 try:
                     data[k]=time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()))
                 except Exception as ex:
                     print(ex)                  
             else :
                 data[k]=objdata[v]
         except:
             pass
     if data is None or data == {}:
         raise BaseError(801)  #参数错误
 
     id =s.save(data,table='system.menu_authority_group')
     if id <= 0:
         raise BaseError(703)  #参数错误 
     if not self.objUserInfo :
         raise BaseError(604)
     name = self.objUserInfo['name']
     #msg=Message(self.db)
     #msg.addMsg(objdata['hospital_code'], objdata['hospital_code'], "%s新增了一个菜单权限组:%s"%(name,objdata['name']))
     operation_log(self.db).addLog(objdata['create_id'],objdata['hospital_code'],'menus_aut_group_manage',"新增了一个菜单权限组:%s"%objdata['name'],id)
     self.response(id)
Beispiel #14
0
 def post(self):
     # 取POST Form提交的数据
     alldata = self.getRequestData()
     inst = entity.Menuadmin(self.db)
     user = self.objUserInfo['name']
     #先删除所有
     inst.remove(alldata['user_id'],
                 table="system.menu_authority_relation",
                 key='user_id',
                 delete=True)
     #再循环插入
     #if not alldata['items']:
     #   raise BaseError(801)
     ids = 0
     for menu_item_id in alldata['items']:
         lstData = {
             'menu_item_id':
             menu_item_id,
             'create_time':
             time.strftime("%Y-%m-%d %H:%M:%S",
                           time.localtime(time.time())),
             'user_id':
             alldata['user_id'],
             'create_id':
             alldata['create_id']
         }
         id = inst.save(lstData, table='system.menu_authority_relation')
         if id <= 0:
             raise BaseError(703)  #参数错误
         ids += 1
     cur = self.db.getCursor()
     cur.execute("select name from public.account where id=%s" %
                 alldata['user_id'])
     rows = cur.fetchall()
     oc = rows[0][0]
     operation_log(self.db).addLog(alldata['create_id'],
                                   alldata['hospital_code'],
                                   'menus_aut_user',
                                   "%s给用户%s授予菜单权限" % (user, oc),
                                   alldata['user_id'])
     #msg=Message(self.db)
     #msg.addMsg(alldata['hospital_code'], alldata['hospital_code'],"%s给用户%s授予菜单权限"%(user,oc))
     self.response(ids)
Beispiel #15
0
	def delete(self):

		cur=self.db.getCursor()
		alldata = self.getRequestData()
		sql="delete from public.doctor a where a.id=%s " % (alldata['doctor_id'])
		#print ("delete"+sql)
		cur.execute(sql)

		#sql="select a.name from public.hospital_account a where a.id=%s " % (alldata['update_person_id']) 
		cur.execute(sql)
		row = cur.fetchone()


		log_str=":删除了医生%s的信息" % (alldata['doctor_name'])
		log_str1="%s删除了医生%s的信息" % (row[0],alldata['doctor_name'])

		operation_log(self.db).addLog(alldata['update_person_id'],alldata['hospital_code'],'Doctor',log_str1,103)
		msg=Message(self.db)
		msg.addMsg(alldata['hospital_code'], alldata['hospital_code'], log_str1);  

		self.response("Operation OK")
Beispiel #16
0
    def put(self):
        # 取POST Form提交的数据
        objdata = self.getRequestData()
        s = entity.Meun_ag_manage(self.db)
        lstData = {
            'update_id':'update_id',
            'name':'name',           
            'update_time':'update_time'
        }
        data = {}
        for (k, v) in lstData.items():
            try:
                if k == 'update_id' or k == 'name':
                    if objdata[v]=="" or objdata[v] is None:
                        raise BaseError(801)
                    data[k] = objdata[v]
                elif k=="update_time":
                    try:
                        data[k]=time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()))
                    except Exception as ex:
                        print(ex)                  
                else :
                    data[k] = objdata[v]
            except:
                pass
        if data is None or data == {}:
            raise BaseError(801)  #参数错误
    
        id =s.save(data,objdata['id'],table='system.menu_authority_group')
        if id <= 0:
            raise BaseError(703)  #参数错误
        if not self.objUserInfo :
            raise BaseError(604)
        name = self.objUserInfo['name']

        #msg=Message(self.db)
        #msg.addMsg(objdata['hospital_code'], objdata['hospital_code'], "%s新增了一个菜单权限组:%s"%(name,objdata['name'])) 
        operation_log(self.db).addLog(objdata['update_id'],objdata['hospital_code'],'menus_aut_group_manage',"修改了一个菜单权限组:%s"%objdata['name'],objdata['id'])
        self.response(id)
Beispiel #17
0
    def delete(self):

        cur = self.db.getCursor()
        alldata = self.getRequestData()
        sql = "delete from public.doctor a where a.id=%s " % (
            alldata['doctor_id'])
        #print ("delete"+sql)
        cur.execute(sql)

        #sql="select a.name from public.hospital_account a where a.id=%s " % (alldata['update_person_id'])
        cur.execute(sql)
        row = cur.fetchone()

        log_str = ":删除了医生%s的信息" % (alldata['doctor_name'])
        log_str1 = "%s删除了医生%s的信息" % (row[0], alldata['doctor_name'])

        operation_log(self.db).addLog(alldata['update_person_id'],
                                      alldata['hospital_code'], 'Doctor',
                                      log_str1, 103)
        msg = Message(self.db)
        msg.addMsg(alldata['hospital_code'], alldata['hospital_code'],
                   log_str1)

        self.response("Operation OK")
Beispiel #18
0
    def put(self):

        mtime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')

        mtype = self.get_argument('type', default='')
        upload = self.get_argument('upload', default='')

        name = self.get_argument('name', default='')
        dept_id = self.get_argument('dept_id', default='')
        account_id = self.get_argument('account_id', default='')
        his_id = self.get_argument('his_id', default='')
        title_id = self.get_argument('title_id', default='')
        post_id = self.get_argument('post_id', default='')
        update_person_id = self.get_argument('update_person_id', default='')
        hospital_code = self.get_argument('hospital_code', default='')
        introduce = self.get_argument('introduce', default='')
        phone = self.get_argument('phone', default='')
        doc_id = self.get_argument('doc_id', default='')

        cur = self.db.getCursor()
        upload_path = self.getUploadPath()

        if (mtype == "modify"):

            sql = "update public.doctor  set name='%s',dept_id=%s,account_id='%s',his_id=%s,title='%s',post='%s',update_time='%s',update_id=%s ,hospital_code='%s',introduce='%s',phone='%s' where id=%s " % (
                name, dept_id, account_id, his_id, title_id, post_id, mtime,
                update_person_id, hospital_code, introduce, phone, doc_id)
            cur.execute(sql)

            #sql="select a.name from public.hospital_account a where a.id=%s " % (update_person_id)
            cur.execute(sql)
            row = cur.fetchone()

            log_str1 = "%s修改了医生%s的信息" % (row[0], name)

            operation_log(self.db).addLog(update_person_id, hospital_code,
                                          'Doctor', log_str1, 101)
            msg = Message(self.db)
            msg.addMsg(hospital_code, hospital_code, log_str1)

            if (int(upload) == 1):

                file_metas = self.request.files['file']
                data = {}
                file_id = 0
                for meta in file_metas:
                    filename = meta['filename']
                    if len(meta['body']) > 4194304:  #文件大于4M则不允许上传

                        data['code'] = 1
                        data['message'] = "文件大于4M则不允许上传"
                    else:
                        timeStamp = int(time.time())
                        fname = str(timeStamp) + '.' + filename.split(
                            '.').pop()  #生成新的文件名
                        filepath = os.path.join(upload_path, fname)
                        #有些文件需要已二进制的形式存储,实际中可以更改
                        with open(filepath, 'wb') as up:
                            up.write(meta['body'])
                        data['code'] = 0
                        data['message'] = "文件上传成功"

                        sql = "insert into public.file (create_time,create_id,file_name,path) values ('%s', %s,'%s','%s') " % (
                            mtime, update_person_id, fname, filepath)
                        cur.execute(sql)

                        sql = "select max(a.id) from public.file a where a.create_time='%s' and a.file_name='%s' " % (
                            mtime, fname)
                        cur.execute(sql)
                        row = cur.fetchone()
                        file_id = row[0]

                        sql = "update public.doctor  set photo_file=%s  where id=%s  " % (
                            file_id, doc_id)
                        #print (sql)
                        cur.execute(sql)

            self.response("Modify Operation OK")
Beispiel #19
0
	def put(self):
	
		mtime=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')

		mtype=self.get_argument('type', default='')
		upload=self.get_argument('upload', default='')

		name=self.get_argument('name', default='')
		dept_id=self.get_argument('dept_id', default='')
		account_id=self.get_argument('account_id', default='')
		his_id=self.get_argument('his_id', default='')
		title_id=self.get_argument('title_id', default='')
		post_id=self.get_argument('post_id', default='')
		update_person_id=self.get_argument('update_person_id', default='')
		hospital_code=self.get_argument('hospital_code', default='')
		introduce=self.get_argument('introduce', default='')
		phone=self.get_argument('phone', default='')
		doc_id=self.get_argument('doc_id', default='')


		cur=self.db.getCursor()
		upload_path=self.getUploadPath()


		if(mtype=="modify"):


		
			sql="update public.doctor  set name='%s',dept_id=%s,account_id='%s',his_id=%s,title='%s',post='%s',update_time='%s',update_id=%s ,hospital_code='%s',introduce='%s',phone='%s' where id=%s " %( name,dept_id,account_id,his_id,title_id,post_id,mtime,update_person_id,hospital_code,introduce,phone,doc_id)
			cur.execute(sql)


			#sql="select a.name from public.hospital_account a where a.id=%s " % (update_person_id) 
			cur.execute(sql)
			row = cur.fetchone()

			log_str1="%s修改了医生%s的信息" % (row[0],name)

			operation_log(self.db).addLog(update_person_id,hospital_code,'Doctor',log_str1,101)
			msg=Message(self.db)
			msg.addMsg(hospital_code,hospital_code,log_str1);  

			if(int(upload)==1):

				file_metas=self.request.files['file']  
				data={}
				file_id=0
				for meta in file_metas:
					filename=meta['filename']
					if len(meta['body'])>4194304:#文件大于4M则不允许上传

						data['code']=1
						data['message']="文件大于4M则不允许上传"                
					else:
						timeStamp = int(time.time())
						fname=str(timeStamp)+'.'+filename.split('.').pop()#生成新的文件名
						filepath=os.path.join(upload_path,fname)
						#有些文件需要已二进制的形式存储,实际中可以更改
						with open(filepath,'wb') as up:      
							up.write(meta['body'])
						data['code']=0
						data['message']="文件上传成功"


						sql="insert into public.file (create_time,create_id,file_name,path) values ('%s', %s,'%s','%s') " %( mtime,update_person_id,fname,filepath)
						cur.execute(sql)

						sql="select max(a.id) from public.file a where a.create_time='%s' and a.file_name='%s' " % (mtime,fname)
						cur.execute(sql)
						row = cur.fetchone()
						file_id=row[0]

						sql="update public.doctor  set photo_file=%s  where id=%s  " %(file_id,doc_id) 
						#print (sql)
						cur.execute(sql)


			self.response("Modify Operation OK")
Beispiel #20
0
 def delete(self):
     alldata = self.getRequestData()
     e = itemEntity.MenuItem(self.db)
     r=e.remove(alldata['id'],delete=True)
     operation_log(self.db).addLog(alldata['uid'],alldata['hospital_code'],'edit_menu_item',"删除菜单项",alldata['id'])
     self.response(r)