新增了获取系统商品列表-限制条数
This commit is contained in:
parent
9f6b54a6c4
commit
ca629cdb2d
@ -300,3 +300,35 @@ func (r *Product) GetPlatformProductList(c *gin.Context) {
|
||||
|
||||
responses.OkWithData(productPlatforms, c)
|
||||
}
|
||||
|
||||
// GetProductList 获取系统商品列表-限制条数
|
||||
func (r *Product) GetProductList(c *gin.Context) {
|
||||
productRequest := requests.ProductRequest{}
|
||||
req := productRequest.GetProductList
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
productDao := dao.ProductDao{}
|
||||
product, err := productDao.GetProductListSearch(req)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
getProductListResponses := dto.GetProductListDto(product)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(getProductListResponses, c)
|
||||
}
|
||||
|
||||
@ -136,7 +136,6 @@ func (r *UserPatient) GetUserPatientList(c *gin.Context) {
|
||||
|
||||
userPatientDao := dao.UserPatientDao{}
|
||||
userPatient, err := userPatientDao.GetUserPatientListSearch(req)
|
||||
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
|
||||
@ -258,3 +258,83 @@ func (r *ProductDao) GetProductExportListSearch(req requests.ProductExportList)
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetProductListSearch 获取系统商品列表-限制条数
|
||||
func (r *ProductDao) GetProductListSearch(req requests.GetProductList) (m []*model.Product, err error) {
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.Product{})
|
||||
|
||||
// 库存表
|
||||
query = query.Preload("ProductPlatformAmount", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("amount_id", "product_platform_id", "product_platform_code", "stock")
|
||||
})
|
||||
|
||||
// 商品名称
|
||||
if req.ProductName != "" {
|
||||
query = query.Where("product_name LIKE ?", "%"+req.ProductName+"%")
|
||||
}
|
||||
|
||||
// 商品通用名
|
||||
if req.CommonName != "" {
|
||||
query = query.Where("common_name LIKE ?", "%"+req.CommonName+"%")
|
||||
}
|
||||
|
||||
// 商品助记码
|
||||
if req.MnemonicCode != "" {
|
||||
query = query.Where("mnemonic_code LIKE ?", "%"+req.MnemonicCode+"%")
|
||||
}
|
||||
|
||||
// 药品类型
|
||||
if req.ProductType != nil {
|
||||
query = query.Where("product_type = ?", req.ProductType)
|
||||
}
|
||||
|
||||
// 是否麻精药品
|
||||
if req.IsMajing != nil {
|
||||
query = query.Where("is_majing = ?", req.IsMajing)
|
||||
}
|
||||
|
||||
// 商品状态
|
||||
if req.ProductStatus != nil {
|
||||
query = query.Where("product_status = ?", req.ProductStatus)
|
||||
}
|
||||
|
||||
// 平台商品id
|
||||
if req.ProductPlatformId != "" {
|
||||
query = query.Where("product_platform_id = ?", req.ProductPlatformId)
|
||||
}
|
||||
|
||||
// 处方平台编码
|
||||
if req.ProductPlatformCode != "" {
|
||||
query = query.Where("product_platform_code LIKE ?", "%"+req.ProductPlatformCode+"%")
|
||||
}
|
||||
|
||||
// 药店编码
|
||||
if req.ProductPharmacyCode != "" {
|
||||
query = query.Where("product_pharmacy_code LIKE ?", "%"+req.ProductPharmacyCode+"%")
|
||||
}
|
||||
|
||||
// 批准文号
|
||||
if req.LicenseNumber != "" {
|
||||
query = query.Where("license_number LIKE ?", "%"+req.LicenseNumber+"%")
|
||||
}
|
||||
|
||||
// 生产厂家
|
||||
if req.Manufacturer != "" {
|
||||
query = query.Where("manufacturer LIKE ?", "%"+req.Manufacturer+"%")
|
||||
}
|
||||
|
||||
// 商品备注
|
||||
if req.ProductRemarks != "" {
|
||||
query = query.Where("product_remarks LIKE ?", "%"+req.ProductRemarks+"%")
|
||||
}
|
||||
|
||||
query = query.Order("gdxz_product.created_at desc")
|
||||
|
||||
err = query.Limit(10).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ type ProductRequest struct {
|
||||
PutProductStatus // 修改商品状态(上/下架)
|
||||
GetPlatformProductList // 获取平台商品列表
|
||||
ProductExportList // 系统药品-导出
|
||||
GetProductList // 获取系统商品列表-限制条数
|
||||
}
|
||||
|
||||
// GetPlatformProductPage 获取平台商品列表-分页
|
||||
@ -51,6 +52,22 @@ type GetProductPage struct {
|
||||
Order *GetProductPageOrder `json:"order" form:"order" label:"排序"`
|
||||
}
|
||||
|
||||
// GetProductList 获取系统商品列表-限制条数
|
||||
type GetProductList struct {
|
||||
ProductName string `json:"product_name" form:"product_name" label:"商品名称"` // 商品名称
|
||||
CommonName string `json:"common_name" form:"common_name" label:"商品通用名"` // 商品通用名
|
||||
MnemonicCode string `json:"mnemonic_code" form:"mnemonic_code" label:"商品助记码"` // 商品助记码(首字母简拼)
|
||||
ProductType *int `json:"product_type" form:"product_type" label:"药品类型"` // 药品类型(0:未知 1:中成药 2:西药)
|
||||
IsMajing *int `json:"is_majing" form:"is_majing" label:"药品类型"` // 是否麻精药品(0:否 1:是)
|
||||
ProductPlatformId string `json:"product_platform_id" form:"product_platform_id" label:"平台商品id"` // 处方平台商品id
|
||||
ProductPlatformCode string `json:"product_platform_code" form:"product_platform_code" label:"处方平台编码"` // 处方平台商品编码
|
||||
ProductPharmacyCode string `json:"product_pharmacy_code" form:"product_pharmacy_code" label:"药店编码"` // 第三方药店商品编码
|
||||
LicenseNumber string `json:"license_number" form:"license_number" label:"批准文号"` // 批准文号
|
||||
Manufacturer string `json:"manufacturer" form:"manufacturer" label:"生产厂家"` // 生产厂家
|
||||
ProductRemarks string `json:"product_remarks" form:"product_remarks" label:"商品备注"` // 商品备注
|
||||
ProductStatus *int `json:"product_status" form:"product_status" label:"商品状态"` // 商品状态(1:正常 2:下架)
|
||||
}
|
||||
|
||||
type GetProductPageOrder struct {
|
||||
Stock string `json:"stock" form:"stock" label:"库存" validate:"oneof=desc asc"`
|
||||
}
|
||||
|
||||
@ -737,7 +737,7 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
productGroup.POST("/page", api.Product.GetProductPage)
|
||||
|
||||
// 获取系统商品列表-限制条数
|
||||
productGroup.GET("/list", api.Product.GetProductPage)
|
||||
productGroup.GET("/list", api.Product.GetProductList)
|
||||
|
||||
// 系统商品详情
|
||||
productGroup.GET("/:product_id", api.Product.GetProduct)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user