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.

131 lines
4.2 KiB

package sys
import (
"bkb-seller/global"
"bkb-seller/model"
"bkb-seller/model/request"
"bkb-seller/model/response"
"bkb-seller/service"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags Business
// @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/createBusiness [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 Business
// @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/deleteBusiness [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 Business
// @Summary 批量删除Business
// @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 更新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/updateBusiness [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查询Business
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SellerStore true "用id查询Business"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /business/findBusiness [get]
func FindBusiness(c *gin.Context) {
var business model.SellerStore
_ = c.ShouldBindQuery(&business)
if err, rebusiness := service.GetBusiness(business.ID); err != nil {
global.MG_LOG.Error("查询失败!", zap.Any("err", err))
response.FailWithMessage("查询失败", c)
} else {
response.OkWithData(gin.H{"rebusiness": rebusiness}, c)
}
}
// @Tags Business
// @Summary 分页获取Business列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.BusinessSearch true "分页获取Business列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /business/getBusinessList [get]
func GetBusinessList(c *gin.Context) {
var pageInfo request.BusinessSearch
_ = c.ShouldBindQuery(&pageInfo)
if err, list, total := service.GetBusinessInfoList(pageInfo); err != nil {
global.MG_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: pageInfo.Page,
PageSize: pageInfo.PageSize,
}, "获取成功", c)
}
}