1.优化产品管理相关接口;

This commit is contained in:
chenlin 2025-03-14 18:05:29 +08:00
parent 1759253505
commit d7b1220ff6
13 changed files with 1489 additions and 992 deletions

View File

@ -0,0 +1,155 @@
package bus_apis
import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/go-admin-team/go-admin-core/sdk/api"
"go-admin/app/admin/models/bus_models"
"go-admin/app/admin/service/bus_service"
"go-admin/tools/app"
"net/http"
)
type ProductApi struct {
api.Api
}
// ProductList 查询产品列表
// @Summary 查询产品列表
// @Tags 产品管理-V1.0.0
// @Produce json
// @Accept json
// @Param request body bus_models.ProductListReq true "查询产品列表模型"
// @Success 200 {object} bus_models.ProductListResp
// @Router /api/v1/product/list [post]
func (e ProductApi) ProductList(c *gin.Context) {
s := bus_service.ProductService{}
var req bus_models.ProductListReq
err := e.MakeContext(c).
MakeOrm().
Bind(&req, binding.JSON).
MakeService(&s.Service).
Errors
if err != nil {
e.Logger.Error(err)
e.Error(500, err, err.Error())
return
}
// 调用服务层的 GetProductList 函数获取数据
resp, err := s.GetProductList(c.Request.Context(), req)
if err != nil {
app.Error(c, http.StatusInternalServerError, err, err.Error())
return
}
// 返回查询结果
app.OK(c, resp, "查询成功")
return
}
// CreateProduct 新建产品
// @Summary 新建产品
// @Tags 产品管理-V1.0.0
// @Produce json
// @Accept json
// @Param request body bus_models.CreateProductReq true "新建产品模型"
// @Success 200 {object} bus_models.CreateProductResp
// @Router /api/v1/product/create [post]
func (e ProductApi) CreateProduct(c *gin.Context) {
s := bus_service.ProductService{}
var req bus_models.CreateProductReq
err := e.MakeContext(c).
MakeOrm().
Bind(&req, binding.JSON).
MakeService(&s.Service).
Errors
if err != nil {
e.Logger.Error(err)
e.Error(500, err, err.Error())
return
}
// 调用服务层的 CreateProduct 函数来处理逻辑
resp, err := s.CreateProduct(req)
if err != nil {
app.Error(c, http.StatusInternalServerError, err, err.Error())
return
}
// 返回创建结果
app.OK(c, resp, "新增成功")
return
}
// EditProduct 编辑产品
// @Summary 编辑产品
// @Tags 产品管理-V1.0.0
// @Produce json
// @Accept json
// @Param request body bus_models.EditProductReq true "编辑产品模型"
// @Success 200 {object} app.Response
// @Router /api/v1/product/edit [post]
func (e ProductApi) EditProduct(c *gin.Context) {
s := bus_service.ProductService{}
var req bus_models.EditProductReq
err := e.MakeContext(c).
MakeOrm().
Bind(&req, binding.JSON).
MakeService(&s.Service).
Errors
if err != nil {
e.Logger.Error(err)
e.Error(500, err, err.Error())
return
}
// 调用服务层的 EditProduct 函数来处理逻辑
err = s.EditProduct(req)
if err != nil {
app.Error(c, http.StatusInternalServerError, err, err.Error())
return
}
// 返回创建结果
app.OK(c, nil, "编辑成功")
return
}
// DeleteProduct 删除产品
// @Summary 删除产品
// @Tags 产品管理-V1.0.0
// @Produce json
// @Accept json
// @Param request body bus_models.DeleteProductReq true "删除产品模型"
// @Success 200 {object} app.Response
// @Router /api/v1/product/delete [post]
func (e ProductApi) DeleteProduct(c *gin.Context) {
s := bus_service.ProductService{}
var req bus_models.DeleteProductReq
err := e.MakeContext(c).
MakeOrm().
Bind(&req, binding.JSON).
MakeService(&s.Service).
Errors
if err != nil {
e.Logger.Error(err)
e.Error(500, err, err.Error())
return
}
// 调用服务层的 DeleteProduct 函数来处理逻辑
err = s.DeleteProduct(req)
if err != nil {
app.Error(c, http.StatusInternalServerError, err, err.Error())
return
}
// 返回创建结果
app.OK(c, nil, "删除成功")
return
}

View File

@ -22,7 +22,7 @@ func (e System) GenerateCaptchaHandler(c *gin.Context) {
e.Error(500, err, "服务初始化失败!")
return
}
id, b64s, err := captcha.DriverDigitFunc()
id, b64s, _, err := captcha.DriverDigitFunc()
if err != nil {
e.Logger.Errorf("DriverDigitFunc error, %s", err.Error())
e.Error(500, err, "验证码获取失败")

View File

@ -1,119 +0,0 @@
package product_manage
import (
"github.com/gin-gonic/gin"
"go-admin/app/admin/models/m_product_manage"
"net/http"
)
// ProductList 查询产品列表
// @Summary 查询产品列表
// @Tags 产品管理
// @Produce json
// @Accept json
// @Param request body m_product_manage.ProductListReq true "查询产品列表模型"
// @Success 200 {object} m_product_manage.ProductListResp
// @Router /api/v1/product/list [post]
func ProductList(c *gin.Context) {
var req m_product_manage.ProductListReq
// 解析请求参数
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
// 调用服务层的 GetProductList 函数获取数据
resp, err := m_product_manage.GetProductList(c.Request.Context(), req)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "查询失败"})
return
}
// 返回查询结果
c.JSON(http.StatusOK, resp)
}
// CreateProduct 新建产品
// @Summary 新建产品
// @Tags 产品管理
// @Produce json
// @Accept json
// @Param request body m_product_manage.CreateProductReq true "新建产品模型"
// @Success 200 {object} m_product_manage.CreateProductResp
// @Router /api/v1/product/create [post]
func CreateProduct(c *gin.Context) {
var req m_product_manage.CreateProductReq
// 解析请求参数
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
// 调用服务层的 CreateProduct 函数来处理逻辑
resp, err := m_product_manage.CreateProduct(req)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "创建失败"})
return
}
// 返回创建结果
c.JSON(http.StatusOK, resp)
}
// EditProduct 编辑产品
// @Summary 编辑产品
// @Tags 产品管理
// @Produce json
// @Accept json
// @Param request body m_product_manage.EditProductReq true "编辑产品模型"
// @Success 200 {object} m_product_manage.EditProductResp
// @Router /api/v1/product/edit [post]
func EditProduct(c *gin.Context) {
var req m_product_manage.EditProductReq
// 解析请求参数
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
// 调用服务层的 EditProduct 函数来处理逻辑
resp, err := m_product_manage.EditProduct(req)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "编辑失败"})
return
}
// 返回编辑结果
c.JSON(http.StatusOK, resp)
}
// DeleteProduct 删除产品
// @Summary 删除产品
// @Tags 产品管理
// @Produce json
// @Accept json
// @Param request body m_product_manage.DeleteProductReq true "删除产品模型"
// @Success 200 {object} m_product_manage.DeleteProductResp
// @Router /api/v1/product/delete [post]
func DeleteProduct(c *gin.Context) {
var req m_product_manage.DeleteProductReq
// 解析请求参数
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
// 调用服务层的 DeleteProduct 函数来处理逻辑
resp, err := m_product_manage.DeleteProduct(req)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "删除失败"})
return
}
// 返回删除结果
c.JSON(http.StatusOK, resp)
}

View File

@ -0,0 +1,99 @@
package bus_models
import (
"go-admin/app/admin/models"
)
// BusProduct 产品表
type BusProduct struct {
models.Model
ProductCode string `gorm:"size:32;not null;uniqueIndex" json:"product_code"` // 产品编码,唯一
ServiceCode string `gorm:"size:32;not null;index" json:"service_code"` // 服务编码,广东深圳移动新产品需要
ProductName string `gorm:"size:64;not null" json:"product_name"` // 产品名称
ProductAttr uint8 `gorm:"not null" json:"product_attr"` // 产品属性1-直连运营商 2-第三方
ProductType uint8 `gorm:"not null;index" json:"product_type"` // 产品类型1-短信 2-话费 3-流量
Type uint8 `gorm:"not null" json:"type"` // 类型1-省内 2-国内
Size string `gorm:"size:16;not null" json:"size"` // 流量大小
Price float64 `gorm:"type:decimal(10,2);not null" json:"price"` // 标准价格
Discount float64 `gorm:"type:decimal(5,2);not null" json:"discount"` // 折扣
RetailPrice float64 `gorm:"type:decimal(10,2);not null" json:"retail_price"` // 建议零售价格
Description string `gorm:"size:128" json:"description,omitempty"` // 产品描述
Province string `gorm:"size:16;not null" json:"province"` // 运营商省份
City string `gorm:"size:32" json:"city,omitempty"` // 城市
Platform uint8 `gorm:"not null;index" json:"platform"` // 运营商1-移动 2-联通 3-电信
}
// ProductListReq 查询产品列表 - 入参
type ProductListReq struct {
ProductCode string `json:"product_code,omitempty"` // 产品编码(可选)
ProductName string `json:"product_name,omitempty"` // 产品名称(可选)
ProductType uint8 `json:"product_type,omitempty"` // 产品类型1-短信 2-话费 3-流量(可选)
Platform uint8 `json:"platform,omitempty"` // 运营商1-移动 2-联通 3-电信(可选)
Province string `json:"province,omitempty"` // 省份(可选)
Page int `json:"page"` // 页码
PageSize int `json:"page_size"` // 每页大小
}
// ProductListResp 查询产品列表 - 出参
type ProductListResp struct {
Total int `json:"total"` // 总记录数
List []BusProduct `json:"list"` // 产品列表
}
// CreateProductReq 新建产品 - 入参
type CreateProductReq struct {
ProductCode string `json:"product_code" binding:"required"` // 产品编码
ServiceCode string `json:"service_code"` // 服务编码
ProductName string `json:"product_name" binding:"required"` // 产品名称
ProductAttr uint8 `json:"product_attr"` // 产品属性1-直连运营商 2-第三方
ProductType uint8 `json:"product_type" binding:"required"` // 产品类型1-短信 2-话费 3-流量
Type uint8 `json:"type"` // 类型1-省内 2-国内
Size string `json:"size"` // 流量大小
Price float64 `json:"price" binding:"required"` // 标准价格
Discount float64 `json:"discount"` // 折扣
RetailPrice float64 `json:"retail_price"` // 建议零售价格
Description string `json:"description"` // 产品描述
Province string `json:"province" binding:"required"` // 运营商省份
City string `json:"city,omitempty"` // 城市(可选)
Platform uint8 `json:"platform" binding:"required"` // 运营商1-移动 2-联通 3-电信
}
// CreateProductResp 新建产品 - 出参
type CreateProductResp struct {
ID uint64 `json:"id"` // 新创建的产品ID
}
// EditProductReq 编辑产品 - 入参
type EditProductReq struct {
ID uint64 `json:"id" binding:"required"` // 产品ID
ProductCode string `json:"product_code" binding:"required"` // 产品编码
ServiceCode string `json:"service_code"` // 服务编码
ProductName string `json:"product_name" binding:"required"` // 产品名称
ProductAttr uint8 `json:"product_attr"` // 产品属性1-直连运营商 2-第三方
ProductType uint8 `json:"product_type"` // 产品类型1-短信 2-话费 3-流量
Type uint8 `json:"type"` // 类型1-省内 2-国内
Size string `json:"size"` // 流量大小
Price float64 `json:"price"` // 标准价格
Discount float64 `json:"discount"` // 折扣
RetailPrice float64 `json:"retail_price"` // 建议零售价格
Description string `json:"description"` // 产品描述
Province string `json:"province"` // 运营商省份
City string `json:"city,omitempty"` // 城市(可选)
Platform uint8 `json:"platform"` // 运营商1-移动 2-联通 3-电信
}
// EditProductResp 编辑产品 - 出参
type EditProductResp struct {
Success bool `json:"success"` // 是否编辑成功
}
// DeleteProductReq 删除产品 - 入参
type DeleteProductReq struct {
ID uint64 `json:"id" binding:"required"` // 产品ID
}
// DeleteProductResp 删除产品 - 出参
type DeleteProductResp struct {
Success bool `json:"success"` // 是否删除成功
}

View File

@ -3,17 +3,19 @@ package router
import (
"github.com/gin-gonic/gin"
jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
"go-admin/app/admin/apis/product_manage"
"go-admin/app/admin/apis/bus_apis"
"go-admin/common/middleware"
)
// 需认证的路由代码
func registerProductManageRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
api := bus_apis.ProductApi{}
product := v1.Group("/product").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
{
product.POST("/list", product_manage.ProductList) // 产品列表
product.POST("/create", product_manage.CreateProduct) // 创建产品
product.POST("/edit", product_manage.EditProduct) // 编辑产品
product.POST("/delete", product_manage.DeleteProduct) // 删除产品
product.POST("/list", api.ProductList) // 产品列表
product.POST("/create", api.CreateProduct) // 创建产品
product.POST("/edit", api.EditProduct) // 编辑产品
product.POST("/delete", api.DeleteProduct) // 删除产品
}
}

View File

@ -0,0 +1,101 @@
package bus_service
import (
"context"
"errors"
"github.com/go-admin-team/go-admin-core/sdk/service"
"go-admin/app/admin/models/bus_models"
)
type ProductService struct {
service.Service
}
// GetProductList 获取产品列表
func (e *ProductService) GetProductList(ctx context.Context, req bus_models.ProductListReq) (bus_models.ProductListResp, error) {
var products []bus_models.BusProduct
var resp bus_models.ProductListResp
// 构建查询条件,假设我们支持根据 product_code 查询
db := e.Orm.WithContext(ctx)
// 如果需要支持分页,可以根据请求条件调整查询
if req.ProductCode != "" {
db = db.Where("product_code = ?", req.ProductCode)
}
if req.ProductName != "" {
db = db.Where("product_name LIKE ?", "%"+req.ProductName+"%")
}
if req.ProductType != 0 {
db = db.Where("product_type = ?", req.ProductType)
}
// 查询数据库
if err := db.Find(&products).Error; err != nil {
return resp, errors.New("查询产品列表失败")
}
resp.List = products
resp.Total = len(products)
return resp, nil
}
// CreateProduct 新建产品
func (e *ProductService) CreateProduct(req bus_models.CreateProductReq) (bus_models.CreateProductResp, error) {
var resp bus_models.CreateProductResp
product := bus_models.BusProduct{
ProductCode: req.ProductCode,
ProductName: req.ProductName,
ProductType: req.ProductType,
Platform: req.Platform,
Price: req.Price,
Discount: req.Discount,
RetailPrice: req.RetailPrice,
Province: req.Province,
City: req.City,
}
// 将产品插入数据库
if err := e.Orm.Create(&product).Error; err != nil {
return resp, errors.New("创建产品失败")
}
// 返回创建成功的响应
resp.ID = product.ID
return resp, nil
}
// EditProduct 编辑产品
func (e *ProductService) EditProduct(req bus_models.EditProductReq) error {
product := bus_models.BusProduct{
ProductCode: req.ProductCode,
ProductName: req.ProductName,
ProductType: req.ProductType,
Platform: req.Platform,
Price: req.Price,
Discount: req.Discount,
RetailPrice: req.RetailPrice,
Province: req.Province,
City: req.City,
}
// 更新产品信息
if err := e.Orm.Model(&bus_models.BusProduct{}).Where("product_code = ?", req.ProductCode).
Updates(&product).Error; err != nil {
return errors.New("编辑产品失败")
}
return nil
}
// DeleteProduct 删除产品
func (e *ProductService) DeleteProduct(req bus_models.DeleteProductReq) error {
// 执行删除操作
if err := e.Orm.Where("id = ?", req.ID).Delete(&bus_models.BusProduct{}).Error; err != nil {
return errors.New("删除产品失败")
}
return nil
}

53
config/settings.dev.yml Normal file
View File

@ -0,0 +1,53 @@
settings:
application:
# dev开发环境 test测试环境 prod线上环境
mode: dev
# 服务器ip默认使用 0.0.0.0
host: 0.0.0.0
# 服务名称
name: testApp
# 端口号
port: 8037 # 服务端口号
readtimeout: 1
writertimeout: 2
# 数据权限功能开关
enabledp: false
ssl:
# https对应的域名
domain: localhost:8000
# https开关
enable: false
# ssl 证书key
key: keystring
# ssl 证书路径
pem: temp/pem.pem
logger:
# 日志存放路径
path: temp/logs
# 日志输出file文件default命令行其他命令行
stdout: '' #控制台日志,启用后,不输出到文件
# 日志等级, trace, debug, info, warn, error, fatal
level: trace
# 数据库日志开关
enableddb: false
jwt:
# token 密钥,生产环境时及的修改
secret: go-admin
# token 过期时间 单位:秒
timeout: 3600
database:
# 数据库类型 mysqlsqlite3 postgres
driver: mysql
# 数据库连接字符串 mysql 缺省信息 charset=utf8&parseTime=True&loc=Local&timeout=1000ms
source: telco_dev:ZePs8EP3EDXbJwhJ@tcp(112.33.14.191:3306)/telco_dev?charset=utf8&parseTime=True&loc=Local&timeout=1000ms
gen:
# 代码生成读取的数据库名称
dbname: dbname
# 代码生成是使用前端代码存放位置需要指定到src文件夹相对路径
frontpath: ../go-admin-ui/src
queue:
memory:
poolSize: 100
extend: # 扩展项使用说明
demo:
name: data

View File

@ -60,9 +60,27 @@ const docTemplateadmin = `{
"summary": "获取验证码",
"responses": {
"200": {
"description": "{\"code\": 200, \"data\": [...], \"id\": \"xyz\", \"msg\": \"success\"}",
"description": "{\"code\": 200, \"data\": [...]}",
"schema": {
"$ref": "#/definitions/response.Response"
"allOf": [
{
"$ref": "#/definitions/response.Response"
},
{
"type": "object",
"properties": {
"data": {
"type": "string"
},
"id": {
"type": "string"
},
"msg": {
"type": "string"
}
}
}
]
}
}
}
@ -1240,7 +1258,7 @@ const docTemplateadmin = `{
"application/json"
],
"tags": [
"产品管理"
"产品管理-V1.0.0"
],
"summary": "新建产品",
"parameters": [
@ -1250,7 +1268,7 @@ const docTemplateadmin = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/m_product_manage.CreateProductReq"
"$ref": "#/definitions/bus_models.CreateProductReq"
}
}
],
@ -1258,7 +1276,7 @@ const docTemplateadmin = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/m_product_manage.CreateProductResp"
"$ref": "#/definitions/bus_models.CreateProductResp"
}
}
}
@ -1273,7 +1291,7 @@ const docTemplateadmin = `{
"application/json"
],
"tags": [
"产品管理"
"产品管理-V1.0.0"
],
"summary": "删除产品",
"parameters": [
@ -1283,7 +1301,7 @@ const docTemplateadmin = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/m_product_manage.DeleteProductReq"
"$ref": "#/definitions/bus_models.DeleteProductReq"
}
}
],
@ -1291,7 +1309,7 @@ const docTemplateadmin = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/m_product_manage.DeleteProductResp"
"$ref": "#/definitions/app.Response"
}
}
}
@ -1306,7 +1324,7 @@ const docTemplateadmin = `{
"application/json"
],
"tags": [
"产品管理"
"产品管理-V1.0.0"
],
"summary": "编辑产品",
"parameters": [
@ -1316,7 +1334,7 @@ const docTemplateadmin = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/m_product_manage.EditProductReq"
"$ref": "#/definitions/bus_models.EditProductReq"
}
}
],
@ -1324,7 +1342,7 @@ const docTemplateadmin = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/m_product_manage.EditProductResp"
"$ref": "#/definitions/app.Response"
}
}
}
@ -1339,7 +1357,7 @@ const docTemplateadmin = `{
"application/json"
],
"tags": [
"产品管理"
"产品管理-V1.0.0"
],
"summary": "查询产品列表",
"parameters": [
@ -1349,7 +1367,7 @@ const docTemplateadmin = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/m_product_manage.ProductListReq"
"$ref": "#/definitions/bus_models.ProductListReq"
}
}
],
@ -1357,7 +1375,7 @@ const docTemplateadmin = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/m_product_manage.ProductListResp"
"$ref": "#/definitions/bus_models.ProductListResp"
}
}
}
@ -2903,6 +2921,309 @@ const docTemplateadmin = `{
}
},
"definitions": {
"app.Response": {
"type": "object",
"properties": {
"code": {
"description": "代码",
"type": "integer",
"example": 200
},
"data": {
"description": "数据集"
},
"msg": {
"description": "消息",
"type": "string"
},
"requestId": {
"description": "请求id",
"type": "string"
}
}
},
"bus_models.BusProduct": {
"type": "object",
"properties": {
"city": {
"description": "城市",
"type": "string"
},
"createdAt": {
"description": "创建时间",
"type": "string"
},
"description": {
"description": "产品描述",
"type": "string"
},
"discount": {
"description": "折扣",
"type": "number"
},
"id": {
"description": "数据库记录编号",
"type": "integer"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信",
"type": "integer"
},
"price": {
"description": "标准价格",
"type": "number"
},
"product_attr": {
"description": "产品属性1-直连运营商 2-第三方",
"type": "integer"
},
"product_code": {
"description": "产品编码,唯一",
"type": "string"
},
"product_name": {
"description": "产品名称",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量",
"type": "integer"
},
"province": {
"description": "运营商省份",
"type": "string"
},
"retail_price": {
"description": "建议零售价格",
"type": "number"
},
"service_code": {
"description": "服务编码,广东深圳移动新产品需要",
"type": "string"
},
"size": {
"description": "流量大小",
"type": "string"
},
"type": {
"description": "类型1-省内 2-国内",
"type": "integer"
},
"updatedAt": {
"description": "更新时间",
"type": "string"
}
}
},
"bus_models.CreateProductReq": {
"type": "object",
"required": [
"platform",
"price",
"product_code",
"product_name",
"product_type",
"province"
],
"properties": {
"city": {
"description": "城市(可选)",
"type": "string"
},
"description": {
"description": "产品描述",
"type": "string"
},
"discount": {
"description": "折扣",
"type": "number"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信",
"type": "integer"
},
"price": {
"description": "标准价格",
"type": "number"
},
"product_attr": {
"description": "产品属性1-直连运营商 2-第三方",
"type": "integer"
},
"product_code": {
"description": "产品编码",
"type": "string"
},
"product_name": {
"description": "产品名称",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量",
"type": "integer"
},
"province": {
"description": "运营商省份",
"type": "string"
},
"retail_price": {
"description": "建议零售价格",
"type": "number"
},
"service_code": {
"description": "服务编码",
"type": "string"
},
"size": {
"description": "流量大小",
"type": "string"
},
"type": {
"description": "类型1-省内 2-国内",
"type": "integer"
}
}
},
"bus_models.CreateProductResp": {
"type": "object",
"properties": {
"id": {
"description": "新创建的产品ID",
"type": "integer"
}
}
},
"bus_models.DeleteProductReq": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"description": "产品ID",
"type": "integer"
}
}
},
"bus_models.EditProductReq": {
"type": "object",
"required": [
"id",
"product_code",
"product_name"
],
"properties": {
"city": {
"description": "城市(可选)",
"type": "string"
},
"description": {
"description": "产品描述",
"type": "string"
},
"discount": {
"description": "折扣",
"type": "number"
},
"id": {
"description": "产品ID",
"type": "integer"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信",
"type": "integer"
},
"price": {
"description": "标准价格",
"type": "number"
},
"product_attr": {
"description": "产品属性1-直连运营商 2-第三方",
"type": "integer"
},
"product_code": {
"description": "产品编码",
"type": "string"
},
"product_name": {
"description": "产品名称",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量",
"type": "integer"
},
"province": {
"description": "运营商省份",
"type": "string"
},
"retail_price": {
"description": "建议零售价格",
"type": "number"
},
"service_code": {
"description": "服务编码",
"type": "string"
},
"size": {
"description": "流量大小",
"type": "string"
},
"type": {
"description": "类型1-省内 2-国内",
"type": "integer"
}
}
},
"bus_models.ProductListReq": {
"type": "object",
"properties": {
"page": {
"description": "页码",
"type": "integer"
},
"page_size": {
"description": "每页大小",
"type": "integer"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信(可选)",
"type": "integer"
},
"product_code": {
"description": "产品编码(可选)",
"type": "string"
},
"product_name": {
"description": "产品名称(可选)",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量(可选)",
"type": "integer"
},
"province": {
"description": "省份(可选)",
"type": "string"
}
}
},
"bus_models.ProductListResp": {
"type": "object",
"properties": {
"list": {
"description": "产品列表",
"type": "array",
"items": {
"$ref": "#/definitions/bus_models.BusProduct"
}
},
"total": {
"description": "总记录数",
"type": "integer"
}
}
},
"dto.GetSetSysConfigReq": {
"type": "object",
"properties": {
@ -4157,286 +4478,6 @@ const docTemplateadmin = `{
}
}
},
"m_product_manage.BusProductDTO": {
"type": "object",
"properties": {
"city": {
"description": "城市(可选,避免返回空字符串)",
"type": "string"
},
"created_at": {
"description": "创建时间",
"type": "string"
},
"discount": {
"description": "折扣",
"type": "number"
},
"id": {
"description": "产品ID",
"type": "integer"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信 4-不限",
"type": "integer"
},
"price": {
"description": "标准价格",
"type": "number"
},
"product_code": {
"description": "产品编码",
"type": "string"
},
"product_name": {
"description": "产品名称",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量",
"type": "integer"
},
"province": {
"description": "运营商省份",
"type": "string"
},
"retail_price": {
"description": "建议零售价格",
"type": "number"
},
"updated_at": {
"description": "更新时间",
"type": "string"
}
}
},
"m_product_manage.CreateProductReq": {
"type": "object",
"required": [
"platform",
"price",
"product_code",
"product_name",
"product_type",
"province"
],
"properties": {
"city": {
"description": "城市(可选)",
"type": "string"
},
"description": {
"description": "产品描述",
"type": "string"
},
"discount": {
"description": "折扣",
"type": "number"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信",
"type": "integer"
},
"price": {
"description": "标准价格",
"type": "number"
},
"product_attr": {
"description": "产品属性1-直连运营商 2-第三方",
"type": "integer"
},
"product_code": {
"description": "产品编码",
"type": "string"
},
"product_name": {
"description": "产品名称",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量",
"type": "integer"
},
"province": {
"description": "运营商省份",
"type": "string"
},
"retail_price": {
"description": "建议零售价格",
"type": "number"
},
"service_code": {
"description": "服务编码",
"type": "string"
},
"size": {
"description": "流量大小",
"type": "string"
},
"type": {
"description": "类型1-省内 2-国内",
"type": "integer"
}
}
},
"m_product_manage.CreateProductResp": {
"type": "object",
"properties": {
"id": {
"description": "新创建的产品ID",
"type": "integer"
}
}
},
"m_product_manage.DeleteProductReq": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"description": "产品ID",
"type": "integer"
}
}
},
"m_product_manage.DeleteProductResp": {
"type": "object",
"properties": {
"success": {
"description": "是否删除成功",
"type": "boolean"
}
}
},
"m_product_manage.EditProductReq": {
"type": "object",
"required": [
"id",
"product_code",
"product_name"
],
"properties": {
"city": {
"description": "城市(可选)",
"type": "string"
},
"description": {
"description": "产品描述",
"type": "string"
},
"discount": {
"description": "折扣",
"type": "number"
},
"id": {
"description": "产品ID",
"type": "integer"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信",
"type": "integer"
},
"price": {
"description": "标准价格",
"type": "number"
},
"product_attr": {
"description": "产品属性1-直连运营商 2-第三方",
"type": "integer"
},
"product_code": {
"description": "产品编码",
"type": "string"
},
"product_name": {
"description": "产品名称",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量",
"type": "integer"
},
"province": {
"description": "运营商省份",
"type": "string"
},
"retail_price": {
"description": "建议零售价格",
"type": "number"
},
"service_code": {
"description": "服务编码",
"type": "string"
},
"size": {
"description": "流量大小",
"type": "string"
},
"type": {
"description": "类型1-省内 2-国内",
"type": "integer"
}
}
},
"m_product_manage.EditProductResp": {
"type": "object",
"properties": {
"success": {
"description": "是否编辑成功",
"type": "boolean"
}
}
},
"m_product_manage.ProductListReq": {
"type": "object",
"properties": {
"page": {
"description": "页码",
"type": "integer"
},
"page_size": {
"description": "每页大小",
"type": "integer"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信(可选)",
"type": "integer"
},
"product_code": {
"description": "产品编码(可选)",
"type": "string"
},
"product_name": {
"description": "产品名称(可选)",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量(可选)",
"type": "integer"
},
"province": {
"description": "省份(可选)",
"type": "string"
}
}
},
"m_product_manage.ProductListResp": {
"type": "object",
"properties": {
"list": {
"description": "产品列表",
"type": "array",
"items": {
"$ref": "#/definitions/m_product_manage.BusProductDTO"
}
},
"total": {
"description": "总记录数",
"type": "integer"
}
}
},
"response.Page": {
"type": "object",
"properties": {

View File

@ -52,9 +52,27 @@
"summary": "获取验证码",
"responses": {
"200": {
"description": "{\"code\": 200, \"data\": [...], \"id\": \"xyz\", \"msg\": \"success\"}",
"description": "{\"code\": 200, \"data\": [...]}",
"schema": {
"$ref": "#/definitions/response.Response"
"allOf": [
{
"$ref": "#/definitions/response.Response"
},
{
"type": "object",
"properties": {
"data": {
"type": "string"
},
"id": {
"type": "string"
},
"msg": {
"type": "string"
}
}
}
]
}
}
}
@ -1232,7 +1250,7 @@
"application/json"
],
"tags": [
"产品管理"
"产品管理-V1.0.0"
],
"summary": "新建产品",
"parameters": [
@ -1242,7 +1260,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/m_product_manage.CreateProductReq"
"$ref": "#/definitions/bus_models.CreateProductReq"
}
}
],
@ -1250,7 +1268,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/m_product_manage.CreateProductResp"
"$ref": "#/definitions/bus_models.CreateProductResp"
}
}
}
@ -1265,7 +1283,7 @@
"application/json"
],
"tags": [
"产品管理"
"产品管理-V1.0.0"
],
"summary": "删除产品",
"parameters": [
@ -1275,7 +1293,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/m_product_manage.DeleteProductReq"
"$ref": "#/definitions/bus_models.DeleteProductReq"
}
}
],
@ -1283,7 +1301,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/m_product_manage.DeleteProductResp"
"$ref": "#/definitions/app.Response"
}
}
}
@ -1298,7 +1316,7 @@
"application/json"
],
"tags": [
"产品管理"
"产品管理-V1.0.0"
],
"summary": "编辑产品",
"parameters": [
@ -1308,7 +1326,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/m_product_manage.EditProductReq"
"$ref": "#/definitions/bus_models.EditProductReq"
}
}
],
@ -1316,7 +1334,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/m_product_manage.EditProductResp"
"$ref": "#/definitions/app.Response"
}
}
}
@ -1331,7 +1349,7 @@
"application/json"
],
"tags": [
"产品管理"
"产品管理-V1.0.0"
],
"summary": "查询产品列表",
"parameters": [
@ -1341,7 +1359,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/m_product_manage.ProductListReq"
"$ref": "#/definitions/bus_models.ProductListReq"
}
}
],
@ -1349,7 +1367,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/m_product_manage.ProductListResp"
"$ref": "#/definitions/bus_models.ProductListResp"
}
}
}
@ -2895,6 +2913,309 @@
}
},
"definitions": {
"app.Response": {
"type": "object",
"properties": {
"code": {
"description": "代码",
"type": "integer",
"example": 200
},
"data": {
"description": "数据集"
},
"msg": {
"description": "消息",
"type": "string"
},
"requestId": {
"description": "请求id",
"type": "string"
}
}
},
"bus_models.BusProduct": {
"type": "object",
"properties": {
"city": {
"description": "城市",
"type": "string"
},
"createdAt": {
"description": "创建时间",
"type": "string"
},
"description": {
"description": "产品描述",
"type": "string"
},
"discount": {
"description": "折扣",
"type": "number"
},
"id": {
"description": "数据库记录编号",
"type": "integer"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信",
"type": "integer"
},
"price": {
"description": "标准价格",
"type": "number"
},
"product_attr": {
"description": "产品属性1-直连运营商 2-第三方",
"type": "integer"
},
"product_code": {
"description": "产品编码,唯一",
"type": "string"
},
"product_name": {
"description": "产品名称",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量",
"type": "integer"
},
"province": {
"description": "运营商省份",
"type": "string"
},
"retail_price": {
"description": "建议零售价格",
"type": "number"
},
"service_code": {
"description": "服务编码,广东深圳移动新产品需要",
"type": "string"
},
"size": {
"description": "流量大小",
"type": "string"
},
"type": {
"description": "类型1-省内 2-国内",
"type": "integer"
},
"updatedAt": {
"description": "更新时间",
"type": "string"
}
}
},
"bus_models.CreateProductReq": {
"type": "object",
"required": [
"platform",
"price",
"product_code",
"product_name",
"product_type",
"province"
],
"properties": {
"city": {
"description": "城市(可选)",
"type": "string"
},
"description": {
"description": "产品描述",
"type": "string"
},
"discount": {
"description": "折扣",
"type": "number"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信",
"type": "integer"
},
"price": {
"description": "标准价格",
"type": "number"
},
"product_attr": {
"description": "产品属性1-直连运营商 2-第三方",
"type": "integer"
},
"product_code": {
"description": "产品编码",
"type": "string"
},
"product_name": {
"description": "产品名称",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量",
"type": "integer"
},
"province": {
"description": "运营商省份",
"type": "string"
},
"retail_price": {
"description": "建议零售价格",
"type": "number"
},
"service_code": {
"description": "服务编码",
"type": "string"
},
"size": {
"description": "流量大小",
"type": "string"
},
"type": {
"description": "类型1-省内 2-国内",
"type": "integer"
}
}
},
"bus_models.CreateProductResp": {
"type": "object",
"properties": {
"id": {
"description": "新创建的产品ID",
"type": "integer"
}
}
},
"bus_models.DeleteProductReq": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"description": "产品ID",
"type": "integer"
}
}
},
"bus_models.EditProductReq": {
"type": "object",
"required": [
"id",
"product_code",
"product_name"
],
"properties": {
"city": {
"description": "城市(可选)",
"type": "string"
},
"description": {
"description": "产品描述",
"type": "string"
},
"discount": {
"description": "折扣",
"type": "number"
},
"id": {
"description": "产品ID",
"type": "integer"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信",
"type": "integer"
},
"price": {
"description": "标准价格",
"type": "number"
},
"product_attr": {
"description": "产品属性1-直连运营商 2-第三方",
"type": "integer"
},
"product_code": {
"description": "产品编码",
"type": "string"
},
"product_name": {
"description": "产品名称",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量",
"type": "integer"
},
"province": {
"description": "运营商省份",
"type": "string"
},
"retail_price": {
"description": "建议零售价格",
"type": "number"
},
"service_code": {
"description": "服务编码",
"type": "string"
},
"size": {
"description": "流量大小",
"type": "string"
},
"type": {
"description": "类型1-省内 2-国内",
"type": "integer"
}
}
},
"bus_models.ProductListReq": {
"type": "object",
"properties": {
"page": {
"description": "页码",
"type": "integer"
},
"page_size": {
"description": "每页大小",
"type": "integer"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信(可选)",
"type": "integer"
},
"product_code": {
"description": "产品编码(可选)",
"type": "string"
},
"product_name": {
"description": "产品名称(可选)",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量(可选)",
"type": "integer"
},
"province": {
"description": "省份(可选)",
"type": "string"
}
}
},
"bus_models.ProductListResp": {
"type": "object",
"properties": {
"list": {
"description": "产品列表",
"type": "array",
"items": {
"$ref": "#/definitions/bus_models.BusProduct"
}
},
"total": {
"description": "总记录数",
"type": "integer"
}
}
},
"dto.GetSetSysConfigReq": {
"type": "object",
"properties": {
@ -4149,286 +4470,6 @@
}
}
},
"m_product_manage.BusProductDTO": {
"type": "object",
"properties": {
"city": {
"description": "城市(可选,避免返回空字符串)",
"type": "string"
},
"created_at": {
"description": "创建时间",
"type": "string"
},
"discount": {
"description": "折扣",
"type": "number"
},
"id": {
"description": "产品ID",
"type": "integer"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信 4-不限",
"type": "integer"
},
"price": {
"description": "标准价格",
"type": "number"
},
"product_code": {
"description": "产品编码",
"type": "string"
},
"product_name": {
"description": "产品名称",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量",
"type": "integer"
},
"province": {
"description": "运营商省份",
"type": "string"
},
"retail_price": {
"description": "建议零售价格",
"type": "number"
},
"updated_at": {
"description": "更新时间",
"type": "string"
}
}
},
"m_product_manage.CreateProductReq": {
"type": "object",
"required": [
"platform",
"price",
"product_code",
"product_name",
"product_type",
"province"
],
"properties": {
"city": {
"description": "城市(可选)",
"type": "string"
},
"description": {
"description": "产品描述",
"type": "string"
},
"discount": {
"description": "折扣",
"type": "number"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信",
"type": "integer"
},
"price": {
"description": "标准价格",
"type": "number"
},
"product_attr": {
"description": "产品属性1-直连运营商 2-第三方",
"type": "integer"
},
"product_code": {
"description": "产品编码",
"type": "string"
},
"product_name": {
"description": "产品名称",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量",
"type": "integer"
},
"province": {
"description": "运营商省份",
"type": "string"
},
"retail_price": {
"description": "建议零售价格",
"type": "number"
},
"service_code": {
"description": "服务编码",
"type": "string"
},
"size": {
"description": "流量大小",
"type": "string"
},
"type": {
"description": "类型1-省内 2-国内",
"type": "integer"
}
}
},
"m_product_manage.CreateProductResp": {
"type": "object",
"properties": {
"id": {
"description": "新创建的产品ID",
"type": "integer"
}
}
},
"m_product_manage.DeleteProductReq": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"description": "产品ID",
"type": "integer"
}
}
},
"m_product_manage.DeleteProductResp": {
"type": "object",
"properties": {
"success": {
"description": "是否删除成功",
"type": "boolean"
}
}
},
"m_product_manage.EditProductReq": {
"type": "object",
"required": [
"id",
"product_code",
"product_name"
],
"properties": {
"city": {
"description": "城市(可选)",
"type": "string"
},
"description": {
"description": "产品描述",
"type": "string"
},
"discount": {
"description": "折扣",
"type": "number"
},
"id": {
"description": "产品ID",
"type": "integer"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信",
"type": "integer"
},
"price": {
"description": "标准价格",
"type": "number"
},
"product_attr": {
"description": "产品属性1-直连运营商 2-第三方",
"type": "integer"
},
"product_code": {
"description": "产品编码",
"type": "string"
},
"product_name": {
"description": "产品名称",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量",
"type": "integer"
},
"province": {
"description": "运营商省份",
"type": "string"
},
"retail_price": {
"description": "建议零售价格",
"type": "number"
},
"service_code": {
"description": "服务编码",
"type": "string"
},
"size": {
"description": "流量大小",
"type": "string"
},
"type": {
"description": "类型1-省内 2-国内",
"type": "integer"
}
}
},
"m_product_manage.EditProductResp": {
"type": "object",
"properties": {
"success": {
"description": "是否编辑成功",
"type": "boolean"
}
}
},
"m_product_manage.ProductListReq": {
"type": "object",
"properties": {
"page": {
"description": "页码",
"type": "integer"
},
"page_size": {
"description": "每页大小",
"type": "integer"
},
"platform": {
"description": "运营商1-移动 2-联通 3-电信(可选)",
"type": "integer"
},
"product_code": {
"description": "产品编码(可选)",
"type": "string"
},
"product_name": {
"description": "产品名称(可选)",
"type": "string"
},
"product_type": {
"description": "产品类型1-短信 2-话费 3-流量(可选)",
"type": "integer"
},
"province": {
"description": "省份(可选)",
"type": "string"
}
}
},
"m_product_manage.ProductListResp": {
"type": "object",
"properties": {
"list": {
"description": "产品列表",
"type": "array",
"items": {
"$ref": "#/definitions/m_product_manage.BusProductDTO"
}
},
"total": {
"description": "总记录数",
"type": "integer"
}
}
},
"response.Page": {
"type": "object",
"properties": {

View File

@ -1,4 +1,226 @@
definitions:
app.Response:
properties:
code:
description: 代码
example: 200
type: integer
data:
description: 数据集
msg:
description: 消息
type: string
requestId:
description: 请求id
type: string
type: object
bus_models.BusProduct:
properties:
city:
description: 城市
type: string
createdAt:
description: 创建时间
type: string
description:
description: 产品描述
type: string
discount:
description: 折扣
type: number
id:
description: 数据库记录编号
type: integer
platform:
description: 运营商1-移动 2-联通 3-电信
type: integer
price:
description: 标准价格
type: number
product_attr:
description: 产品属性1-直连运营商 2-第三方
type: integer
product_code:
description: 产品编码,唯一
type: string
product_name:
description: 产品名称
type: string
product_type:
description: 产品类型1-短信 2-话费 3-流量
type: integer
province:
description: 运营商省份
type: string
retail_price:
description: 建议零售价格
type: number
service_code:
description: 服务编码,广东深圳移动新产品需要
type: string
size:
description: 流量大小
type: string
type:
description: 类型1-省内 2-国内
type: integer
updatedAt:
description: 更新时间
type: string
type: object
bus_models.CreateProductReq:
properties:
city:
description: 城市(可选)
type: string
description:
description: 产品描述
type: string
discount:
description: 折扣
type: number
platform:
description: 运营商1-移动 2-联通 3-电信
type: integer
price:
description: 标准价格
type: number
product_attr:
description: 产品属性1-直连运营商 2-第三方
type: integer
product_code:
description: 产品编码
type: string
product_name:
description: 产品名称
type: string
product_type:
description: 产品类型1-短信 2-话费 3-流量
type: integer
province:
description: 运营商省份
type: string
retail_price:
description: 建议零售价格
type: number
service_code:
description: 服务编码
type: string
size:
description: 流量大小
type: string
type:
description: 类型1-省内 2-国内
type: integer
required:
- platform
- price
- product_code
- product_name
- product_type
- province
type: object
bus_models.CreateProductResp:
properties:
id:
description: 新创建的产品ID
type: integer
type: object
bus_models.DeleteProductReq:
properties:
id:
description: 产品ID
type: integer
required:
- id
type: object
bus_models.EditProductReq:
properties:
city:
description: 城市(可选)
type: string
description:
description: 产品描述
type: string
discount:
description: 折扣
type: number
id:
description: 产品ID
type: integer
platform:
description: 运营商1-移动 2-联通 3-电信
type: integer
price:
description: 标准价格
type: number
product_attr:
description: 产品属性1-直连运营商 2-第三方
type: integer
product_code:
description: 产品编码
type: string
product_name:
description: 产品名称
type: string
product_type:
description: 产品类型1-短信 2-话费 3-流量
type: integer
province:
description: 运营商省份
type: string
retail_price:
description: 建议零售价格
type: number
service_code:
description: 服务编码
type: string
size:
description: 流量大小
type: string
type:
description: 类型1-省内 2-国内
type: integer
required:
- id
- product_code
- product_name
type: object
bus_models.ProductListReq:
properties:
page:
description: 页码
type: integer
page_size:
description: 每页大小
type: integer
platform:
description: 运营商1-移动 2-联通 3-电信(可选)
type: integer
product_code:
description: 产品编码(可选)
type: string
product_name:
description: 产品名称(可选)
type: string
product_type:
description: 产品类型1-短信 2-话费 3-流量(可选)
type: integer
province:
description: 省份(可选)
type: string
type: object
bus_models.ProductListResp:
properties:
list:
description: 产品列表
items:
$ref: '#/definitions/bus_models.BusProduct'
type: array
total:
description: 总记录数
type: integer
type: object
dto.GetSetSysConfigReq:
properties:
configKey:
@ -851,210 +1073,6 @@ definitions:
- username
- uuid
type: object
m_product_manage.BusProductDTO:
properties:
city:
description: 城市(可选,避免返回空字符串)
type: string
created_at:
description: 创建时间
type: string
discount:
description: 折扣
type: number
id:
description: 产品ID
type: integer
platform:
description: 运营商1-移动 2-联通 3-电信 4-不限
type: integer
price:
description: 标准价格
type: number
product_code:
description: 产品编码
type: string
product_name:
description: 产品名称
type: string
product_type:
description: 产品类型1-短信 2-话费 3-流量
type: integer
province:
description: 运营商省份
type: string
retail_price:
description: 建议零售价格
type: number
updated_at:
description: 更新时间
type: string
type: object
m_product_manage.CreateProductReq:
properties:
city:
description: 城市(可选)
type: string
description:
description: 产品描述
type: string
discount:
description: 折扣
type: number
platform:
description: 运营商1-移动 2-联通 3-电信
type: integer
price:
description: 标准价格
type: number
product_attr:
description: 产品属性1-直连运营商 2-第三方
type: integer
product_code:
description: 产品编码
type: string
product_name:
description: 产品名称
type: string
product_type:
description: 产品类型1-短信 2-话费 3-流量
type: integer
province:
description: 运营商省份
type: string
retail_price:
description: 建议零售价格
type: number
service_code:
description: 服务编码
type: string
size:
description: 流量大小
type: string
type:
description: 类型1-省内 2-国内
type: integer
required:
- platform
- price
- product_code
- product_name
- product_type
- province
type: object
m_product_manage.CreateProductResp:
properties:
id:
description: 新创建的产品ID
type: integer
type: object
m_product_manage.DeleteProductReq:
properties:
id:
description: 产品ID
type: integer
required:
- id
type: object
m_product_manage.DeleteProductResp:
properties:
success:
description: 是否删除成功
type: boolean
type: object
m_product_manage.EditProductReq:
properties:
city:
description: 城市(可选)
type: string
description:
description: 产品描述
type: string
discount:
description: 折扣
type: number
id:
description: 产品ID
type: integer
platform:
description: 运营商1-移动 2-联通 3-电信
type: integer
price:
description: 标准价格
type: number
product_attr:
description: 产品属性1-直连运营商 2-第三方
type: integer
product_code:
description: 产品编码
type: string
product_name:
description: 产品名称
type: string
product_type:
description: 产品类型1-短信 2-话费 3-流量
type: integer
province:
description: 运营商省份
type: string
retail_price:
description: 建议零售价格
type: number
service_code:
description: 服务编码
type: string
size:
description: 流量大小
type: string
type:
description: 类型1-省内 2-国内
type: integer
required:
- id
- product_code
- product_name
type: object
m_product_manage.EditProductResp:
properties:
success:
description: 是否编辑成功
type: boolean
type: object
m_product_manage.ProductListReq:
properties:
page:
description: 页码
type: integer
page_size:
description: 每页大小
type: integer
platform:
description: 运营商1-移动 2-联通 3-电信(可选)
type: integer
product_code:
description: 产品编码(可选)
type: string
product_name:
description: 产品名称(可选)
type: string
product_type:
description: 产品类型1-短信 2-话费 3-流量(可选)
type: integer
province:
description: 省份(可选)
type: string
type: object
m_product_manage.ProductListResp:
properties:
list:
description: 产品列表
items:
$ref: '#/definitions/m_product_manage.BusProductDTO'
type: array
total:
description: 总记录数
type: integer
type: object
response.Page:
properties:
count:
@ -1284,9 +1302,18 @@ paths:
description: 获取验证码
responses:
"200":
description: '{"code": 200, "data": [...], "id": "xyz", "msg": "success"}'
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/response.Response'
allOf:
- $ref: '#/definitions/response.Response'
- properties:
data:
type: string
id:
type: string
msg:
type: string
type: object
summary: 获取验证码
tags:
- 登陆
@ -2026,17 +2053,17 @@ paths:
name: request
required: true
schema:
$ref: '#/definitions/m_product_manage.CreateProductReq'
$ref: '#/definitions/bus_models.CreateProductReq'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/m_product_manage.CreateProductResp'
$ref: '#/definitions/bus_models.CreateProductResp'
summary: 新建产品
tags:
- 产品管理
- 产品管理-V1.0.0
/api/v1/product/delete:
post:
consumes:
@ -2047,17 +2074,17 @@ paths:
name: request
required: true
schema:
$ref: '#/definitions/m_product_manage.DeleteProductReq'
$ref: '#/definitions/bus_models.DeleteProductReq'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/m_product_manage.DeleteProductResp'
$ref: '#/definitions/app.Response'
summary: 删除产品
tags:
- 产品管理
- 产品管理-V1.0.0
/api/v1/product/edit:
post:
consumes:
@ -2068,17 +2095,17 @@ paths:
name: request
required: true
schema:
$ref: '#/definitions/m_product_manage.EditProductReq'
$ref: '#/definitions/bus_models.EditProductReq'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/m_product_manage.EditProductResp'
$ref: '#/definitions/app.Response'
summary: 编辑产品
tags:
- 产品管理
- 产品管理-V1.0.0
/api/v1/product/list:
post:
consumes:
@ -2089,17 +2116,17 @@ paths:
name: request
required: true
schema:
$ref: '#/definitions/m_product_manage.ProductListReq'
$ref: '#/definitions/bus_models.ProductListReq'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/m_product_manage.ProductListResp'
$ref: '#/definitions/bus_models.ProductListResp'
summary: 查询产品列表
tags:
- 产品管理
- 产品管理-V1.0.0
/api/v1/public/uploadFile:
post:
consumes:

131
go.mod
View File

@ -1,73 +1,78 @@
module go-admin
go 1.21
go 1.23.0
require (
github.com/alibaba/sentinel-golang v1.0.4
github.com/alibaba/sentinel-golang/pkg/adapters/gin v0.0.0-20230626085943-08071855bc67
github.com/aliyun/aliyun-oss-go-sdk v3.0.1+incompatible
github.com/alibaba/sentinel-golang/pkg/adapters/gin v0.0.0-20241224061304-f4c2c5964666
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
github.com/bitly/go-simplejson v0.5.1
github.com/bytedance/go-tagexpr/v2 v2.9.11
github.com/casbin/casbin/v2 v2.77.2
github.com/gin-gonic/gin v1.9.1
github.com/go-admin-team/go-admin-core v1.5.2-0.20231103105356-84418ed9252c
github.com/go-admin-team/go-admin-core/sdk v1.5.2-0.20231103105356-84418ed9252c
github.com/google/uuid v1.4.0
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.23.9+incompatible
github.com/casbin/casbin/v2 v2.103.0
github.com/gin-gonic/gin v1.10.0
github.com/go-admin-team/go-admin-core v1.5.2
github.com/go-admin-team/go-admin-core/sdk v1.5.2
github.com/google/uuid v1.6.0
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.24.9+incompatible
github.com/mssola/user_agent v0.6.0
github.com/opentracing/opentracing-go v1.2.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.17.0
github.com/qiniu/go-sdk/v7 v7.18.2
github.com/prometheus/client_golang v1.21.1
github.com/qiniu/go-sdk/v7 v7.25.2
github.com/robfig/cron/v3 v3.0.1
github.com/shirou/gopsutil/v3 v3.23.10
github.com/spf13/cobra v1.7.0
github.com/shirou/gopsutil/v3 v3.24.5
github.com/spf13/cast v1.5.1
github.com/spf13/cobra v1.9.1
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.0
github.com/swaggo/swag v1.16.2
github.com/unrolled/secure v1.13.0
golang.org/x/crypto v0.23.0
gorm.io/driver/mysql v1.5.2
gorm.io/driver/postgres v1.5.4
gorm.io/driver/sqlite v1.5.4
gorm.io/driver/sqlserver v1.5.2
gorm.io/gorm v1.25.5
github.com/swaggo/swag v1.16.4
github.com/unrolled/secure v1.17.0
golang.org/x/crypto v0.36.0
gorm.io/driver/mysql v1.5.7
gorm.io/driver/postgres v1.5.11
gorm.io/driver/sqlite v1.5.7
gorm.io/driver/sqlserver v1.5.4
gorm.io/gorm v1.25.12
)
require (
dario.cat/mergo v1.0.0 // indirect
github.com/AlecAivazis/survey/v2 v2.3.6 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/alex-ant/gomath v0.0.0-20160516115720-89013a210a82 // indirect
github.com/andeya/ameda v1.5.3 // indirect
github.com/andeya/goutil v1.0.1 // indirect
github.com/andygrunwald/go-jira v1.16.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/bsm/redislock v0.9.4 // indirect
github.com/bytedance/sonic v1.10.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/casbin/govaluate v1.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chanxuehong/rand v0.0.0-20211009035549-2f07823e8e99 // indirect
github.com/chanxuehong/wechat v0.0.0-20230222024006-36f0325263cd // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gammazero/toposort v0.1.1 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/git-chglog/git-chglog v0.15.4 // indirect
github.com/go-admin-team/go-admin-core/plugins/logger/zap v1.3.5-rc.0.0.20231103105142-2d9e40ec6f71 // indirect
github.com/go-admin-team/gorm-adapter/v3 v3.7.8-0.20220809100335-eaf9f67b3d21 // indirect
github.com/go-admin-team/go-admin-core/plugins/logger/zap v1.5.2 // indirect
github.com/go-admin-team/gorm-adapter/v3 v3.2.1-0.20210902112335-4148cb356a24 // indirect
github.com/go-admin-team/redis-watcher/v2 v2.0.0-20231102130416-bfe327cac940 // indirect
github.com/go-admin-team/redisqueue/v2 v2.0.1-0.20231102124201-508101cc789a // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
@ -77,9 +82,10 @@ require (
github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.15.5 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
@ -91,71 +97,74 @@ require (
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.13.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.1 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.4.3 // indirect
github.com/jackc/pgx/v5 v5.5.5 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/kyokomi/emoji/v2 v2.2.11 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/mattn/go-sqlite3 v1.14.22 // indirect
github.com/mattn/goveralls v0.0.12 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/microsoft/go-mssqldb v1.6.0 // indirect
github.com/microsoft/go-mssqldb v1.7.2 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mojocn/base64Captcha v1.3.5 // indirect
github.com/mojocn/base64Captcha v1.3.6 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nsqio/go-nsq v1.1.0 // indirect
github.com/nyaruka/phonenumbers v1.0.55 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/redis/go-redis/v9 v9.3.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.62.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/redis/go-redis/v9 v9.3.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shamsher31/goimgext v1.0.0 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tidwall/gjson v1.14.4 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/trivago/tgo v1.0.7 // indirect
github.com/tsuyoshiwada/go-gitcmd v0.0.0-20180205145712-5f1f5f9475df // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/urfave/cli/v2 v2.24.3 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.uber.org/multierr v1.10.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/image v0.13.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/term v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sync v0.12.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/term v0.30.0 // indirect
golang.org/x/text v0.23.0 // indirect
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
golang.org/x/tools v0.8.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/protobuf v1.36.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/plugin/dbresolver v1.4.7 // indirect
gorm.io/plugin/dbresolver v1.5.3 // indirect
modernc.org/fileutil v1.0.0 // indirect
)

25
tools/app/model.go Normal file
View File

@ -0,0 +1,25 @@
package app
type Response struct {
Code int `json:"code" example:"200"` // 代码
Data interface{} `json:"data"` // 数据集
Msg string `json:"msg"` // 消息
RequestId string `json:"requestId"` // 请求id
}
type Page struct {
List interface{} `json:"list"`
Count int `json:"count"`
PageIndex int `json:"pageIndex"`
PageSize int `json:"pageSize"`
}
func (res *Response) ReturnOK() *Response {
res.Code = 200
return res
}
func (res *Response) ReturnError(code int) *Response {
res.Code = code
return res
}

63
tools/app/return.go Normal file
View File

@ -0,0 +1,63 @@
package app
import (
"encoding/json"
"github.com/google/uuid"
"github.com/spf13/cast"
"net/http"
"github.com/gin-gonic/gin"
)
// Error 失败数据处理
func Error(c *gin.Context, code int, err error, msg string) {
var res Response
if err != nil {
res.Msg = err.Error()
}
if msg != "" {
res.Msg = msg
}
res.RequestId = GenerateMsgIDFromContext(c)
c.JSON(http.StatusOK, res.ReturnError(code))
response, _ := json.Marshal(res)
c.Set("response", string(response))
}
// OK 通常成功数据处理
func OK(c *gin.Context, data interface{}, msg string) {
var res Response
res.Data = data
if msg != "" {
res.Msg = msg
}
res.RequestId = GenerateMsgIDFromContext(c)
c.JSON(http.StatusOK, res.ReturnOK())
response, _ := json.Marshal(res)
c.Set("response", string(response))
}
// PageOK 分页数据处理
func PageOK(c *gin.Context, result interface{}, count int, pageIndex int, pageSize int, msg string) {
var res Page
res.List = result
res.Count = count
res.PageIndex = pageIndex
res.PageSize = pageSize
OK(c, res, msg)
}
// GenerateMsgIDFromContext 生成msgID
func GenerateMsgIDFromContext(c *gin.Context) string {
var msgID string
data, ok := c.Get("msgID")
if !ok {
msgID = uuid.New().String()
c.Set("msgID", msgID)
return msgID
}
msgID = cast.ToString(data)
return msgID
}