Beispiel #1
0
 def patch(self):
     #通过id获取详细信息
     s = entity.Upload(self.db)
     alldata = self.getRequestData()
     cur = self.db.getCursor()
     data = {}
     #获取案例学习信息
     cur.execute(
         "select a.id,a.name,b.name as creater_name,a.create_time,a.related_case,a.detail from public.case_learn a "
         "left join public.account b on a.create_id=b.id "
         "where a.id=%s" % (alldata['case_id']))
     rows = cur.fetchall()
     rowdata = {}
     rowdata[
         'struct'] = "id,name,creater_name,create_time,related_case,detail"
     rowdata['rows'] = rows
     data['medcase'] = rowdata
     #获取文件信息
     rowdata = {}
     cur.execute(
         "select a.id,a.file_id,a.file_name,a.size,a.remark,b.path from public.case_learn_file a "
         "left join public.file b on a.file_id=b.id "
         "where a.case_id=%s " % (alldata['case_id']))
     rows = cur.fetchall()
     rowdata['struct'] = "id,file_id,file_name,size,remark,path"
     rowdata['rows'] = rows
     data['files'] = rowdata
     self.response(data)
Beispiel #2
0
    def delete(self):
        objdata = self.getRequestData()
        inst = entity.Upload(self.db)

        lstData = {"id": "id"}
        data = {}
        eid = inst.remove(data["id"],
                          table="medrec.upload",
                          key="id",
                          delete=True)
        self.response(eid)
Beispiel #3
0
    def get(self):

        s = entity.Upload(self.db)

        cond2 = {
            "select": "id,upload_filename,upload_filePath",
            "where": "id>0",
        }

        result = s.find(cond2)
        self.response(result)
Beispiel #4
0
    def post(self):

        user = self.objUserInfo

        uid = "1"
        if user:
            uid = user["id"]

        module = self.get_argument("module", default="tm")
        modulePath = os.path.join(os.path.dirname(__file__),
                                  "../../app/uploads/" + module)
        os.makedirs(modulePath, exist_ok=True)

        file_metas = self.request.files["upfile"]
        for meta in file_metas:
            fname = meta["filename"]
            ftype = meta["content_type"]

            saveName = self.getSaveFileName(modulePath, fname)
            filePath = os.path.join(modulePath, saveName)
            fileUrl = "uploads/" + module + "/" + saveName

            #print("upload_path : " + modulePath)
            #print("fileUrl : " + fileUrl)
            #print("filePath : " + filePath)

            with open(filePath, "wb") as up:
                up.write(meta["body"])

            s = entity.Upload(self.db)
            data = {
                "file_name": fname,
                "create_time": self.now_time(),
                "update_time": self.now_time(),
                "path": fileUrl,
                "create_id": uid,
                "update_id": uid,
            }
            fid = s.add(data)
            data["id"] = fid
            #self.response(data)
            #return "{'url':'" + ueconfig_url + '/' + newFileName + "','title':'" + picTitle + "','original':'" + fileName + "','state':'" + "SUCCESS" + "'}"
            #return "{'url':'" + fileUrl + '/' + saveName + "','title':'" + saveName + "','original':'" + fname + "','state':'" + "SUCCESS" + "'}"
            lsData = {
                'url': fileUrl,
                'title': saveName,
                'original': fname,
                'state': 'SUCCESS'
            }
            self.response(lsData)
Beispiel #5
0
    def post(self):

        user = self.objUserInfo

        uid = "1"
        if user:
            uid = user["id"]

        module = self.get_argument("module", default="common")
        modulePath = os.path.join(os.path.dirname(__file__),
                                  "../../app/uploads/" + module)
        os.makedirs(modulePath, exist_ok=True)

        file_metas = self.request.files["file"]
        for meta in file_metas:
            fname = meta["filename"]
            ftype = meta["content_type"]

            saveName = self.getSaveFileName(modulePath, fname)
            filePath = os.path.join(modulePath, saveName)
            fileUrl = "uploads/" + module + "/" + saveName

            #print("upload_path : " + modulePath)
            #print("fileUrl : " + fileUrl)
            #print("filePath : " + filePath)

            with open(filePath, "wb") as up:
                up.write(meta["body"])

            s = entity.Upload(self.db)
            data = {
                "file_name": fname,
                "create_time": self.now_time(),
                "update_time": self.now_time(),
                "path": fileUrl,
                "create_id": uid,
                "update_id": uid,
            }
            fid = s.add(data)
            data["id"] = fid
            self.response(data)
Beispiel #6
0
    def get(self):
        s = entity.Upload(self.db)
        action = self.get_argument("action", default="")
        if action == 'config':
            data = {
                #上传图片配置项
                "imageActionName":
                "uploadimage",
                "imageFieldName":
                "upfile",
                "imageMaxSize":
                2048000,
                "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"],
                "imageCompressEnable":
                True,
                "imageCompressBorder":
                1600,
                "imageInsertAlign":
                "none",
                "imageUrlPrefix":
                "",
                "imagePathFormat":
                "../../app/uploads/{yyyy}{mm}{dd}/{time}{rand:6}",

                #涂鸦图片上传配置项
                "scrawlActionName":
                "uploadscrawl",
                "scrawlFieldName":
                "upfile",
                "scrawlPathFormat":
                "../../app/uploads/{yyyy}{mm}{dd}/{time}{rand:6}",
                "scrawlMaxSize":
                2048000,
                "scrawlUrlPrefix":
                "",
                "scrawlInsertAlign":
                "none",

                #/* 截图工具上传 */
                "snapscreenActionName":
                "uploadimage",
                "snapscreenPathFormat":
                "../../app/uploads/{yyyy}{mm}{dd}/{time}{rand:6}",
                "snapscreenUrlPrefix":
                "",
                "snapscreenInsertAlign":
                "none",

                #/* 抓取远程图片配置 */
                "catcherLocalDomain":
                ["127.0.0.1", "localhost", "img.baidu.com"],
                "catcherActionName":
                "catchimage",
                "catcherFieldName":
                "source",
                "catcherPathFormat":
                "../../app/uploads/{yyyy}{mm}{dd}/{time}{rand:6}",
                "catcherUrlPrefix":
                "",
                "catcherMaxSize":
                2048000,
                "catcherAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"],

                #/* 上传视频配置 */
                "videoActionName":
                "uploadvideo",
                "videoFieldName":
                "upfile",
                "videoPathFormat":
                "../../app/uploads/{yyyy}{mm}{dd}/{time}{rand:6}",
                "videoUrlPrefix":
                "",
                "videoMaxSize":
                102400000,
                "videoAllowFiles": [
                    ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg",
                    ".mpg", ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm",
                    ".mp3", ".wav", ".mid"
                ],

                #/* 上传文件配置 */
                "fileActionName":
                "uploadfile",
                "fileFieldName":
                "upfile",
                "filePathFormat":
                "../../app/uploads/{yyyy}{mm}{dd}/{time}{rand:6}",
                "fileUrlPrefix":
                "",
                "fileMaxSize":
                51200000,
                "fileAllowFiles": [
                    ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".flv", ".swf",
                    ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", ".ogg",
                    ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav",
                    ".mid", ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2",
                    ".cab", ".iso", ".doc", ".docx", ".xls", ".xlsx", ".ppt",
                    ".pptx", ".pdf", ".txt", ".md", ".xml"
                ],

                #/* 列出指定目录下的图片 */
                "imageManagerActionName":
                "listimage",
                "imageManagerListPath":
                "../../app/uploads/",
                "imageManagerListSize":
                20,
                "imageManagerUrlPrefix":
                "",
                "imageManagerInsertAlign":
                "none",
                "imageManagerAllowFiles":
                [".png", ".jpg", ".jpeg", ".gif", ".bmp"],

                #/* 列出指定目录下的文件 */
                "fileManagerActionName":
                "listfile",
                "fileManagerListPath":
                "../../app/uploads/",
                "fileManagerUrlPrefix":
                "",
                "fileManagerListSize":
                20,
                "fileManagerAllowFiles": [
                    ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".flv", ".swf",
                    ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", ".ogg",
                    ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav",
                    ".mid", ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2",
                    ".cab", ".iso", ".doc", ".docx", ".xls", ".xlsx", ".ppt",
                    ".pptx", ".pdf", ".txt", ".md", ".xml"
                ]
            }

            self.response(data)