feat: integrate swagger documentation and gin cors middleware
This commit is contained in:
@@ -30,9 +30,9 @@ func NewCompaniesController() *CompaniesController {
|
||||
// @Param page query int false "页码"
|
||||
// @Param limit query int false "每页数量"
|
||||
// @Param search query string false "搜索关键词"
|
||||
// @Success 200 {object} gin.H{message: string, data: []models.Company, pagination: gin.H{page: int, limit: int, total: int, totalPages: int}}
|
||||
// @Failure 401 {object} gin.H{message: string}
|
||||
// @Failure 500 {object} gin.H{message: string}
|
||||
// @Success 200 {object} models.PaginationResponse
|
||||
// @Failure 401 {object} models.ErrorResponse
|
||||
// @Failure 500 {object} models.ErrorResponse
|
||||
// @Router /companies [get]
|
||||
func (c *CompaniesController) FindAll(ctx *gin.Context) {
|
||||
page, _ := strconv.Atoi(ctx.DefaultQuery("page", "1"))
|
||||
@@ -66,12 +66,12 @@ func (c *CompaniesController) FindAll(ctx *gin.Context) {
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param companyData body gin.H{companyName: string} true "企业数据"
|
||||
// @Success 201 {object} gin.H{message: string, company: models.Company}
|
||||
// @Failure 400 {object} gin.H{message: string}
|
||||
// @Failure 401 {object} gin.H{message: string}
|
||||
// @Failure 409 {object} gin.H{message: string}
|
||||
// @Failure 500 {object} gin.H{message: string}
|
||||
// @Param companyData body models.CompanyDataRequest true "企业数据"
|
||||
// @Success 201 {object} models.CompanyResponse
|
||||
// @Failure 400 {object} models.ErrorResponse
|
||||
// @Failure 401 {object} models.ErrorResponse
|
||||
// @Failure 409 {object} models.ErrorResponse
|
||||
// @Failure 500 {object} models.ErrorResponse
|
||||
// @Router /companies [post]
|
||||
func (c *CompaniesController) Create(ctx *gin.Context) {
|
||||
var companyData struct {
|
||||
@@ -113,13 +113,13 @@ func (c *CompaniesController) Create(ctx *gin.Context) {
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param companyName path string true "企业名称"
|
||||
// @Param companyData body gin.H{companyName?: string, isActive?: bool} true "企业数据"
|
||||
// @Success 200 {object} gin.H{message: string, company: models.Company}
|
||||
// @Failure 400 {object} gin.H{message: string}
|
||||
// @Failure 401 {object} gin.H{message: string}
|
||||
// @Failure 404 {object} gin.H{message: string}
|
||||
// @Failure 409 {object} gin.H{message: string}
|
||||
// @Failure 500 {object} gin.H{message: string}
|
||||
// @Param companyData body models.CompanyUpdateRequest true "企业数据"
|
||||
// @Success 200 {object} models.CompanyResponse
|
||||
// @Failure 400 {object} models.ErrorResponse
|
||||
// @Failure 401 {object} models.ErrorResponse
|
||||
// @Failure 404 {object} models.ErrorResponse
|
||||
// @Failure 409 {object} models.ErrorResponse
|
||||
// @Failure 500 {object} models.ErrorResponse
|
||||
// @Router /companies/{companyName} [put]
|
||||
func (c *CompaniesController) Update(ctx *gin.Context) {
|
||||
companyName := ctx.Param("companyName")
|
||||
@@ -167,11 +167,11 @@ func (c *CompaniesController) Update(ctx *gin.Context) {
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param companyName path string true "企业名称"
|
||||
// @Success 200 {object} gin.H{message: string}
|
||||
// @Failure 400 {object} gin.H{message: string}
|
||||
// @Failure 401 {object} gin.H{message: string}
|
||||
// @Failure 404 {object} gin.H{message: string}
|
||||
// @Failure 500 {object} gin.H{message: string}
|
||||
// @Success 200 {object} models.BaseResponse
|
||||
// @Failure 400 {object} models.ErrorResponse
|
||||
// @Failure 401 {object} models.ErrorResponse
|
||||
// @Failure 404 {object} models.ErrorResponse
|
||||
// @Failure 500 {object} models.ErrorResponse
|
||||
// @Router /companies/{companyName} [delete]
|
||||
func (c *CompaniesController) Delete(ctx *gin.Context) {
|
||||
companyName := ctx.Param("companyName")
|
||||
|
||||
Reference in New Issue
Block a user