Compare commits
10 Commits
d2b41220c4
...
42cc40b531
| Author | SHA1 | Date | |
|---|---|---|---|
| 42cc40b531 | |||
| e2a6e69df4 | |||
| 97ada2d27f | |||
| 355706b83d | |||
| 34600c4307 | |||
| 0334f91251 | |||
| e0e1e6468c | |||
| 839a490533 | |||
| 4ad5d2d226 | |||
| 2b31f64d39 |
@ -8,6 +8,7 @@ import (
|
||||
"hospital-admin-api/config"
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Public struct{}
|
||||
@ -27,20 +28,6 @@ func (b *Public) GetCaptcha(c *gin.Context) {
|
||||
|
||||
// Login 登陆
|
||||
func (b *Public) Login(c *gin.Context) {
|
||||
//orderService := service.OrderService{}
|
||||
//res, err := orderService.PdfToImg()
|
||||
//if err != nil {
|
||||
// responses.FailWithMessage(err.Error(), c)
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//if res != true {
|
||||
// responses.FailWithMessage("错误", c)
|
||||
// return
|
||||
//}
|
||||
//responses.Ok(c)
|
||||
//return
|
||||
|
||||
var adminRequest requests.AdminRequest
|
||||
|
||||
if err := c.ShouldBind(&adminRequest.Login); err != nil {
|
||||
@ -72,5 +59,15 @@ func (b *Public) Login(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 开始记录api请求时间
|
||||
key := "request_" + token.UserId
|
||||
|
||||
// 增加缓存
|
||||
_, err = global.Redis.Set(c, "request_api"+key, time.Now().Unix(), 30*60*time.Second).Result()
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(token, c)
|
||||
}
|
||||
|
||||
62
api/dao/adminApiRequest.go
Normal file
62
api/dao/adminApiRequest.go
Normal file
@ -0,0 +1,62 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type AdminApiRequestDao struct {
|
||||
}
|
||||
|
||||
// GetAdminApiRequestById 获取接口数据-接口id
|
||||
func (r *AdminApiRequestDao) GetAdminApiRequestById(RequestId int64) (m *model.AdminAPI, err error) {
|
||||
err = global.Db.First(&m, RequestId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddAdminApiRequest 新增接口
|
||||
func (r *AdminApiRequestDao) AddAdminApiRequest(tx *gorm.DB, model *model.AdminAPI) (*model.AdminAPI, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// GetAdminApiRequestList 获取接口列表
|
||||
func (r *AdminApiRequestDao) GetAdminApiRequestList(maps interface{}) (m []*model.AdminAPI, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetAdminApiRequest 获取
|
||||
func (r *AdminApiRequestDao) GetAdminApiRequest(maps interface{}) (m *model.AdminAPI, err error) {
|
||||
err = global.Db.Where(maps).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteAdminApiRequestById 删除接口-接口id
|
||||
func (r *AdminApiRequestDao) DeleteAdminApiRequestById(tx *gorm.DB, RequestId int64) error {
|
||||
if err := tx.Delete(&model.AdminAPI{}, RequestId).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditAdminApiRequestById 修改接口-接口id
|
||||
func (r *AdminApiRequestDao) EditAdminApiRequestById(tx *gorm.DB, RequestId int64, data interface{}) error {
|
||||
err := tx.Model(&model.AdminAPI{}).Where("request_id = ?", RequestId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -29,6 +29,7 @@ func GetArticleScienceDto(m *model.ArticleScience) *ArticleScienceDto {
|
||||
ArticleTitle: m.ArticleTitle,
|
||||
ArticleStatus: m.ArticleStatus,
|
||||
IsTop: m.IsTop,
|
||||
Sort: m.Sort,
|
||||
ArticleImage: utils.AddOssDomain(m.ArticleImage),
|
||||
SourceId: fmt.Sprintf("%d", m.SourceId),
|
||||
ArticleUrl: m.ArticleUrl,
|
||||
@ -49,6 +50,7 @@ func GetArticleScienceListDto(m []*model.ArticleScience) []*ArticleScienceDto {
|
||||
ArticleTitle: v.ArticleTitle,
|
||||
ArticleStatus: v.ArticleStatus,
|
||||
IsTop: v.IsTop,
|
||||
Sort: v.Sort,
|
||||
ArticleImage: utils.AddOssDomain(v.ArticleImage),
|
||||
SourceId: fmt.Sprintf("%d", v.SourceId),
|
||||
ArticleUrl: v.ArticleUrl,
|
||||
|
||||
60
api/middlewares/requestApi.go
Normal file
60
api/middlewares/requestApi.go
Normal file
@ -0,0 +1,60 @@
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/responses"
|
||||
"hospital-admin-api/consts"
|
||||
"hospital-admin-api/global"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
// RequestApi 请求api处理
|
||||
func RequestApi() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
// 获取用户id
|
||||
userId := c.GetInt64("UserId")
|
||||
if userId == 0 {
|
||||
responses.Fail(c)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
key := "request_" + fmt.Sprintf("%d", userId)
|
||||
|
||||
res, _ := global.Redis.Get(c, "request_api"+key).Result()
|
||||
if res == "" {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "长时间未操作,重新登录",
|
||||
"code": consts.TokenExptired,
|
||||
"data": "",
|
||||
})
|
||||
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
timestamp, err := strconv.ParseInt(res, 10, 64)
|
||||
if err != nil {
|
||||
fmt.Println("时间戳转换错误:", err)
|
||||
return
|
||||
}
|
||||
|
||||
now := time.Now().Unix() // 当前时间戳
|
||||
diff := now - timestamp // 计算时间差(秒)
|
||||
|
||||
// 20-30分钟时,重新缓存
|
||||
if diff >= 25*60 && diff <= 30*60 {
|
||||
// 增加缓存
|
||||
_, err := global.Redis.Set(c, "request_api"+key, time.Now().Unix(), 30*60*time.Second).Result()
|
||||
if err != nil {
|
||||
responses.FailWithMessage("错误", c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
36
api/model/AdminApiRequest.go
Normal file
36
api/model/AdminApiRequest.go
Normal file
@ -0,0 +1,36 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// AdminApiRequest 后台api请求记录
|
||||
type AdminApiRequest struct {
|
||||
RequestId int64 `gorm:"column:request_id;type:bigint(19);primary_key;comment:主键id" json:"request_id"`
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:后台用户id" json:"user_id"`
|
||||
ApiName string `gorm:"column:api_name;type:varchar(100);comment:api名称" json:"api_name"`
|
||||
ApiPath string `gorm:"column:api_path;type:varchar(255);comment: 接口路径(全路径 id为:id)" json:"api_path"`
|
||||
ApiMethod string `gorm:"column:api_method;type:varchar(10);comment:请求类型(put:修改 post:新增 get:获取 )" json:"api_method"`
|
||||
RequestTime LocalTime `gorm:"column:request_time;type:datetime;comment:请求时间" json:"request_time"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *AdminApiRequest) TableName() string {
|
||||
return "gdxz_admin_api_request"
|
||||
}
|
||||
|
||||
func (m *AdminApiRequest) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.RequestId == 0 {
|
||||
m.RequestId = global.Snowflake.Generate().Int64()
|
||||
}
|
||||
|
||||
m.CreatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||||
|
||||
m.UpdatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -15,6 +15,7 @@ type OrderProductItem struct {
|
||||
ProductId int64 `gorm:"column:product_id;type:bigint(19);comment:商品id" json:"product_id"`
|
||||
ProductName string `gorm:"column:product_name;type:varchar(255);comment:商品名称" json:"product_name"`
|
||||
ProductPrice float64 `gorm:"column:product_price;type:decimal(10,2);comment:商品价格" json:"product_price"`
|
||||
ActualProductPrice float64 `gorm:"column:actual_product_price;type:decimal(10,2);comment:实际商品价格" json:"actual_product_price"`
|
||||
ProductPlatformCode string `gorm:"column:product_platform_code;type:varchar(100);comment:商品处方平台编码" json:"product_platform_code"`
|
||||
Amount int `gorm:"column:amount;type:int(11);comment:数量" json:"amount"`
|
||||
Manufacturer string `gorm:"column:manufacturer;type:varchar(255);comment:生产厂家" json:"manufacturer"`
|
||||
|
||||
@ -27,12 +27,12 @@ type GetArticleScienceSourceList struct {
|
||||
|
||||
// PutArticleScienceSource 修改科普文章来源
|
||||
type PutArticleScienceSource struct {
|
||||
SourceName string `json:"source_name" form:"source_name" label:"来源名称" validate:"required"` // 来源名称
|
||||
SourceImage string `json:"source_image" form:"source_image" label:"来源图片" validate:"required"` // 来源图片
|
||||
SourceName string `json:"source_name" form:"source_name" label:"来源名称" validate:"required"` // 来源名称
|
||||
SourceImage string `json:"source_image" form:"source_image" label:"来源图片"` // 来源图片
|
||||
}
|
||||
|
||||
// AddArticleScienceSource 新增科普文章来源
|
||||
type AddArticleScienceSource struct {
|
||||
SourceName string `json:"source_name" form:"source_name" label:"来源名称" validate:"required"` // 来源名称
|
||||
SourceImage string `json:"source_image" form:"source_image" label:"来源图片" validate:"required"` // 来源图片
|
||||
SourceName string `json:"source_name" form:"source_name" label:"来源名称" validate:"required"` // 来源名称
|
||||
SourceImage string `json:"source_image" form:"source_image" label:"来源图片"` // 来源图片
|
||||
}
|
||||
|
||||
@ -58,6 +58,9 @@ func Init() *gin.Engine {
|
||||
// 验证权限
|
||||
r.Use(middlewares.Auth())
|
||||
|
||||
// 请求api处理
|
||||
r.Use(middlewares.RequestApi())
|
||||
|
||||
// 私有路由-验证权限
|
||||
privateRouter(r, api)
|
||||
|
||||
|
||||
@ -200,13 +200,14 @@ func (r *OrderService) ReportPreProduct(orderProductId, adminUserId int64) (bool
|
||||
|
||||
// 药品数据2
|
||||
orderDrugRequest := prescription.OrderDrugListRequest{
|
||||
DrugCode: product.ProductPlatformCode, // 药品编码
|
||||
ApprovalNumber: product.LicenseNumber, // 批准文号
|
||||
DrugName: product.ProductName, // 药品名称
|
||||
Specifications: product.ProductSpec, // 药品规格
|
||||
Price: product.ProductPrice, // 药品单价
|
||||
DrugCount: o.Amount, // 药品数量
|
||||
PackingUnit: product.PackagingUnit, // 药品单位
|
||||
DrugCode: product.ProductPlatformCode, // 药品编码
|
||||
ApprovalNumber: product.LicenseNumber, // 批准文号
|
||||
DrugName: product.ProductName, // 药品名称
|
||||
Specifications: product.ProductSpec, // 药品规格
|
||||
Price: product.ProductPrice, // 药品单价
|
||||
DrugCount: o.Amount, // 药品数量
|
||||
PackingUnit: product.PackagingUnit, // 药品单位
|
||||
ActualSellingPrice: o.ActualProductPrice, // 实际商品价格
|
||||
}
|
||||
orderDrugListRequests[i] = orderDrugRequest
|
||||
}
|
||||
|
||||
@ -1559,11 +1559,11 @@ func (r *UserDoctorService) GetDoctorCompletedWaitEntryAmount(doctorId int64) (g
|
||||
for _, inquiry := range orderInquirys {
|
||||
// 等同于math.Floor((completedWaitEntryAmount+inquiry.AmountTotal)*0.75*100) / 100
|
||||
amountTotal := decimal.NewFromFloat(inquiry.AmountTotal)
|
||||
completedWaitEntryAmount = completedWaitEntryAmount.Add(amountTotal).Mul(decimal.NewFromFloat(0.75)).Mul(decimal.NewFromFloat(100)).Floor().Div(decimal.NewFromFloat(100))
|
||||
completedWaitEntryAmount = completedWaitEntryAmount.Add(amountTotal)
|
||||
}
|
||||
}
|
||||
|
||||
result, _ := completedWaitEntryAmount.Float64()
|
||||
result, _ := completedWaitEntryAmount.Mul(decimal.NewFromFloat(0.75)).Mul(decimal.NewFromFloat(100)).Floor().Div(decimal.NewFromFloat(100)).Float64()
|
||||
return result, nil
|
||||
}
|
||||
|
||||
|
||||
@ -105,13 +105,14 @@ type DrugListRequest struct {
|
||||
|
||||
// OrderDrugListRequest 上报处方请求值-药品数据2
|
||||
type OrderDrugListRequest struct {
|
||||
DrugCode string `json:"drugCode"` // 药品编码
|
||||
ApprovalNumber string `json:"approvalNumber"` // 批准文号
|
||||
DrugName string `json:"drugName"` // 药品名称
|
||||
Specifications string `json:"specifications"` // 药品规格
|
||||
Price float64 `json:"price"` // 药品单价
|
||||
DrugCount int `json:"drugCount"` // 药品数量
|
||||
PackingUnit string `json:"packingUnit"` // 药品单位
|
||||
DrugCode string `json:"drugCode"` // 药品编码
|
||||
ApprovalNumber string `json:"approvalNumber"` // 批准文号
|
||||
DrugName string `json:"drugName"` // 药品名称
|
||||
Specifications string `json:"specifications"` // 药品规格
|
||||
Price float64 `json:"price"` // 药品单价
|
||||
DrugCount int `json:"drugCount"` // 药品数量
|
||||
PackingUnit string `json:"packingUnit"` // 药品单位
|
||||
ActualSellingPrice float64 `json:"actual_product_price"` // 药品实际销售单价
|
||||
}
|
||||
|
||||
// GetProdStockRequest 获取商品库存请求值
|
||||
|
||||
@ -274,7 +274,13 @@ func fillDataWithMerge(f *excelize.File, sheetName string, header []HeaderCellDa
|
||||
// 设置单元格样式
|
||||
for i := 0; i < filedNumSlice; i++ {
|
||||
axis = s + fmt.Sprintf("%d", row+i+1)
|
||||
err := setCellStyle(f, sheetName, axis, header[row+i], alignment)
|
||||
|
||||
column, err := excelize.ColumnNameToNumber(s)
|
||||
if err != nil {
|
||||
return row, err
|
||||
}
|
||||
|
||||
err = setCellStyle(f, sheetName, axis, header[column-1], alignment)
|
||||
if err != nil {
|
||||
return row, err
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user