浏览代码

添加获取附件信息的接口

wuww 6 年之前
父节点
当前提交
34f64a6c30
共有 2 个文件被更改,包括 28 次插入0 次删除
  1. 21 0
      controllers/partial/SysAttachmentController.go
  2. 7 0
      light-apiengine.xml

+ 21 - 0
controllers/partial/SysAttachmentController.go

@@ -160,6 +160,27 @@ func SysAttachment_Delete(c *entitys.CtrlContext) {
 	c.Ctx.JSON(200, sysmodel.SysReturn{200, "", attrId})
 }
 
+// _Get
+// @Title _Get
+// @Description 获取附件信息
+// @Param	id    string  false  "附件id"
+// @Success 200 {object} Account
+// @Failure 403 :id is empty
+func SysAttachment_Get(c *entitys.CtrlContext) {
+	var id = c.Ctx.Query("id")
+	attach := sysmodel.SysAttachment{Id:id}
+	has, err := c.PlatformDbEngine.Get(&attach)
+	if err == nil {
+		if has {
+			c.Ctx.JSON(200, sysmodel.SysReturn{200, "", attach})
+		} else {
+			c.Ctx.JSON(200, sysmodel.SysReturn{500, "附件不存在", nil})
+		}
+	} else {
+		c.Ctx.JSON(200, sysmodel.SysReturn{500, err.Error(), nil})
+	}
+}
+
 func doUpload(c *entitys.CtrlContext) (*sysmodel.SysAttachment, error) {
 	file, fInfo, err := c.Ctx.Request.FormFile("file")
 	if err != nil {

+ 7 - 0
light-apiengine.xml

@@ -29,6 +29,13 @@
             </api>
         </controller>
         <controller name="sys_attachment" desc="系统管理" skip_login="true">
+            <api name="get" desc="获取附件信息" method="get">
+                <param name="id" type="string" desc="附件id" />
+                <return>
+                    <success ref="$sys_return"></success>
+                    <failure ref="$sys_return"></failure>
+                </return>
+            </api>
             <api name="upload" desc="上传文件" method="post">
                 <return>
                     <success ref="$sys_return"></success>