1.修改合同相关接口返回结构;
This commit is contained in:
parent
ad773bac1b
commit
15c6dda42a
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
"go-admin/app/admin/models/bus_models"
|
||||
"go-admin/app/admin/service/bus_service"
|
||||
"go-admin/tools/app"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -38,11 +39,12 @@ func (e *ContractApi) CreateContract(c *gin.Context) {
|
|||
|
||||
resp, err := s.CreateContract(c, req)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
app.Error(c, http.StatusInternalServerError, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "新增成功", "data": resp})
|
||||
app.OK(c, resp, "新增成功")
|
||||
return
|
||||
}
|
||||
|
||||
// EditContract 编辑合同信息
|
||||
|
@ -73,12 +75,12 @@ func (e *ContractApi) EditContract(c *gin.Context) {
|
|||
// 调用服务层逻辑
|
||||
err = s.EditContract(req)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
app.Error(c, http.StatusInternalServerError, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 返回成功响应
|
||||
c.JSON(http.StatusOK, gin.H{"message": "合同信息更新成功"})
|
||||
app.OK(c, "", "合同信息更新成功")
|
||||
return
|
||||
}
|
||||
|
||||
// ContractList 获取合同列表
|
||||
|
@ -106,11 +108,12 @@ func (e *ContractApi) ContractList(c *gin.Context) {
|
|||
|
||||
resp, err := s.ListContracts(req)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
app.Error(c, http.StatusInternalServerError, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"data": resp})
|
||||
app.OK(c, resp, "查询成功")
|
||||
return
|
||||
}
|
||||
|
||||
// ContractDetail 获取合同详情
|
||||
|
@ -138,11 +141,12 @@ func (e *ContractApi) ContractDetail(c *gin.Context) {
|
|||
|
||||
resp, err := s.GetContractDetail(req)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
app.Error(c, http.StatusInternalServerError, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"data": resp})
|
||||
app.OK(c, resp, "查询成功")
|
||||
return
|
||||
}
|
||||
|
||||
// EditContractRemark 编辑合同备注
|
||||
|
@ -169,11 +173,12 @@ func (e *ContractApi) EditContractRemark(c *gin.Context) {
|
|||
}
|
||||
|
||||
if err := s.UpdateContractRemark(req); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
app.Error(c, http.StatusInternalServerError, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "备注更新成功"})
|
||||
app.OK(c, "", "备注更新成功")
|
||||
return
|
||||
}
|
||||
|
||||
// InvalidContract 作废合同
|
||||
|
@ -199,11 +204,12 @@ func (e *ContractApi) InvalidContract(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
if err := s.InvalidateContract(req); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
app.Error(c, http.StatusInternalServerError, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "合同已作废"})
|
||||
app.OK(c, "", "合同已作废")
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteContract 删除合同
|
||||
|
@ -230,16 +236,17 @@ func (e *ContractApi) DeleteContract(c *gin.Context) {
|
|||
}
|
||||
|
||||
if err = s.RemoveContract(req); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
app.Error(c, http.StatusInternalServerError, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "合同已删除"})
|
||||
app.OK(c, "", "合同已删除")
|
||||
return
|
||||
}
|
||||
|
||||
// GetContractDownloadLink 获取合同下载链接
|
||||
// @Summary 获取合同下载链接
|
||||
// @Tags 合同管理
|
||||
// @Tags 合同管理-V1.0.0
|
||||
// @Produce json
|
||||
// @Accept json
|
||||
// @Param request body bus_models.GetContractDownloadLinkReq true "获取合同下载链接请求"
|
||||
|
@ -265,10 +272,10 @@ func (e *ContractApi) GetContractDownloadLink(c *gin.Context) {
|
|||
// 调用服务层逻辑
|
||||
resp, err := s.GetContractDownloadLink(req)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
app.Error(c, http.StatusInternalServerError, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 返回下载链接
|
||||
c.JSON(http.StatusOK, resp)
|
||||
app.OK(c, resp, "查询成功")
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user