122 lines
4.1 KiB
Go
122 lines
4.1 KiB
Go
package controller
|
|
|
|
import (
|
|
dto "assets/model/dto/procurement"
|
|
service "assets/service/procurement"
|
|
"context"
|
|
|
|
"gitea.com/red-future/common/beans"
|
|
)
|
|
|
|
type supplier struct{}
|
|
|
|
// Supplier 供应商控制器
|
|
var Supplier = new(supplier)
|
|
|
|
// CreateSupplier 创建供应商
|
|
// @Summary 创建供应商
|
|
// @Tags 供应商管理
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param body body procurement.CreateSupplierReq true "创建供应商请求"
|
|
// @Success 200 {object} procurement.CreateSupplierRes
|
|
// @Router /supplier/createSupplier [post]
|
|
func (c *supplier) CreateSupplier(ctx context.Context, req *dto.CreateSupplierReq) (res *dto.CreateSupplierRes, err error) {
|
|
return service.Supplier.CreateSupplier(ctx, req)
|
|
}
|
|
|
|
// BatchCreateSuppliers 批量创建供应商
|
|
// @Summary 批量创建供应商
|
|
// @Tags 供应商管理
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param body body procurement.BatchCreateSuppliersReq true "批量创建供应商请求"
|
|
// @Success 200 {object} procurement.BatchCreateSuppliersRes
|
|
// @Router /supplier/batchCreateSuppliers [post]
|
|
func (c *supplier) BatchCreateSuppliers(ctx context.Context, req *dto.BatchCreateSuppliersReq) (res *dto.BatchCreateSuppliersRes, err error) {
|
|
return service.Supplier.BatchCreateSuppliers(ctx, req)
|
|
}
|
|
|
|
// UpdateSupplier 更新供应商
|
|
// @Summary 更新供应商
|
|
// @Tags 供应商管理
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param body body procurement.UpdateSupplierReq true "更新供应商请求"
|
|
// @Success 200 {object} beans.ResponseEmpty
|
|
// @Router /supplier/updateSupplier [put]
|
|
func (c *supplier) UpdateSupplier(ctx context.Context, req *dto.UpdateSupplierReq) (res *beans.ResponseEmpty, err error) {
|
|
err = service.Supplier.UpdateSupplier(ctx, req)
|
|
return
|
|
}
|
|
|
|
// DeleteSupplier 删除供应商
|
|
// @Summary 删除供应商
|
|
// @Tags 供应商管理
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param id query string true "供应商ID"
|
|
// @Success 200 {object} beans.ResponseEmpty
|
|
// @Router /supplier/deleteSupplier [delete]
|
|
func (c *supplier) DeleteSupplier(ctx context.Context, req *dto.DeleteSupplierReq) (res *beans.ResponseEmpty, err error) {
|
|
err = service.Supplier.DeleteSupplier(ctx, req.ID)
|
|
return
|
|
}
|
|
|
|
// GetSupplier 获取供应商详情
|
|
// @Summary 获取供应商详情
|
|
// @Tags 供应商管理
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param id query string true "供应商ID"
|
|
// @Success 200 {object} procurement.GetSupplierRes
|
|
// @Router /supplier/getSupplier [get]
|
|
func (c *supplier) GetSupplier(ctx context.Context, req *dto.GetSupplierReq) (res *dto.GetSupplierRes, err error) {
|
|
return service.Supplier.GetSupplier(ctx, req.ID)
|
|
}
|
|
|
|
// ListSuppliers 获取供应商列表
|
|
// @Summary 获取供应商列表
|
|
// @Tags 供应商管理
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param name query string false "供应商名称"
|
|
// @Param code query string false "供应商编码"
|
|
// @Param status query int false "供应商状态"
|
|
// @Param pageNum query int false "页码" default(1)
|
|
// @Param pageSize query int false "每页大小" default(10)
|
|
// @Success 200 {object} procurement.ListSuppliersRes
|
|
// @Router /supplier/listSuppliers [get]
|
|
func (c *supplier) ListSuppliers(ctx context.Context, req *dto.ListSuppliersReq) (res *dto.ListSuppliersRes, err error) {
|
|
return service.Supplier.ListSuppliers(ctx, req)
|
|
}
|
|
|
|
// GetSupplierOptions 获取供应商选项
|
|
// @Summary 获取供应商选项(用于下拉选择)
|
|
// @Tags 供应商管理
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {object} procurement.GetSupplierOptionsRes
|
|
// @Router /supplier/getSupplierOptions [get]
|
|
func (c *supplier) GetSupplierOptions(ctx context.Context, req *dto.GetSupplierOptionsReq) (res *dto.GetSupplierOptionsRes, err error) {
|
|
list, err := service.Supplier.GetSupplierOptions(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &dto.GetSupplierOptionsRes{
|
|
List: list,
|
|
}, nil
|
|
}
|
|
|
|
// GenerateTestData 生成测试数据
|
|
// @Summary 生成测试数据
|
|
// @Tags 供应商管理
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {object} beans.ResponseEmpty
|
|
// @Router /supplier/generateTestData [post]
|
|
func (c *supplier) GenerateTestData(ctx context.Context, req *dto.GenerateSupplierTestDataReq) (res *beans.ResponseEmpty, err error) {
|
|
err = service.Supplier.GenerateTestData(ctx)
|
|
return
|
|
}
|