123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- /*
- * @description: 附件相关的接口api
- * @Author: LanJianRong
- * @Date: 2020-12-07 10:26:49
- * @FilePath: \construction_management\web\api\annex_api.go
- */
- package api
- import (
- "fmt"
- "strconv"
- "github.com/kataras/iris/v12"
- "go.mod/services"
- "go.mod/web/utils"
- )
- type AnnexApi struct {
- //框架-web应用上下文环境
- Ctx iris.Context
- // 需要用的service
- ServiceAnnex services.AnnexService
- }
- // @Summary 获取附件列表
- // @Tags 附件
- // @Description 获得附件列表
- // @Accept json
- // @Produce json
- // @Security ApiKeyAuth
- // @Param dataType path int true "附件类型"
- // @Param dataId path string true "源数据id"
- // @Success 200 {object} viewmodels.AnnexList "{code:0成功,data:viewmodels.AnnexList,msg:}"
- // @Failure 400 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
- // @Router /api/file [get]
- func (c *AnnexApi) Get() {
- // 1.规则验证
- annexData, err := c.ServiceAnnex.ValidRule(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- dataId, err := utils.GetDecryptId(annexData.DataId)
- dataType, err := strconv.Atoi(annexData.DataType)
- data = c.ServiceAnnex.Get(dataType, dataId)
- c.Ctx.JSON(iris.Map{
- "code": 0,
- "msg": "请求成功",
- "data": data,
- })
- }
|