增加 系统药品导出
This commit is contained in:
@@ -546,3 +546,51 @@ func (r *Export) OrderPrescription(c *gin.Context) {
|
||||
|
||||
responses.OkWithData(ossAddress, c)
|
||||
}
|
||||
|
||||
// Product 系统药品
|
||||
func (r *Export) Product(c *gin.Context) {
|
||||
productRequest := requests.ProductRequest{}
|
||||
req := productRequest.ProductExportList
|
||||
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{}
|
||||
products, err := productDao.GetProductExportListSearch(req)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
exportService := service.ExportService{}
|
||||
ossAddress, err := exportService.Product(products)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取当前登陆用户id
|
||||
userId := c.GetInt64("UserId")
|
||||
if userId != 0 {
|
||||
// 记录日志
|
||||
logExport := &model.LogExport{
|
||||
AdminUserId: userId,
|
||||
ExportModule: "处方",
|
||||
ExportFile: utils.RemoveOssDomain(ossAddress),
|
||||
}
|
||||
|
||||
logExportDao := dao.LogExportDao{}
|
||||
_, _ = logExportDao.AddLogExportUnTransaction(logExport)
|
||||
}
|
||||
|
||||
responses.OkWithData(ossAddress, c)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user