You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
4.8 KiB

package v1
import (
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"pure-admin/global"
"pure-admin/model"
"pure-admin/model/request"
"pure-admin/model/response"
"pure-admin/service"
)
// @Tags Businessv0.0.0
// @Summary 创建Business
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SellerStore true "创建Business"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /business [post]
func CreateBusiness(c *gin.Context) {
var business model.SellerStore
_ = c.ShouldBindJSON(&business)
if err := service.CreateBusiness(business); err != nil {
global.MG_LOG.Error("创建失败!", zap.Any("err", err))
response.FailWithMessage("创建失败", c)
} else {
response.OkWithMessage("创建成功", c)
}
}
// @Tags Businessv0.0.0
// @Summary 删除Business
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SellerStore true "删除Business"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /business [delete]
func DeleteBusiness(c *gin.Context) {
var business model.SellerStore
_ = c.ShouldBindJSON(&business)
if err := service.DeleteBusiness(business); err != nil {
global.MG_LOG.Error("删除失败!", zap.Any("err", err))
response.FailWithMessage("删除失败", c)
} else {
response.OkWithMessage("删除成功", c)
}
}
// @Tags Businessv0.0.0
// @Summary 批量删除商家
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除Business"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
// @Router /business/deleteBusinessByIds [delete]
func DeleteBusinessByIds(c *gin.Context) {
var IDS request.IdsReq
_ = c.ShouldBindJSON(&IDS)
if err := service.DeleteBusinessByIds(IDS); err != nil {
global.MG_LOG.Error("批量删除失败!", zap.Any("err", err))
response.FailWithMessage("批量删除失败", c)
} else {
response.OkWithMessage("批量删除成功", c)
}
}
// @Tags Business
// @Summary 更新商家
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SellerStore true "更新Business"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /business [put]
func UpdateBusiness(c *gin.Context) {
var business model.SellerStore
_ = c.ShouldBindJSON(&business)
if err := service.UpdateBusiness(business); err != nil {
global.MG_LOG.Error("更新失败!", zap.Any("err", err))
response.FailWithMessage("更新失败", c)
} else {
response.OkWithMessage("更新成功", c)
}
}
// @Tags Business
// @Summary 用id查询商家
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body response.StoreInfoItem true "用id查询Business"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /business [get]
func GetBusiness(c *gin.Context) {
var info request.IdReq
_ = c.ShouldBindQuery(&info)
rebusiness, err := service.GetBusiness(info.ID)
if err != nil {
global.MG_LOG.Error("查询失败!", zap.Any("err", err))
response.FailWithMessage("查询失败", c)
} else {
response.OkWithData(rebusiness, c)
}
}
// @Tags Business
// @Summary 商家列表
// @Security ApiKeyAuth
// @accept application/json
// @Param data body request.PageInfo true "分页获取商家列表"
// @Success 200 {object} model.SellerStoreInfo "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /business/list [get]
func ListBusiness(c *gin.Context) {
var info request.PageInfo
_ = c.ShouldBindQuery(&info)
if info.Page == 0 {
info.Page = 1
}
list, total, err := service.GetBusinessInfoList(info)
if err != nil {
global.MG_LOG.Error("获取失败!" + err.Error())
response.FailWithMessage("获取失败", c)
} else {
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: info.Page,
PageSize: info.PageSize,
}, "获取成功", c)
}
}
// @Tags Business
// @Summary 商家搜索
// @Security ApiKeyAuth
// @accept application/json
// @Param data body request.SearchStore true "分页获取商家列表"
// @Success 200 {object} model.SellerStoreInfo "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /business/search [get]
func SearchBusiness(c *gin.Context) {
var info request.SearchStore
_ = c.ShouldBindQuery(&info)
if info.Page == 0 {
info.Page = 1
}
list, total, err := service.SearchBusiness(info)
if err != nil {
global.MG_LOG.Error("获取失败!" + err.Error())
response.FailWithMessage("获取失败", c)
} else {
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: info.Page,
PageSize: info.PageSize,
}, "获取成功", c)
}
}