后端重构
This commit is contained in:
@@ -9,14 +9,15 @@ import (
|
||||
|
||||
type AttachmentCategoryApi struct{}
|
||||
|
||||
// AddCategory 创建/更新分类
|
||||
// @Summary 创建/更新分类
|
||||
// @Tags ExaAttachmentCategory
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param data body CategoryRequest true "分类信息"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /attachmentCategory/addCategory [post]
|
||||
// AddCategory
|
||||
// @Tags ExaAttachmentCategory
|
||||
// @Summary 创建/更新分类
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body CategoryRequest true "分类信息"
|
||||
// @Success 200 {object} response.Response{msg=string} "创建/更新分类"
|
||||
// @Router /attachmentCategory/addCategory [post]
|
||||
func (api *AttachmentCategoryApi) AddCategory(c *gin.Context) {
|
||||
var req CategoryRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -38,14 +39,15 @@ func (api *AttachmentCategoryApi) AddCategory(c *gin.Context) {
|
||||
response.OkWithMessage("创建/更新成功", c)
|
||||
}
|
||||
|
||||
// DeleteCategory 删除分类
|
||||
// @Summary 删除分类
|
||||
// @Tags ExaAttachmentCategory
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param data body DeleteCategoryRequest true "分类ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /attachmentCategory/deleteCategory [post]
|
||||
// DeleteCategory
|
||||
// @Tags ExaAttachmentCategory
|
||||
// @Summary 删除分类
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body DeleteCategoryRequest true "分类ID"
|
||||
// @Success 200 {object} response.Response{msg=string} "删除分类"
|
||||
// @Router /attachmentCategory/deleteCategory [post]
|
||||
func (api *AttachmentCategoryApi) DeleteCategory(c *gin.Context) {
|
||||
var req DeleteCategoryRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -66,13 +68,14 @@ func (api *AttachmentCategoryApi) DeleteCategory(c *gin.Context) {
|
||||
response.OkWithMessage("删除成功", c)
|
||||
}
|
||||
|
||||
// GetCategoryList 获取分类列表
|
||||
// @Summary 获取分类列表
|
||||
// @Tags ExaAttachmentCategory
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} response.Response{data=[]CategoryResponse}
|
||||
// @Router /attachmentCategory/getCategoryList [get]
|
||||
// GetCategoryList
|
||||
// @Tags ExaAttachmentCategory
|
||||
// @Summary 获取分类列表
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Success 200 {object} response.Response{data=[]CategoryResponse,msg=string} "获取分类列表"
|
||||
// @Router /attachmentCategory/getCategoryList [get]
|
||||
func (api *AttachmentCategoryApi) GetCategoryList(c *gin.Context) {
|
||||
list, err := attachmentCategoryUsecase.GetCategoryList(c.Request.Context())
|
||||
if err != nil {
|
||||
|
||||
@@ -12,7 +12,15 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// BreakpointContinue 断点续传到服务器
|
||||
// BreakpointContinue
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Summary 断点续传到服务器
|
||||
// @Security ApiKeyAuth
|
||||
// @accept multipart/form-data
|
||||
// @Produce application/json
|
||||
// @Param file formData file true "断点续传示例"
|
||||
// @Success 200 {object} response.Response{msg=string} "断点续传到服务器"
|
||||
// @Router /fileUploadAndDownload/breakpointContinue [post]
|
||||
func (f *FileUploadApi) BreakpointContinue(c *gin.Context) {
|
||||
fileMd5 := c.Request.FormValue("fileMd5")
|
||||
fileName := c.Request.FormValue("fileName")
|
||||
@@ -59,7 +67,17 @@ func (f *FileUploadApi) BreakpointContinue(c *gin.Context) {
|
||||
response.OkWithMessage("切片创建成功", c)
|
||||
}
|
||||
|
||||
// FindFile 查找文件
|
||||
// FindFile
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Summary 查找文件
|
||||
// @Security ApiKeyAuth
|
||||
// @accept multipart/form-data
|
||||
// @Produce application/json
|
||||
// @Param fileMd5 query string true "文件MD5"
|
||||
// @Param fileName query string true "文件名"
|
||||
// @Param chunkTotal query int true "切片总数"
|
||||
// @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "查找文件,返回包括文件详情"
|
||||
// @Router /fileUploadAndDownload/findFile [get]
|
||||
func (f *FileUploadApi) FindFile(c *gin.Context) {
|
||||
fileMd5 := c.Query("fileMd5")
|
||||
fileName := c.Query("fileName")
|
||||
@@ -74,7 +92,16 @@ func (f *FileUploadApi) FindFile(c *gin.Context) {
|
||||
response.OkWithDetailed(gin.H{"file": toFileResponse(file)}, "查找成功", c)
|
||||
}
|
||||
|
||||
// BreakpointContinueFinish 创建文件(合并切片)
|
||||
// BreakpointContinueFinish
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Summary 创建文件
|
||||
// @Security ApiKeyAuth
|
||||
// @accept multipart/form-data
|
||||
// @Produce application/json
|
||||
// @Param fileMd5 query string true "文件MD5"
|
||||
// @Param fileName query string true "文件名"
|
||||
// @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "创建文件,返回包括文件路径"
|
||||
// @Router /fileUploadAndDownload/findFile [post]
|
||||
func (f *FileUploadApi) BreakpointContinueFinish(c *gin.Context) {
|
||||
fileMd5 := c.Query("fileMd5")
|
||||
fileName := c.Query("fileName")
|
||||
@@ -88,7 +115,15 @@ func (f *FileUploadApi) BreakpointContinueFinish(c *gin.Context) {
|
||||
response.OkWithDetailed(gin.H{"filePath": filePath}, "文件创建成功", c)
|
||||
}
|
||||
|
||||
// RemoveChunk 删除切片
|
||||
// RemoveChunk
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Summary 删除切片
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body map[string]string true "删除缓存切片"
|
||||
// @Success 200 {object} response.Response{msg=string} "删除切片"
|
||||
// @Router /fileUploadAndDownload/removeChunk [post]
|
||||
func (f *FileUploadApi) RemoveChunk(c *gin.Context) {
|
||||
var req struct {
|
||||
FileMd5 string `json:"fileMd5"`
|
||||
|
||||
@@ -10,14 +10,15 @@ import (
|
||||
|
||||
type CustomerApi struct{}
|
||||
|
||||
// CreateExaCustomer 创建客户
|
||||
// @Summary 创建客户
|
||||
// @Tags ExaCustomer
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param data body CustomerRequest true "客户信息"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /customer/customer [post]
|
||||
// CreateExaCustomer
|
||||
// @Tags ExaCustomer
|
||||
// @Summary 创建客户
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body CustomerRequest true "客户用户名, 客户手机号码"
|
||||
// @Success 200 {object} response.Response{msg=string} "创建客户"
|
||||
// @Router /customer/customer [post]
|
||||
func (api *CustomerApi) CreateExaCustomer(c *gin.Context) {
|
||||
var req CustomerRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -40,14 +41,15 @@ func (api *CustomerApi) CreateExaCustomer(c *gin.Context) {
|
||||
response.OkWithMessage("创建成功", c)
|
||||
}
|
||||
|
||||
// DeleteExaCustomer 删除客户
|
||||
// @Summary 删除客户
|
||||
// @Tags ExaCustomer
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param data body DeleteCustomerRequest true "客户ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /customer/customer [delete]
|
||||
// DeleteExaCustomer
|
||||
// @Tags ExaCustomer
|
||||
// @Summary 删除客户
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body DeleteCustomerRequest true "客户ID"
|
||||
// @Success 200 {object} response.Response{msg=string} "删除客户"
|
||||
// @Router /customer/customer [delete]
|
||||
func (api *CustomerApi) DeleteExaCustomer(c *gin.Context) {
|
||||
var req DeleteCustomerRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -63,14 +65,15 @@ func (api *CustomerApi) DeleteExaCustomer(c *gin.Context) {
|
||||
response.OkWithMessage("删除成功", c)
|
||||
}
|
||||
|
||||
// UpdateExaCustomer 更新客户
|
||||
// @Summary 更新客户
|
||||
// @Tags ExaCustomer
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param data body CustomerRequest true "客户信息"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /customer/customer [put]
|
||||
// UpdateExaCustomer
|
||||
// @Tags ExaCustomer
|
||||
// @Summary 更新客户信息
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body CustomerRequest true "客户ID, 客户信息"
|
||||
// @Success 200 {object} response.Response{msg=string} "更新客户信息"
|
||||
// @Router /customer/customer [put]
|
||||
func (api *CustomerApi) UpdateExaCustomer(c *gin.Context) {
|
||||
var req CustomerRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -92,14 +95,15 @@ func (api *CustomerApi) UpdateExaCustomer(c *gin.Context) {
|
||||
response.OkWithMessage("更新成功", c)
|
||||
}
|
||||
|
||||
// GetExaCustomer 获取客户信息
|
||||
// @Summary 获取客户信息
|
||||
// @Tags ExaCustomer
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param data body GetCustomerRequest true "客户ID"
|
||||
// @Success 200 {object} response.Response{data=CustomerResponse}
|
||||
// @Router /customer/customer [get]
|
||||
// GetExaCustomer
|
||||
// @Tags ExaCustomer
|
||||
// @Summary 获取单一客户信息
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data query GetCustomerRequest true "客户ID"
|
||||
// @Success 200 {object} response.Response{data=CustomerResponse,msg=string} "获取单一客户信息,返回包括客户详情"
|
||||
// @Router /customer/customer [get]
|
||||
func (api *CustomerApi) GetExaCustomer(c *gin.Context) {
|
||||
var req GetCustomerRequest
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
@@ -116,14 +120,15 @@ func (api *CustomerApi) GetExaCustomer(c *gin.Context) {
|
||||
response.OkWithDetailed(toCustomerResponse(customer), "获取成功", c)
|
||||
}
|
||||
|
||||
// GetExaCustomerList 分页获取客户列表
|
||||
// @Summary 分页获取客户列表
|
||||
// @Tags ExaCustomer
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param data body GetCustomerListRequest true "分页参数"
|
||||
// @Success 200 {object} response.Response{data=response.PageResult}
|
||||
// @Router /customer/customerList [get]
|
||||
// GetExaCustomerList
|
||||
// @Tags ExaCustomer
|
||||
// @Summary 分页获取权限客户列表
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data query GetCustomerListRequest true "页码, 每页大小"
|
||||
// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "分页获取权限客户列表,返回包括列表,总数,页码,每页数量"
|
||||
// @Router /customer/customerList [get]
|
||||
func (api *CustomerApi) GetExaCustomerList(c *gin.Context) {
|
||||
var req GetCustomerListRequest
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
|
||||
@@ -11,14 +11,15 @@ import (
|
||||
|
||||
type FileUploadApi struct{}
|
||||
|
||||
// UploadFile 上传文件
|
||||
// @Summary 上传文件
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Accept multipart/form-data
|
||||
// @Produce json
|
||||
// @Param file formance file true "上传文件"
|
||||
// @Success 200 {object} response.Response{data=FileUploadResponse}
|
||||
// @Router /fileUploadAndDownload/upload [post]
|
||||
// UploadFile
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Summary 上传文件示例
|
||||
// @Security ApiKeyAuth
|
||||
// @accept multipart/form-data
|
||||
// @Produce application/json
|
||||
// @Param file formData file true "上传文件示例"
|
||||
// @Success 200 {object} response.Response{data=FileUploadResponse,msg=string} "上传文件示例,返回包括文件详情"
|
||||
// @Router /fileUploadAndDownload/upload [post]
|
||||
func (api *FileUploadApi) UploadFile(c *gin.Context) {
|
||||
noSave := c.DefaultQuery("noSave", "0")
|
||||
classIdStr := c.DefaultQuery("classId", "0")
|
||||
@@ -39,14 +40,15 @@ func (api *FileUploadApi) UploadFile(c *gin.Context) {
|
||||
response.OkWithDetailed(toFileUploadResponse(file), "上传成功", c)
|
||||
}
|
||||
|
||||
// DeleteFile 删除文件
|
||||
// @Summary 删除文件
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param data body DeleteFileRequest true "文件ID"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /fileUploadAndDownload/deleteFile [post]
|
||||
// DeleteFile
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Summary 删除文件
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body DeleteFileRequest true "传入文件里面id即可"
|
||||
// @Success 200 {object} response.Response{msg=string} "删除文件"
|
||||
// @Router /fileUploadAndDownload/deleteFile [post]
|
||||
func (api *FileUploadApi) DeleteFile(c *gin.Context) {
|
||||
var req DeleteFileRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -62,14 +64,15 @@ func (api *FileUploadApi) DeleteFile(c *gin.Context) {
|
||||
response.OkWithMessage("删除成功", c)
|
||||
}
|
||||
|
||||
// EditFileName 编辑文件名
|
||||
// @Summary 编辑文件名
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param data body EditFileNameRequest true "文件信息"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /fileUploadAndDownload/editFileName [post]
|
||||
// EditFileName
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Summary 编辑文件名或者备注
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body EditFileNameRequest true "文件信息"
|
||||
// @Success 200 {object} response.Response{msg=string} "编辑成功"
|
||||
// @Router /fileUploadAndDownload/editFileName [post]
|
||||
func (api *FileUploadApi) EditFileName(c *gin.Context) {
|
||||
var req EditFileNameRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -85,14 +88,15 @@ func (api *FileUploadApi) EditFileName(c *gin.Context) {
|
||||
response.OkWithMessage("编辑成功", c)
|
||||
}
|
||||
|
||||
// GetFileList 分页获取文件列表
|
||||
// @Summary 分页获取文件列表
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param data body GetFileListRequest true "分页参数"
|
||||
// @Success 200 {object} response.Response{data=response.PageResult}
|
||||
// @Router /fileUploadAndDownload/getFileList [post]
|
||||
// GetFileList
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Summary 分页文件列表
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body GetFileListRequest true "页码, 每页大小, 分类id"
|
||||
// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "分页文件列表,返回包括列表,总数,页码,每页数量"
|
||||
// @Router /fileUploadAndDownload/getFileList [post]
|
||||
func (api *FileUploadApi) GetFileList(c *gin.Context) {
|
||||
var req GetFileListRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -126,14 +130,15 @@ func (api *FileUploadApi) GetFileList(c *gin.Context) {
|
||||
}, "获取成功", c)
|
||||
}
|
||||
|
||||
// ImportURL 导入URL
|
||||
// @Summary 导入URL
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param data body []FileUploadResponse true "文件列表"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Router /fileUploadAndDownload/importURL [post]
|
||||
// ImportURL
|
||||
// @Tags ExaFileUploadAndDownload
|
||||
// @Summary 导入URL
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body []FileUploadResponse true "对象"
|
||||
// @Success 200 {object} response.Response{msg=string} "导入URL"
|
||||
// @Router /fileUploadAndDownload/importURL [post]
|
||||
func (api *FileUploadApi) ImportURL(c *gin.Context) {
|
||||
var req []FileUploadResponse
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user