1.修改合同相关接口返回结构;

This commit is contained in:
chenlin 2025-04-09 10:20:02 +08:00
parent ad773bac1b
commit 15c6dda42a

View File

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